AX: Reduce parent lookups in unignoredChildren pre-order traversal#64803
Merged
webkit-commit-queue merged 1 commit intoMay 13, 2026
Conversation
Collaborator
|
EWS run on previous version of this PR (hash 7358b48) Details
|
7358b48 to
05fa6d2
Compare
Collaborator
|
EWS run on current version of this PR (hash 05fa6d2) Details |
minorninth
approved these changes
May 13, 2026
https://bugs.webkit.org/show_bug.cgi?id=314691 rdar://176932652 Reviewed by Dominic Mazzoni. Samples taken during AX queries showed nextSiblingIncludingIgnored as ~95% of time in stitchedUnignoredChildren -> unignoredChildren -> nextInPreOrder. Each call went through parentObject(), a virtual call whose cost varies by subclass (HashMap lookup on AXIsolatedObject; DOM traversal + axObjectCache lookup on AccessibilityRenderObject / AccessibilityNodeObject) but is always non-trivial. The traversal was paying for that lookup twice per ascended level. Two adjustments cut the per-hop work: 1. nextInPreOrder: replace the pre-loop nextSiblingIncludingIgnored() call + in-loop parentObject() ascent with a single loop that fetches parent once per level. In the non-cross-frame case, the sibling-search parent and ascent parent are the same value, so the ascent reuses it via WTF::move, eliminating the duplicate parentObject() call and the accompanying RefPtr ref()/deref() per ascended level. 2. unignoredChildren: for ignored or invalid descendants, inline the descent step (matching nextInPreOrder's Column / TableHeaderContainer role guard via shouldSetChildIndexInParent()) instead of falling back to nextInPreOrder(). The function already had its own sibling-or- ascend loop that caches parent + siblings across sibling hops, but the nextInPreOrder() fallback was invalidating that cache every time the traversal crossed an ignored descendant. With the fallback gone, cached parent/siblings now survive through ignored-descendant traversal, and the per-hop cost drops to descendant->indexInParent() + a vector index. * Source/WebCore/accessibility/AXCoreObject.cpp: (WebCore::AXCoreObject::unignoredChildren): (WebCore::AXCoreObject::nextInPreOrder): Canonical link: https://commits.webkit.org/313164@main
05fa6d2 to
058338e
Compare
Collaborator
|
Committed 313164@main (058338e): https://commits.webkit.org/313164@main Reviewed commits have been landed. Closing PR #64803 and removing active labels. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
058338e
05fa6d2
🧪 win-tests