-
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: VoiceOver doesn't read characters when user presses left / right …
…arrows in Monaco code editor https://bugs.webkit.org/show_bug.cgi?id=270616 rdar://123984168 Reviewed by Andres Gonzalez. When the character or selection extent moves by just one visible position, infer that it was a character granularity move, rather than a discontiguous selection. * LayoutTests/accessibility/mac/custom-text-editor-expected.txt: Added. * LayoutTests/accessibility/mac/custom-text-editor.html: Added. * Source/WebCore/accessibility/AXObjectCache.h: * Source/WebCore/accessibility/mac/AXObjectCacheMac.mm: (WebCore::AXObjectCache::inferDirectionFromIntent): (WebCore::AXObjectCache::postTextStateChangePlatformNotification): Canonical link: https://commits.webkit.org/275998@main
- Loading branch information
Dominic Mazzoni
committed
Mar 12, 2024
1 parent
c0a2b30
commit 18d9a43
Showing
4 changed files
with
170 additions
and
1 deletion.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
LayoutTests/accessibility/mac/custom-text-editor-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,24 @@ | ||
Tests that we infer intents when JS is used to move the cursor in a text editor; this practice is common in online code editors. | ||
|
||
PASS: addedNotification === true | ||
Move to 0 | ||
move discontiguous | ||
Move to 1 | ||
move next character | ||
Move to 2 | ||
move next character | ||
Move to 3 | ||
move next character | ||
Move to 4 | ||
move next character | ||
Move to 6 | ||
move next character | ||
Move to 8 | ||
move discontiguous | ||
Move to 9 | ||
move next character | ||
|
||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
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,92 @@ | ||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<script src="../../resources/accessibility-helper.js"></script> | ||
<script src="../../resources/js-test.js"></script> | ||
</head> | ||
<body> | ||
|
||
<textarea autofocus id="text" role="textbox">Text😀area with custom cursor handling</textarea> | ||
|
||
<script> | ||
var output = "Tests that we infer intents when JS is used to move the cursor in a text editor; this practice is common in online code editors.\n\n"; | ||
|
||
const AXTextStateChangeTypeSelectionMove = 2; | ||
const AXTextStateChangeTypeSelectionExtend = AXTextStateChangeTypeSelectionMove + 1; | ||
|
||
const AXTextSelectionDirectionBeginning = 1; | ||
const AXTextSelectionDirectionEnd = AXTextSelectionDirectionBeginning + 1; | ||
const AXTextSelectionDirectionPrevious = AXTextSelectionDirectionEnd + 1; | ||
const AXTextSelectionDirectionNext = AXTextSelectionDirectionPrevious + 1; | ||
const AXTextSelectionDirectionDiscontiguous = AXTextSelectionDirectionNext + 1; | ||
|
||
const AXTextSelectionGranularityCharacter = 1; | ||
|
||
function notificationCallback(notification, userInfo) { | ||
if (notification != "AXSelectedTextChanged") | ||
return; | ||
|
||
let str = ""; | ||
let type = userInfo["AXTextStateChangeType"]; | ||
if (type == AXTextStateChangeTypeSelectionMove) | ||
str += "move"; | ||
|
||
let dir = userInfo["AXTextSelectionDirection"]; | ||
if (dir == AXTextSelectionDirectionNext) | ||
str += " next"; | ||
else if (dir == AXTextSelectionDirectionPrevious) | ||
str += " previous"; | ||
else if (dir == AXTextSelectionDirectionDiscontiguous) | ||
str += " discontiguous"; | ||
|
||
let granularity = userInfo["AXTextSelectionGranularity"]; | ||
if (granularity == AXTextSelectionGranularityCharacter) | ||
str += " character"; | ||
|
||
str += "\n"; | ||
output += str; | ||
|
||
if (resolveNotificationPromise) | ||
resolveNotificationPromise(); | ||
} | ||
|
||
async function moveAndWaitForNotification(offset) { | ||
text = document.getElementById("text"); | ||
output += "Move to " + offset + "\n"; | ||
let promise = new Promise((resolve, reject) => { | ||
resolveNotificationPromise = resolve; | ||
}); | ||
text.setSelectionRange(offset, offset); | ||
await promise; | ||
resolveNotificationPromise = null; | ||
} | ||
|
||
if (window.accessibilityController) { | ||
window.jsTestIsAsync = true; | ||
|
||
accessibilityController.enableEnhancedAccessibility(true); | ||
|
||
webArea = accessibilityController.rootElement.childAtIndex(0); | ||
var addedNotification = webArea.addNotificationListener(notificationCallback); | ||
output += expect("addedNotification", "true"); | ||
|
||
setTimeout(async function() { | ||
await moveAndWaitForNotification(0); | ||
await moveAndWaitForNotification(1); | ||
await moveAndWaitForNotification(2); | ||
await moveAndWaitForNotification(3); | ||
await moveAndWaitForNotification(4); | ||
|
||
await moveAndWaitForNotification(6); // Note single character (emoji) | ||
|
||
await moveAndWaitForNotification(8); // Discontiguous | ||
await moveAndWaitForNotification(9); | ||
|
||
debug(output); | ||
finishJSTest(); | ||
}, 0); | ||
} | ||
</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