Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: f20ec536521f2da91bd2993b1a9034e456d1f907
https://github.com/WebKit/WebKit/commit/f20ec536521f2da91bd2993b1a9034e456d1f907
Author: Samar Sunkaria <[email protected]>
Date: 2024-09-21 (Sat, 21 Sep 2024)
Changed paths:
M
LayoutTests/accessibility/mac/text-operation/text-operation-replace-expected.txt
M
LayoutTests/accessibility/mac/text-operation/text-operation-replace-preserve-case-expected.txt
M
LayoutTests/accessibility/mac/text-operation/text-operation-replace-preserve-case.html
M LayoutTests/accessibility/mac/text-operation/text-operation-replace.html
M Source/WebCore/accessibility/AXCoreObject.h
M Source/WebCore/accessibility/AccessibilityObject.cpp
M Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm
M Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp
M Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h
M Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl
M Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm
Log Message:
-----------
AX: Support multiple replacement strings in AXTextOperation
https://bugs.webkit.org/show_bug.cgi?id=279888
rdar://problem/136220931
Reviewed by Tyler Wilcock.
WebKit’s `AXTextOperation` parameterized accessibility attribute, among its
other capabilities,
lets you replace text across multiple text marker ranges in an editable text
field. It takes a
dictionary as its parameter, with an array of text marker ranges to be
replaced, and one
replacement string. The existing API mirrors the contract for a simple
find-and-replace
operation. Utilizing `AXSearchTextWithCriteria`, you can locate text marker
ranges for a search
string and, substitute them with a replacement string using `AXTextOperation`.
However,
AXTextOperation’s usability is severely limited beyond this specific use case.
This change adds the ability to replace _individual_ ranges with different
replacement strings,
allowing AXTextOperations to be used outside the narrow scope of a simple
find-and-replace
operation, enabling richer replacements from an accessibility client, like
Grammarly (which
intends to use this attribute).
A new `AXTextOperationIndividualReplacementStrings` key has been added to the
`AXTextOperation`
parameter dictionary, which expects an array of strings as its value. This
array is expected to
have the same length as the `AXTextOperationMarkerRanges` array, where each
replacement string
corresponds to one replacement range.
Client pseudo-code:
```
// Editable text: Lorem ipsum dolor sit amet, consectetur adipiscing elit.
// To replace "dolor" -> "foo" and "elit" -> "bar":
CFTypeRef result;
AXUIElementCopyParameterizedAttributeValue(element, "AXTextOperation", @[
NSAccessibilityTextOperationType: NSAccessibilityTextOperationReplace,
NSAccessibilityTextOperationIndividualReplacementStrings: @[ @"bar", @"foo" ],
NSAccessibilityTextOperationMarkerRanges: @[ rangeOfElit, rangeOfDolor ]
], &result)
```
This is an additive change to the AXTextOperation API. The existing
`AXTextOperationReplacementString` key for providing a single replacement
string will continue
to work as expected.
*
LayoutTests/accessibility/mac/text-operation/text-operation-replace-expected.txt:
*
LayoutTests/accessibility/mac/text-operation/text-operation-replace-preserve-case-expected.txt:
*
LayoutTests/accessibility/mac/text-operation/text-operation-replace-preserve-case.html:
* LayoutTests/accessibility/mac/text-operation/text-operation-replace.html:
* Source/WebCore/accessibility/AXCoreObject.h:
* Source/WebCore/accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::performTextOperation):
* Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(accessibilityTextCriteriaForParameterizedAttribute):
(accessibilityTextOperationForParameterizedAttribute):
* Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp:
(WTR::AccessibilityUIElement::performTextOperation):
* Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h:
* Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl:
* Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm:
(WTR::textOperationParameterizedAttribute):
(WTR::AccessibilityUIElement::performTextOperation):
Canonical link: https://commits.webkit.org/284044@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes