[:has() perf] Include full selector context to :has() invalidation selectors#63132
Merged
webkit-commit-queue merged 1 commit intoApr 21, 2026
Merged
Conversation
Collaborator
|
EWS run on previous version of this PR (hash b1a1edf) Details |
alanbaradlay
approved these changes
Apr 20, 2026
b1a1edf to
61b1526
Compare
Collaborator
|
EWS run on current version of this PR (hash 61b1526) Details |
…lectors https://bugs.webkit.org/show_bug.cgi?id=312786 rdar://175177078 Reviewed by Alan Baradlay. When there is a mutation that may affect :has() we run the selector in has argument to see if any of the added or removed elements match. Previously this was done with the argument as is. For .foo:has(.bar) .baz the invalidation selector was <has-scope> .bar where <has-scope> would always match. Any appearance of .bar would trigger invalidation traversal. With this patch we include the full context to invalidation selector so in above case it will be .foo .bar potentially ruling out many cases where .bar alone matches. Test: fast/selectors/has-invalidation-traversal-size.html Document some traversal sizes. * LayoutTests/fast/selectors/has-invalidation-traversal-size-expected.txt: Added. * LayoutTests/fast/selectors/has-invalidation-traversal-size.html: Added. * Source/WebCore/css/parser/CSSSelectorParser.cpp: (WebCore::CSSSelectorParser::makeHasArgumentReplacingScope): Add helper for resolving <has-scope>. * Source/WebCore/css/parser/CSSSelectorParser.h: * Source/WebCore/dom/Document.h: (WebCore::Document::styleInvalidationTraversalCountForTesting const): (WebCore::Document::incrementStyleInvalidationTraversalCountForTesting): (WebCore::Document::resetStyleInvalidationTraversalCountForTesting): * Source/WebCore/style/RuleFeature.cpp: (WebCore::Style::RuleFeatureSet::recursivelyCollectFeaturesFromSelector): (WebCore::Style::RuleFeatureSet::collectFeatures): Resolve the scope. * Source/WebCore/style/RuleFeature.h: * Source/WebCore/style/StyleInvalidator.cpp: (WebCore::Style::Invalidator::invalidateIfNeeded): (WebCore::Style::Invalidator::invalidateWithMatchElementRuleSets): * Source/WebCore/style/StyleInvalidator.h: * Source/WebCore/testing/Internals.cpp: (WebCore::Internals::styleInvalidationTraversalCount const): (WebCore::Internals::resetStyleInvalidationTraversalCount): Add testing support * Source/WebCore/testing/Internals.h: * Source/WebCore/testing/Internals.idl: Canonical link: https://commits.webkit.org/311642@main
61b1526 to
e538024
Compare
Collaborator
|
Committed 311642@main (e538024): https://commits.webkit.org/311642@main Reviewed commits have been landed. Closing PR #63132 and removing active labels. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🛠 gtk3-libwebrtc
e538024
61b1526