Skip to content

Commit

Permalink
AX: Moving testing only attributes in WebAccessibilityObjectWrapperMa…
Browse files Browse the repository at this point in the history
…c.mm to attributeValueForTesting

https://bugs.webkit.org/show_bug.cgi?id=273711
rdar://problem/127512021

Reviewed by Chris Fleizach.

This is a tiny performance improvement and code cleanup.

This patch also includes another performance improvement in AXObjectCache::handleTextChanged. Prior to this patch,
it used to fire notification AXTextUnderElementChanged when text changed underneath an AccessibilityRole::ListItem,
in turn causing expensive isolated tree property updates for the list item. This is completely unnecessary, as
AccessibilityRole::ListItem does not return true for dependsOnTextUnderElement().

* Source/WebCore/accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::handleTextChanged):
* Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
(attributeValueForTesting):

Canonical link: https://commits.webkit.org/278375@main
  • Loading branch information
twilco committed May 4, 2024
1 parent e96d0ed commit 06293e1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 30 deletions.
3 changes: 1 addition & 2 deletions Source/WebCore/accessibility/AXObjectCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1190,8 +1190,7 @@ void AXObjectCache::handleTextChanged(AccessibilityObject* object)

if (isText) {
bool dependsOnTextUnderElement = ancestor->dependsOnTextUnderElement();
auto role = ancestor->roleValue();
dependsOnTextUnderElement |= role == AccessibilityRole::ListItem || role == AccessibilityRole::Label;
dependsOnTextUnderElement |= ancestor->roleValue() == AccessibilityRole::Label;

// If the starting object is a static text, its underlying text has changed.
if (dependsOnTextUnderElement) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,6 @@
#define NSAccessibilityPathAttribute @"AXPath"
#endif

#ifndef NSAccessibilityIsMultiSelectableAttribute
#define NSAccessibilityIsMultiSelectableAttribute @"AXIsMultiSelectable"
#endif

#define NSAccessibilityDOMIdentifierAttribute @"AXDOMIdentifier"
#define NSAccessibilityDOMClassListAttribute @"AXDOMClassList"

Expand Down Expand Up @@ -2186,26 +2182,16 @@ - (id)accessibilityAttributeValue:(NSString *)attributeName
if ([attributeName isEqualToString:@"_AXAssociatedPluginParent"])
return [self _associatedPluginParentWith:backingObject];

// this is used only by DumpRenderTree for testing
if ([attributeName isEqualToString:@"AXClickPoint"])
return [NSValue valueWithPoint:backingObject->clickPoint()];

// This is used by DRT to verify CSS3 speech works.
// This used to be a testing-only attribute, but unfortunately some ATs do actually request it.
if ([attributeName isEqualToString:@"AXDRTSpeechAttribute"])
return [self baseAccessibilitySpeechHint];

if ([attributeName isEqualToString:@"AXAutocompleteValue"])
return backingObject->autoCompleteValue();

if ([attributeName isEqualToString:NSAccessibilityPopupValueAttribute])
return backingObject->popupValue();

if ([attributeName isEqualToString:NSAccessibilityKeyShortcutsAttribute])
return backingObject->keyShortcuts();

if ([attributeName isEqualToString:@"AXARIAPressedIsPresent"])
return [NSNumber numberWithBool:backingObject->pressedIsPresent()];

if ([attributeName isEqualToString:AXHasDocumentRoleAncestorAttribute])
return [NSNumber numberWithBool:backingObject->hasDocumentRoleAncestor()];

Expand All @@ -2218,9 +2204,6 @@ - (id)accessibilityAttributeValue:(NSString *)attributeName
if ([attributeName isEqualToString:@"AXIsInDescriptionListTerm"])
return [NSNumber numberWithBool:backingObject->isInDescriptionListTerm()];

if ([attributeName isEqualToString:@"AXIsInCell"])
return [NSNumber numberWithBool:backingObject->isInCell()];

if ([attributeName isEqualToString:@"AXDetailsElements"])
return makeNSArray(backingObject->detailedByObjects());

Expand All @@ -2241,10 +2224,6 @@ - (id)accessibilityAttributeValue:(NSString *)attributeName
return makeNSArray(backingObject->errorMessageObjects());
}

// Multi-selectable
if ([attributeName isEqualToString:NSAccessibilityIsMultiSelectableAttribute])
return [NSNumber numberWithBool:backingObject->isMultiSelectable()];

if ([attributeName isEqualToString:NSAccessibilityFocusableAncestorAttribute]) {
AXCoreObject* object = backingObject->focusableAncestor();
return object ? object->wrapper() : nil;
Expand All @@ -2260,12 +2239,6 @@ - (id)accessibilityAttributeValue:(NSString *)attributeName
return object ? object->wrapper() : nil;
}

if ([attributeName isEqualToString:@"AXIsOnScreen"])
return [NSNumber numberWithBool:backingObject->isOnScreen()];

if ([attributeName isEqualToString:@"AXIsIndeterminate"])
return [NSNumber numberWithBool: backingObject->isIndeterminate()];

if ([attributeName isEqualToString:NSAccessibilityTextInputMarkedRangeAttribute]) {
auto range = backingObject->textInputMarkedTextMarkerRange();
auto nsRange = range.nsRange();
Expand Down Expand Up @@ -2332,6 +2305,27 @@ id attributeValueForTesting(const RefPtr<AXCoreObject>& backingObject, NSString
if ([attributeName isEqualToString:@"AXOwners"])
return makeNSArray(backingObject->owners());

if ([attributeName isEqualToString:@"AXIsInCell"])
return [NSNumber numberWithBool:backingObject->isInCell()];

if ([attributeName isEqualToString:@"AXARIAPressedIsPresent"])
return [NSNumber numberWithBool:backingObject->pressedIsPresent()];

if ([attributeName isEqualToString:@"AXAutocompleteValue"])
return backingObject->autoCompleteValue();

if ([attributeName isEqualToString:@"AXClickPoint"])
return [NSValue valueWithPoint:backingObject->clickPoint()];

if ([attributeName isEqualToString:@"AXIsIndeterminate"])
return [NSNumber numberWithBool:backingObject->isIndeterminate()];

if ([attributeName isEqualToString:@"AXIsMultiSelectable"])
return [NSNumber numberWithBool:backingObject->isMultiSelectable()];

if ([attributeName isEqualToString:@"AXIsOnScreen"])
return [NSNumber numberWithBool:backingObject->isOnScreen()];

return nil;
}

Expand Down

0 comments on commit 06293e1

Please sign in to comment.