Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[:has() pseudo-class] Use Bloom filter to quickly reject :has() selec…
…tors https://bugs.webkit.org/show_bug.cgi?id=234341 Reviewed by Dean Jackson. We can dramatically speed up cases where there are many :has rules, most of which don't match their argument by building a Bloom filter describing the features of the subtree. * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * css/SelectorChecker.cpp: (WebCore::SelectorChecker::matchHasPseudoClass const): Build and cache HasSelectorFilter per element/filter type. It will be constructed only if multiple :has() selectors are tested for the same element (otherwise the regular match cache is more efficient). Use it to quickly reject selectors. Also add a basic inital optimization to bail out if there are no child/sibling elements that could match. * css/SelectorFilter.cpp: (WebCore::SelectorFilter::collectElementIdentifierHashes): (WebCore::SelectorFilter::collectSimpleSelectorHash): (WebCore::SelectorFilter::collectSelectorHashes): (WebCore::SelectorFilter::chooseSelectorHashesForFilter): (WebCore::collectElementIdentifierHashes): Deleted. (WebCore::collectSimpleSelectorHash): Deleted. (WebCore::collectSelectorHashes): Deleted. (WebCore::chooseSelectorHashesForFilter): Deleted. * css/SelectorFilter.h: * style/HasSelectorFilter.cpp: Added. (WebCore::Style::HasSelectorFilter::HasSelectorFilter): (WebCore::Style::HasSelectorFilter::typeForMatchElement): (WebCore::Style::HasSelectorFilter::makeKey): The key consists of the most specific string in the rightmost compound of the selector along with :hover pseudo class, if any. (WebCore::Style::HasSelectorFilter::add): Add an Element to the filter. The features collected are the same as for the regular selector filter, plus permutations with :hover pseudo-class if it would match. * style/HasSelectorFilter.h: Copied from Source/WebCore/style/SelectorMatchingState.h. (WebCore::Style::HasSelectorFilter::type const): (WebCore::Style::HasSelectorFilter::reject const): Add HasSelectorFilter which uses non-counting BloomFilter internally. The size of the filter is 512 bytes. * style/SelectorMatchingState.h: (WebCore::Style::makeHasPseudoClassSelectorFilterKey): Canonical link: https://commits.webkit.org/245283@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@287091 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
9 changed files
with
323 additions
and
36 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.