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

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

Issue 2818503002: Improved isInteresting heuristic, made more AutomationNodes focusable (Closed)
Patch Set: Responded to comment Created 3 years, 8 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
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 move to the appropriate node in the accessibility tree. 6 * Class to move to the appropriate node in the accessibility tree.
7 * 7 *
8 * @constructor 8 * @constructor
9 */ 9 */
10 function AutomationTreeWalker() {}; 10 function AutomationTreeWalker() {};
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 while (node.lastChild) 109 while (node.lastChild)
110 node = node.lastChild; 110 node = node.lastChild;
111 111
112 return node; 112 return node;
113 }, 113 },
114 114
115 /** 115 /**
116 * Returns true if |node| is interesting. 116 * Returns true if |node| is interesting.
117 * 117 *
118 * @param {!chrome.automation.AutomationNode} node 118 * @param {!chrome.automation.AutomationNode} node
119 * @return {boolean|undefined} 119 * @return {boolean}
120 * @private 120 * @private
121 */ 121 */
122 isInteresting_: function(node) { 122 isInteresting_: function(node) {
123 return node.state && node.state.focusable; 123 let loc = node.location;
124 let parent = node.parent;
125 let root = node.root;
126 let role = node.role;
127 let state = node.state;
128
129 // Skip things that are offscreen
130 if (state[chrome.automation.StateType.OFFSCREEN]
131 || loc.top < 0 || loc.left < 0)
132 return false;
133
134 if (parent) {
135 // crbug.com/710559
136 // Work around for browser tabs
137 if (role === chrome.automation.RoleType.TAB
138 && parent.role === chrome.automation.RoleType.TAB_LIST
139 && root.role === chrome.automation.RoleType.DESKTOP)
140 return true;
141 }
142
143 // The general rule that applies to everything.
144 return state[chrome.automation.StateType.FOCUSABLE] === true;
124 }, 145 },
125 146
126 /** 147 /**
127 * Return the next sibling of |node| if it has one. 148 * Return the next sibling of |node| if it has one.
128 * 149 *
129 * @param {chrome.automation.AutomationNode} node 150 * @param {chrome.automation.AutomationNode} node
130 * @return {chrome.automation.AutomationNode} 151 * @return {chrome.automation.AutomationNode}
131 */ 152 */
132 debugMoveToNext: function(node) { 153 debugMoveToNext: function(node) {
133 if (!node) 154 if (!node)
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 let parent = node.parent; 217 let parent = node.parent;
197 if (parent) { 218 if (parent) {
198 return parent; 219 return parent;
199 } else { 220 } else {
200 console.log('Node has no parent'); 221 console.log('Node has no parent');
201 console.log('\n'); 222 console.log('\n');
202 return null; 223 return null;
203 } 224 }
204 } 225 }
205 }; 226 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698