Commit 54877075 authored by Sara Kato's avatar Sara Kato Committed by Commit Bot

Use statetype enum in automation_predicate.js

There were inconsistent usages of node.state.type,
and node.state[State.type].

Also fix closure_compiler errors.

AX-Relnotes: n/a.
Bug: None (refactoring).
Test: webui_closure_compile, shows no errors
Change-Id: I78483d79336c8e71df34309f2ba306e7ac07d031
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2210604Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Commit-Queue: Sara Kato <sarakato@chromium.org>
Auto-Submit: Sara Kato <sarakato@chromium.org>
Cr-Commit-Position: refs/heads/master@{#772086}
parent 39ebe906
...@@ -123,7 +123,8 @@ AutomationPredicate = class { ...@@ -123,7 +123,8 @@ AutomationPredicate = class {
*/ */
static editText(node) { static editText(node) {
return node.role == Role.TEXT_FIELD || return node.role == Role.TEXT_FIELD ||
(node.state.editable && node.parent && !node.parent.state.editable); (node.state[State.EDITABLE] && !!node.parent &&
!node.parent.state[State.EDITABLE]);
} }
/** /**
...@@ -147,7 +148,7 @@ AutomationPredicate = class { ...@@ -147,7 +148,7 @@ AutomationPredicate = class {
* @return {boolean} * @return {boolean}
*/ */
static focused(node) { static focused(node) {
return node.state.focused; return node.state[State.FOCUSED];
} }
/** /**
...@@ -232,14 +233,14 @@ AutomationPredicate = class { ...@@ -232,14 +233,14 @@ AutomationPredicate = class {
// Editable nodes are within a text-like field and don't make sense when // Editable nodes are within a text-like field and don't make sense when
// performing object navigation. Users should use line, word, or character // performing object navigation. Users should use line, word, or character
// navigation. Only navigate to the top level node. // navigation. Only navigate to the top level node.
if (node.parent && node.parent.state.editable && if (node.parent && node.parent.state[State.EDITABLE] &&
!node.parent.state[State.RICHLY_EDITABLE]) { !node.parent.state[State.RICHLY_EDITABLE]) {
return false; return false;
} }
// Given no other information, ChromeVox wants to visit focusable // Given no other information, ChromeVox wants to visit focusable
// (e.g. tabindex=0) nodes only when it has a name or is a control. // (e.g. tabindex=0) nodes only when it has a name or is a control.
if (node.state.focusable && if (node.state[State.FOCUSABLE] &&
(node.name || node.state[State.EDITABLE] || (node.name || node.state[State.EDITABLE] ||
AutomationPredicate.formField(node))) { AutomationPredicate.formField(node))) {
return true; return true;
...@@ -319,7 +320,8 @@ AutomationPredicate = class { ...@@ -319,7 +320,8 @@ AutomationPredicate = class {
// Sometimes a focusable node will have a static text child with the same // Sometimes a focusable node will have a static text child with the same
// name. During object navigation, the child will receive focus, resulting // name. During object navigation, the child will receive focus, resulting
// in the name being read out twice. // in the name being read out twice.
if (node.state.focusable && nodeNameContainedInStaticTextChildren(node)) { if (node.state[State.FOCUSABLE] &&
nodeNameContainedInStaticTextChildren(node)) {
return false; return false;
} }
...@@ -337,8 +339,8 @@ AutomationPredicate = class { ...@@ -337,8 +339,8 @@ AutomationPredicate = class {
}, },
function(node) { function(node) {
return ( return (
node.state.editable && node.parent && node.state[State.EDITABLE] && node.parent &&
!node.parent.state.editable); !node.parent.state[State.EDITABLE]);
} }
] ]
})(node); })(node);
...@@ -394,7 +396,7 @@ AutomationPredicate = class { ...@@ -394,7 +396,7 @@ AutomationPredicate = class {
*/ */
static rootOrEditableRoot(node) { static rootOrEditableRoot(node) {
return AutomationPredicate.root(node) || return AutomationPredicate.root(node) ||
(node.state.richlyEditable && node.state.focused && (node.state[State.RICHLY_EDITABLE] && node.state[State.FOCUSED] &&
node.children.length > 0); node.children.length > 0);
} }
...@@ -406,7 +408,7 @@ AutomationPredicate = class { ...@@ -406,7 +408,7 @@ AutomationPredicate = class {
*/ */
static shouldIgnoreNode(node) { static shouldIgnoreNode(node) {
// Ignore invisible nodes. // Ignore invisible nodes.
if (node.state.invisible || if (node.state[State.INVISIBLE] ||
(node.location.height == 0 && node.location.width == 0)) { (node.location.height == 0 && node.location.width == 0)) {
return true; return true;
} }
......
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