diff --git a/layout/style/CSSStyleSheet.cpp b/layout/style/CSSStyleSheet.cpp index 4833bce7c89f..939c1ea3b243 100644 --- a/layout/style/CSSStyleSheet.cpp +++ b/layout/style/CSSStyleSheet.cpp @@ -371,7 +371,6 @@ CSSStyleSheetInner::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const CSSStyleSheet::CSSStyleSheet(css::SheetParsingMode aParsingMode, CORSMode aCORSMode, ReferrerPolicy aReferrerPolicy) : StyleSheet(StyleBackendType::Gecko, aParsingMode), - mParent(nullptr), mOwnerRule(nullptr), mDirty(false), mInRuleProcessorCache(false), @@ -387,7 +386,6 @@ CSSStyleSheet::CSSStyleSheet(css::SheetParsingMode aParsingMode, ReferrerPolicy aReferrerPolicy, const SRIMetadata& aIntegrity) : StyleSheet(StyleBackendType::Gecko, aParsingMode), - mParent(nullptr), mOwnerRule(nullptr), mDirty(false), mInRuleProcessorCache(false), @@ -404,7 +402,6 @@ CSSStyleSheet::CSSStyleSheet(const CSSStyleSheet& aCopy, nsIDocument* aDocumentToUse, nsINode* aOwningNodeToUse) : StyleSheet(aCopy, aDocumentToUse, aOwningNodeToUse), - mParent(aParentToUse), mOwnerRule(aOwnerRuleToUse), mDirty(aCopy.mDirty), mInRuleProcessorCache(false), @@ -412,6 +409,7 @@ CSSStyleSheet::CSSStyleSheet(const CSSStyleSheet& aCopy, mInner(aCopy.mInner), mRuleProcessors(nullptr) { + mParent = aParentToUse; mInner->AddSheet(this); @@ -609,12 +607,6 @@ CSSStyleSheet::EnabledStateChangedInternal() ClearRuleCascades(); } -CSSStyleSheet* -CSSStyleSheet::GetParentSheet() const -{ - return mParent; -} - void CSSStyleSheet::SetAssociatedDocument(nsIDocument* aDocument, DocumentAssociationMode aAssociationMode) @@ -657,7 +649,8 @@ CSSStyleSheet::FindOwningWindowInnerID() const } if (windowID == 0 && mParent) { - windowID = mParent->FindOwningWindowInnerID(); + CSSStyleSheet* parentAsCSS = mParent->AsGecko(); + windowID = parentAsCSS->FindOwningWindowInnerID(); } return windowID; diff --git a/layout/style/CSSStyleSheet.h b/layout/style/CSSStyleSheet.h index 8ba8a83860a7..329cc7091941 100644 --- a/layout/style/CSSStyleSheet.h +++ b/layout/style/CSSStyleSheet.h @@ -115,8 +115,6 @@ public: bool HasRules() const; - // style sheet owner info - CSSStyleSheet* GetParentSheet() const; // may be null void SetAssociatedDocument(nsIDocument* aDocument, DocumentAssociationMode aAssociationMode); @@ -236,7 +234,6 @@ protected: void EnabledStateChangedInternal(); RefPtr mNext; - CSSStyleSheet* mParent; // weak ref css::ImportRule* mOwnerRule; // weak ref RefPtr mRuleCollection; diff --git a/layout/style/ServoStyleSheet.cpp b/layout/style/ServoStyleSheet.cpp index f6f34300cafa..fee88cf95b66 100644 --- a/layout/style/ServoStyleSheet.cpp +++ b/layout/style/ServoStyleSheet.cpp @@ -67,15 +67,6 @@ ServoStyleSheet::SetAssociatedDocument(nsIDocument* aDocument, mDocumentAssociationMode = aAssociationMode; } -ServoStyleSheet* -ServoStyleSheet::GetParentSheet() const -{ - // XXXheycam: When we implement support for child sheets, we'll have - // to fix SetAssociatedDocument to propagate the associated document down - // to the children. - MOZ_CRASH("stylo: not implemented"); -} - void ServoStyleSheet::AppendStyleSheet(ServoStyleSheet* aSheet) { diff --git a/layout/style/ServoStyleSheet.h b/layout/style/ServoStyleSheet.h index 8411febbb543..48dee2029839 100644 --- a/layout/style/ServoStyleSheet.h +++ b/layout/style/ServoStyleSheet.h @@ -42,7 +42,6 @@ public: void SetAssociatedDocument(nsIDocument* aDocument, DocumentAssociationMode aAssociationMode); - ServoStyleSheet* GetParentSheet() const; void AppendStyleSheet(ServoStyleSheet* aSheet); MOZ_MUST_USE nsresult ParseSheet(css::Loader* aLoader, diff --git a/layout/style/StyleSheet.cpp b/layout/style/StyleSheet.cpp index 81b002d346ed..5e499c4d0605 100644 --- a/layout/style/StyleSheet.cpp +++ b/layout/style/StyleSheet.cpp @@ -19,7 +19,8 @@ namespace mozilla { StyleSheet::StyleSheet(StyleBackendType aType, css::SheetParsingMode aParsingMode) - : mDocument(nullptr) + : mParent(nullptr) + , mDocument(nullptr) , mOwningNode(nullptr) , mParsingMode(aParsingMode) , mType(aType) @@ -31,7 +32,8 @@ StyleSheet::StyleSheet(StyleBackendType aType, css::SheetParsingMode aParsingMod StyleSheet::StyleSheet(const StyleSheet& aCopy, nsIDocument* aDocumentToUse, nsINode* aOwningNodeToUse) - : mTitle(aCopy.mTitle) + : mParent(nullptr) + , mTitle(aCopy.mTitle) , mDocument(aDocumentToUse) , mOwningNode(aOwningNodeToUse) , mParsingMode(aCopy.mParsingMode) diff --git a/layout/style/StyleSheet.h b/layout/style/StyleSheet.h index 1ee75cd680d0..74815f5bcabf 100644 --- a/layout/style/StyleSheet.h +++ b/layout/style/StyleSheet.h @@ -124,7 +124,7 @@ public: DocumentAssociationMode aMode); inline void ClearAssociatedDocument(); nsINode* GetOwnerNode() const { return mOwningNode; } - inline StyleSheet* GetParentSheet() const; + inline StyleSheet* GetParentSheet() const { return mParent; } inline void AppendStyleSheet(StyleSheet* aSheet); @@ -227,6 +227,8 @@ protected: // Called from SetEnabled when the enabled state changed. void EnabledStateChanged(); + StyleSheet* mParent; // weak ref + nsString mTitle; nsIDocument* mDocument; // weak ref; parents maintain this for their children nsINode* mOwningNode; // weak ref diff --git a/layout/style/StyleSheetInlines.h b/layout/style/StyleSheetInlines.h index c0b8495f8757..43d8b4154c4c 100644 --- a/layout/style/StyleSheetInlines.h +++ b/layout/style/StyleSheetInlines.h @@ -96,12 +96,6 @@ StyleSheet::ClearAssociatedDocument() MOZ_STYLO_FORWARD(SetAssociatedDocument, (nullptr, NotOwnedByDocument)); } -StyleSheet* -StyleSheet::GetParentSheet() const -{ - MOZ_STYLO_FORWARD(GetParentSheet, ()) -} - StyleSheet* StyleSheet::GetParentStyleSheet() const {