[webkit-changes] [WebKit/WebKit] c87b5b: AX: Make m_deferredFocusedNodeChange a single item...

Tyler Wilcock noreply at github.com
Wed Mar 1 19:10:24 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: c87b5bf70b93f43af797c33996af245ecc2ff338
      https://github.com/WebKit/WebKit/commit/c87b5bf70b93f43af797c33996af245ecc2ff338
  Author: Tyler Wilcock <tyler_w at apple.com>
  Date:   2023-03-01 (Wed, 01 Mar 2023)

  Changed paths:
    M LayoutTests/accessibility/ios-simulator/focus-change-notifications-expected.txt
    M LayoutTests/accessibility/ios-simulator/focus-change-notifications.html
    M Source/WebCore/accessibility/AXObjectCache.cpp
    M Source/WebCore/accessibility/AXObjectCache.h
    M Source/WebCore/dom/Document.cpp

  Log Message:
  -----------
  AX: Make m_deferredFocusedNodeChange a single item rather than a list to make AXObjectCache::handleFocusedUIElementChanged easier to reason about
https://bugs.webkit.org/show_bug.cgi?id=252964
rdar://problem/105950128

Reviewed by Chris Fleizach.

Prior to this patch, m_deferredFocusedNodeChange was a Vector<std::pair<Node*, Node*>>.
And when we processed it in AXObjectCache::performDeferredCacheUpdate, we looped over this list,
calling AXObjectCache::handleFocusedUIElementChanged on each iteration.

This behavior doesn't make sense since only the last change in this list really matters. This patch
codifies this by changing the type of m_deferredFocusedNodeChange to be a single
std::optional<std::pair<WeakPtr<Node>, WeakPtr<Node>>> pair.

The main benefit of this is that it makes AXObjectCache::handleFocusedUIElementChanged easier to reason about,
since now we know that when it's called we should *actually* send notifications and perform any post-focus
work (like updating the isolated tree), rather than sometimes repeating this work back-to-back in a loop.

* LayoutTests/accessibility/ios-simulator/focus-change-notifications.html:
Modify test to wait for first focus change notification before sending
the second focus change.
* Source/WebCore/accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::remove):
(WebCore::AXObjectCache::onFocusChange):
(WebCore::AXObjectCache::focusCurrentModal):
(WebCore::AXObjectCache::prepareForDocumentDestruction):
(WebCore::AXObjectCache::performDeferredCacheUpdate):
(WebCore::AXObjectCache::deferFocusedUIElementChangeIfNeeded):
Renamed to onFocusChange to match the naming scheme we are moving
towards for other DOM / render tree updates.
* Source/WebCore/accessibility/AXObjectCache.h:
(WebCore::AXObjectCache::onFocusChange):
(WebCore::AXObjectCache::deferFocusedUIElementChangeIfNeeded): Deleted.
* Source/WebCore/dom/Document.cpp:
(WebCore::Document::setFocusedElement):
Drive-by change to use `existingAXObjectCache()` instead of
`axObjectCache()` (which creates the cache if not already created) for
non-GTK platforms. There is no reason for non-GTK platforms to take this
performance hit for non-accessibility users.

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




More information about the webkit-changes mailing list