Commit d751c62d authored by David Tseng's avatar David Tseng Committed by Commit Bot

Recover ChromeVox range to last hover target for navigation gestures

R=dmazzoni@chromium.org

Change-Id: I78f5c5274ef665b844e4f85648a77b74f9b953de
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2157991Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Commit-Queue: David Tseng <dtseng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#760998}
parent 4038d923
...@@ -57,6 +57,9 @@ DesktopAutomationHandler = class extends BaseAutomationHandler { ...@@ -57,6 +57,9 @@ DesktopAutomationHandler = class extends BaseAutomationHandler {
/** @private {!Date} */ /** @private {!Date} */
this.lastHoverExit_ = new Date(); this.lastHoverExit_ = new Date();
/** @private {!AutomationNode|undefined} */
this.lastHoverTarget_;
this.addListener_(EventType.ALERT, this.onAlert); this.addListener_(EventType.ALERT, this.onAlert);
this.addListener_(EventType.BLUR, this.onBlur); this.addListener_(EventType.BLUR, this.onBlur);
this.addListener_( this.addListener_(
...@@ -96,6 +99,14 @@ DesktopAutomationHandler = class extends BaseAutomationHandler { ...@@ -96,6 +99,14 @@ DesktopAutomationHandler = class extends BaseAutomationHandler {
return this.textEditHandler_; return this.textEditHandler_;
} }
/**
* @return {!AutomationNode|undefined} The target of the last observed hover
* event.
*/
get lastHoverTarget() {
return this.lastHoverTarget_;
}
/** @override */ /** @override */
willHandleEvent_(evt) { willHandleEvent_(evt) {
return false; return false;
...@@ -152,6 +163,9 @@ DesktopAutomationHandler = class extends BaseAutomationHandler { ...@@ -152,6 +163,9 @@ DesktopAutomationHandler = class extends BaseAutomationHandler {
EventSourceState.set(EventSourceType.TOUCH_GESTURE); EventSourceState.set(EventSourceType.TOUCH_GESTURE);
// Save the last hover target for use by the gesture handler.
this.lastHoverTarget_ = evt.target;
let target = evt.target; let target = evt.target;
let targetLeaf = null; let targetLeaf = null;
let targetObject = null; let targetObject = null;
......
...@@ -14,7 +14,8 @@ goog.provide('GestureGranularity'); ...@@ -14,7 +14,8 @@ goog.provide('GestureGranularity');
* command: string, * command: string,
* menuKeyOverride: (boolean|undefined), * menuKeyOverride: (boolean|undefined),
* keyOverride: ({keyCode: number, modifiers: ({ctrl: * keyOverride: ({keyCode: number, modifiers: ({ctrl:
* boolean}|undefined)}|undefined) * boolean}|undefined)}|undefined),
* shouldRecoverRange: (boolean|undefined)
* }>} * }>}
* @const * @const
*/ */
...@@ -24,25 +25,29 @@ GestureCommandData.GESTURE_COMMAND_MAP = { ...@@ -24,25 +25,29 @@ GestureCommandData.GESTURE_COMMAND_MAP = {
msgId: 'swipeUp1_gesture', msgId: 'swipeUp1_gesture',
command: 'previousAtGranularity', command: 'previousAtGranularity',
menuKeyOverride: true, menuKeyOverride: true,
keyOverride: {keyCode: 38 /* up */, skipStart: true, multiline: true} keyOverride: {keyCode: 38 /* up */, skipStart: true, multiline: true},
shouldRecoverRange: true
}, },
'swipeDown1': { 'swipeDown1': {
msgId: 'swipeDown1_gesture', msgId: 'swipeDown1_gesture',
command: 'nextAtGranularity', command: 'nextAtGranularity',
menuKeyOverride: true, menuKeyOverride: true,
keyOverride: {keyCode: 40 /* Down */, skipEnd: true, multiline: true} keyOverride: {keyCode: 40 /* Down */, skipEnd: true, multiline: true},
shouldRecoverRange: true
}, },
'swipeLeft1': { 'swipeLeft1': {
msgId: 'swipeLeft1_gesture', msgId: 'swipeLeft1_gesture',
command: 'previousObject', command: 'previousObject',
menuKeyOverride: true, menuKeyOverride: true,
keyOverride: {keyCode: 37 /* left */} keyOverride: {keyCode: 37 /* left */},
shouldRecoverRange: true
}, },
'swipeRight1': { 'swipeRight1': {
msgId: 'swipeRight1_gesture', msgId: 'swipeRight1_gesture',
command: 'nextObject', command: 'nextObject',
menuKeyOverride: true, menuKeyOverride: true,
keyOverride: {keyCode: 39 /* right */} keyOverride: {keyCode: 39 /* right */},
shouldRecoverRange: true
}, },
'swipeUp2': {msgId: 'swipeUp2_gesture', command: 'jumpToTop'}, 'swipeUp2': {msgId: 'swipeUp2_gesture', command: 'jumpToTop'},
'swipeDown2': {msgId: 'swipeDown2_gesture', command: 'readFromHere'}, 'swipeDown2': {msgId: 'swipeDown2_gesture', command: 'readFromHere'},
......
...@@ -76,6 +76,14 @@ GestureCommandHandler.onAccessibilityGesture_ = function(gesture) { ...@@ -76,6 +76,14 @@ GestureCommandHandler.onAccessibilityGesture_ = function(gesture) {
} }
} }
if (!ChromeVoxState.instance.currentRange && commandData.shouldRecoverRange) {
const recoverTo = DesktopAutomationHandler.instance.lastHoverTarget;
if (recoverTo) {
ChromeVoxState.instance.setCurrentRange(
cursors.Range.fromNode(recoverTo));
}
}
const command = commandData.command; const command = commandData.command;
if (command) { if (command) {
CommandHandler.onCommand(command); CommandHandler.onCommand(command);
......
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