Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 7390911815756fa40d848cae074bcd7cbd7e77a9
https://github.com/WebKit/WebKit/commit/7390911815756fa40d848cae074bcd7cbd7e77a9
Author: Antti Koivisto <[email protected]>
Date: 2026-09-10 (Thu, 10 Sep 2026)
Changed paths:
M LayoutTests/fast/selectors/selector-filter-hashes-expected.txt
M LayoutTests/fast/selectors/selector-filter-hashes.html
M
LayoutTests/imported/w3c/web-platform-tests/css/selectors/attribute-selectors/attribute-case/cssom-expected.txt
M
LayoutTests/imported/w3c/web-platform-tests/css/selectors/attribute-selectors/attribute-case/cssom.html
M Source/WebCore/css/CSSSelector.cpp
M Source/WebCore/css/CSSSelector.h
M Source/WebCore/css/SelectorChecker.cpp
M Source/WebCore/css/SelectorFilter.cpp
M Source/WebCore/css/parser/CSSSelectorParser.cpp
M Source/WebCore/css/parser/MutableCSSSelector.h
M Source/WebCore/cssjit/SelectorCompiler.cpp
M Source/WebCore/style/RuleFeature.cpp
M Source/WebCore/style/RuleSet.cpp
Log Message:
-----------
Optimize attribute selector [class~=foo] like class selector
https://bugs.webkit.org/show_bug.cgi?id=323871
rdar://164128575
Reviewed by Alan Baradlay.
In standards mode [class~=foo] is exactly the same as .foo and can use the same
optimizations
for filtering, bucketing and matching.
This pattern shows up in some Tailwind sites like code.claude.com and
gitbook.com.
*
LayoutTests/imported/w3c/web-platform-tests/css/selectors/attribute-selectors/attribute-case/cssom-expected.txt:
*
LayoutTests/imported/w3c/web-platform-tests/css/selectors/attribute-selectors/attribute-case/cssom.html:
Expand serialization coverage.
* LayoutTests/fast/selectors/selector-filter-hashes-expected.txt:
* LayoutTests/fast/selectors/selector-filter-hashes.html:
* Source/WebCore/css/CSSSelector.cpp:
(WebCore::CSSSelector::CSSSelector):
The bitfields are copied by hand, in both the copy and the move constructor.
* Source/WebCore/css/CSSSelector.h:
(WebCore::CSSSelector::isEquivalentToClassSelector const):
(WebCore::CSSSelector::setIsEquivalentToClassSelector):
The match stays Match::List so CSSOM serialization is unaffected.
(WebCore::CSSSelector::CSSSelector):
* Source/WebCore/css/SelectorChecker.cpp:
(WebCore::SelectorChecker::checkOne const):
* Source/WebCore/css/SelectorFilter.cpp:
(WebCore::SelectorFilter::collectSimpleSelectorHash):
class is an excluded attribute name so these had no ancestor hash at all before.
* Source/WebCore/css/parser/CSSSelectorParser.cpp:
(WebCore::isEquivalentToClassSelector):
Standards mode only. Quirks mode lowercases the class list while [class~=]
stays case
sensitive, and UA sheets are shared with quirks mode documents.
(WebCore::CSSSelectorParser::consumeAttribute):
* Source/WebCore/css/parser/MutableCSSSelector.h:
(WebCore::MutableCSSSelector::setIsEquivalentToClassSelector):
* Source/WebCore/cssjit/SelectorCompiler.cpp:
(WebCore::SelectorCompiler::constructFragmentsInternal):
* Source/WebCore/style/RuleFeature.cpp:
(WebCore::Style::RuleFeatureSet::recursivelyCollectFeaturesFromSelector):
Needed for correctness: AttributeChangeInvalidation runs before
Element::classAttributeChanged updates the class list, ClassChangeInvalidation
after.
(WebCore::Style::makePseudoClassInvalidationKey):
* Source/WebCore/style/RuleSet.cpp:
(WebCore::Style::RuleSet::addRuleToBucket):
Canonical link: https://commits.webkit.org/320862@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications