Bug 252964 - AX: Make m_deferredFocusedNodeChange a single item rather than a list to make AXObjectCache::handleFocusedUIElementChanged easier to reason about
Summary: AX: Make m_deferredFocusedNodeChange a single item rather than a list to make...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Accessibility (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Tyler Wilcock
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-02-26 12:41 PST by Tyler Wilcock
Modified: 2023-03-01 19:10 PST (History)
13 users (show)

See Also:


Attachments
Patch (10.60 KB, patch)
2023-02-26 13:01 PST, Tyler Wilcock
no flags Details | Formatted Diff | Diff
Patch (10.77 KB, patch)
2023-02-26 15:10 PST, Tyler Wilcock
no flags Details | Formatted Diff | Diff
Patch (10.91 KB, patch)
2023-02-26 15:18 PST, Tyler Wilcock
no flags Details | Formatted Diff | Diff
Patch (13.85 KB, patch)
2023-02-26 19:03 PST, Tyler Wilcock
no flags Details | Formatted Diff | Diff
Patch (13.85 KB, patch)
2023-02-28 09:50 PST, Tyler Wilcock
no flags Details | Formatted Diff | Diff
Patch (14.08 KB, patch)
2023-02-28 10:12 PST, Tyler Wilcock
no flags Details | Formatted Diff | Diff
Patch (15.16 KB, patch)
2023-02-28 21:12 PST, Tyler Wilcock
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (15.17 KB, patch)
2023-02-28 21:24 PST, Tyler Wilcock
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (15.17 KB, patch)
2023-02-28 21:50 PST, Tyler Wilcock
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tyler Wilcock 2023-02-26 12:41:10 PST
Make m_deferredFocusedNodeChange a single item rather than a list to make AXObjectCache::handleFocusedUIElementChanged easier to reason about
Comment 1 Radar WebKit Bug Importer 2023-02-26 12:41:25 PST
<rdar://problem/105950128>
Comment 2 Tyler Wilcock 2023-02-26 13:01:58 PST
Created attachment 465186 [details]
Patch
Comment 3 chris fleizach 2023-02-26 13:31:45 PST
Comment on attachment 465186 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=465186&action=review

> Source/WebCore/accessibility/AXObjectCache.cpp:1380
> +            m_deferredFocusedNodeChange->second = newNode;

Do we need to handle case where 

Old = a
New = b

Then 2nd
Old = b
New = a

Do we avoid any work here?
Comment 4 Tyler Wilcock 2023-02-26 13:52:05 PST
(In reply to chris fleizach from comment #3)
> Comment on attachment 465186 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=465186&action=review
> 
> > Source/WebCore/accessibility/AXObjectCache.cpp:1380
> > +            m_deferredFocusedNodeChange->second = newNode;
> 
> Do we need to handle case where 
> 
> Old = a
> New = b
> 
> Then 2nd
> Old = b
> New = a
> 
> Do we avoid any work here?
Ah, good point. I would interpret that sequence as no focus change happening (because we never were actually able to commit `b` as the new focused element before `a` regained focus). I'll update the patch.
Comment 5 Tyler Wilcock 2023-02-26 15:10:22 PST
Created attachment 465188 [details]
Patch
Comment 6 Tyler Wilcock 2023-02-26 15:18:27 PST
Created attachment 465189 [details]
Patch
Comment 7 Tyler Wilcock 2023-02-26 19:03:41 PST
Created attachment 465193 [details]
Patch
Comment 8 Andres Gonzalez 2023-02-27 06:46:35 PST
(In reply to Tyler Wilcock from comment #7)
> Created attachment 465193 [details]
> Patch

--- a/Source/WebCore/accessibility/AXObjectCache.cpp
+++ b/Source/WebCore/accessibility/AXObjectCache.cpp

         // Recompute isIgnored after a focus change in case that altered visibility.
-        recomputeIsIgnored(deferredFocusedChangeContext.first);
-        recomputeIsIgnored(deferredFocusedChangeContext.second);
+        recomputeIsIgnored(m_deferredFocusedNodeChange->first.get());
+        recomputeIsIgnored(m_deferredFocusedNodeChange->second.get());

in the case of a -> b -> c, in rapid submission, you end up with (a, c), so you never do above for b. Would that have any side effect?

--- a/LayoutTests/accessibility/ios-simulator/focus-change-notifications.html
+++ b/LayoutTests/accessibility/ios-simulator/focus-change-notifications.html

+var rootElement = 0;

+var rootElement = null;

While you're at this test, can we modernize it?
Comment 9 Tyler Wilcock 2023-02-28 09:50:39 PST
Created attachment 465222 [details]
Patch
Comment 10 Andres Gonzalez 2023-02-28 10:05:39 PST
(In reply to Tyler Wilcock from comment #9)
> Created attachment 465222 [details]
> Patch

--- a/LayoutTests/accessibility/ios-simulator/focus-change-notifications.html
+++ b/LayoutTests/accessibility/ios-simulator/focus-change-notifications.html

+successfullyParsed = true;

I don't think this variable is needed at all.
Comment 11 Tyler Wilcock 2023-02-28 10:12:57 PST
Created attachment 465224 [details]
Patch
Comment 12 Tyler Wilcock 2023-02-28 21:12:17 PST
Created attachment 465229 [details]
Patch
Comment 13 Tyler Wilcock 2023-02-28 21:24:39 PST
Created attachment 465231 [details]
Patch
Comment 14 Tyler Wilcock 2023-02-28 21:50:28 PST
Created attachment 465232 [details]
Patch
Comment 15 EWS 2023-03-01 19:10:14 PST
Committed 261037@main (c87b5bf70b93): <https://commits.webkit.org/261037@main>

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