Commit 1f641f5e authored by Anastasia Helfinstein's avatar Anastasia Helfinstein Committed by Commit Bot

[Switch Access] Handle combo boxes

Because the options in a combo box are not in the automation tree, we
will handle combo boxes by simulating arrow keys. This behavior will be
changed when the underlying data is available.

AX-Relnotes: n/a.
Bug: 996401
Change-Id: Ice9003de483a4d9cdb7edd32f97f8024ec8b477b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2231660
Commit-Queue: Anastasia Helfinstein <anastasi@google.com>
Reviewed-by: default avatarAbigail Klein <abigailbklein@google.com>
Cr-Commit-Position: refs/heads/master@{#776161}
parent 8eade9d1
......@@ -65,6 +65,7 @@ run_jsbundler("switch_access_copied_files") {
"metrics.js",
"navigation_manager.js",
"nodes/back_button_node.js",
"nodes/combo_box_node.js",
"nodes/desktop_node.js",
"nodes/editable_text_node.js",
"nodes/group_node.js",
......@@ -134,6 +135,7 @@ js_type_check("closure_compile") {
":auto_scan_manager",
":back_button_node",
":background",
":combo_box_node",
":commands",
":desktop_node",
":editable_text_node",
......@@ -157,6 +159,7 @@ js_type_check("closure_compile") {
":system_menu_node",
":tab_node",
":text_navigation_manager",
"../common:automation_predicate",
"../common:closure_shim",
"../common:constants",
"../common:tree_walker",
......@@ -185,6 +188,16 @@ js_library("back_button_node") {
]
}
js_library("combo_box_node") {
sources = [ "nodes/combo_box_node.js" ]
deps = [
":event_helper",
":node_wrapper",
":switch_access_constants",
]
externs_list = []
}
js_library("commands") {
deps = [
":auto_scan_manager",
......@@ -327,6 +340,7 @@ js_library("node_wrapper") {
":switch_access_constants",
":switch_access_node",
":switch_access_predicate",
"../common:automation_predicate",
"../common:constants",
"../common:tree_walker",
]
......@@ -381,6 +395,7 @@ js_library("switch_access_predicate") {
deps = [
":switch_access_constants",
":switch_access_node",
"../common:automation_predicate",
]
externs_list = [ "$externs_path/automation.js" ]
}
......
// Copyright 2020 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.
/**
* This class handles interactions with combo boxes.
* TODO(anastasi): Add a test for this class.
*/
class ComboBoxNode extends NodeWrapper {
/** @override */
get actions() {
return [SwitchAccessMenuAction.INCREMENT, SwitchAccessMenuAction.DECREMENT];
}
/** @override */
doDefaultAction() {
this.performAction(SwitchAccessMenuAction.INCREMENT);
}
/** @override */
onFocus() {
super.onFocus();
this.automationNode.focus();
}
/** @override */
performAction(action) {
// The box of options that typically pops up with combo boxes is not
// currently represented in the automation tree, so we work around that by
// selecting a value without opening the pop-up, using the up and down
// arrows.
switch (action) {
case SwitchAccessMenuAction.DECREMENT:
EventHelper.simulateKeyPress(EventHelper.KeyCode.UP_ARROW);
return SAConstants.ActionResponse.REMAIN_OPEN;
case SwitchAccessMenuAction.INCREMENT:
EventHelper.simulateKeyPress(EventHelper.KeyCode.DOWN_ARROW);
return SAConstants.ActionResponse.REMAIN_OPEN;
}
return SAConstants.ActionResponse.NO_ACTION_TAKEN;
}
}
......@@ -199,6 +199,9 @@ class NodeWrapper extends SAChildNode {
* @return {!NodeWrapper}
*/
static create(baseNode, parent) {
if (AutomationPredicate.comboBox(baseNode)) {
return new ComboBoxNode(baseNode, parent);
}
if (SwitchAccessPredicate.isTextInput(baseNode)) {
return new EditableTextNode(baseNode, parent);
}
......
......@@ -68,7 +68,8 @@ const SwitchAccessPredicate = {
return true;
}
if (SwitchAccessPredicate.isTextInput(node)) {
if (AutomationPredicate.comboBox(node) ||
SwitchAccessPredicate.isTextInput(node)) {
return true;
}
......@@ -120,6 +121,9 @@ const SwitchAccessPredicate = {
if (node.state[StateType.INVISIBLE]) {
return false;
}
if (AutomationPredicate.comboBox(node)) {
return false;
}
let interestingBranchesCount =
SwitchAccessPredicate.isActionable(node) ? 1 : 0;
......
......@@ -12,10 +12,10 @@
"background": {
"scripts": [
"common/array_util.js",
"switch_access/auto_scan_manager.js",
"common/closure_shim.js",
"switch_access/commands.js",
"common/constants.js",
"switch_access/auto_scan_manager.js",
"switch_access/commands.js",
"switch_access/event_helper.js",
"switch_access/focus_ring_manager.js",
"switch_access/history.js",
......@@ -25,6 +25,7 @@
"switch_access/nodes/switch_access_node.js",
"switch_access/nodes/node_wrapper.js",
"switch_access/nodes/back_button_node.js",
"switch_access/nodes/combo_box_node.js",
"switch_access/nodes/desktop_node.js",
"switch_access/nodes/editable_text_node.js",
"switch_access/nodes/group_node.js",
......@@ -37,6 +38,7 @@
"switch_access/switch_access_constants.js",
"switch_access/switch_access_predicate.js",
"switch_access/text_navigation_manager.js",
"common/automation_predicate.js",
"common/tree_walker.js",
"switch_access/background.js"
]
......
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