diff --git a/layout/style/CSSStyleSheet.cpp b/layout/style/CSSStyleSheet.cpp index 6c79946753c9..ea1878949e52 100644 --- a/layout/style/CSSStyleSheet.cpp +++ b/layout/style/CSSStyleSheet.cpp @@ -601,8 +601,8 @@ CSSStyleSheet::List(FILE* out, int32_t aIndent) const } #endif -void -CSSStyleSheet::ClearRuleCascadesInternal() +void +CSSStyleSheet::ClearRuleCascades() { // We might be in ClearRuleCascadesInternal because we had a modification // to the sheet that resulted in an nsCSSSelector being destroyed. @@ -628,6 +628,10 @@ CSSStyleSheet::ClearRuleCascadesInternal() (*iter)->ClearRuleCascades(); } } + + if (mParent) { + static_cast(mParent)->ClearRuleCascades(); + } } void diff --git a/layout/style/CSSStyleSheet.h b/layout/style/CSSStyleSheet.h index 4259862787cf..a90fea404a69 100644 --- a/layout/style/CSSStyleSheet.h +++ b/layout/style/CSSStyleSheet.h @@ -178,7 +178,7 @@ private: protected: virtual ~CSSStyleSheet(); - void ClearRuleCascadesInternal() override; + void ClearRuleCascades(); // Add the namespace mapping from this @namespace rule to our namespace map nsresult RegisterNamespaceRule(css::Rule* aRule); diff --git a/layout/style/ServoStyleSheet.cpp b/layout/style/ServoStyleSheet.cpp index 3ef739872519..a6b273e07bf1 100644 --- a/layout/style/ServoStyleSheet.cpp +++ b/layout/style/ServoStyleSheet.cpp @@ -219,15 +219,6 @@ ServoStyleSheet::Clone(StyleSheet* aCloneParent, return clone.forget(); } -void -ServoStyleSheet::ClearRuleCascadesInternal() -{ - for (StyleSetHandle& setHandle : mStyleSets) { - setHandle->AsServo()->NoteStyleSheetsChanged(); - setHandle->AsServo()->UpdateStylistIfNeeded(); - } -} - CSSRuleList* ServoStyleSheet::GetCssRulesInternal(ErrorResult& aRv) { diff --git a/layout/style/ServoStyleSheet.h b/layout/style/ServoStyleSheet.h index 57aa098efd0c..fb8441d7e773 100644 --- a/layout/style/ServoStyleSheet.h +++ b/layout/style/ServoStyleSheet.h @@ -123,8 +123,6 @@ public: protected: virtual ~ServoStyleSheet(); - void ClearRuleCascadesInternal() override; - ServoStyleSheetInner* Inner() const { return static_cast(mInner); diff --git a/layout/style/StyleSheet.cpp b/layout/style/StyleSheet.cpp index 8dc4bc4ff1cd..2f94d9d3b781 100644 --- a/layout/style/StyleSheet.cpp +++ b/layout/style/StyleSheet.cpp @@ -127,15 +127,6 @@ StyleSheet::TraverseInner(nsCycleCollectionTraversalCallback &cb) } } -void -StyleSheet::ClearRuleCascades() -{ - ClearRuleCascadesInternal(); - if (mParent) { - mParent->ClearRuleCascades(); - } -} - // QueryInterface implementation for StyleSheet NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(StyleSheet) NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY @@ -448,7 +439,14 @@ StyleSheet::EnsureUniqueInner() mInner = clone; // Ensure we're using the new rules. - ClearRuleCascades(); + // + // NOTE: In Servo, all kind of changes that change the set of selectors or + // rules we match are covered by the PresShell notifications. In Gecko that's + // true too, but this is probably needed because selectors are not refcounted + // and can become stale. + if (CSSStyleSheet* geckoSheet = GetAsGecko()) { + geckoSheet->ClearRuleCascades(); + } // let our containing style sets know that if we call // nsPresContext::EnsureSafeToHandOutCSSRules we will need to restyle the diff --git a/layout/style/StyleSheet.h b/layout/style/StyleSheet.h index 57a92a1d81b7..99ccd99fee1f 100644 --- a/layout/style/StyleSheet.h +++ b/layout/style/StyleSheet.h @@ -288,9 +288,6 @@ protected: // Traverse our inner, if needed, for cycle collection virtual void TraverseInner(nsCycleCollectionTraversalCallback &); - void ClearRuleCascades(); - virtual void ClearRuleCascadesInternal() {} - StyleSheet* mParent; // weak ref nsString mTitle;