-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AX: Expose suggestion, insertion, deletion roles and attributes
https://bugs.webkit.org/show_bug.cgi?id=242401 Reviewed by Andres Gonzalez. At present, screenreaders on iOS and macOS do not convey information related to elements with an insertion, deletion, or suggestion role (or, alternatively, `<ins>` and `<del>`) besides their content. To appropriately convey the proper annotation information and purpose, insertions, deletions, and suggestions are now exposed via new attributes and with new methods on the Web Accessibility Wrapper for iOS. This allows screenreaders to appropriately label the start and end positions of these elements. * LayoutTests/accessibility/ios-simulator/suggestion-insertion-deletion-attributes-expected.txt: Added. * LayoutTests/accessibility/ios-simulator/suggestion-insertion-deletion-attributes.html: Added. * LayoutTests/accessibility/mac/attributed-string-includes-insertion-deletion-expected.txt: Added. * LayoutTests/accessibility/mac/attributed-string-includes-insertion-deletion.html: Added. * LayoutTests/accessibility/mac/suggestion-subrole-and-roledescription-expected.txt: Added. * LayoutTests/accessibility/mac/suggestion-subrole-and-roledescription.html: Added. Tests to check for the correct subrole and attributes. * Source/WebCore/accessibility/AccessibilityNodeObject.cpp: (WebCore::AccessibilityNodeObject::text const): Exposes inner content of static text methods. * Source/WebCore/accessibility/AccessibilityObject.cpp: (WebCore::initializeRoleMap): (WebCore::AccessibilityObject::roleDescription const): * Source/WebCore/accessibility/AccessibilityObjectInterface.h: (WebCore::accessibilityRoleToString): * Source/WebCore/accessibility/mac/AccessibilityObjectMac.mm: (WebCore::AccessibilityObject::subrolePlatformString const): (WebCore::Accessibility::createPlatformRoleMap): Adds new mappings for "suggestion" role so they are recognized as roles. * Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm: (-[WebAccessibilityObjectWrapper determineIsAccessibilityElement]): (-[WebAccessibilityObjectWrapper accessibilityIsInsertion]): (-[WebAccessibilityObjectWrapper accessibilityIsDeletion]): New methods that check for an ancestor that is an insertion or deletion, respectively, to convey if we are inside an element with one of those roles. (-[WebAccessibilityObjectWrapper accessibilityIsFirstItemInSuggestion]): (-[WebAccessibilityObjectWrapper accessibilityIsLastItemInSuggestion]): New methods that look for an ancestor that is a suggestion in addition to checking whether a subelement in a suggestion is the first or last item, so that screenreaders can convey the start and end points for a suggestion. * Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm: (AXAttributeStringSetStyle): Applies the right attributes for insertions, deletions, and suggestions based on traversing the ancestors. (AXAttributedStringAppendText): Fixes an issue when appending text where the appended string inherits the attributes of the root string. (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:forParameter:]): * Source/WebCore/en.lproj/Localizable.strings: * Source/WebCore/platform/LocalizedStrings.cpp: (WebCore::AXSuggestionRoleDescriptionText): * Source/WebCore/platform/LocalizedStrings.h: * Tools/DumpRenderTree/AccessibilityUIElement.cpp: (getIsInsertionCallback): (getIsDeletionCallback): (getIsFirstItemInSuggestionCallback): (getIsLastItemInSuggestionCallback): (AccessibilityUIElement::getJSClass): * Tools/DumpRenderTree/AccessibilityUIElement.h: * Tools/DumpRenderTree/ios/AccessibilityUIElementIOS.mm: (AccessibilityUIElement::isInsertion): (AccessibilityUIElement::isDeletion): (AccessibilityUIElement::isFirstItemInSuggestion): (AccessibilityUIElement::isLastItemInSuggestion): * Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h: * Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl: * Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm: (WTR::AccessibilityUIElement::isInsertion const): (WTR::AccessibilityUIElement::isDeletion const): (WTR::AccessibilityUIElement::isFirstItemInSuggestion const): (WTR::AccessibilityUIElement::isLastItemInSuggestion const): * Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm: (WTR::AccessibilityUIElement::isInsertion const): (WTR::AccessibilityUIElement::isDeletion const): (WTR::AccessibilityUIElement::isFirstItemInSuggestion const): (WTR::AccessibilityUIElement::isLastItemInSuggestion const): Exposes the new methods for use in testing. Canonical link: https://commits.webkit.org/252516@main
- Loading branch information
1 parent
86cccca
commit 3395d79
Showing
24 changed files
with
420 additions
and
5 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
...utTests/accessibility/ios-simulator/suggestion-insertion-deletion-attributes-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
This test makes sure that suggestions, insertions, and deletions expose the right attributes. | ||
PASS: ins1.isInsertion === true | ||
PASS: ins1.isFirstItemInSuggestion === true | ||
PASS: ins1.isLastItemInSuggestion === false | ||
PASS: del1.isDeletion === true | ||
PASS: del1.isLastItemInSuggestion === true | ||
PASS: del1.isFirstItemInSuggestion === false | ||
PASS: ins2.isInsertion === true | ||
PASS: ins2.isFirstItemInSuggestion === true | ||
PASS: ins3.isInsertion === true | ||
PASS: ins2.isLastItemInSuggestion === false | ||
PASS: del2.isLastItemInSuggestion === true | ||
PASS: ins3.isFirstItemInSuggestion === false | ||
|
||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
inserted textdeleted text | ||
inserted textdeleted text |
46 changes: 46 additions & 0 deletions
46
LayoutTests/accessibility/ios-simulator/suggestion-insertion-deletion-attributes.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | ||
<html> | ||
<head> | ||
<script src="../../resources/js-test.js"></script> | ||
<script src="../../resources/accessibility-helper.js"></script> | ||
</head> | ||
<body> | ||
|
||
<div id="sug1" role="suggestion"><span id="ins1" role="insertion">inserted text</span><span id="del1" role="deletion">deleted text</span></div> | ||
|
||
<div id="sug2" role="suggestion"><span id="ins2" role="insertion"><b>inserted</b> text</span><span id="del2" role="deletion">deleted text</span></div> | ||
|
||
|
||
<script> | ||
|
||
if (window.accessibilityController) { | ||
|
||
let output = "This test makes sure that suggestions, insertions, and deletions expose the right attributes.\n"; | ||
|
||
var ins1 = accessibilityController.accessibleElementById("ins1").childAtIndex(0); | ||
output += expect("ins1.isInsertion", "true"); | ||
output += expect("ins1.isFirstItemInSuggestion", "true"); | ||
output += expect("ins1.isLastItemInSuggestion", "false"); | ||
|
||
var del1 = accessibilityController.accessibleElementById("del1").childAtIndex(0); | ||
output += expect("del1.isDeletion", "true"); | ||
output += expect("del1.isLastItemInSuggestion", "true"); | ||
output += expect("del1.isFirstItemInSuggestion", "false"); | ||
|
||
var ins2 = accessibilityController.accessibleElementById("ins2").childAtIndex(0); | ||
var ins3 = accessibilityController.accessibleElementById("ins2").childAtIndex(1); | ||
var del2 = accessibilityController.accessibleElementById("del2").childAtIndex(0); | ||
output += expect("ins2.isInsertion", "true"); | ||
output += expect("ins2.isFirstItemInSuggestion", "true"); | ||
output += expect("ins3.isInsertion", "true"); | ||
output += expect("ins2.isLastItemInSuggestion", "false"); | ||
output += expect("del2.isLastItemInSuggestion", "true"); | ||
output += expect("ins3.isFirstItemInSuggestion", "false"); | ||
|
||
debug(output); | ||
} | ||
|
||
</script> | ||
|
||
</body> | ||
</html> |
11 changes: 11 additions & 0 deletions
11
LayoutTests/accessibility/mac/attributed-string-includes-insertion-deletion-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
This verifies that using the insertion and deletion roles adds the attribute to the attributed string. | ||
PASS: item1.attributedStringForTextMarkerRangeContainsAttribute('AXIsSuggestedInsertion', markerRange) === true | ||
PASS: item2.attributedStringForTextMarkerRangeContainsAttribute('AXIsSuggestedDeletion', markerRange) === true | ||
PASS: item3.attributedStringForTextMarkerRangeContainsAttribute('AXIsSuggestion', markerRange) === true | ||
|
||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
inserted text | ||
deleted text | ||
hellohi |
34 changes: 34 additions & 0 deletions
34
LayoutTests/accessibility/mac/attributed-string-includes-insertion-deletion.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | ||
<html> | ||
<head> | ||
<script src="../../resources/js-test.js"></script> | ||
<script src="../../resources/accessibility-helper.js"></script> | ||
</head> | ||
<body id="body" role="group"> | ||
|
||
<div id="item1"><span role="insertion">inserted text</span></div> | ||
<div id="item2"><span role="deletion">deleted text</span></div> | ||
<div id="item3"><span role="suggestion"><span role="insertion">hello</span><span role="deletion">hi</span></span></div> | ||
|
||
<script> | ||
if (window.accessibilityController) { | ||
let output = "This verifies that using the insertion and deletion roles adds the attribute to the attributed string.\n"; | ||
|
||
var item1 = accessibilityController.accessibleElementById("item1"); | ||
var markerRange = item1.textMarkerRangeForElement(item1); | ||
output += expect("item1.attributedStringForTextMarkerRangeContainsAttribute('AXIsSuggestedInsertion', markerRange)", "true"); | ||
|
||
var item2 = accessibilityController.accessibleElementById("item2"); | ||
var markerRange = item2.textMarkerRangeForElement(item2); | ||
output += expect("item2.attributedStringForTextMarkerRangeContainsAttribute('AXIsSuggestedDeletion', markerRange)", "true"); | ||
|
||
var item3 = accessibilityController.accessibleElementById("item3"); | ||
var markerRange = item3.textMarkerRangeForElement(item3); | ||
output += expect("item3.attributedStringForTextMarkerRangeContainsAttribute('AXIsSuggestion', markerRange)", "true"); | ||
|
||
debug(output); | ||
} | ||
</script> | ||
</body> | ||
</html> |
17 changes: 17 additions & 0 deletions
17
LayoutTests/accessibility/mac/suggestion-subrole-and-roledescription-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
This tests that suggestion, insertion, and deletion elements have the right subroles. | ||
PASS: suggestion1.role === 'AXRole: AXGroup' | ||
PASS: suggestion1.subrole === 'AXSubrole: AXSuggestion' | ||
PASS: suggestion1.roleDescription === 'AXRoleDescription: suggestion' | ||
PASS: ins1.subrole === 'AXSubrole: AXInsertStyleGroup' | ||
PASS: ins2.subrole === 'AXSubrole: AXInsertStyleGroup' | ||
PASS: del1.subrole === 'AXSubrole: AXDeleteStyleGroup' | ||
PASS: del2.subrole === 'AXSubrole: AXDeleteStyleGroup' | ||
|
||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
This is some test to insert and delete | ||
this is inserted text. | ||
This is also inserted text | ||
This is deleted text | ||
this is also deleted text |
43 changes: 43 additions & 0 deletions
43
LayoutTests/accessibility/mac/suggestion-subrole-and-roledescription.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | ||
<html> | ||
<head> | ||
<script src="../../resources/js-test.js"></script> | ||
<script src="../../resources/accessibility-helper.js"></script> | ||
</head> | ||
<body id="body"> | ||
|
||
<div id="suggestion1" role="suggestion">This is some test to <span role="insertion">insert</span> and <span role="deletion">delete</span></div> | ||
|
||
<div id="ins1" role="insertion">this is inserted text.</div> | ||
<ins id="ins2">This is also inserted text</ins> | ||
|
||
<div id="del1" role="deletion">This is deleted text</div> | ||
<del id="del2">this is also deleted text</div> | ||
|
||
<script> | ||
if (window.accessibilityController) { | ||
let output = "This tests that suggestion, insertion, and deletion elements have the right subroles.\n"; | ||
|
||
var suggestion1 = accessibilityController.accessibleElementById("suggestion1"); | ||
var ins1 = accessibilityController.accessibleElementById("ins1"); | ||
var ins2 = accessibilityController.accessibleElementById("ins2"); | ||
var del1 = accessibilityController.accessibleElementById("del1"); | ||
var del2 = accessibilityController.accessibleElementById("del2"); | ||
|
||
output += expect("suggestion1.role", "'AXRole: AXGroup'"); | ||
output += expect("suggestion1.subrole", "'AXSubrole: AXSuggestion'"); | ||
output += expect("suggestion1.roleDescription", "'AXRoleDescription: suggestion'"); | ||
|
||
output += expect("ins1.subrole", "'AXSubrole: AXInsertStyleGroup'"); | ||
output += expect("ins2.subrole", "'AXSubrole: AXInsertStyleGroup'"); | ||
|
||
output += expect("del1.subrole", "'AXSubrole: AXDeleteStyleGroup'"); | ||
output += expect("del2.subrole", "'AXSubrole: AXDeleteStyleGroup'"); | ||
|
||
debug(output); | ||
} | ||
|
||
</script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.