| 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 utilities for the automation extension API. | 6 * @fileoverview ChromeVox utilities for the automation extension API. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 goog.provide('AutomationUtil'); | 9 goog.provide('AutomationUtil'); |
| 10 | 10 |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 * @param {AutomationNode} a | 230 * @param {AutomationNode} a |
| 231 * @param {AutomationNode} b | 231 * @param {AutomationNode} b |
| 232 * @return {boolean} | 232 * @return {boolean} |
| 233 */ | 233 */ |
| 234 AutomationUtil.isInSameTree = function(a, b) { | 234 AutomationUtil.isInSameTree = function(a, b) { |
| 235 if (!a || !b) | 235 if (!a || !b) |
| 236 return true; | 236 return true; |
| 237 | 237 |
| 238 // Given two non-desktop roots, consider them in the "same" tree. | 238 // Given two non-desktop roots, consider them in the "same" tree. |
| 239 return a.root === b.root || | 239 return a.root === b.root || |
| 240 (a.root.role == b.root.role && a.root.role == RoleType.rootWebArea); | 240 (a.root.role == b.root.role && a.root.role == RoleType.ROOT_WEB_AREA); |
| 241 }; | 241 }; |
| 242 | 242 |
| 243 /** | 243 /** |
| 244 * Determines whether or not a node is or is the descendant of another node. | 244 * Determines whether or not a node is or is the descendant of another node. |
| 245 * @param {!AutomationNode} node | 245 * @param {!AutomationNode} node |
| 246 * @param {!AutomationNode} ancestor | 246 * @param {!AutomationNode} ancestor |
| 247 * @return {boolean} | 247 * @return {boolean} |
| 248 */ | 248 */ |
| 249 AutomationUtil.isDescendantOf = function(node, ancestor) { | 249 AutomationUtil.isDescendantOf = function(node, ancestor) { |
| 250 var testNode = node; | 250 var testNode = node; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 278 return null; | 278 return null; |
| 279 }; | 279 }; |
| 280 | 280 |
| 281 /** | 281 /** |
| 282 * Gets a top level root. | 282 * Gets a top level root. |
| 283 * @param {!AutomationNode} node | 283 * @param {!AutomationNode} node |
| 284 * @return {AutomationNode} | 284 * @return {AutomationNode} |
| 285 */ | 285 */ |
| 286 AutomationUtil.getTopLevelRoot = function(node) { | 286 AutomationUtil.getTopLevelRoot = function(node) { |
| 287 var root = node.root; | 287 var root = node.root; |
| 288 if (!root || root.role == RoleType.desktop) | 288 if (!root || root.role == RoleType.DESKTOP) |
| 289 return null; | 289 return null; |
| 290 | 290 |
| 291 while (root && | 291 while (root && |
| 292 root.parent && | 292 root.parent && |
| 293 root.parent.root && | 293 root.parent.root && |
| 294 root.parent.root.role != RoleType.desktop) { | 294 root.parent.root.role != RoleType.DESKTOP) { |
| 295 root = root.parent.root; | 295 root = root.parent.root; |
| 296 } | 296 } |
| 297 return root; | 297 return root; |
| 298 }; | 298 }; |
| 299 | 299 |
| 300 /** | 300 /** |
| 301 * @param {!AutomationNode} prevNode | 301 * @param {!AutomationNode} prevNode |
| 302 * @param {!AutomationNode} node | 302 * @param {!AutomationNode} node |
| 303 * @return {AutomationNode} | 303 * @return {AutomationNode} |
| 304 */ | 304 */ |
| (...skipping 10 matching lines...) Expand all Loading... |
| 315 /** | 315 /** |
| 316 * Gets the accessible text for this node based on its role. | 316 * Gets the accessible text for this node based on its role. |
| 317 * This text is suitable for caret navigation and selection in the node. | 317 * This text is suitable for caret navigation and selection in the node. |
| 318 * @param {AutomationNode} node | 318 * @param {AutomationNode} node |
| 319 * @return {string} | 319 * @return {string} |
| 320 */ | 320 */ |
| 321 AutomationUtil.getText = function(node) { | 321 AutomationUtil.getText = function(node) { |
| 322 if (!node) | 322 if (!node) |
| 323 return ''; | 323 return ''; |
| 324 | 324 |
| 325 if (node.role === RoleType.textField) | 325 if (node.role === RoleType.TEXT_FIELD) |
| 326 return node.value; | 326 return node.value || ''; |
| 327 return node.name || ''; | 327 return node.name || ''; |
| 328 }; | 328 }; |
| 329 | 329 |
| 330 }); // goog.scope | 330 }); // goog.scope |
| OLD | NEW |