Commit 3da2345d authored by Akihiro Ota's avatar Akihiro Ota Committed by Commit Bot

ChromeVox: Clean up style in tree_walker.js

This change:
1. Adds braces for all control structures according to the Google
JavaScript style guidelines: http://go/js-style.
2. Access the phase member variable (this.phase_) when checking
the current phase. The previous code was confusing because
sometimes we would check the tree walker phase using the getter
(this.phase) and other times we would directly check the member
variable (this.phase_).

Change-Id: Id2288716d7b1bb1a08fb8c06760a17a753be8081
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1880178
Commit-Queue: Aaron Leventhal <aleventhal@chromium.org>
Reviewed-by: default avatarAaron Leventhal <aleventhal@chromium.org>
Reviewed-by: default avatarAnastasia Helfinstein <anastasi@google.com>
Cr-Commit-Position: refs/heads/master@{#714702}
parent 7cf0a17b
...@@ -93,13 +93,15 @@ AutomationTreeWalker = function(node, dir, opt_restrictions) { ...@@ -93,13 +93,15 @@ AutomationTreeWalker = function(node, dir, opt_restrictions) {
this.visitPred_ = function(node) { this.visitPred_ = function(node) {
if (this.skipInitialAncestry_ && if (this.skipInitialAncestry_ &&
this.phase_ == AutomationTreeWalkerPhase.ANCESTOR) this.phase_ == AutomationTreeWalkerPhase.ANCESTOR) {
return false; return false;
}
if (this.skipInitialSubtree_ && if (this.skipInitialSubtree_ &&
this.phase != AutomationTreeWalkerPhase.ANCESTOR && this.phase_ != AutomationTreeWalkerPhase.ANCESTOR &&
this.phase != AutomationTreeWalkerPhase.OTHER) this.phase_ != AutomationTreeWalkerPhase.OTHER) {
return false; return false;
}
if (restrictions.visit) { if (restrictions.visit) {
return restrictions.visit(node); return restrictions.visit(node);
...@@ -174,7 +176,7 @@ AutomationTreeWalker.prototype = { ...@@ -174,7 +176,7 @@ AutomationTreeWalker.prototype = {
} }
if (!this.skipInitialSubtree_ || if (!this.skipInitialSubtree_ ||
this.phase != AutomationTreeWalkerPhase.DESCENDANT) { this.phase_ != AutomationTreeWalkerPhase.DESCENDANT) {
this.node_ = node.firstChild; this.node_ = node.firstChild;
return; return;
} }
...@@ -201,8 +203,9 @@ AutomationTreeWalker.prototype = { ...@@ -201,8 +203,9 @@ AutomationTreeWalker.prototype = {
// Exit if we encounter a root-like node and are not searching descendants // Exit if we encounter a root-like node and are not searching descendants
// of the initial node. // of the initial node.
if (searchNode.parent && this.rootPred_(searchNode.parent) && if (searchNode.parent && this.rootPred_(searchNode.parent) &&
this.phase_ != AutomationTreeWalkerPhase.DESCENDANT) this.phase_ != AutomationTreeWalkerPhase.DESCENDANT) {
break; break;
}
searchNode = searchNode.parent; searchNode = searchNode.parent;
} }
...@@ -218,8 +221,9 @@ AutomationTreeWalker.prototype = { ...@@ -218,8 +221,9 @@ AutomationTreeWalker.prototype = {
this.phase_ = AutomationTreeWalkerPhase.OTHER; this.phase_ = AutomationTreeWalkerPhase.OTHER;
node = node.previousSibling; node = node.previousSibling;
while (!this.leafPred_(node) && node.lastChild) while (!this.leafPred_(node) && node.lastChild) {
node = node.lastChild; node = node.lastChild;
}
this.node_ = node; this.node_ = node;
return; return;
......
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