Skip to content

Commit

Permalink
AX: NSAccessibilityUIElementCountForSearchPredicateParameterizedAttri…
Browse files Browse the repository at this point in the history
…bute is not used by any AT

https://bugs.webkit.org/show_bug.cgi?id=265004
rdar://118546456

Reviewed by Chris Fleizach.

This was added in https://bugs.webkit.org/show_bug.cgi?id=124561, but isn't by any assistive technology anymore.
This patch removes it.

There are some tests that use uiElementCountForSearchPredicate to count the number of objects of certain types,
and we probably want to keep these test conditions. So this patch reimplements this function in terms of AXUIElementsForSearchPredicate,
which is heavily used by VoiceOver, and just counts the results.

* LayoutTests/accessibility/mac/bounds-for-range-expected.txt:
* Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(-[WebAccessibilityObjectWrapper ALLOW_DEPRECATED_IMPLEMENTATIONS_END]):
(-[WebAccessibilityObjectWrapper accessibilityAttributeValue:forParameter:]):
* Tools/DumpRenderTree/mac/AccessibilityUIElementMac.mm:
(AccessibilityUIElement::uiElementCountForSearchPredicate):
* Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm:
(WTR::AccessibilityUIElement::uiElementCountForSearchPredicate):

Canonical link: https://commits.webkit.org/270872@main
  • Loading branch information
twilco committed Nov 17, 2023
1 parent 4fb442b commit 114aa2c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ AXStyleTextMarkerRangeForTextMarker
AXLengthForTextMarkerRange
AXBoundsForRange
AXStringForRange
AXUIElementCountForSearchPredicate
AXUIElementsForSearchPredicate
AXEndTextMarkerForBounds
AXStartTextMarkerForBounds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,6 @@
#endif


#ifndef NSAccessibilityUIElementCountForSearchPredicateParameterizedAttribute
#define NSAccessibilityUIElementCountForSearchPredicateParameterizedAttribute @"AXUIElementCountForSearchPredicate"
#endif

#ifndef NSAccessibilityUIElementsForSearchPredicateParameterizedAttribute
#define NSAccessibilityUIElementsForSearchPredicateParameterizedAttribute @"AXUIElementsForSearchPredicate"
#endif
Expand Down Expand Up @@ -2396,7 +2392,6 @@ - (NSArray *)accessibilityParameterizedAttributeNames
AXLengthForTextMarkerRangeAttribute,
NSAccessibilityBoundsForRangeParameterizedAttribute,
NSAccessibilityStringForRangeParameterizedAttribute,
NSAccessibilityUIElementCountForSearchPredicateParameterizedAttribute,
NSAccessibilityUIElementsForSearchPredicateParameterizedAttribute,
AXEndTextMarkerForBoundsAttribute,
AXStartTextMarkerForBoundsAttribute,
Expand Down Expand Up @@ -3105,25 +3100,6 @@ - (id)accessibilityAttributeValue:(NSString*)attribute forParameter:(id)paramete
return createNSArray(operationResult).autorelease();
}

if ([attribute isEqualToString:NSAccessibilityUIElementCountForSearchPredicateParameterizedAttribute]) {
AccessibilitySearchCriteria criteria = accessibilitySearchCriteriaForSearchPredicateParameterizedAttribute(dictionary);
NSUInteger widgetChildrenSize = 0;
if (isMatchingPlugin(*backingObject, criteria)) {
// FIXME: We should also be searching the tree(s) resulting from `renderWidgetChildren` for matches.
// This is tracked by https://bugs.webkit.org/show_bug.cgi?id=230167.
if (auto* widgetChildren = [self renderWidgetChildren]) {
widgetChildrenSize = [widgetChildren count];
if (widgetChildrenSize >= criteria.resultsLimit)
return @(std::min(widgetChildrenSize, NSUInteger(criteria.resultsLimit)));
criteria.resultsLimit -= widgetChildrenSize;
}
}

AccessibilityObject::AccessibilityChildrenVector results;
backingObject->findMatchingObjects(&criteria, results);
return @(results.size() + widgetChildrenSize);
}

if ([attribute isEqualToString:NSAccessibilityUIElementsForSearchPredicateParameterizedAttribute]) {
AccessibilitySearchCriteria criteria = accessibilitySearchCriteriaForSearchPredicateParameterizedAttribute(dictionary);
NSArray *widgetChildren = nil;
Expand Down
6 changes: 3 additions & 3 deletions Tools/DumpRenderTree/mac/AccessibilityUIElementMac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1123,9 +1123,9 @@ - (void)_accessibilitySetValue:(id)value forAttribute:(NSString*)attributeName;
{
BEGIN_AX_OBJC_EXCEPTIONS
NSDictionary *parameterizedAttribute = searchPredicateParameterizedAttributeForSearchCriteria(context, startElement, isDirectionNext, UINT_MAX, searchKey, searchText, visibleOnly, immediateDescendantsOnly);
id value = [m_element accessibilityAttributeValue:@"AXUIElementCountForSearchPredicate" forParameter:parameterizedAttribute];
if ([value isKindOfClass:[NSNumber class]])
return [value unsignedIntValue];
id value = [m_element accessibilityAttributeValue:@"AXUIElementsForSearchPredicate" forParameter:parameterizedAttribute];
if ([value isKindOfClass:[NSArray class]])
return [value count];
END_AX_OBJC_EXCEPTIONS

return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1298,9 +1298,9 @@ void setAttributeValue(id element, NSString* attribute, id value, bool synchrono
{
BEGIN_AX_OBJC_EXCEPTIONS
NSDictionary *parameterizedAttribute = searchPredicateParameterizedAttributeForSearchCriteria(context, startElement, isDirectionNext, UINT_MAX, searchKey, searchText, visibleOnly, immediateDescendantsOnly);
auto value = attributeValueForParameter(@"AXUIElementCountForSearchPredicate", parameterizedAttribute);
if ([value isKindOfClass:[NSNumber class]])
return [value unsignedIntValue];
auto value = attributeValueForParameter(@"AXUIElementsForSearchPredicate", parameterizedAttribute);
if ([value isKindOfClass:[NSArray class]])
return [value count];
END_AX_OBJC_EXCEPTIONS

return 0;
Expand Down

0 comments on commit 114aa2c

Please sign in to comment.