Commit acef8023 authored by Anastasia Helfinstein's avatar Anastasia Helfinstein Committed by Commit Bot

Click virtual keyboard keys when selected with Switch Access.

Because the virtual keyboard's doDefault() behavior is to do nothing,
in order for Switch Access to type on the virtual keyboard we have to
send synthetic mouse events.

Bug: 864826
Change-Id: Ie0562073d3f78baa42a9a6884dc41928922f2d4d
Reviewed-on: https://chromium-review.googlesource.com/c/1380340Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Commit-Queue: Anastasia Helfinstein <anastasi@google.com>
Cr-Commit-Position: refs/heads/master@{#618270}
parent 76d0e732
......@@ -47,6 +47,7 @@ run_jsbundler("switch_access_copied_files") {
"prefs.js",
"switch_access.js",
"switch_access_predicate.js",
"text_input_manager.js",
]
rewrite_rules = [
rebase_path(".", root_build_dir) + ":",
......@@ -151,6 +152,7 @@ js_type_check("closure_compile") {
":options",
":prefs",
":switch_access_predicate",
":text_input_manager",
"../chromevox:constants",
"../chromevox:tree_walker",
"../select_to_speak:closure_shim",
......@@ -168,7 +170,9 @@ js_library("auto_scan_manager") {
js_library("navigation_manager") {
deps = [
":context_menu_manager",
":switch_access_predicate",
":text_input_manager",
"../chromevox:constants",
"../chromevox:tree_walker",
]
......@@ -243,3 +247,7 @@ js_library("switch_access_interface") {
js_library("switch_access_predicate") {
externs_list = [ "$externs_path/automation.js" ]
}
js_library("text_input_manager") {
externs_list = [ "$externs_path/accessibility_private.js" ]
}
......@@ -22,6 +22,7 @@
"navigation_manager.js",
"prefs.js",
"switch_access.js",
"text_input_manager.js",
"tree_walker.js",
"background.js"
]
......
......@@ -180,6 +180,10 @@ class NavigationManager {
if (!this.node_.role)
return;
if (TextInputManager.pressKey(this.node_)) {
return;
}
if (this.node_ === this.scope_) {
// If we're visiting the scope as actionable, perform the default action.
if (this.visitingScopeAsActionable_) {
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* Class to handle text input for improved accuracy and efficiency.
*/
const TextInputManager = {
/** @type {number} */
KEY_PRESS_DURATION: 100,
/**
* Sends a keyEvent to click the center of the provided node.
* @param {!chrome.automation.AutomationNode} node
* @return {boolean} Whether a key was pressed.
*/
pressKey: (node) => {
if (node.role !== chrome.automation.RoleType.BUTTON)
return false;
if (!TextInputManager.inVirtualKeyboard_(node))
return false;
const x = node.location.left + Math.round(node.location.width / 2);
const y = node.location.top + Math.round(node.location.height / 2);
chrome.accessibilityPrivate.sendSyntheticMouseEvent({
type: chrome.accessibilityPrivate.SyntheticMouseEventType.PRESS,
x: x,
y: y
});
setTimeout(
() => chrome.accessibilityPrivate.sendSyntheticMouseEvent({
type: chrome.accessibilityPrivate.SyntheticMouseEventType.RELEASE,
x: x,
y: y
}),
TextInputManager.KEY_PRESS_DURATION);
return true;
},
/**
* Checks if |node| is in the virtual keyboard.
* @private
* @param {!chrome.automation.AutomationNode} node
* @return {boolean}
*/
inVirtualKeyboard_: (node) => {
if (node.role === chrome.automation.RoleType.KEYBOARD)
return true;
if (node.parent)
return TextInputManager.inVirtualKeyboard_(node.parent);
return false;
},
};
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