Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 9e56c492916730d10279948a4907f2a35cadbade
https://github.com/WebKit/WebKit/commit/9e56c492916730d10279948a4907f2a35cadbade
Author: Charlie Wolfe <[email protected]>
Date: 2026-10-13 (Tue, 13 Oct 2026)
Changed paths:
M Source/WebCore/dom/ContainerNode.cpp
M Source/WebCore/dom/Document.cpp
M Source/WebCore/dom/Document.h
M Source/WebCore/dom/Element.cpp
M Source/WebCore/dom/EventTarget.h
M Source/WebCore/dom/Node.cpp
M Source/WebCore/page/MemoryRelease.cpp
Log Message:
-----------
Cache document.querySelector() results
https://bugs.webkit.org/show_bug.cgi?id=327220
rdar://189789022
Reviewed by Ryosuke Niwa.
Extend Document's per-context QuerySelectorAllResults cache so that
querySelector() stores and
reuses its first-match Element for selectors that are eligible for caching.
Entries now hold either
a NodeList (querySelectorAll) or the first Element (querySelector). A
querySelectorAll() call for
the same selector upgrades a querySelector() entry to a full NodeList, and a
querySelector() call on
a cached NodeList returns its first item. Existing invalidation applies to both
entry kinds.
* Source/WebCore/dom/ContainerNode.cpp:
* Source/WebCore/dom/Document.cpp:
(WebCore::Document::removedLastRef):
(WebCore::QuerySelectorResults::find):
(WebCore::QuerySelectorResults::add):
(WebCore::Document::querySelectorResults):
(WebCore::Document::ensureQuerySelectorResults):
(WebCore::Document::resultForSelectorAll):
(WebCore::Document::addResultForSelectorAll):
(WebCore::Document::addResultForSelector):
(WebCore::Document::invalidateQuerySelectorResults):
(WebCore::Document::invalidateQuerySelectorResultsForClassAttributeChange):
(WebCore::Document::clearQuerySelectorResults):
(WebCore::Document::invalidateQuerySelectorAllResults): Deleted.
(WebCore::Document::invalidateQuerySelectorAllResultsForClassAttributeChange):
Deleted.
(WebCore::Document::clearQuerySelectorAllResults): Deleted.
* Source/WebCore/dom/Document.h:
* Source/WebCore/dom/Element.cpp:
(WebCore::Element::classAttributeChanged):
* Source/WebCore/dom/EventTarget.h:
* Source/WebCore/dom/Node.cpp:
(WebCore::Node::invalidateNodeListAndCollectionCachesInAncestors):
* Source/WebCore/page/MemoryRelease.cpp:
(WebCore::releaseCriticalMemory):
Canonical link: https://commits.webkit.org/323620@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications