Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 8b7c9b52a2c5166d71da7c97345fa12aec5b6d07
      
https://github.com/WebKit/WebKit/commit/8b7c9b52a2c5166d71da7c97345fa12aec5b6d07
  Author: Tyler Wilcock <[email protected]>
  Date:   2026-07-21 (Tue, 21 Jul 2026)

  Changed paths:
    A 
LayoutTests/accessibility/aria-relations-disconnected-subtree-no-timeout-expected.txt
    A 
LayoutTests/accessibility/aria-relations-disconnected-subtree-no-timeout.html
    M Source/WebCore/accessibility/AXObjectCache.cpp
    M Source/WebCore/accessibility/AXObjectCache.h

  Log Message:
  -----------
  AX: Inefficiencies around id dirtying and searching when building 
accessibility relations
https://bugs.webkit.org/show_bug.cgi?id=319937
rdar://182309307

Reviewed by Dominic Mazzoni and Chris Fleizach.

When accessibility relations are rebuilt, updateRelationsIfNeeded() iterates
m_elementsWithRelationAttributes, which can hold detached elements. For an 
origin
that is not in a tree scope, Element::elementsArrayForAttributeInternal() cannot
use the TreeScope id map and falls back to 
getElementByIdIncludingDisconnected(),
which linearly scans the entire detached subtree once per referenced id. On 
pages
with large detached subtrees that carry ARIA relation attributes, this can 
severely
harm performance.

Fix this by skipping resolution of  relations for origins that are not in a 
tree scope.
Such elements have no accessibility object, so their relations have no consumer.

Additionally, this commit reduces how often relations are rebuilt. 
performDeferredCacheUpdate()
used to mark all relations dirty on every id-attribute change, forcing a full 
rebuild, regardless
of whether that id was part of a relation. Now we track every id referenced by 
a relation attribute
(resolved or not) in a new m_referencedRelationTargetIds set and only dirty 
relations when a changed
id can actually affect one.

* 
LayoutTests/accessibility/aria-relations-disconnected-subtree-no-timeout-expected.txt:
 Added.
* 
LayoutTests/accessibility/aria-relations-disconnected-subtree-no-timeout.html: 
Added.
* Source/WebCore/accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::performDeferredCacheUpdate):
(WebCore::AXObjectCache::updateRelationsIfNeeded):
(WebCore::AXObjectCache::idChangeCanAffectRelations const):
(WebCore::AXObjectCache::addRelation):
(WebCore::AXObjectCache::addLabelForRelation):
* Source/WebCore/accessibility/AXObjectCache.h:

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



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

Reply via email to