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

[Switch Access] Improve back button node clarity

Also removed a TODO, as the code no longer polls for the back button.

Bug: None
Change-Id: I167aca4a6e98ae7537bca431e33973a45dbf256d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2071040
Commit-Queue: Anastasia Helfinstein <anastasi@google.com>
Reviewed-by: default avatarAkihiro Ota <akihiroota@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746915}
parent 7ca21d22
......@@ -27,7 +27,7 @@ class BackButtonNode extends SAChildNode {
/** @override */
get automationNode() {
return BackButtonNode.automationNode_;
return BackButtonNode.automationNode;
}
/** @override */
......@@ -35,8 +35,8 @@ class BackButtonNode extends SAChildNode {
if (BackButtonNode.locationForTesting) {
return BackButtonNode.locationForTesting;
}
if (BackButtonNode.automationNode_) {
return BackButtonNode.automationNode_.location;
if (this.automationNode) {
return this.automationNode.location;
}
}
......@@ -59,8 +59,7 @@ class BackButtonNode extends SAChildNode {
/** @override */
isEquivalentTo(node) {
return node instanceof BackButtonNode ||
BackButtonNode.automationNode_ === node;
return node instanceof BackButtonNode || this.automationNode === node;
}
/** @override */
......@@ -70,7 +69,7 @@ class BackButtonNode extends SAChildNode {
/** @override */
isValidAndVisible() {
return BackButtonNode.automationNode_ !== null;
return this.automationNode !== null;
}
/** @override */
......@@ -106,17 +105,19 @@ class BackButtonNode extends SAChildNode {
// ================= Static methods =================
/** Looks for the back button node. */
static findAutomationNode() {
/**
* Looks for the back button node.
* @return {?chrome.automation.AutomationNode}
*/
static get automationNode() {
if (BackButtonNode.automationNode_) {
return BackButtonNode.automationNode_;
}
const treeWalker = new AutomationTreeWalker(
NavigationManager.instance.desktopNode, constants.Dir.FORWARD,
{visit: (node) => node.htmlAttributes.id === SAConstants.BACK_ID});
BackButtonNode.automationNode_ = treeWalker.next().node;
// TODO(anastasi): Generate event when Switch Access Panel is loaded instead
// of polling.
if (!BackButtonNode.automationNode_) {
setTimeout(BackButtonNode.findAutomationNode, 100);
}
return BackButtonNode.automationNode_;
}
}
......@@ -15,7 +15,6 @@ class SwitchAccess {
AutoScanManager.initialize();
NavigationManager.initialize(desktop);
BackButtonNode.findAutomationNode();
Commands.initialize();
KeyboardRootNode.startWatchingVisibility();
MenuManager.initialize();
......
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