diff options
30 files changed, 206 insertions, 44 deletions
diff --git a/dom/base/CustomElementRegistry.cpp b/dom/base/CustomElementRegistry.cpp index 67bd8e185..df2201407 100644 --- a/dom/base/CustomElementRegistry.cpp +++ b/dom/base/CustomElementRegistry.cpp @@ -453,6 +453,12 @@ nsISupports* CustomElementRegistry::GetParentObject() const return mWindow; } +DocGroup* +CustomElementRegistry::GetDocGroup() const +{ + return mWindow ? mWindow->GetDocGroup() : nullptr; +} + static const char* kLifeCycleCallbackNames[] = { "connectedCallback", "disconnectedCallback", diff --git a/dom/base/CustomElementRegistry.h b/dom/base/CustomElementRegistry.h index a736e3019..eacf568c9 100644 --- a/dom/base/CustomElementRegistry.h +++ b/dom/base/CustomElementRegistry.h @@ -27,6 +27,7 @@ struct CustomElementData; struct ElementDefinitionOptions; class CallbackFunction; class CustomElementReaction; +class DocGroup; class Function; class Promise; @@ -513,6 +514,8 @@ private: public: nsISupports* GetParentObject() const; + DocGroup* GetDocGroup() const; + virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; void Define(const nsAString& aName, Function& aFunctionConstructor, diff --git a/dom/base/nsDOMAttributeMap.cpp b/dom/base/nsDOMAttributeMap.cpp index 2a90df7e4..29a4a6349 100644 --- a/dom/base/nsDOMAttributeMap.cpp +++ b/dom/base/nsDOMAttributeMap.cpp @@ -524,3 +524,9 @@ nsDOMAttributeMap::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) { return NamedNodeMapBinding::Wrap(aCx, this, aGivenProto); } + +DocGroup* +nsDOMAttributeMap::GetDocGroup() const +{ + return mContent ? mContent->OwnerDoc()->GetDocGroup() : nullptr; +} diff --git a/dom/base/nsDOMAttributeMap.h b/dom/base/nsDOMAttributeMap.h index 31eb701e3..d73d1c3b6 100644 --- a/dom/base/nsDOMAttributeMap.h +++ b/dom/base/nsDOMAttributeMap.h @@ -22,6 +22,11 @@ class nsIAtom; class nsIDocument; +namespace mozilla { +namespace dom { +class DocGroup; +} // namespace dom +} // namespace mozilla /** * Structure used as a key for caching Attrs in nsDOMAttributeMap's mAttributeCache. @@ -87,6 +92,7 @@ class nsDOMAttributeMap final : public nsIDOMMozNamedAttrMap { public: typedef mozilla::dom::Attr Attr; + typedef mozilla::dom::DocGroup DocGroup; typedef mozilla::dom::Element Element; typedef mozilla::ErrorResult ErrorResult; @@ -135,6 +141,7 @@ public: return mContent; } virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; + DocGroup* GetDocGroup() const; // WebIDL Attr* GetNamedItem(const nsAString& aAttrName); diff --git a/dom/base/nsDOMTokenList.cpp b/dom/base/nsDOMTokenList.cpp index 39ff60e12..961beb50e 100644 --- a/dom/base/nsDOMTokenList.cpp +++ b/dom/base/nsDOMTokenList.cpp @@ -366,6 +366,12 @@ nsDOMTokenList::Stringify(nsAString& aResult) mElement->GetAttr(kNameSpaceID_None, mAttrAtom, aResult); } +DocGroup* +nsDOMTokenList::GetDocGroup() const +{ + return mElement ? mElement->OwnerDoc()->GetDocGroup() : nullptr; +} + JSObject* nsDOMTokenList::WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto) { diff --git a/dom/base/nsDOMTokenList.h b/dom/base/nsDOMTokenList.h index e44e042d5..0b3f70319 100644 --- a/dom/base/nsDOMTokenList.h +++ b/dom/base/nsDOMTokenList.h @@ -22,7 +22,9 @@ namespace mozilla { class ErrorResult; - +namespace dom { +class DocGroup; +} // namespace dom } // namespace mozilla class nsAttrValue; @@ -35,6 +37,7 @@ class nsDOMTokenList : public nsISupports, { protected: typedef mozilla::dom::Element Element; + typedef mozilla::dom::DocGroup DocGroup; typedef nsWhitespaceTokenizerTemplate<nsContentUtils::IsHTMLWhitespace> WhitespaceTokenizer; @@ -52,6 +55,8 @@ public: return mElement; } + DocGroup* GetDocGroup() const; + uint32_t Length(); void Item(uint32_t aIndex, nsAString& aResult) { diff --git a/dom/base/nsINode.cpp b/dom/base/nsINode.cpp index 560ded6a9..d0cbdb454 100644 --- a/dom/base/nsINode.cpp +++ b/dom/base/nsINode.cpp @@ -3132,3 +3132,9 @@ nsINode::IsStyledByServo() const return OwnerDoc()->IsStyledByServo(); } #endif + +DocGroup* +nsINode::GetDocGroup() const +{ + return OwnerDoc()->GetDocGroup(); +} diff --git a/dom/base/nsINode.h b/dom/base/nsINode.h index a07bcae51..7fb535701 100644 --- a/dom/base/nsINode.h +++ b/dom/base/nsINode.h @@ -72,6 +72,7 @@ inline bool IsSpaceCharacter(char aChar) { class AccessibleNode; struct BoxQuadOptions; struct ConvertCoordinateOptions; +class DocGroup; class DOMPoint; class DOMQuad; class DOMRectReadOnly; @@ -299,6 +300,7 @@ class nsINode : public mozilla::dom::EventTarget public: typedef mozilla::dom::BoxQuadOptions BoxQuadOptions; typedef mozilla::dom::ConvertCoordinateOptions ConvertCoordinateOptions; + typedef mozilla::dom::DocGroup DocGroup; typedef mozilla::dom::DOMPoint DOMPoint; typedef mozilla::dom::DOMPointInit DOMPointInit; typedef mozilla::dom::DOMQuad DOMQuad; @@ -614,6 +616,11 @@ public: } /** + * Returns the DocGroup of the "node document" of this node. + */ + DocGroup* GetDocGroup() const; + + /** * Print a debugger friendly descriptor of this element. This will describe * the position of this element in the document. */ diff --git a/dom/base/nsRange.cpp b/dom/base/nsRange.cpp index a3704a1de..82e28f645 100644 --- a/dom/base/nsRange.cpp +++ b/dom/base/nsRange.cpp @@ -49,6 +49,12 @@ nsRange::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) return RangeBinding::Wrap(aCx, this, aGivenProto); } +DocGroup* +nsRange::GetDocGroup() const +{ + return mOwner ? mOwner->GetDocGroup() : nullptr; +} + /****************************************************** * stack based utilty class for managing monitor ******************************************************/ diff --git a/dom/base/nsRange.h b/dom/base/nsRange.h index 30c17a254..2c0c19edc 100644 --- a/dom/base/nsRange.h +++ b/dom/base/nsRange.h @@ -26,6 +26,7 @@ namespace mozilla { class ErrorResult; namespace dom { struct ClientRectsAndTexts; +class DocGroup; class DocumentFragment; class DOMRect; class DOMRectList; @@ -38,6 +39,7 @@ class nsRange final : public nsIDOMRange, public nsWrapperCache { typedef mozilla::ErrorResult ErrorResult; + typedef mozilla::dom::DocGroup DocGroup; typedef mozilla::dom::DOMRect DOMRect; typedef mozilla::dom::DOMRectList DOMRectList; @@ -280,6 +282,7 @@ public: nsINode* GetParentObject() const { return mOwner; } virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override final; + DocGroup* GetDocGroup() const; private: // no copy's or assigns diff --git a/dom/bindings/BindingUtils.cpp b/dom/bindings/BindingUtils.cpp index 51274f1af..ee321772e 100644 --- a/dom/bindings/BindingUtils.cpp +++ b/dom/bindings/BindingUtils.cpp @@ -3406,28 +3406,6 @@ GetDesiredProto(JSContext* aCx, const JS::CallArgs& aCallArgs, return true; } -CustomElementReactionsStack* -GetCustomElementReactionsStack(JS::Handle<JSObject*> aObj) -{ - // This might not be the right object, if there are wrappers. Unwrap if we can. - JSObject* obj = js::CheckedUnwrap(aObj); - if (!obj) { - return nullptr; - } - - nsGlobalWindow* window = xpc::WindowGlobalOrNull(obj); - if (!window) { - return nullptr; - } - - DocGroup* docGroup = window->AsInner()->GetDocGroup(); - if (!docGroup) { - return nullptr; - } - - return docGroup->CustomElementReactionsStack(); -} - // https://html.spec.whatwg.org/multipage/dom.html#htmlconstructor already_AddRefed<nsGenericHTMLElement> CreateHTMLElement(const GlobalObject& aGlobal, const JS::CallArgs& aCallArgs, diff --git a/dom/bindings/BindingUtils.h b/dom/bindings/BindingUtils.h index e583d0e06..356d3aa00 100644 --- a/dom/bindings/BindingUtils.h +++ b/dom/bindings/BindingUtils.h @@ -3422,12 +3422,6 @@ bool GetDesiredProto(JSContext* aCx, const JS::CallArgs& aCallArgs, JS::MutableHandle<JSObject*> aDesiredProto); -// Get the CustomElementReactionsStack for the docgroup of the global -// of the underlying object of aObj. This can be null if aObj can't -// be CheckUnwrapped, or if the global of the result has no docgroup -// (e.g. because it's not a Window global). -CustomElementReactionsStack* -GetCustomElementReactionsStack(JS::Handle<JSObject*> aObj); // This function is expected to be called from the constructor function for an // HTML element interface; the global/callargs need to be whatever was passed to // that constructor function. diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index 8985863e8..c9a5e9f41 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -7680,14 +7680,14 @@ class CGPerSignatureCall(CGThing): if (idlNode.getExtendedAttribute('CEReactions') is not None and not getter): - cgThings.append(CGGeneric(fill( + cgThings.append(CGGeneric(dedent( """ - CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(${obj}); - Maybe<AutoCEReaction> ceReaction; - if (reactionsStack) { - ceReaction.emplace(reactionsStack, cx); + Maybe<AutoCEReaction> ceReaction; + DocGroup* docGroup = self->GetDocGroup(); + if (docGroup) { + ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx); } - """, obj=objectName))) + """))) # If this is a method that was generated by a maplike/setlike # interface, use the maplike/setlike generator to fill in the body. @@ -13786,6 +13786,8 @@ class CGForwardDeclarations(CGWrapper): builder.add(d.nativeType + "Atoms", isStruct=True) for t in getTypesFromDescriptor(d): builder.forwardDeclareForType(t, config) + if d.hasCEReactions(): + builder.addInMozillaDom("DocGroup") for d in dictionaries: if len(d.members) > 0: @@ -13857,18 +13859,15 @@ class CGBindingRoot(CGThing): iface = desc.interface return any(m.getExtendedAttribute("Deprecated") for m in iface.members + [iface]) - def descriptorHasCEReactions(desc): - iface = desc.interface - return any(m.getExtendedAttribute("CEReactions") for m in iface.members + [iface]) - bindingHeaders["nsIDocument.h"] = any( descriptorDeprecated(d) for d in descriptors) bindingHeaders["mozilla/Preferences.h"] = any( descriptorRequiresPreferences(d) for d in descriptors) bindingHeaders["mozilla/dom/DOMJSProxyHandler.h"] = any( d.concrete and d.proxy for d in descriptors) - bindingHeaders["mozilla/dom/CustomElementRegistry.h"] = any( - descriptorHasCEReactions(d) for d in descriptors) + hasCEReactions = any(d.hasCEReactions() for d in descriptors) + bindingHeaders["mozilla/dom/CustomElementRegistry.h"] = hasCEReactions + bindingHeaders["mozilla/dom/DocGroup.h"] = hasCEReactions def descriptorHasChromeOnly(desc): ctor = desc.interface.ctor() @@ -14704,6 +14703,12 @@ class CGBindingImplClass(CGClass): breakAfterReturnDecl=" ", override=descriptor.wrapperCache, body=self.getWrapObjectBody())) + if descriptor.hasCEReactions(): + self.methodDecls.insert(0, + ClassMethod("GetDocGroup", "DocGroup*", [], + const=True, + breakAfterReturnDecl=" ", + body=self.getGetDocGroupBody())) if wantGetParent: self.methodDecls.insert(0, ClassMethod("GetParentObject", @@ -14724,6 +14729,9 @@ class CGBindingImplClass(CGClass): def getGetParentObjectBody(self): return None + def getGetDocGroupBody(self): + return None + def deps(self): return self._deps @@ -14863,6 +14871,8 @@ class CGExampleRoot(CGThing): self.root = CGNamespace.build(["mozilla", "dom"], self.root) builder = ForwardDeclarationBuilder() + if descriptor.hasCEReactions(): + builder.addInMozillaDom("DocGroup") for member in descriptor.interface.members: if not member.isAttr() and not member.isMethod(): continue @@ -15174,7 +15184,7 @@ class CGJSImplClass(CGBindingImplClass): private: RefPtr<${jsImplName}> mImpl; - nsCOMPtr<nsISupports> mParent; + nsCOMPtr<nsIGlobalObject> mParent; """, isupportsDecl=isupportsDecl, @@ -15253,6 +15263,16 @@ class CGJSImplClass(CGBindingImplClass): def getGetParentObjectBody(self): return "return mParent;\n" + def getGetDocGroupBody(self): + return dedent( + """ + nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(mParent); + if (!window) { + return nullptr; + } + return window->GetDocGroup(); + """) + def getCreateFromExistingBody(self): # XXXbz we could try to get parts of this (e.g. the argument # conversions) auto-generated by somehow creating an IDLMethod and diff --git a/dom/bindings/Configuration.py b/dom/bindings/Configuration.py index a56f2f2fd..2669e3e4c 100644 --- a/dom/bindings/Configuration.py +++ b/dom/bindings/Configuration.py @@ -631,6 +631,9 @@ class Descriptor(DescriptorProvider): not self.interface.isExposedInWindow()) or self.interface.isExposedInSomeButNotAllWorkers()) + def hasCEReactions(self): + return any(m.getExtendedAttribute("CEReactions") for m in self.interface.members) + def isExposedConditionally(self): return (self.interface.isExposedConditionally() or self.interface.isExposedInSomeButNotAllWorkers()) diff --git a/dom/bindings/test/TestBindingHeader.h b/dom/bindings/test/TestBindingHeader.h index 7d9963700..4e2e10e43 100644 --- a/dom/bindings/test/TestBindingHeader.h +++ b/dom/bindings/test/TestBindingHeader.h @@ -21,6 +21,7 @@ // this one for it, for ParentDict. Hopefully it won't begin to rely on it in more fundamental ways. namespace mozilla { namespace dom { +class DocGroup; class TestExternalInterface; class Promise; } // namespace dom @@ -46,8 +47,9 @@ public: NS_DECLARE_STATIC_IID_ACCESSOR(NS_RENAMED_INTERFACE_IID) NS_DECL_ISUPPORTS - // We need a GetParentObject to make binding codegen happy + // We need a GetParentObject and GetDocGroup to make binding codegen happy virtual nsISupports* GetParentObject(); + DocGroup* GetDocGroup() const; }; NS_DEFINE_STATIC_IID_ACCESSOR(nsRenamedInterface, NS_RENAMED_INTERFACE_IID) @@ -64,8 +66,9 @@ public: NS_DECLARE_STATIC_IID_ACCESSOR(NS_INDIRECTLY_IMPLEMENTED_INTERFACE_IID) NS_DECL_ISUPPORTS - // We need a GetParentObject to make binding codegen happy + // We need a GetParentObject and GetDocGroup to make binding codegen happy virtual nsISupports* GetParentObject(); + DocGroup* GetDocGroup() const; bool IndirectlyImplementedProperty(); void IndirectlyImplementedProperty(bool); diff --git a/dom/html/HTMLOptionsCollection.cpp b/dom/html/HTMLOptionsCollection.cpp index 67de97fc4..da8a9d571 100644 --- a/dom/html/HTMLOptionsCollection.cpp +++ b/dom/html/HTMLOptionsCollection.cpp @@ -239,6 +239,12 @@ HTMLOptionsCollection::GetParentObject() return mSelect; } +DocGroup* +HTMLOptionsCollection::GetDocGroup() const +{ + return mSelect ? mSelect->GetDocGroup() : nullptr; +} + NS_IMETHODIMP HTMLOptionsCollection::NamedItem(const nsAString& aName, nsIDOMNode** aReturn) diff --git a/dom/html/HTMLOptionsCollection.h b/dom/html/HTMLOptionsCollection.h index 496919555..9dd1561f6 100644 --- a/dom/html/HTMLOptionsCollection.h +++ b/dom/html/HTMLOptionsCollection.h @@ -23,6 +23,7 @@ class nsIDOMHTMLOptionElement; namespace mozilla { namespace dom { +class DocGroup; class HTMLElementOrLong; class HTMLOptionElementOrHTMLOptGroupElement; class HTMLSelectElement; @@ -62,6 +63,7 @@ public: virtual Element* GetElementAt(uint32_t aIndex) override; virtual nsINode* GetParentObject() override; + DocGroup* GetDocGroup() const; NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(HTMLOptionsCollection, nsIHTMLCollection) diff --git a/dom/html/nsDOMStringMap.cpp b/dom/html/nsDOMStringMap.cpp index 6d2bc424d..7e2ed0ece 100644 --- a/dom/html/nsDOMStringMap.cpp +++ b/dom/html/nsDOMStringMap.cpp @@ -62,6 +62,12 @@ nsDOMStringMap::~nsDOMStringMap() } } +DocGroup* +nsDOMStringMap::GetDocGroup() const +{ + return mElement ? mElement->GetDocGroup() : nullptr; +} + /* virtual */ JSObject* nsDOMStringMap::WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto) diff --git a/dom/html/nsDOMStringMap.h b/dom/html/nsDOMStringMap.h index bf28957f7..6506f1464 100644 --- a/dom/html/nsDOMStringMap.h +++ b/dom/html/nsDOMStringMap.h @@ -16,6 +16,9 @@ namespace mozilla { class ErrorResult; +namespace dom { +class DocGroup; +} // namespace dom } // namespace mozilla class nsDOMStringMap : public nsStubMutationObserver, @@ -32,6 +35,8 @@ public: return mElement; } + mozilla::dom::DocGroup* GetDocGroup() const; + explicit nsDOMStringMap(mozilla::dom::Element* aElement); // WebIDL API diff --git a/dom/xslt/xslt/txMozillaXSLTProcessor.cpp b/dom/xslt/xslt/txMozillaXSLTProcessor.cpp index facb435b4..0a2dd9b08 100644 --- a/dom/xslt/xslt/txMozillaXSLTProcessor.cpp +++ b/dom/xslt/xslt/txMozillaXSLTProcessor.cpp @@ -1284,6 +1284,11 @@ txMozillaXSLTProcessor::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenP return XSLTProcessorBinding::Wrap(aCx, this, aGivenProto); } +DocGroup* +txMozillaXSLTProcessor::GetDocGroup() const +{ + return mStylesheetDocument ? mStylesheetDocument->GetDocGroup() : nullptr; +} /* static */ already_AddRefed<txMozillaXSLTProcessor> txMozillaXSLTProcessor::Constructor(const GlobalObject& aGlobal, diff --git a/dom/xslt/xslt/txMozillaXSLTProcessor.h b/dom/xslt/xslt/txMozillaXSLTProcessor.h index 93d3c2c30..fc76585f2 100644 --- a/dom/xslt/xslt/txMozillaXSLTProcessor.h +++ b/dom/xslt/xslt/txMozillaXSLTProcessor.h @@ -29,6 +29,7 @@ class txIGlobalParameter; namespace mozilla { namespace dom { +class DocGroup; class Document; class DocumentFragment; class GlobalObject; @@ -103,6 +104,8 @@ public: return mOwner; } + mozilla::dom::DocGroup* GetDocGroup() const; + static already_AddRefed<txMozillaXSLTProcessor> Constructor(const mozilla::dom::GlobalObject& aGlobal, mozilla::ErrorResult& aRv); diff --git a/layout/generic/Selection.h b/layout/generic/Selection.h index 5414d15c1..cc696a7c7 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 994ec4852..919ab0815 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 622f498dd..aca97a505 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 4b90b6f0c..dc79e471d 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 daefaf3f9..1bd468cb6 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 e94d8dbf6..5af518c2e 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 ce638a9c2..7b659a8cc 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 7c0fbacc0..25f7eee74 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 ff6ec4a78..fa80c17f5 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. |