Commit 8680cfba authored by Zach Helfinstein's avatar Zach Helfinstein Committed by Commit Bot

Add scrolling to SwitchAccess context menu

Bug: 864796
Change-Id: Ic975c0b63742476415a995e74a351e746908468f
Reviewed-on: https://chromium-review.googlesource.com/1231741Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Commit-Queue: Zach Helfinstein <zhelfins@chromium.org>
Cr-Commit-Position: refs/heads/master@{#592988}
parent 3ce1bdcd
......@@ -139,6 +139,34 @@ class AutomationManager {
this.setCurrentNode_(node);
}
/**
* Scrolls the current node in the direction indicated by |scrollAction|.
* @param {!ContextMenuManager.Action} scrollAction
*/
scroll(scrollAction) {
// Find the closest ancestor to the current node that is scrollable.
let scrollNode = this.node_;
while (scrollNode && scrollNode.scrollX === undefined)
scrollNode = scrollNode.parent;
if (!scrollNode)
return;
if (scrollAction === ContextMenuManager.Action.SCROLL_DOWN)
scrollNode.scrollDown(() => {});
else if (scrollAction === ContextMenuManager.Action.SCROLL_UP)
scrollNode.scrollUp(() => {});
else if (scrollAction === ContextMenuManager.Action.SCROLL_LEFT)
scrollNode.scrollLeft(() => {});
else if (scrollAction === ContextMenuManager.Action.SCROLL_RIGHT)
scrollNode.scrollRight(() => {});
else if (scrollAction === ContextMenuManager.Action.SCROLL_FORWARD)
scrollNode.scrollForward(() => {});
else if (scrollAction === ContextMenuManager.Action.SCROLL_BACKWARD)
scrollNode.scrollBackward(() => {});
else
console.log('Unrecognized scroll action: ', scrollAction);
}
/**
* Perform the default action for the currently highlighted node. If the node
* is the current scope, go back to the previous scope. If the node is a group
......@@ -222,8 +250,10 @@ class AutomationManager {
*/
getRelevantMenuActions_() {
// TODO(crbug/881080): determine relevant actions programmatically.
let actions =
[ContextMenuManager.Action.CLICK, ContextMenuManager.Action.OPTIONS];
let actions = [
ContextMenuManager.Action.CLICK, ContextMenuManager.Action.OPTIONS,
ContextMenuManager.Action.SCROLL_UP, ContextMenuManager.Action.SCROLL_DOWN
];
return actions;
}
......
......@@ -57,7 +57,13 @@ function ContextMenuManager(automationManager, desktop) {
*/
ContextMenuManager.Action = {
CLICK: 'click',
OPTIONS: 'options'
OPTIONS: 'options',
SCROLL_BACKWARD: 'scroll-backward',
SCROLL_DOWN: 'scroll-down',
SCROLL_FORWARD: 'scroll-forward',
SCROLL_LEFT: 'scroll-left',
SCROLL_RIGHT: 'scroll-right',
SCROLL_UP: 'scroll-up'
};
/**
......@@ -211,6 +217,12 @@ ContextMenuManager.prototype = {
this.automationManager_.selectCurrentNode();
else if (event.data === ContextMenuManager.Action.OPTIONS)
window.switchAccess.showOptionsPage();
else if (
event.data === ContextMenuManager.Action.SCROLL_DOWN ||
event.data === ContextMenuManager.Action.SCROLL_UP ||
event.data === ContextMenuManager.Action.SCROLL_LEFT ||
event.data === ContextMenuManager.Action.SCROLL_RIGHT)
this.automationManager_.scroll(event.data);
},
/**
......
......@@ -15,6 +15,10 @@
<div id="switchaccess_contextmenu_actions"
aria-label="TODO-i18n(Context Menu)">
<button class="action" id="click">Click</button>
<button class="action" id="scroll-down" disabled>Scroll down</button>
<button class="action" id="scroll-up" disabled>Scroll up</button>
<button class="action" id="scroll-right" disabled>Scroll right</button>
<button class="action" id="scroll-left" disabled>Scroll left</button>
<button class="action" id="options">Options</button>
</div>
</body>
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