From def92d1b8e9d373e2f6f27c366d578d97d8960c6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 15 May 2024 05:34:50 +0200 Subject: Merging upstream version 126.0. Signed-off-by: Daniel Baumann --- layout/style/ServoCSSRuleList.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'layout/style/ServoCSSRuleList.cpp') diff --git a/layout/style/ServoCSSRuleList.cpp b/layout/style/ServoCSSRuleList.cpp index 6fcdfdd4b5..133a962256 100644 --- a/layout/style/ServoCSSRuleList.cpp +++ b/layout/style/ServoCSSRuleList.cpp @@ -22,6 +22,8 @@ #include "mozilla/dom/CSSNamespaceRule.h" #include "mozilla/dom/CSSPageRule.h" #include "mozilla/dom/CSSPropertyRule.h" +#include "mozilla/dom/CSSScopeRule.h" +#include "mozilla/dom/CSSStartingStyleRule.h" #include "mozilla/dom/CSSStyleRule.h" #include "mozilla/dom/CSSSupportsRule.h" #include "mozilla/IntegerRange.h" @@ -98,6 +100,8 @@ css::Rule* ServoCSSRuleList::GetRule(uint32_t aIndex) { CASE_RULE_UNLOCKED(LayerBlock, LayerBlock) CASE_RULE_UNLOCKED(LayerStatement, LayerStatement) CASE_RULE_UNLOCKED(Container, Container) + CASE_RULE_UNLOCKED(Scope, Scope) + CASE_RULE_UNLOCKED(StartingStyle, StartingStyle) #undef CASE_RULE_LOCKED #undef CASE_RULE_UNLOCKED #undef CASE_RULE_WITH_PREFIX @@ -208,12 +212,21 @@ nsresult ServoCSSRuleList::InsertRule(const nsACString& aRule, } StyleCssRuleType type; uint32_t containingTypes = 0; + Maybe parseRelativeRuleType; for (css::Rule* rule = mParentRule; rule; rule = rule->GetParentRule()) { - containingTypes |= (1 << uint32_t(rule->Type())); + const auto ruleType = rule->Type(); + containingTypes |= (1 << uint32_t(ruleType)); + if (parseRelativeRuleType.isNothing() && + (ruleType == StyleCssRuleType::Style || + ruleType == StyleCssRuleType::Scope)) { + // Only the closest applicable type to this rule matters. + parseRelativeRuleType = Some(ruleType); + } } nsresult rv = Servo_CssRules_InsertRule( mRawRules, mStyleSheet->RawContents(), &aRule, aIndex, containingTypes, - loader, allowImportRules, mStyleSheet, &type); + parseRelativeRuleType.ptrOr(nullptr), loader, allowImportRules, + mStyleSheet, &type); NS_ENSURE_SUCCESS(rv, rv); mRules.InsertElementAt(aIndex, uintptr_t(type)); return rv; @@ -276,6 +289,8 @@ void ServoCSSRuleList::SetRawContents(RefPtr aNewRules, RULE_CASE_UNLOCKED(LayerBlock, LayerBlock) RULE_CASE_UNLOCKED(LayerStatement, LayerStatement) RULE_CASE_UNLOCKED(Container, Container) + RULE_CASE_UNLOCKED(Scope, Scope) + RULE_CASE_UNLOCKED(StartingStyle, StartingStyle) case StyleCssRuleType::Keyframe: MOZ_ASSERT_UNREACHABLE("keyframe rule cannot be here"); break; -- cgit v1.2.3