Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: ec745337f725898a4e6d8daa72aa28678ec3e2fe
      
https://github.com/WebKit/WebKit/commit/ec745337f725898a4e6d8daa72aa28678ec3e2fe
  Author: Tyler Wilcock <[email protected]>
  Date:   2026-04-28 (Tue, 28 Apr 2026)

  Changed paths:
    M Source/WebCore/accessibility/AXObjectCache.cpp
    M Source/WebCore/accessibility/AXObjectCache.h
    M Source/WebCore/accessibility/AccessibilityObject.h

  Log Message:
  -----------
  AX: updateRelationsIfNeeded() walks the entire DOM when it should walk only 
the elements that have relations-attributes
https://bugs.webkit.org/show_bug.cgi?id=313445
rdar://175681348

Reviewed by Joshua Hoffman.

updateRelationsIfNeeded() previously walked every element in the entire DOM on
every rebuild, checking all 13 relation attributes per element. This is wasteful
because only a small fraction of elements have relation attributes.

Track elements with relation attributes in a WeakHashSet during the initial
full-DOM build, and maintain it incrementally as attributes change. Subsequent
rebuilds (triggered by id changes, reference target changes, etc.) iterate only
the tracked elements instead of the full DOM.

On a page with 1000 DOM elements but only 5 labels and 0 ARIA relation
attributes, the rebuild now walks 5 elements instead of 1000.

This change is a 0.51% improvement on Speedometer 3.1.

* Source/WebCore/accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::handleAttributeChange):
(WebCore::AXObjectCache::performDeferredCacheUpdate):
(WebCore::AXObjectCache::updateRelationsIfNeeded):
(WebCore::AXObjectCache::updateRelationsForTree):
* Source/WebCore/accessibility/AXObjectCache.h:
* Source/WebCore/accessibility/AccessibilityObject.h:

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



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

Reply via email to