| 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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 | 186 |
| 187 /** | 187 /** |
| 188 * Matches against nodes visited during object navigation. An object as | 188 * Matches against nodes visited during object navigation. An object as |
| 189 * defined below, are all nodes that are focusable or static text. When used in | 189 * defined below, are all nodes that are focusable or static text. When used in |
| 190 * tree walking, it should visit all nodes that tab traversal would as well as | 190 * tree walking, it should visit all nodes that tab traversal would as well as |
| 191 * non-focusable static text. | 191 * non-focusable static text. |
| 192 * @param {!AutomationNode} node | 192 * @param {!AutomationNode} node |
| 193 * @return {boolean} | 193 * @return {boolean} |
| 194 */ | 194 */ |
| 195 AutomationPredicate.object = function(node) { | 195 AutomationPredicate.object = function(node) { |
| 196 // Editable nodes are within a text-like field and don't make sense when |
| 197 // performing object navigation. Users should use line, word, or character |
| 198 // navigation. Only navigate to the top level node. |
| 199 if (node.parent && node.parent.state.editable) |
| 200 return false; |
| 201 |
| 196 return node.state.focusable || | 202 return node.state.focusable || |
| 197 (AutomationPredicate.leafOrStaticText(node) && | 203 (AutomationPredicate.leafOrStaticText(node) && |
| 198 (/\S+/.test(node.name) || | 204 (/\S+/.test(node.name) || |
| 199 (node.role != RoleType.lineBreak && | 205 (node.role != RoleType.lineBreak && |
| 200 node.role != RoleType.staticText && | 206 node.role != RoleType.staticText && |
| 201 node.role != RoleType.inlineTextBox))); | 207 node.role != RoleType.inlineTextBox))); |
| 202 }; | 208 }; |
| 203 | 209 |
| 204 /** | 210 /** |
| 205 * @param {!AutomationNode} first | 211 * @param {!AutomationNode} first |
| (...skipping 14 matching lines...) Expand all Loading... |
| 220 * @param {!AutomationNode} node | 226 * @param {!AutomationNode} node |
| 221 * @return {boolean} | 227 * @return {boolean} |
| 222 */ | 228 */ |
| 223 AutomationPredicate.container = function(node) { | 229 AutomationPredicate.container = function(node) { |
| 224 return AutomationPredicate.structuralContainer(node) || | 230 return AutomationPredicate.structuralContainer(node) || |
| 225 node.role == RoleType.div || | 231 node.role == RoleType.div || |
| 226 node.role == RoleType.document || | 232 node.role == RoleType.document || |
| 227 node.role == RoleType.group || | 233 node.role == RoleType.group || |
| 228 node.role == RoleType.listItem || | 234 node.role == RoleType.listItem || |
| 229 node.role == RoleType.toolbar || | 235 node.role == RoleType.toolbar || |
| 230 node.role == RoleType.window; | 236 node.role == RoleType.window || |
| 237 // For example, crosh. |
| 238 (node.role == RoleType.textField && node.state.readOnly) || |
| 239 (node.state.editable && node.parent && !node.parent.state.editable); |
| 231 }; | 240 }; |
| 232 | 241 |
| 233 /** | 242 /** |
| 234 * Matches against nodes that contain interesting nodes, but should never be | 243 * Matches against nodes that contain interesting nodes, but should never be |
| 235 * visited. | 244 * visited. |
| 236 * @param {!AutomationNode} node | 245 * @param {!AutomationNode} node |
| 237 * @return {boolean} | 246 * @return {boolean} |
| 238 */ | 247 */ |
| 239 AutomationPredicate.structuralContainer = function(node) { | 248 AutomationPredicate.structuralContainer = function(node) { |
| 240 return node.role == RoleType.rootWebArea || | 249 return node.role == RoleType.rootWebArea || |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 * @param {number} level 1-6 | 409 * @param {number} level 1-6 |
| 401 * @return {AutomationPredicate.Unary} | 410 * @return {AutomationPredicate.Unary} |
| 402 */ | 411 */ |
| 403 AutomationPredicate.makeHeadingPredicate = function(level) { | 412 AutomationPredicate.makeHeadingPredicate = function(level) { |
| 404 return function(node) { | 413 return function(node) { |
| 405 return node.role == RoleType.heading && node.hierarchicalLevel == level; | 414 return node.role == RoleType.heading && node.hierarchicalLevel == level; |
| 406 }; | 415 }; |
| 407 }; | 416 }; |
| 408 | 417 |
| 409 }); // goog.scope | 418 }); // goog.scope |
| OLD | NEW |