From 1ea913ec8d2748f78e7f9560996ab4db2684b5e9 Mon Sep 17 00:00:00 2001 From: Cristian Tuns Date: Thu, 28 Apr 2022 05:37:52 -0400 Subject: [PATCH] Backed out 2 changesets (bug 1644102, bug 1752392) for causing mochitest failures in test_parseStyleSheetImport.html CLOSED TREE Backed out changeset b5c0bdafaf5e (bug 1644102) Backed out changeset 092814d96f1d (bug 1752392) --- layout/style/ServoCSSRuleList.cpp | 28 ++++++------------- layout/style/ServoCSSRuleList.h | 9 +----- layout/style/StyleSheet.cpp | 25 ++++++----------- layout/style/StyleSheet.h | 5 ---- modules/libpref/init/StaticPrefList.yaml | 2 +- .../CSSStyleSheet-constructable-cssRules.html | 22 --------------- toolkit/components/featuregates/Features.toml | 2 +- 7 files changed, 20 insertions(+), 73 deletions(-) delete mode 100644 testing/web-platform/tests/css/cssom/CSSStyleSheet-constructable-cssRules.html diff --git a/layout/style/ServoCSSRuleList.cpp b/layout/style/ServoCSSRuleList.cpp index 808770095188..74136b549ec9 100644 --- a/layout/style/ServoCSSRuleList.cpp +++ b/layout/style/ServoCSSRuleList.cpp @@ -36,7 +36,9 @@ ServoCSSRuleList::ServoCSSRuleList(already_AddRefed aRawRules, StyleSheet* aSheet, css::GroupRule* aParentRule) : mStyleSheet(aSheet), mParentRule(aParentRule), mRawRules(aRawRules) { - ResetRules(); + if (mRawRules) { + Servo_CssRules_ListTypes(mRawRules, &mRules); + } } // QueryInterface implementation for ServoCSSRuleList @@ -132,7 +134,10 @@ static void DropRule(already_AddRefed aRule) { rule->DropReferences(); } -void ServoCSSRuleList::ResetRules() { +void ServoCSSRuleList::DropAllRules() { + mStyleSheet = nullptr; + mParentRule = nullptr; + mRawRules = nullptr; // DropRule could reenter here via the cycle collector. auto rules = std::move(mRules); for (uintptr_t rule : rules) { @@ -141,17 +146,6 @@ void ServoCSSRuleList::ResetRules() { } } MOZ_ASSERT(mRules.IsEmpty()); - if (mRawRules) { - Servo_CssRules_ListTypes(mRawRules, &mRules); - } -} - -void ServoCSSRuleList::DropAllRules() { - mStyleSheet = nullptr; - mParentRule = nullptr; - mRawRules = nullptr; - - ResetRules(); } void ServoCSSRuleList::DropSheetReference() { @@ -227,14 +221,8 @@ nsresult ServoCSSRuleList::DeleteRule(uint32_t aIndex) { return rv; } -void ServoCSSRuleList::SetRawContents(RefPtr aNewRules, - bool aFromClone) { +void ServoCSSRuleList::SetRawAfterClone(RefPtr aNewRules) { mRawRules = std::move(aNewRules); - if (!aFromClone) { - ResetRules(); - return; - } - EnumerateInstantiatedRules([&](css::Rule* aRule, uint32_t aIndex) { #define CASE_FOR(constant_, type_) \ case StyleCssRuleType::constant_: { \ diff --git a/layout/style/ServoCSSRuleList.h b/layout/style/ServoCSSRuleList.h index 4c65e0097c21..18eefb3f04ff 100644 --- a/layout/style/ServoCSSRuleList.h +++ b/layout/style/ServoCSSRuleList.h @@ -48,13 +48,7 @@ class ServoCSSRuleList final : public dom::CSSRuleList { nsresult InsertRule(const nsACString& aRule, uint32_t aIndex); nsresult DeleteRule(uint32_t aIndex); - // aFromClone says whether this comes from a clone of the stylesheet (and thus - // we should also fix up the wrappers for the individual rules in the rule - // lists). - void SetRawContents(RefPtr, bool aFromClone); - void SetRawAfterClone(RefPtr aRules) { - SetRawContents(std::move(aRules), /* aFromClone = */ true); - } + void SetRawAfterClone(RefPtr); private: virtual ~ServoCSSRuleList(); @@ -75,7 +69,6 @@ class ServoCSSRuleList final : public dom::CSSRuleList { void EnumerateInstantiatedRules(Func aCallback); void DropAllRules(); - void ResetRules(); bool IsReadOnly() const; diff --git a/layout/style/StyleSheet.cpp b/layout/style/StyleSheet.cpp index 3b2c02a61a3f..66d04666aa5b 100644 --- a/layout/style/StyleSheet.cpp +++ b/layout/style/StyleSheet.cpp @@ -773,8 +773,8 @@ void StyleSheet::ReplaceSync(const nsACString& aText, ErrorResult& aRv) { .Consume(); // 5. Set sheet's rules to the new rules. + DropRuleList(); Inner().mContents = std::move(rawContent); - FixUpRuleListAfterContentsChangeIfNeeded(); FinishParse(); RuleChanged(nullptr, StyleRuleChangeKind::Generic); } @@ -1109,25 +1109,18 @@ JSObject* StyleSheet::WrapObject(JSContext* aCx, return dom::CSSStyleSheet_Binding::Wrap(aCx, this, aGivenProto); } -void StyleSheet::FixUpRuleListAfterContentsChangeIfNeeded(bool aFromClone) { - if (!mRuleList) { - return; - } - - RefPtr rules = - Servo_StyleSheet_GetRules(Inner().mContents.get()).Consume(); - mRuleList->SetRawContents(std::move(rules), aFromClone); -} - void StyleSheet::FixUpAfterInnerClone() { MOZ_ASSERT(Inner().mSheets.Length() == 1, "Should've just cloned"); MOZ_ASSERT(Inner().mSheets[0] == this); MOZ_ASSERT(Inner().mChildren.IsEmpty()); - FixUpRuleListAfterContentsChangeIfNeeded(/* aFromClone = */ true); + auto* contents = Inner().mContents.get(); + RefPtr rules = Servo_StyleSheet_GetRules(contents).Consume(); + + if (mRuleList) { + mRuleList->SetRawAfterClone(rules); + } - RefPtr rules = - Servo_StyleSheet_GetRules(Inner().mContents.get()).Consume(); uint32_t index = 0; while (true) { uint32_t line, column; // Actually unused. @@ -1336,11 +1329,11 @@ void StyleSheet::ReparseSheet(const nsACString& aInput, ErrorResult& aRv) { } } + DropRuleList(); + ParseSheetSync(loader, aInput, /* aLoadData = */ nullptr, lineNumber, &reusableSheets); - FixUpRuleListAfterContentsChangeIfNeeded(); - // Notify the stylesets about the new rules. { // Get the rule list (which will need to be regenerated after ParseSheet). diff --git a/layout/style/StyleSheet.h b/layout/style/StyleSheet.h index d68f1a0cac33..128bd4dbce74 100644 --- a/layout/style/StyleSheet.h +++ b/layout/style/StyleSheet.h @@ -516,11 +516,6 @@ class StyleSheet final : public nsICSSLoaderObserver, public nsWrapperCache { // correctly to `aPrimarySheet`. void FixUpAfterInnerClone(); - // aFromClone says whether this comes from a clone of the stylesheet (and thus - // we should also fix up the wrappers for the individual rules in the rule - // lists). - void FixUpRuleListAfterContentsChangeIfNeeded(bool aFromClone = false); - void DropRuleList(); // Called when a rule is removed from the sheet from CSSOM. diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml index 1f7908c26a64..0af459383c52 100644 --- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -7330,7 +7330,7 @@ # Whether Constructable Stylesheets are enabled in script. - name: layout.css.constructable-stylesheets.enabled type: bool - value: true + value: false mirror: always # Whether trigonometric constants and functions are enabled in calc(). diff --git a/testing/web-platform/tests/css/cssom/CSSStyleSheet-constructable-cssRules.html b/testing/web-platform/tests/css/cssom/CSSStyleSheet-constructable-cssRules.html deleted file mode 100644 index 72b0e15c8b84..000000000000 --- a/testing/web-platform/tests/css/cssom/CSSStyleSheet-constructable-cssRules.html +++ /dev/null @@ -1,22 +0,0 @@ - - -CSSStyleSheet.replace/replaceSync() doesn't change cssRules object - - - - - - -Should be green - diff --git a/toolkit/components/featuregates/Features.toml b/toolkit/components/featuregates/Features.toml index ed509f43dc01..ac719e3db76c 100644 --- a/toolkit/components/featuregates/Features.toml +++ b/toolkit/components/featuregates/Features.toml @@ -40,7 +40,7 @@ preference = "layout.css.constructable-stylesheets.enabled" type = "boolean" bug-numbers = [1520690] is-public = {default = false, nightly = true} -default-value = true +default-value = false [devtools-compatibility-panel] title = "experimental-features-devtools-compatibility-panel"