Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: chrome/browser/resources/chromeos/switch_access/automation_manager.js

Issue 2868723006: Changing focus ring color by node. Focus ring can now change color without changing bounds (Closed)
Patch Set: Responded to comment Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/chromeos/ui/focus_ring_layer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * Class to manage interactions with the accessibility tree, including moving 6 * Class to manage interactions with the accessibility tree, including moving
7 * to and selecting nodes. 7 * to and selecting nodes.
8 * 8 *
9 * @constructor 9 * @constructor
10 */ 10 */
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 /** 42 /**
43 * Moves to the appropriate node in the accessibility tree. 43 * Moves to the appropriate node in the accessibility tree.
44 * 44 *
45 * @private {AutomationTreeWalker} 45 * @private {AutomationTreeWalker}
46 */ 46 */
47 this.treeWalker_ = null; 47 this.treeWalker_ = null;
48 48
49 this.init_(); 49 this.init_();
50 }; 50 };
51 51
52 /**
53 * Highlight colors for the focus ring to distinguish between different types
54 * of nodes.
55 *
56 * @const
57 */
58 AutomationManager.Color = {
59 SCOPE: '#de742f', // dark orange
60 GROUP: '#ffbb33', // light orange
61 LEAF: '#78e428' //light green
62 };
63
52 AutomationManager.prototype = { 64 AutomationManager.prototype = {
53 /** 65 /**
54 * Set this.node_, this.root_, and this.desktop_ to the desktop node, and 66 * Set this.node_, this.root_, and this.desktop_ to the desktop node, and
55 * creates an initial tree walker. 67 * creates an initial tree walker.
56 * 68 *
57 * @private 69 * @private
58 */ 70 */
59 init_: function() { 71 init_: function() {
60 chrome.automation.getDesktop(function(desktop) { 72 chrome.automation.getDesktop(function(desktop) {
61 this.node_ = desktop; 73 this.node_ = desktop;
(...skipping 14 matching lines...) Expand all
76 * @param {boolean} doNext 88 * @param {boolean} doNext
77 */ 89 */
78 moveToNode: function(doNext) { 90 moveToNode: function(doNext) {
79 if (!this.treeWalker_) 91 if (!this.treeWalker_)
80 return; 92 return;
81 93
82 let node = this.treeWalker_.moveToNode(doNext); 94 let node = this.treeWalker_.moveToNode(doNext);
83 if (node) { 95 if (node) {
84 this.node_ = node; 96 this.node_ = node;
85 this.printNode_(this.node_); 97 this.printNode_(this.node_);
86 chrome.accessibilityPrivate.setFocusRing([this.node_.location]); 98
99 let color;
100 if (this.node_ === this.scope_)
101 color = AutomationManager.Color.SCOPE;
102 else if (AutomationPredicate.isInteresting(this.node_))
103 color = AutomationManager.Color.LEAF;
104 else
105 color = AutomationManager.Color.GROUP;
106 chrome.accessibilityPrivate.setFocusRing([this.node_.location], color);
87 } 107 }
88 }, 108 },
89 109
90 /** 110 /**
91 * Select the currently highlighted node. If the node is the current scope, 111 * Select the currently highlighted node. If the node is the current scope,
92 * go back to the previous scope (i.e., create a new tree walker rooted at 112 * go back to the previous scope (i.e., create a new tree walker rooted at
93 * the previous scope). If the node is a group other than the current scope, 113 * the previous scope). If the node is a group other than the current scope,
94 * create a new tree walker for the new subtree the user is scanning through. 114 * create a new tree walker for the new subtree the user is scanning through.
95 * Otherwise, meaning the node is interesting, perform the default action on 115 * Otherwise, meaning the node is interesting, perform the default action on
96 * it. 116 * it.
(...skipping 10 matching lines...) Expand all
107 // Find a previous scope that is still valid. 127 // Find a previous scope that is still valid.
108 let oldScope; 128 let oldScope;
109 do { 129 do {
110 oldScope = this.scopeStack_.pop(); 130 oldScope = this.scopeStack_.pop();
111 } while (oldScope && !oldScope.role); 131 } while (oldScope && !oldScope.role);
112 132
113 // oldScope will always be valid here, so this will always be true. 133 // oldScope will always be valid here, so this will always be true.
114 if (oldScope) { 134 if (oldScope) {
115 this.scope_ = oldScope; 135 this.scope_ = oldScope;
116 this.treeWalker_ = this.createTreeWalker_(this.scope_, this.node_); 136 this.treeWalker_ = this.createTreeWalker_(this.scope_, this.node_);
137 chrome.accessibilityPrivate.setFocusRing(
138 [this.node_.location], AutomationManager.Color.GROUP);
117 } 139 }
118 return; 140 return;
119 } 141 }
120 142
121 if (AutomationPredicate.isGroup(this.node_, this.scope_)) { 143 if (AutomationPredicate.isGroup(this.node_, this.scope_)) {
122 this.scopeStack_.push(this.scope_); 144 this.scopeStack_.push(this.scope_);
123 this.scope_ = this.node_; 145 this.scope_ = this.node_;
124 this.treeWalker_ = this.createTreeWalker_(this.scope_); 146 this.treeWalker_ = this.createTreeWalker_(this.scope_);
125 this.moveToNode(true); 147 this.moveToNode(true);
126 return; 148 return;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 */ 251 */
230 debugMoveToParent: function() { 252 debugMoveToParent: function() {
231 let parent = this.treeWalker_.debugMoveToParent(this.node_); 253 let parent = this.treeWalker_.debugMoveToParent(this.node_);
232 if (parent) { 254 if (parent) {
233 this.node_ = parent; 255 this.node_ = parent;
234 this.printNode_(this.node_); 256 this.printNode_(this.node_);
235 chrome.accessibilityPrivate.setFocusRing([this.node_.location]); 257 chrome.accessibilityPrivate.setFocusRing([this.node_.location]);
236 } 258 }
237 } 259 }
238 }; 260 };
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/ui/focus_ring_layer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698