[webkit-changes] [WebKit/WebKit] b7af35: AX: AXIsolatedObject should perform actions and se...

Tyler Wilcock noreply at github.com
Sat May 6 10:46:14 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: b7af35598b4eaf1570ca0ad1ea949fd3a3916dfb
      https://github.com/WebKit/WebKit/commit/b7af35598b4eaf1570ca0ad1ea949fd3a3916dfb
  Author: Tyler Wilcock <tyler_w at apple.com>
  Date:   2023-05-06 (Sat, 06 May 2023)

  Changed paths:
    M Source/WebCore/accessibility/AccessibilityObject.cpp
    M Source/WebCore/accessibility/AccessibilityObject.h
    M Source/WebCore/accessibility/AccessibilityObjectInterface.h
    M Source/WebCore/accessibility/AccessibilityRenderObject.cpp
    M Source/WebCore/accessibility/AccessibilityRenderObject.h
    M Source/WebCore/accessibility/atspi/AccessibilityObjectComponentAtspi.cpp
    M Source/WebCore/accessibility/atspi/AccessibilityObjectTextAtspi.cpp
    M Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp
    M Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h
    M Source/WebCore/accessibility/isolatedtree/mac/AXIsolatedObjectMac.mm
    M Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm

  Log Message:
  -----------
  AX: AXIsolatedObject should perform actions and setters asynchronously
https://bugs.webkit.org/show_bug.cgi?id=256244
rdar://problem/108825366

Reviewed by Andres Gonzalez.

Currently, most AXIsolatedObjects that need to set a value or perform an action (i.e scroll to make visible)
on the main-thread do so synchronously. This is not necessary in most cases, and affects WebKit's responsiveness
to other AX requests.

With this patch, the existing AXIsolatedObject::performFunctionOnMainThread is made async, and a new
AXIsolatedObject::performFunctionOnMainThreadAndWait function is introduced and used in the few places that do
require synchronous behavior.

This patch also introduces AXCoreObject::setValueIgnoringResult and AXCoreObject::performDismissActionIgnoringResult.
The existing versions of these functions (setValue and performDismissAction) return a bool, thus requiring synchronous
communication, even though WebAccessibilityObjectWrapperMac does not use the returned bool. This patch replaces
these usages with the new, async-friendly setValueIgnoringResult and performDismissActionIgnoringResult.

The most significant improvement from this patch is making AXIsolatedObject::scrollToMakeVisible async. VoiceOver
performs this action every single navigation event, and because it is currently synchronous, it regularly shows
up as taking thousands of samples in `sample` runs on various websites.

* Source/WebCore/accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::setSelectedRows):
(WebCore::AccessibilityObject::scrollToMakeVisibleWithSubFocus const):
(WebCore::AccessibilityObject::scrollToGlobalPoint const):
* Source/WebCore/accessibility/AccessibilityObject.h:
* Source/WebCore/accessibility/AccessibilityObjectInterface.h:
(WebCore::Accessibility::performFunctionOnMainThreadAndWait):
(WebCore::Accessibility::performFunctionOnMainThread):
* Source/WebCore/accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::setSelectedTextRange):
* Source/WebCore/accessibility/AccessibilityRenderObject.h:
* Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp:
(WebCore::AXIsolatedObject::setSelectedChildren):
(WebCore::AXIsolatedObject::setARIAGrabbed):
(WebCore::AXIsolatedObject::setIsExpanded):
(WebCore::AXIsolatedObject::performDismissActionIgnoringResult):
(WebCore::AXIsolatedObject::scrollToMakeVisibleWithSubFocus const):
(WebCore::AXIsolatedObject::scrollToGlobalPoint const):
(WebCore::AXIsolatedObject::setValueIgnoringResult):
(WebCore::AXIsolatedObject::setSelected):
(WebCore::AXIsolatedObject::setSelectedRows):
(WebCore::AXIsolatedObject::setFocused):
(WebCore::AXIsolatedObject::setSelectedText):
(WebCore::AXIsolatedObject::setSelectedTextRange):
(WebCore::AXIsolatedObject::getOrRetrievePropertyValue):
* Source/WebCore/accessibility/isolatedtree/mac/AXIsolatedObjectMac.mm:
(WebCore::AXIsolatedObject::attributedStringForTextMarkerRange const):
(WebCore::AXIsolatedObject::setPreventKeyboardDOMEventDispatch):
(WebCore::AXIsolatedObject::setCaretBrowsingEnabled):
Because these functions are now calling the main-thread asynchronously,
change lambda parameters to add `protectedThis` and copy input values rather
than passing them by reference (because said references may not be valid
by the time the lambda actually executes).

(WebCore::AXIsolatedObject::makeRangeVisible):
This function and the advertisement of NSAccessibilityVisibleCharacterRange being
settable were removed with this patch because AccessibilityObject::makeRangeVisible is a no-op.
This meant that if AX clients tried to use this function, it would be a main-thread hit to do nothing.

I elected to remove this function rather than figure out how to implement it (and if we even need to).
We can add it later if necessary.

* Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h:
* Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(-[WebAccessibilityObjectWrapper accessibilityIsAttributeSettable:]):
(-[WebAccessibilityObjectWrapper _accessibilityPerformPressAction]):
(-[WebAccessibilityObjectWrapper accessibilityPerformAction:]):
(-[WebAccessibilityObjectWrapper _accessibilitySetValue:forAttribute:]):

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




More information about the webkit-changes mailing list