Commit 6e37a7f7 authored by David Tseng's avatar David Tseng Committed by Commit Bot

Remap two finger swipe left and right to escape and return

See go /chromevox-touch-gestures

Note that the previous mappings were to previous and next word which are now available via three finger left/right to word and then flick up or down.

R=akihiroota@chromium.org

Bug: 1124454
Test: browser_tests --gtest_filter=ChromeVox*.SwipeLeftRight2
Change-Id: I82e98a1b6da15dd82d0ff9c55ce98cdedb99aad1
AX-Relnotes: makes ChromeVox two finger swipe left and right perform escape and return respectively.
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2386009
Commit-Queue: David Tseng <dtseng@chromium.org>
Reviewed-by: default avatarAkihiro Ota <akihiroota@chromium.org>
Cr-Commit-Position: refs/heads/master@{#805451}
parent 4c8e589d
......@@ -3015,3 +3015,22 @@ TEST_F('ChromeVoxBackgroundTest', 'SwipeLeftRight4ByContainers', function() {
.replay();
});
});
TEST_F('ChromeVoxBackgroundTest', 'SwipeLeftRight2', function() {
const mockFeedback = this.createMockFeedback();
this.runWithLoadedTree(
`
<p id="live" aria-live="polite"</p>
<script>
document.body.addEventListener('keydown', (evt) => {
document.getElementById('live').textContent = evt.key;
});
</script>
`,
function(root) {
mockFeedback.call(doGesture('swipeRight2')).expectSpeech('Enter');
mockFeedback.call(doGesture('swipeLeft2'))
.expectSpeech('Escape')
.replay();
});
});
......@@ -10,15 +10,13 @@ goog.require('KeyCode');
/**
* Map from gesture names (ax::mojom::Gesture defined in
* ui/accessibility/ax_enums.mojom.) to commands.
* @type {!Object<string,
* {
* msgId: string,
* command: (string|undefined),
* @type {!Object<string, {msgId: string, command: (string|undefined),
* acceleratorAction:
* (chrome.accessibilityPrivate.AcceleratorAction|undefined),
* menuKeyOverride:
* ({keyCode: KeyCode, modifiers: ({ctrl: boolean}|undefined)}|undefined)
* }>}
* (chrome.accessibilityPrivate.AcceleratorAction|undefined),
* globalKey: ({keyCode: KeyCode, modifiers:
* (chrome.accessibilityPrivate.SyntheticKeyboardModifiers|undefined)}|undefined),
* menuKeyOverride: ({keyCode: KeyCode, modifiers:
* (chrome.accessibilityPrivate.SyntheticKeyboardModifiers|undefined)}|undefined)}>}
* @const
*/
GestureCommandData.GESTURE_COMMAND_MAP = {
......@@ -45,8 +43,10 @@ GestureCommandData.GESTURE_COMMAND_MAP = {
},
'swipeUp2': {msgId: 'swipeup2_gesture', command: 'jumpToTop'},
'swipeDown2': {msgId: 'swipedown2_gesture', command: 'readFromHere'},
'swipeLeft2': {msgId: 'swipeleft2_gesture', command: 'previousWord'},
'swipeRight2': {msgId: 'swiperight2_gesture', command: 'nextWord'},
'swipeLeft2':
{msgId: 'swipeleft2_gesture', globalKey: {keyCode: KeyCode.ESCAPE}},
'swipeRight2':
{msgId: 'swiperight2_gesture', globalKey: {keyCode: KeyCode.RETURN}},
'swipeUp3': {msgId: 'swipeup3_gesture', command: 'nextPage'},
'swipeDown3': {msgId: 'swipedown3_gesture', command: 'previousPage'},
'swipeLeft3': {msgId: 'swipeleft3_gesture', command: 'previousGranularity'},
......
......@@ -65,8 +65,9 @@ GestureCommandHandler.onAccessibilityGesture_ = function(gesture, x, y) {
return;
}
// Map gestures to arrow keys while within menus belonging to the desktop or
// generally in the ChromeVox Panel.
// Handle gestures mapped to keys. Global keys are handled in place of
// commands, and menu key overrides are handled only in menus.
let key;
if (ChromeVoxState.instance.currentRange) {
const range = ChromeVoxState.instance.currentRange;
if (commandData.menuKeyOverride && range.start && range.start.node &&
......@@ -74,12 +75,19 @@ GestureCommandHandler.onAccessibilityGesture_ = function(gesture, x, y) {
range.start.node.root.role == RoleType.DESKTOP) ||
range.start.node.root.docUrl.indexOf(
chrome.extension.getURL('chromevox/panel/panel.html')) == 0)) {
const key = commandData.menuKeyOverride;
EventGenerator.sendKeyPress(key.keyCode, key.modifiers);
return;
key = commandData.menuKeyOverride;
}
}
if (!key) {
key = commandData.globalKey;
}
if (key) {
EventGenerator.sendKeyPress(key.keyCode, key.modifiers);
return;
}
// Always try to recover the range to the previous hover target, if there's no
// range.
if (!ChromeVoxState.instance.currentRange) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment