Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 29dd51e27d30df4400bf36644d4bee25f2a0e636
https://github.com/WebKit/WebKit/commit/29dd51e27d30df4400bf36644d4bee25f2a0e636
Author: Anne van Kesteren <[email protected]>
Date: 2026-09-17 (Thu, 17 Sep 2026)
Changed paths:
M LayoutTests/TestExpectations
A LayoutTests/fast/shadow-dom/host-featureless-matching-expected.txt
A LayoutTests/fast/shadow-dom/host-featureless-matching-no-jit-expected.txt
A LayoutTests/fast/shadow-dom/host-featureless-matching-no-jit.html
A LayoutTests/fast/shadow-dom/host-featureless-matching.html
A LayoutTests/fast/shadow-dom/resources/host-featureless-matching.js
A
LayoutTests/imported/w3c/web-platform-tests/css/selectors/featureless-006-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/css/selectors/featureless-006.html
A
LayoutTests/imported/w3c/web-platform-tests/css/selectors/featureless-007-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/css/selectors/featureless-007.html
M LayoutTests/imported/w3c/web-platform-tests/css/selectors/w3c-import.log
M Source/WebCore/css/CSSSelector.cpp
M Source/WebCore/css/CSSSelector.h
M Source/WebCore/css/SelectorChecker.cpp
M Source/WebCore/css/SelectorChecker.h
M Source/WebCore/style/ElementRuleCollector.cpp
M Source/WebCore/style/RuleFeature.cpp
M Source/WebCore/style/RuleSet.cpp
M Source/WebCore/style/RuleSet.h
M Source/WebCore/style/StyleInvalidationFunctions.h
M Source/WebCore/style/StyleInvalidator.cpp
M Source/WebCore/style/StyleInvalidator.h
Log Message:
-----------
Improve :host selector matching
https://bugs.webkit.org/show_bug.cgi?id=283062
rdar://140284766
Reviewed by Antti Koivisto.
The shadow host is featureless when matched from inside its own shadow tree. It
only matches selectors it is explicitly allowed to match. checkOne() let
functional pseudo-classes through so that :is(:host) works, but excluded :not()
entirely, so :not(:not(:host)) never matched the host.
Whether a selector is allowed to match a featureless element depends on the
selector alone, not on what it matched. That is what separates :not(:not(:host))
from :not(.foo:host) and :not(:host > .foo). The latter two never match, even
though the host has no such class and is not its own descendant. So add a
predicate over the selector and use it to gate :not(). Negation is the only
place it is needed, since it is the only place a nested failure becomes a
success.
addRuleToBucket() now asks the same predicate which rules can match the host,
instead of a looser "does :host or :scope appear in a nested selector list"
check that only inspected the leftmost simple selector of each list entry. That
missed :not(:has(.nope):host) while catching :not(:host:has(.nope)), and having
one definition removes the ordering sensitivity. Those rules go in their own
vector rather than setting a RuleSet-wide flag that made
matchHostPseudoClassRules() collect the entire universal bucket. That is also
less work per shadow host.
Rules that can match the host but are not in m_hostPseudoClassRules were
invisible to style invalidation, which asked whether that one bucket was empty.
Test coverage is added for this as well.
Compiled selectors and the rule hash shortcut do not implement featureless
matching either. Both are reachable for a rule collected for the host, so assert
that neither reports a match there.
Tests: fast/shadow-dom/host-featureless-matching-no-jit.html
fast/shadow-dom/host-featureless-matching.html
imported/w3c/web-platform-tests/css/selectors/featureless-006.html
imported/w3c/web-platform-tests/css/selectors/featureless-007.html
Tests upstream: https://github.com/web-platform-tests/wpt/pull/62706
featureless-007 asserts what Gecko, Blink, and WebKit all do rather than what
Selectors says: a compound containing only :host is exempt from the default
namespace while :is(:host) is not, which the spec does not distinguish.
https://github.com/w3c/csswg-drafts/issues/14504 tracks that.
Canonical link: https://commits.webkit.org/321328@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications