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 { ...@@ -27,7 +27,7 @@ class BackButtonNode extends SAChildNode {
/** @override */ /** @override */
get automationNode() { get automationNode() {
return BackButtonNode.automationNode_; return BackButtonNode.automationNode;
} }
/** @override */ /** @override */
...@@ -35,8 +35,8 @@ class BackButtonNode extends SAChildNode { ...@@ -35,8 +35,8 @@ class BackButtonNode extends SAChildNode {
if (BackButtonNode.locationForTesting) { if (BackButtonNode.locationForTesting) {
return BackButtonNode.locationForTesting; return BackButtonNode.locationForTesting;
} }
if (BackButtonNode.automationNode_) { if (this.automationNode) {
return BackButtonNode.automationNode_.location; return this.automationNode.location;
} }
} }
...@@ -59,8 +59,7 @@ class BackButtonNode extends SAChildNode { ...@@ -59,8 +59,7 @@ class BackButtonNode extends SAChildNode {
/** @override */ /** @override */
isEquivalentTo(node) { isEquivalentTo(node) {
return node instanceof BackButtonNode || return node instanceof BackButtonNode || this.automationNode === node;
BackButtonNode.automationNode_ === node;
} }
/** @override */ /** @override */
...@@ -70,7 +69,7 @@ class BackButtonNode extends SAChildNode { ...@@ -70,7 +69,7 @@ class BackButtonNode extends SAChildNode {
/** @override */ /** @override */
isValidAndVisible() { isValidAndVisible() {
return BackButtonNode.automationNode_ !== null; return this.automationNode !== null;
} }
/** @override */ /** @override */
...@@ -106,17 +105,19 @@ class BackButtonNode extends SAChildNode { ...@@ -106,17 +105,19 @@ class BackButtonNode extends SAChildNode {
// ================= Static methods ================= // ================= 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( const treeWalker = new AutomationTreeWalker(
NavigationManager.instance.desktopNode, constants.Dir.FORWARD, NavigationManager.instance.desktopNode, constants.Dir.FORWARD,
{visit: (node) => node.htmlAttributes.id === SAConstants.BACK_ID}); {visit: (node) => node.htmlAttributes.id === SAConstants.BACK_ID});
BackButtonNode.automationNode_ = treeWalker.next().node; BackButtonNode.automationNode_ = treeWalker.next().node;
return BackButtonNode.automationNode_;
// TODO(anastasi): Generate event when Switch Access Panel is loaded instead
// of polling.
if (!BackButtonNode.automationNode_) {
setTimeout(BackButtonNode.findAutomationNode, 100);
}
} }
} }
...@@ -15,7 +15,6 @@ class SwitchAccess { ...@@ -15,7 +15,6 @@ class SwitchAccess {
AutoScanManager.initialize(); AutoScanManager.initialize();
NavigationManager.initialize(desktop); NavigationManager.initialize(desktop);
BackButtonNode.findAutomationNode();
Commands.initialize(); Commands.initialize();
KeyboardRootNode.startWatchingVisibility(); KeyboardRootNode.startWatchingVisibility();
MenuManager.initialize(); 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