| Index: chrome/browser/resources/chromeos/switch_access/switch_access.js
|
| diff --git a/chrome/browser/resources/chromeos/switch_access/switch_access.js b/chrome/browser/resources/chromeos/switch_access/switch_access.js
|
| index 58bcb3a7b0c2c8ccf72ccda79a5f617f95ae4da9..f24f524cd3dd7ee3d33f4ea080674d6afaec0f22 100644
|
| --- a/chrome/browser/resources/chromeos/switch_access/switch_access.js
|
| +++ b/chrome/browser/resources/chromeos/switch_access/switch_access.js
|
| @@ -33,33 +33,19 @@ function SwitchAccess() {
|
| this.keyboardHandler_ = null;
|
|
|
| /**
|
| - * Moves to the appropriate node in the accessibility tree.
|
| + * Handles interactions with the accessibility tree, including moving to and
|
| + * selecting nodes.
|
| *
|
| - * @private {AutomationTreeWalker}
|
| + * @private {AutomationManager}
|
| */
|
| - this.treeWalker_ = null;
|
| -
|
| - /**
|
| - * Currently selected node.
|
| - *
|
| - * @private {chrome.automation.AutomationNode}
|
| - */
|
| - this.node_ = null;
|
| -
|
| - /**
|
| - * Root node (i.e., the desktop).
|
| - *
|
| - * @private {chrome.automation.AutomationNode}
|
| - */
|
| - this.root_ = null;
|
| + this.automationManager_ = null;
|
|
|
| this.init_();
|
| };
|
|
|
| SwitchAccess.prototype = {
|
| /**
|
| - * Set this.node_ and this.root_ to the desktop node, and set up preferences,
|
| - * controllers, and event listeners.
|
| + * Set up preferences, controllers, and event listeners.
|
| *
|
| * @private
|
| */
|
| @@ -67,47 +53,30 @@ SwitchAccess.prototype = {
|
| this.switchAccessPrefs = new SwitchAccessPrefs();
|
| this.autoScanManager_ = new AutoScanManager(this);
|
| this.keyboardHandler_ = new KeyboardHandler(this);
|
| - this.treeWalker_ = new AutomationTreeWalker();
|
| -
|
| - chrome.automation.getDesktop(function(desktop) {
|
| - this.node_ = desktop;
|
| - this.root_ = desktop;
|
| - console.log('AutomationNode for desktop is loaded');
|
| - this.printNode_(this.node_);
|
| - }.bind(this));
|
| + this.automationManager_ = new AutomationManager();
|
|
|
| document.addEventListener(
|
| 'prefsUpdate', this.handlePrefsUpdate_.bind(this));
|
| },
|
|
|
| /**
|
| - * Set this.node_ to the next/previous interesting node. If no interesting
|
| - * node is found, set this.node_ to the first/last interesting node. If
|
| - * |doNext| is true, will search for next node. Otherwise, will search for
|
| - * previous node.
|
| + * Move to the next/previous interesting node. If |doNext| is true, move to
|
| + * the next node. Otherwise, move to the previous node.
|
| *
|
| * @param {boolean} doNext
|
| * @override
|
| */
|
| moveToNode: function(doNext) {
|
| - let node = this.treeWalker_.moveToNode(this.node_, this.root_, doNext);
|
| - if (node) {
|
| - this.node_ = node;
|
| - this.printNode_(this.node_);
|
| - chrome.accessibilityPrivate.setFocusRing([this.node_.location]);
|
| - }
|
| + this.automationManager_.moveToNode(doNext);
|
| },
|
|
|
| /**
|
| - * Perform the default action on the currently selected node.
|
| + * Perform the default action on the current node.
|
| *
|
| * @override
|
| */
|
| doDefault: function() {
|
| - if (!this.node_)
|
| - return;
|
| -
|
| - this.node_.doDefault();
|
| + this.automationManager_.doDefault();
|
| },
|
|
|
| /**
|
| @@ -150,88 +119,39 @@ SwitchAccess.prototype = {
|
| }
|
| },
|
|
|
| - // TODO(elichtenberg): Move print functions to a custom logger class. Only
|
| - // log when debuggingEnabled is true.
|
| /**
|
| - * Print out details about a node.
|
| - *
|
| - * @param {chrome.automation.AutomationNode} node
|
| - * @private
|
| - */
|
| - printNode_: function(node) {
|
| - if (node) {
|
| - console.log('Name = ' + node.name);
|
| - console.log('Role = ' + node.role);
|
| - console.log('Root role = ' + node.root.role);
|
| - if (!node.parent)
|
| - console.log('At index ' + node.indexInParent + ', has no parent');
|
| - else {
|
| - let numSiblings = node.parent.children.length;
|
| - console.log(
|
| - 'At index ' + node.indexInParent + ', there are '
|
| - + numSiblings + ' siblings');
|
| - }
|
| - console.log('Has ' + node.children.length + ' children');
|
| - } else {
|
| - console.log('Node is null');
|
| - }
|
| - console.log(node);
|
| - console.log('\n');
|
| - },
|
| -
|
| - /**
|
| - * Move to the next sibling of this.node_ if it has one.
|
| + * Move to the next sibling of the current node if it has one.
|
| *
|
| * @override
|
| */
|
| debugMoveToNext: function() {
|
| - let next = this.treeWalker_.debugMoveToNext(this.node_);
|
| - if (next) {
|
| - this.node_ = next;
|
| - this.printNode_(this.node_);
|
| - chrome.accessibilityPrivate.setFocusRing([this.node_.location]);
|
| - }
|
| + this.automationManager_.debugMoveToNext();
|
| },
|
|
|
| /**
|
| - * Move to the previous sibling of this.node_ if it has one.
|
| + * Move to the previous sibling of the current node if it has one.
|
| *
|
| * @override
|
| */
|
| debugMoveToPrevious: function() {
|
| - let prev = this.treeWalker_.debugMoveToPrevious(this.node_);
|
| - if (prev) {
|
| - this.node_ = prev;
|
| - this.printNode_(this.node_);
|
| - chrome.accessibilityPrivate.setFocusRing([this.node_.location]);
|
| - }
|
| + this.automationManager_.debugMoveToPrevious();
|
| },
|
|
|
| /**
|
| - * Move to the first child of this.node_ if it has one.
|
| + * Move to the first child of the current node if it has one.
|
| *
|
| * @override
|
| */
|
| debugMoveToFirstChild: function() {
|
| - let child = this.treeWalker_.debugMoveToFirstChild(this.node_);
|
| - if (child) {
|
| - this.node_ = child;
|
| - this.printNode_(this.node_);
|
| - chrome.accessibilityPrivate.setFocusRing([this.node_.location]);
|
| - }
|
| + this.automationManager_.debugMoveToFirstChild();
|
| },
|
|
|
| /**
|
| - * Move to the parent of this.node_ if it has one.
|
| + * Move to the parent of the current node if it has one.
|
| *
|
| * @override
|
| */
|
| debugMoveToParent: function() {
|
| - let parent = this.treeWalker_.debugMoveToParent(this.node_);
|
| - if (parent) {
|
| - this.node_ = parent;
|
| - this.printNode_(this.node_);
|
| - chrome.accessibilityPrivate.setFocusRing([this.node_.location]);
|
| - }
|
| + this.automationManager_.debugMoveToParent();
|
| }
|
| };
|
|
|