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

[Switch Access] Refactor isGroup function to allow for changing values

In preparation for future changes, change the behavior of how Switch
Access checks if a child node is a group from initializing a field on
construction to implementing an abstract function.

Bug: None
Change-Id: I9a0657c19fcd7b3428ddfecb108d52a9cd0b2250
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1907192Reviewed-by: default avatarAran Gilman <gilmanmh@google.com>
Commit-Queue: Anastasia Helfinstein <anastasi@google.com>
Cr-Commit-Position: refs/heads/master@{#713989}
parent ee70c140
......@@ -10,7 +10,7 @@ class BackButtonNode extends SAChildNode {
* @param {!SARootNode} group
*/
constructor(group) {
super(false /* isGroup */);
super();
/**
* The group that the back button is shown for.
* @private {!SARootNode}
......@@ -65,6 +65,11 @@ class BackButtonNode extends SAChildNode {
return this.node_ === node;
}
/** @override */
isGroup() {
return false;
}
/** @override */
asRootNode() {
return null;
......
......@@ -15,7 +15,7 @@ class GroupNode extends SAChildNode {
* @private
*/
constructor(children) {
super(true /* isGroup */);
super();
/** @type {!Array<!SAChildNode>} */
this.children_ = children;
......@@ -70,6 +70,11 @@ class GroupNode extends SAChildNode {
return false;
}
/** @override */
isGroup() {
return true;
}
/** @override */
asRootNode() {
const root = new SARootNode();
......
......@@ -14,9 +14,12 @@ class NodeWrapper extends SAChildNode {
* @param {?SARootNode} parent
*/
constructor(baseNode, parent) {
super(SwitchAccessPredicate.isGroup(baseNode, parent));
super();
/** @private {!AutomationNode} */
this.baseNode_ = baseNode;
/** @private {boolean} */
this.isGroup_ = SwitchAccessPredicate.isGroup(this.baseNode_, parent);
}
/** @override */
......@@ -138,6 +141,11 @@ class NodeWrapper extends SAChildNode {
return this.baseNode_ === node;
}
/** @override */
isGroup() {
return this.isGroup_;
}
/** @override */
asRootNode() {
if (!this.isGroup()) {
......
......@@ -13,12 +13,7 @@
* @abstract
*/
class SAChildNode {
/**
* @param {boolean} isGroup
*/
constructor(isGroup) {
this.isGroup_ = isGroup;
constructor() {
/** @private {?SAChildNode} */
this.previous_ = null;
......@@ -71,10 +66,9 @@ class SAChildNode {
/**
* Returns whether this node should be displayed as a group.
* @return {boolean}
* @abstract
*/
isGroup() {
return this.isGroup_;
}
isGroup() {}
/**
* Returns a list of all the actions available for this node.
......@@ -159,7 +153,7 @@ class SAChildNode {
* @return {string}
*/
debugString(wholeTree, prefix = '', currentNode = null) {
if (this.isGroup_ && wholeTree) {
if (this.isGroup() && wholeTree) {
return this.asRootNode().debugString(
wholeTree, prefix + ' ', currentNode);
}
......@@ -176,7 +170,7 @@ class SAChildNode {
str += 'loc(' + RectHelper.toString(loc) + ') ';
}
if (this.isGroup_) {
if (this.isGroup()) {
str += '[isGroup]';
}
......
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