Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: ccdac632b4110551b4b90dbc49ad88112ff976c5
https://github.com/WebKit/WebKit/commit/ccdac632b4110551b4b90dbc49ad88112ff976c5
Author: Ahmad Saleem <[email protected]>
Date: 2026-10-09 (Fri, 09 Oct 2026)
Changed paths:
A
LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/scope-implicit-constructed-document-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/scope-implicit-constructed-document.html
M Source/WebCore/css/SelectorChecker.cpp
M Source/WebCore/style/ElementRuleCollector.cpp
Log Message:
-----------
Implicit @scope in a constructed stylesheet adopted by a document matches
nothing
https://bugs.webkit.org/show_bug.cgi?id=326937
rdar://189584948
Reviewed by Antti Koivisto.
Per [1], "if no such element exists and the containing node tree is a shadow
tree, then the scoping root is the shadow host. Otherwise, the scoping root is
the root of the containing node tree." For a constructed stylesheet adopted by
a document, that is the Document. ElementRuleCollector only produced implicit
scoping roots for shadow root adopters, so nothing in such a sheet matched.
Use the Document as the scoping root. Since scoped selectors are relative, "with
the scoping root and descendant combinator implied at the start" [2],
SelectorChecker's descendant and child combinator walks now treat reaching a
Document scoping root as matching a lone :scope (or :where(:scope), which is
what & resolves to). Every element "that is an inclusive descendant of the
scoping root" [3] is therefore in scope, including the root element, while
:scope itself still matches no element.
[1] https://drafts.csswg.org/css-cascade-6/#scope-limits
[2] https://drafts.csswg.org/css-cascade-6/#scoped-rules
[3] https://drafts.csswg.org/css-cascade-6/#scope-atrule
Test:
imported/w3c/web-platform-tests/css/css-cascade/scope-implicit-constructed-document.html
*
LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/scope-implicit-constructed-document-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/scope-implicit-constructed-document.html:
Added.
* Source/WebCore/css/SelectorChecker.cpp:
(WebCore::isScopeOnlyCompoundSelector):
(WebCore::matchesDocumentScopingRoot):
(WebCore::SelectorChecker::matchRecursively const):
* Source/WebCore/style/ElementRuleCollector.cpp:
(WebCore::Style::ElementRuleCollector::scopeRulesMatch):
Canonical link: https://commits.webkit.org/323237@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications