diff --git a/layout/style/CSSStyleSheet.cpp b/layout/style/CSSStyleSheet.cpp index f811405590d8..6c79946753c9 100644 --- a/layout/style/CSSStyleSheet.cpp +++ b/layout/style/CSSStyleSheet.cpp @@ -568,16 +568,6 @@ CSSStyleSheet::GetStyleRuleAt(int32_t aIndex) const return Inner()->mOrderedRules.SafeObjectAt(aIndex); } -void -CSSStyleSheet::AppendAllChildSheets(nsTArray& aArray) -{ - for (StyleSheet* child = GetFirstChild(); child; - child = child->mNext) { - - aArray.AppendElement(child->AsGecko()); - } -} - already_AddRefed CSSStyleSheet::Clone(StyleSheet* aCloneParent, css::ImportRule* aCloneOwnerRule, diff --git a/layout/style/CSSStyleSheet.h b/layout/style/CSSStyleSheet.h index cce2b86f70d8..4259862787cf 100644 --- a/layout/style/CSSStyleSheet.h +++ b/layout/style/CSSStyleSheet.h @@ -140,9 +140,6 @@ public: NS_IMETHOD StyleSheetLoaded(StyleSheet* aSheet, bool aWasAlternate, nsresult aStatus) override; - // Append all of this sheet's child sheets to aArray. - void AppendAllChildSheets(nsTArray& aArray); - bool UseForPresentation(nsPresContext* aPresContext, nsMediaQueryResultCacheKey& aKey) const; diff --git a/layout/style/ServoStyleSet.cpp b/layout/style/ServoStyleSet.cpp index 6265152150e8..a1abcc3d8503 100644 --- a/layout/style/ServoStyleSet.cpp +++ b/layout/style/ServoStyleSet.cpp @@ -987,9 +987,29 @@ ServoStyleSet::ComputeAnimationValue( bool ServoStyleSet::EnsureUniqueInnerOnCSSSheets() { + AutoTArray queue; + for (auto& entryArray : mSheets) { + for (auto& sheet : entryArray) { + queue.AppendElement(sheet); + } + } // This is a stub until more of the functionality of nsStyleSet is // replicated for Servo here. + // Bug 1290276 will replicate the nsStyleSet work of checking + // a nsBindingManager + + while (!queue.IsEmpty()) { + uint32_t idx = queue.Length() - 1; + StyleSheet* sheet = queue[idx]; + queue.RemoveElementAt(idx); + + sheet->EnsureUniqueInner(); + + // Enqueue all the sheet's children. + sheet->AppendAllChildSheets(queue); + } + bool res = mNeedsRestyleAfterEnsureUniqueInner; mNeedsRestyleAfterEnsureUniqueInner = false; return res; diff --git a/layout/style/StyleSheet.cpp b/layout/style/StyleSheet.cpp index db86f5a2ee38..a2b338c0b3a1 100644 --- a/layout/style/StyleSheet.cpp +++ b/layout/style/StyleSheet.cpp @@ -458,6 +458,14 @@ StyleSheet::EnsureUniqueInner() } } +void +StyleSheet::AppendAllChildSheets(nsTArray& aArray) +{ + for (StyleSheet* child = GetFirstChild(); child; child = child->mNext) { + aArray.AppendElement(child); + } +} + // WebIDL CSSStyleSheet API #define FORWARD_INTERNAL(method_, args_) \ diff --git a/layout/style/StyleSheet.h b/layout/style/StyleSheet.h index 4d8199e8eee2..eaa7e65ffb1b 100644 --- a/layout/style/StyleSheet.h +++ b/layout/style/StyleSheet.h @@ -124,6 +124,9 @@ public: void EnsureUniqueInner(); + // Append all of this sheet's child sheets to aArray. + void AppendAllChildSheets(nsTArray& aArray); + // style sheet owner info enum DocumentAssociationMode { // OwnedByDocument means mDocument owns us (possibly via a chain of other diff --git a/layout/style/nsStyleSet.cpp b/layout/style/nsStyleSet.cpp index c1a7d9a2baa5..a6f2e390c685 100644 --- a/layout/style/nsStyleSet.cpp +++ b/layout/style/nsStyleSet.cpp @@ -2638,9 +2638,9 @@ nsStyleSet::MediumFeaturesChanged() bool nsStyleSet::EnsureUniqueInnerOnCSSSheets() { - AutoTArray queue; + AutoTArray queue; for (SheetType type : gCSSSheetTypes) { - for (CSSStyleSheet* sheet : mSheets[type]) { + for (StyleSheet* sheet : mSheets[type]) { queue.AppendElement(sheet); } } @@ -2660,7 +2660,7 @@ nsStyleSet::EnsureUniqueInnerOnCSSSheets() while (!queue.IsEmpty()) { uint32_t idx = queue.Length() - 1; - CSSStyleSheet* sheet = queue[idx]; + StyleSheet* sheet = queue[idx]; queue.RemoveElementAt(idx); sheet->EnsureUniqueInner();