diff options
author | Matt A. Tobin <email@mattatobin.com> | 2020-04-17 07:29:57 -0400 |
---|---|---|
committer | Matt A. Tobin <email@mattatobin.com> | 2020-04-17 07:29:57 -0400 |
commit | 010f37f47b9c15935a6113cd82e43f0673122016 (patch) | |
tree | ced1fbdc9767f6d87428f30331bf6305938a291e /layout | |
parent | 38056aa9c931ef7e769f7fd42613318dc8aeb77b (diff) | |
download | uxp-010f37f47b9c15935a6113cd82e43f0673122016.tar.gz |
Bug 1422197 - Add fast path to get DocGroup in binding code for [CEReactions]
Tag #1375
Diffstat (limited to 'layout')
-rw-r--r-- | layout/generic/Selection.h | 4 | ||||
-rw-r--r-- | layout/generic/nsSelection.cpp | 12 | ||||
-rw-r--r-- | layout/style/StyleRule.cpp | 10 | ||||
-rw-r--r-- | layout/style/nsCSSRules.cpp | 29 | ||||
-rw-r--r-- | layout/style/nsCSSRules.h | 8 | ||||
-rw-r--r-- | layout/style/nsComputedDOMStyle.h | 6 | ||||
-rw-r--r-- | layout/style/nsDOMCSSAttrDeclaration.cpp | 6 | ||||
-rw-r--r-- | layout/style/nsDOMCSSAttrDeclaration.h | 1 | ||||
-rw-r--r-- | layout/style/nsICSSDeclaration.h | 6 |
9 files changed, 82 insertions, 0 deletions
diff --git a/layout/generic/Selection.h b/layout/generic/Selection.h index 5414d15c12..cc696a7c78 100644 --- a/layout/generic/Selection.h +++ b/layout/generic/Selection.h @@ -31,6 +31,9 @@ class nsHTMLCopyEncoder; namespace mozilla { class ErrorResult; struct AutoPrepareFocusRange; +namespace dom { +class DocGroup; +} // namespace dom } // namespace mozilla struct RangeData @@ -73,6 +76,7 @@ public: nsresult EndBatchChangesInternal(int16_t aReason = nsISelectionListener::NO_REASON); nsIDocument* GetParentObject() const; + DocGroup* GetDocGroup() const; // utility methods for scrolling the selection into view nsPresContext* GetPresContext() const; diff --git a/layout/generic/nsSelection.cpp b/layout/generic/nsSelection.cpp index 994ec48520..919ab0815a 100644 --- a/layout/generic/nsSelection.cpp +++ b/layout/generic/nsSelection.cpp @@ -3521,6 +3521,18 @@ Selection::GetParentObject() const return nullptr; } +DocGroup* +Selection::GetDocGroup() const +{ + nsIPresShell* shell = GetPresShell(); + if (!shell) { + return nullptr; + } + + nsIDocument* doc = shell->GetDocument(); + return doc ? doc->GetDocGroup() : nullptr; +} + NS_IMPL_CYCLE_COLLECTION_CLASS(Selection) NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(Selection) diff --git a/layout/style/StyleRule.cpp b/layout/style/StyleRule.cpp index 622f498ddd..aca97a505e 100644 --- a/layout/style/StyleRule.cpp +++ b/layout/style/StyleRule.cpp @@ -1078,6 +1078,16 @@ public: return mRule ? mRule->GetDocument() : nullptr; } + virtual DocGroup* GetDocGroup() const override + { + if (!mRule) { + return nullptr; + } + + nsIDocument* document = mRule->GetDocument(); + return document ? document->GetDocGroup() : nullptr; + } + friend class css::DOMCSSStyleRule; protected: diff --git a/layout/style/nsCSSRules.cpp b/layout/style/nsCSSRules.cpp index 4b90b6f0c0..dc79e471d8 100644 --- a/layout/style/nsCSSRules.cpp +++ b/layout/style/nsCSSRules.cpp @@ -1515,6 +1515,13 @@ nsCSSFontFaceStyleDecl::GetParentObject() return ContainingRule()->GetDocument(); } +DocGroup* +nsCSSFontFaceStyleDecl::GetDocGroup() const +{ + nsIDocument* document = ContainingRule()->GetDocument(); + return document ? document->GetDocGroup() : nullptr; +} + JSObject* nsCSSFontFaceStyleDecl::WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto) { @@ -1991,6 +1998,17 @@ nsCSSKeyframeStyleDeclaration::GetParentObject() return mRule ? mRule->GetDocument() : nullptr; } +DocGroup* +nsCSSKeyframeStyleDeclaration::GetDocGroup() const +{ + if (!mRule) { + return nullptr; + } + + nsIDocument* document = mRule->GetDocument(); + return document ? document->GetDocGroup() : nullptr; +} + // ------------------------------------------- // nsCSSKeyframeRule // @@ -2538,6 +2556,17 @@ nsCSSPageStyleDeclaration::GetParentObject() return mRule ? mRule->GetDocument() : nullptr; } +DocGroup* +nsCSSPageStyleDeclaration::GetDocGroup() const +{ + if (!mRule) { + return nullptr; + } + + nsIDocument* document = mRule->GetDocument(); + return document ? document->GetDocGroup() : nullptr; +} + // ------------------------------------------- // nsCSSPageRule // diff --git a/layout/style/nsCSSRules.h b/layout/style/nsCSSRules.h index daefaf3f98..1bd468cb6c 100644 --- a/layout/style/nsCSSRules.h +++ b/layout/style/nsCSSRules.h @@ -39,6 +39,11 @@ class nsMediaList; namespace mozilla { +namespace dom { +class DocGroup; +class DocGroup; +} // namespace dom + class ErrorResult; namespace css { @@ -209,6 +214,7 @@ public: using nsICSSDeclaration::GetPropertyCSSValue; virtual nsINode *GetParentObject() override; + virtual mozilla::dom::DocGroup* GetDocGroup() const override; virtual void IndexedGetter(uint32_t aIndex, bool& aFound, nsAString& aPropName) override; nsresult GetPropertyValue(nsCSSFontDesc aFontDescID, @@ -366,6 +372,7 @@ public: nsICSSDeclaration) virtual nsINode* GetParentObject() override; + virtual mozilla::dom::DocGroup* GetDocGroup() const override; protected: virtual ~nsCSSKeyframeStyleDeclaration(); @@ -496,6 +503,7 @@ public: nsICSSDeclaration) virtual nsINode *GetParentObject() override; + virtual mozilla::dom::DocGroup* GetDocGroup() const override; protected: virtual ~nsCSSPageStyleDeclaration(); diff --git a/layout/style/nsComputedDOMStyle.h b/layout/style/nsComputedDOMStyle.h index e94d8dbf64..5af518c2eb 100644 --- a/layout/style/nsComputedDOMStyle.h +++ b/layout/style/nsComputedDOMStyle.h @@ -27,6 +27,7 @@ namespace mozilla { namespace dom { +class DocGroup; class Element; } // namespace dom struct ComputedGridTrackInfo; @@ -84,6 +85,11 @@ public: return mElement; } + virtual mozilla::dom::DocGroup* GetDocGroup() const override + { + return mElement ? mElement->GetDocGroup() : nullptr; + } + static already_AddRefed<nsStyleContext> GetStyleContextForElement(mozilla::dom::Element* aElement, nsIAtom* aPseudo, nsIPresShell* aPresShell, diff --git a/layout/style/nsDOMCSSAttrDeclaration.cpp b/layout/style/nsDOMCSSAttrDeclaration.cpp index ce638a9c2e..7b659a8cc2 100644 --- a/layout/style/nsDOMCSSAttrDeclaration.cpp +++ b/layout/style/nsDOMCSSAttrDeclaration.cpp @@ -178,6 +178,12 @@ nsDOMCSSAttributeDeclaration::GetParentObject() return mElement; } +/* virtual */ DocGroup* +nsDOMCSSAttributeDeclaration::GetDocGroup() const +{ + return mElement ? mElement->OwnerDoc()->GetDocGroup() : nullptr; +} + NS_IMETHODIMP nsDOMCSSAttributeDeclaration::SetPropertyValue(const nsCSSPropertyID aPropID, const nsAString& aValue) diff --git a/layout/style/nsDOMCSSAttrDeclaration.h b/layout/style/nsDOMCSSAttrDeclaration.h index 7c0fbacc05..25f7eee741 100644 --- a/layout/style/nsDOMCSSAttrDeclaration.h +++ b/layout/style/nsDOMCSSAttrDeclaration.h @@ -35,6 +35,7 @@ public: NS_IMETHOD GetParentRule(nsIDOMCSSRule **aParent) override; virtual nsINode* GetParentObject() override; + virtual DocGroup* GetDocGroup() const override; NS_IMETHOD SetPropertyValue(const nsCSSPropertyID aPropID, const nsAString& aValue) override; diff --git a/layout/style/nsICSSDeclaration.h b/layout/style/nsICSSDeclaration.h index ff6ec4a782..fa80c17f5a 100644 --- a/layout/style/nsICSSDeclaration.h +++ b/layout/style/nsICSSDeclaration.h @@ -31,6 +31,11 @@ #include "nsCOMPtr.h" class nsINode; +namespace mozilla { +namespace dom { +class DocGroup; +} // namespace dom +} // namespace mozilla // dbeabbfa-6cb3-4f5c-aec2-dd558d9d681f #define NS_ICSSDECLARATION_IID \ @@ -62,6 +67,7 @@ public: const nsAString& aValue) = 0; virtual nsINode *GetParentObject() = 0; + virtual mozilla::dom::DocGroup* GetDocGroup() const = 0; // Also have to declare all the nsIDOMCSSStyleDeclaration methods, // since we want to be able to call them from the WebIDL versions. |