commit fca5d629d71baf5c4f60bfe2577b0db73d1a9880
parent f4bf2392ed0b9a75309ad03535fa50a9cb162535
Author: David Shin <dshin@mozilla.com>
Date: Thu, 23 Oct 2025 16:34:14 +0000
Bug 1996051: Let the ceiling of the outer scope be a candidate for the inner scope. r=firefox-style-system-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D269785
Diffstat:
2 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/servo/components/style/stylesheets/scope_rule.rs b/servo/components/style/stylesheets/scope_rule.rs
@@ -302,9 +302,6 @@ where
let mut parent = Some(element);
let mut proximity = 0usize;
while let Some(p) = parent {
- if ceiling == Some(p.opaque()) {
- break;
- }
if target.check(p, ceiling, scope_subject_map, context) {
result.push(ScopeRootCandidate {
root: p.opaque(),
@@ -313,6 +310,9 @@ where
// Note that we can't really break here - we need to consider
// ALL scope roots to figure out whch one didn't end.
}
+ if ceiling == Some(p.opaque()) {
+ break;
+ }
parent = p.parent_element();
proximity += 1;
// We we got to the top of the shadow tree - keep going
diff --git a/testing/web-platform/tests/css/css-cascade/scope-implicit.html b/testing/web-platform/tests/css/css-cascade/scope-implicit.html
@@ -256,3 +256,24 @@ test((t) => {
assert_equals(getComputedStyle(inner).zIndex, '1');
}, 'Implicit @scope sandwiched between non-implicit scopes');
</script>
+
+<template id=test_implicit_in_explicit>
+ <div id=outer>
+ <style>
+ @scope (#outer) {
+ @scope {
+ :scope {
+ z-index: 1;
+ }
+ }
+ }
+ </style>
+ </div>
+</template>
+<script>
+test((t) => {
+ t.add_cleanup(() => main.replaceChildren());
+ main.append(test_implicit_in_explicit.content.cloneNode(true));
+ assert_equals(getComputedStyle(outer).zIndex, '1');
+}, 'Implicit @scope sandwiched right under an explicit scope');
+</script>