Bug 262929 - AX: Attribute cache is not enabled in traverseToOffsetInRange
Summary: AX: Attribute cache is not enabled in traverseToOffsetInRange
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Accessibility (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Joshua Hoffman
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-10-09 15:40 PDT by Joshua Hoffman
Modified: 2023-10-10 09:45 PDT (History)
10 users (show)

See Also:


Attachments
Patch (1.50 KB, patch)
2023-10-09 16:29 PDT, Joshua Hoffman
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joshua Hoffman 2023-10-09 15:40:00 PDT
The attribute cache is not enabled in traverseToOffsetInRange, causing more accessibilityIsIgnored calls than necessary.
Comment 1 Radar WebKit Bug Importer 2023-10-09 15:40:09 PDT
<rdar://problem/116703599>
Comment 2 Joshua Hoffman 2023-10-09 16:29:37 PDT
Created attachment 468137 [details]
Patch
Comment 3 Andres Gonzalez 2023-10-10 06:39:38 PDT
(In reply to Joshua Hoffman from comment #2)
> Created attachment 468137 [details]
> Patch

diff --git a/Source/WebCore/accessibility/AXObjectCache.cpp b/Source/WebCore/accessibility/AXObjectCache.cpp
index 05688086b278..bea7eaf1ef97 100644
--- a/Source/WebCore/accessibility/AXObjectCache.cpp
+++ b/Source/WebCore/accessibility/AXObjectCache.cpp
@@ -2679,6 +2679,9 @@ CharacterOffset AXObjectCache::traverseToOffsetInRange(const SimpleRange& range,
         behaviors.add(TextIteratorBehavior::EntersTextControls);
     TextIterator iterator(range, behaviors);

+    // Enable the cache here for accessibilityIsIgnored calls in replacedNodeNeedsCharacter
+    AXAttributeCacheEnabler enableCache(this);

AG: if the problem is in replacedNodeNeedsCharacter, shouldn't we enable the caching there instead?
+
     // When the range has zero length, there might be replaced node or brTag that we need to increment the characterOffset.
     if (iterator.atEnd()) {
         currentNode = range.start.container.ptr();
Comment 4 Joshua Hoffman 2023-10-10 08:48:40 PDT
(In reply to Andres Gonzalez from comment #3)
> (In reply to Joshua Hoffman from comment #2)
> > Created attachment 468137 [details]
> > Patch
> +    // Enable the cache here for accessibilityIsIgnored calls in
> replacedNodeNeedsCharacter
> +    AXAttributeCacheEnabler enableCache(this);
> 
> AG: if the problem is in replacedNodeNeedsCharacter, shouldn't we enable the
> caching there instead?

replacedNodeNeedsCharacter, is called in a loop inside traverseToOffsetInRange, so we want to make sure the cache stays enabled across all of those calls to prevent duplicate work.
Comment 5 EWS 2023-10-10 09:45:51 PDT
Committed 269149@main (7d4e7afc92b3): <https://commits.webkit.org/269149@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 468137 [details].