| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 /** @type {AutomationPredicate.Unary} */ | 64 /** @type {AutomationPredicate.Unary} */ |
| 65 AutomationPredicate.heading = AutomationPredicate.roles([Role.heading]); | 65 AutomationPredicate.heading = AutomationPredicate.roles([Role.heading]); |
| 66 /** @type {AutomationPredicate.Unary} */ | 66 /** @type {AutomationPredicate.Unary} */ |
| 67 AutomationPredicate.inlineTextBox = | 67 AutomationPredicate.inlineTextBox = |
| 68 AutomationPredicate.roles([Role.inlineTextBox]); | 68 AutomationPredicate.roles([Role.inlineTextBox]); |
| 69 /** @type {AutomationPredicate.Unary} */ | 69 /** @type {AutomationPredicate.Unary} */ |
| 70 AutomationPredicate.link = AutomationPredicate.roles([Role.link]); | 70 AutomationPredicate.link = AutomationPredicate.roles([Role.link]); |
| 71 /** @type {AutomationPredicate.Unary} */ | 71 /** @type {AutomationPredicate.Unary} */ |
| 72 AutomationPredicate.row = AutomationPredicate.roles([Role.row]); | 72 AutomationPredicate.row = AutomationPredicate.roles([Role.row]); |
| 73 /** @type {AutomationPredicate.Unary} */ | 73 /** @type {AutomationPredicate.Unary} */ |
| 74 AutomationPredicate.table = AutomationPredicate.roles([Role.table]); | 74 AutomationPredicate.table = AutomationPredicate.roles([Role.grid, Role.table]); |
| 75 | 75 |
| 76 /** | 76 /** |
| 77 * @param {!AutomationNode} node | 77 * @param {!AutomationNode} node |
| 78 * @return {boolean} | 78 * @return {boolean} |
| 79 */ | 79 */ |
| 80 AutomationPredicate.button = function(node) { | 80 AutomationPredicate.button = function(node) { |
| 81 return /button/i.test(node.role); | 81 return /button/i.test(node.role); |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 /** | 84 /** |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 | 190 |
| 191 return node.state.focusable || | 191 return node.state.focusable || |
| 192 (AutomationPredicate.leafOrStaticText(node) && | 192 (AutomationPredicate.leafOrStaticText(node) && |
| 193 (/\S+/.test(node.name) || | 193 (/\S+/.test(node.name) || |
| 194 (node.role != Role.lineBreak && | 194 (node.role != Role.lineBreak && |
| 195 node.role != Role.staticText && | 195 node.role != Role.staticText && |
| 196 node.role != Role.inlineTextBox))); | 196 node.role != Role.inlineTextBox))); |
| 197 }; | 197 }; |
| 198 | 198 |
| 199 /** | 199 /** |
| 200 * Matches against nodes visited during group navigation. An object as |
| 201 * @param {!AutomationNode} node |
| 202 * @return {boolean} |
| 203 */ |
| 204 AutomationPredicate.group = AutomationPredicate.match({ |
| 205 anyRole: [ |
| 206 Role.heading, |
| 207 Role.list, |
| 208 Role.paragraph |
| 209 ], |
| 210 anyPredicate: [ |
| 211 AutomationPredicate.editText, |
| 212 AutomationPredicate.formField, |
| 213 AutomationPredicate.object, |
| 214 AutomationPredicate.table |
| 215 ] |
| 216 }); |
| 217 |
| 218 /** |
| 200 * @param {!AutomationNode} first | 219 * @param {!AutomationNode} first |
| 201 * @param {!AutomationNode} second | 220 * @param {!AutomationNode} second |
| 202 * @return {boolean} | 221 * @return {boolean} |
| 203 */ | 222 */ |
| 204 AutomationPredicate.linebreak = function(first, second) { | 223 AutomationPredicate.linebreak = function(first, second) { |
| 205 // TODO(dtseng): Use next/previousOnLin once available. | 224 // TODO(dtseng): Use next/previousOnLin once available. |
| 206 var fl = first.location; | 225 var fl = first.location; |
| 207 var sl = second.location; | 226 var sl = second.location; |
| 208 return fl.top != sl.top || | 227 return fl.top != sl.top || |
| 209 (fl.top + fl.height != sl.top + sl.height); | 228 (fl.top + fl.height != sl.top + sl.height); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 227 (node.role == Role.textField && node.state.readOnly) || | 246 (node.role == Role.textField && node.state.readOnly) || |
| 228 (node.state.editable && node.parent && !node.parent.state.editable); | 247 (node.state.editable && node.parent && !node.parent.state.editable); |
| 229 }; | 248 }; |
| 230 | 249 |
| 231 /** | 250 /** |
| 232 * Matches against nodes that contain interesting nodes, but should never be | 251 * Matches against nodes that contain interesting nodes, but should never be |
| 233 * visited. | 252 * visited. |
| 234 * @param {!AutomationNode} node | 253 * @param {!AutomationNode} node |
| 235 * @return {boolean} | 254 * @return {boolean} |
| 236 */ | 255 */ |
| 237 AutomationPredicate.structuralContainer = function(node) { | 256 AutomationPredicate.structuralContainer = AutomationPredicate.roles([ |
| 238 return node.role == Role.rootWebArea || | 257 Role.rootWebArea, |
| 239 node.role == Role.embeddedObject || | 258 Role.embeddedObject, |
| 240 node.role == Role.iframe || | 259 Role.iframe, |
| 241 node.role == Role.iframePresentational; | 260 Role.iframePresentational]); |
| 242 }; | |
| 243 | 261 |
| 244 /** | 262 /** |
| 245 * Returns whether the given node should not be crossed when performing | 263 * Returns whether the given node should not be crossed when performing |
| 246 * traversals up the ancestry chain. | 264 * traversals up the ancestry chain. |
| 247 * @param {AutomationNode} node | 265 * @param {AutomationNode} node |
| 248 * @return {boolean} | 266 * @return {boolean} |
| 249 */ | 267 */ |
| 250 AutomationPredicate.root = function(node) { | 268 AutomationPredicate.root = function(node) { |
| 251 switch (node.role) { | 269 switch (node.role) { |
| 252 case Role.dialog: | 270 case Role.dialog: |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 * @param {number} level 1-6 | 413 * @param {number} level 1-6 |
| 396 * @return {AutomationPredicate.Unary} | 414 * @return {AutomationPredicate.Unary} |
| 397 */ | 415 */ |
| 398 AutomationPredicate.makeHeadingPredicate = function(level) { | 416 AutomationPredicate.makeHeadingPredicate = function(level) { |
| 399 return function(node) { | 417 return function(node) { |
| 400 return node.role == Role.heading && node.hierarchicalLevel == level; | 418 return node.role == Role.heading && node.hierarchicalLevel == level; |
| 401 }; | 419 }; |
| 402 }; | 420 }; |
| 403 | 421 |
| 404 }); // goog.scope | 422 }); // goog.scope |
| OLD | NEW |