Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 891cd2f9fe343cc9554506aa29cb10227fc424e9
      
https://github.com/WebKit/WebKit/commit/891cd2f9fe343cc9554506aa29cb10227fc424e9
  Author: Charlie Wolfe <[email protected]>
  Date:   2026-10-11 (Sun, 11 Oct 2026)

  Changed paths:
    M Source/WebCore/dom/CustomElementReactionQueue.cpp
    M Source/WebCore/dom/CustomElementReactionQueue.h
    M Source/WebCore/dom/CustomElementRegistry.cpp
    M Source/WebCore/dom/Document.h
    M Source/WebCore/dom/Element.cpp
    M Source/WebCore/dom/Node.cpp

  Log Message:
  -----------
  Avoid tree walks in customElements.define() when no candidate has the name
https://bugs.webkit.org/show_bug.cgi?id=327126
rdar://189726682

Reviewed by Ryosuke Niwa.

customElements.define() walked every document associated with the registry in 
shadow-including tree
order to find upgrade candidates, even when none of them had the defined name.

Document now keeps a set of local names of connected upgrade candidates that 
are still waiting for
a definition. Element::insertionSteps() adds a name when a candidate is 
connected but can't be
upgraded yet. define() skips the walk if the name isn't in the set. It removes 
the name after a walk
that leaves no candidate with that name, such as one that belongs to a 
different registry.

Node::moveNodeToNewDocumentFastCase() now takes the slow path for upgrade 
candidates, so candidates
moved in from another document are tracked correctly.

~1% PLT improvement.

* Source/WebCore/dom/CustomElementReactionQueue.cpp:
(WebCore::CustomElementReactionQueue::tryToUpgradeElement):
* Source/WebCore/dom/CustomElementReactionQueue.h:
* Source/WebCore/dom/CustomElementRegistry.cpp:
(WebCore::enqueueUpgradeInShadowIncludingTreeOrder):
(WebCore::enqueueUpgradeInDocument):
(WebCore::CustomElementRegistry::addElementDefinition):
* Source/WebCore/dom/Document.h:
(WebCore::Document::addCustomElementUpgradeCandidateLocalName):
(WebCore::Document::removeCustomElementUpgradeCandidateLocalName):
(WebCore::Document::mayHaveCustomElementUpgradeCandidate const):
* Source/WebCore/dom/Element.cpp:
(WebCore::Element::insertionSteps):
* Source/WebCore/dom/Node.cpp:
(WebCore::Node::moveNodeToNewDocumentFastCase):

Canonical link: https://commits.webkit.org/323421@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to