[webkit-changes] [WebKit/WebKit] bc149c: Make SelectorQueryCache global
Antti Koivisto
noreply at github.com
Thu Mar 30 13:26:06 PDT 2023
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: bc149c287545dc1e7668aa4a4375c103d4915754
https://github.com/WebKit/WebKit/commit/bc149c287545dc1e7668aa4a4375c103d4915754
Author: Antti Koivisto <antti at apple.com>
Date: 2023-03-30 (Thu, 30 Mar 2023)
Changed paths:
M Source/WebCore/css/parser/CSSSelectorParser.cpp
M Source/WebCore/css/parser/CSSSelectorParser.h
M Source/WebCore/dom/Document.cpp
M Source/WebCore/dom/Document.h
M Source/WebCore/dom/SelectorQuery.cpp
M Source/WebCore/dom/SelectorQuery.h
M Source/WebCore/page/MemoryRelease.cpp
Log Message:
-----------
Make SelectorQueryCache global
https://bugs.webkit.org/show_bug.cgi?id=254732
rdar://107414722
Reviewed by Chris Dumez.
It is currently per-Document but there is no reason why selectors can't be shared across documents.
* Source/WebCore/css/parser/CSSSelectorParser.cpp:
(WebCore::CSSSelectorParserContext::CSSSelectorParserContext):
(WebCore::CSSSelectorParserContext::operator== const):
Switch to using a separate (and much simpler) CSSSelectorParserContext struct in CSSSelectorParser
instead of CSSParserContext. This is a more compact type to use in a hash key.
(WebCore::add):
Make it hashable.
(WebCore::parseCSSSelector):
(WebCore::CSSSelectorParser::CSSSelectorParser):
(WebCore::CSSSelectorParser::supportsComplexSelector):
(WebCore::CSSSelectorParser::splitCompoundAtImplicitShadowCrossingCombinator):
* Source/WebCore/css/parser/CSSSelectorParser.h:
(WebCore::CSSSelectorParserContextHash::hash):
(WebCore::CSSSelectorParserContextHash::equal):
(WTF::HashTraits<WebCore::CSSSelectorParserContext>::constructDeletedValue):
(WTF::HashTraits<WebCore::CSSSelectorParserContext>::isDeletedValue):
(WTF::HashTraits<WebCore::CSSSelectorParserContext>::emptyValue):
* Source/WebCore/dom/Document.cpp:
(WebCore::Document::setCompatibilityMode):
(WebCore::Document::updateBaseURL):
(WebCore::Document::setBackForwardCacheState):
No need to explicitly clear the cache in these cases, the changes are captured by the cache key.
(WebCore::Document::clearSelectorQueryCache): Deleted.
* Source/WebCore/dom/Document.h:
* Source/WebCore/dom/SelectorQuery.cpp:
(WebCore::SelectorQueryCache::singleton):
Make the cache a singleton.
(WebCore::SelectorQueryCache::add):
The key includes the query string, CSSSelectorParserContext and the document security origin.
Only do a single hash lookup.
Also cache parse failures.
(WebCore::SelectorQueryCache::clear):
(): Deleted.
* Source/WebCore/dom/SelectorQuery.h:
* Source/WebCore/page/MemoryRelease.cpp:
(WebCore::releaseNoncriticalMemory):
Canonical link: https://commits.webkit.org/262362@main
More information about the webkit-changes
mailing list