OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 * @fileoverview ChromeVox predicates for the automation extension API. | 6 * @fileoverview ChromeVox predicates for the automation extension API. |
7 */ | 7 */ |
8 | 8 |
9 goog.provide('AutomationPredicate'); | 9 goog.provide('AutomationPredicate'); |
10 goog.provide('AutomationPredicate.Binary'); | 10 goog.provide('AutomationPredicate.Binary'); |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 /** | 161 /** |
162 * @param {!AutomationNode} node | 162 * @param {!AutomationNode} node |
163 * @return {boolean} | 163 * @return {boolean} |
164 */ | 164 */ |
165 AutomationPredicate.leafWithText = function(node) { | 165 AutomationPredicate.leafWithText = function(node) { |
166 return AutomationPredicate.leaf(node) && | 166 return AutomationPredicate.leaf(node) && |
167 !!(node.name || node.value); | 167 !!(node.name || node.value); |
168 }; | 168 }; |
169 | 169 |
170 /** | 170 /** |
171 * Non-inline textbox nodes which have an equivalent in the DOM. | 171 * Matches against leaves or static text nodes. Useful when restricting |
| 172 * traversal to non-inline textboxes while still allowing them if navigation |
| 173 * already entered into an inline textbox. |
172 * @param {!AutomationNode} node | 174 * @param {!AutomationNode} node |
173 * @return {boolean} | 175 * @return {boolean} |
174 */ | 176 */ |
175 AutomationPredicate.leafDomNode = function(node) { | 177 AutomationPredicate.leafOrStaticText = function(node) { |
176 return AutomationPredicate.leaf(node) || | 178 return AutomationPredicate.leaf(node) || |
177 node.role == RoleType.staticText; | 179 node.role == RoleType.staticText; |
178 }; | 180 }; |
179 | 181 |
180 /** | 182 /** |
181 * Matches against nodes visited during object navigation. An object as | 183 * Matches against nodes visited during object navigation. An object as |
182 * defined below, are all nodes that are focusable or static text. When used in | 184 * defined below, are all nodes that are focusable or static text. When used in |
183 * tree walking, it should visit all nodes that tab traversal would as well as | 185 * tree walking, it should visit all nodes that tab traversal would as well as |
184 * non-focusable static text. | 186 * non-focusable static text. |
185 * @param {!AutomationNode} node | 187 * @param {!AutomationNode} node |
186 * @return {boolean} | 188 * @return {boolean} |
187 */ | 189 */ |
188 AutomationPredicate.object = function(node) { | 190 AutomationPredicate.object = function(node) { |
189 return node.state.focusable || | 191 return node.state.focusable || |
190 (AutomationPredicate.leafDomNode(node) && | 192 (AutomationPredicate.leafOrStaticText(node) && |
191 (/\S+/.test(node.name) || | 193 (/\S+/.test(node.name) || |
192 (node.role != RoleType.lineBreak && | 194 (node.role != RoleType.lineBreak && |
193 node.role != RoleType.staticText && | 195 node.role != RoleType.staticText && |
194 node.role != RoleType.inlineTextBox))); | 196 node.role != RoleType.inlineTextBox))); |
195 }; | 197 }; |
196 | 198 |
197 /** | 199 /** |
198 * @param {!AutomationNode} first | 200 * @param {!AutomationNode} first |
199 * @param {!AutomationNode} second | 201 * @param {!AutomationNode} second |
200 * @return {boolean} | 202 * @return {boolean} |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 * @return {boolean} | 298 * @return {boolean} |
297 */ | 299 */ |
298 AutomationPredicate.checkable = function(node) { | 300 AutomationPredicate.checkable = function(node) { |
299 return node.role == RoleType.checkBox || | 301 return node.role == RoleType.checkBox || |
300 node.role == RoleType.radioButton || | 302 node.role == RoleType.radioButton || |
301 node.role == RoleType.menuItemCheckBox || | 303 node.role == RoleType.menuItemCheckBox || |
302 node.role == RoleType.menuItemRadio; | 304 node.role == RoleType.menuItemRadio; |
303 }; | 305 }; |
304 | 306 |
305 }); // goog.scope | 307 }); // goog.scope |
OLD | NEW |