Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 8e1eba971f76d1095cec337ae98d5f30143d4d69
https://github.com/WebKit/WebKit/commit/8e1eba971f76d1095cec337ae98d5f30143d4d69
Author: Antti Koivisto <[email protected]>
Date: 2025-12-19 (Fri, 19 Dec 2025)
Changed paths:
M Source/WebCore/css/CSSSelector.cpp
M Source/WebCore/css/CSSSelector.h
M Source/WebCore/css/CSSSelectorList.cpp
M Source/WebCore/css/CSSSelectorList.h
M Source/WebCore/style/RuleFeature.cpp
M Source/WebCore/style/RuleFeature.h
M Source/WebCore/style/RuleSet.cpp
M Source/WebCore/style/RuleSet.h
M Source/WebCore/style/RuleSetBuilder.cpp
M Source/WebCore/style/RuleSetBuilder.h
Log Message:
-----------
RuleFeatureSet should collect features from a selector only once
https://bugs.webkit.org/show_bug.cgi?id=304391
rdar://166770565
Reviewed by Alan Baradlay.
Duplicate selectors are common. We should only collect features from them once.
* Source/WebCore/css/CSSSelector.cpp:
(WebCore::shouldSkipForEqualMode):
(WebCore::complexSelectorsEqual):
(WebCore::addSimpleSelector):
(WebCore::addComplexSelector):
Add hashing support.
* Source/WebCore/css/CSSSelector.h:
* Source/WebCore/css/CSSSelectorList.cpp:
(WebCore::add):
Add hashing support.
* Source/WebCore/css/CSSSelectorList.h:
* Source/WebCore/style/RuleFeature.cpp:
(WebCore::Style::SelectorDeduplicationKey::SelectorDeduplicationKey):
Compute and cache the selector hash for fast rehashing.
(WebCore::Style::SelectorDeduplicationKey::operator== const):
(WebCore::Style::RuleFeatureSet::recursivelyCollectFeaturesFromSelector):
(WebCore::Style::RuleFeatureSet::collectFeatures):
(WebCore::Style::RuleFeatureSet::collectPseudoElementFeatures):
Separate pseudo-element feature collection as regular collection path treats
otherwise identical selectors
with or without pseudo element as equivalent.
(WebCore::Style::equalIgnoringPseudoElement): Deleted.
* Source/WebCore/style/RuleFeature.h:
(WebCore::Style::SelectorDeduplicationKey::hash const):
(WebCore::Style::RuleFeatureSet::collectFeatures):
Only enter recursive feature collection for selectors we haven't seen before.
Remove the existing deduplication code based on searching feature vectors on
append.
That was inefficient with complex selectors that were added to many vectors.
* Source/WebCore/style/RuleSet.cpp:
(WebCore::Style::RuleSet::addRule):
* Source/WebCore/style/RuleSet.h:
* Source/WebCore/style/RuleSetBuilder.cpp:
(WebCore::Style::RuleSetBuilder::addStyleRuleWithSelectorList):
Pass a temporary context that contains the deduplication HashSet.
* Source/WebCore/style/RuleSetBuilder.h:
Canonical link: https://commits.webkit.org/304734@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications