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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 /** @type {AutomationPredicate.Unary} */ | 48 /** @type {AutomationPredicate.Unary} */ |
49 AutomationPredicate.link = | 49 AutomationPredicate.link = |
50 AutomationPredicate.makeRolePredicate( | 50 AutomationPredicate.makeRolePredicate( |
51 chrome.automation.RoleType.link); | 51 chrome.automation.RoleType.link); |
52 | 52 |
53 /** | 53 /** |
54 * @param {chrome.automation.AutomationNode} node | 54 * @param {chrome.automation.AutomationNode} node |
55 * @return {boolean} | 55 * @return {boolean} |
56 */ | 56 */ |
57 AutomationPredicate.leaf = function(node) { | 57 AutomationPredicate.leaf = function(node) { |
58 return !node.firstChild || node.children.every(function(n) { | 58 return !node.firstChild || |
59 return n.state.invisible; | 59 node.role == chrome.automation.RoleType.button || |
60 }); | 60 node.children.every(function(n) { |
| 61 return n.state.invisible; |
| 62 }); |
61 }; | 63 }; |
62 | 64 |
63 /** | 65 /** |
64 * @param {chrome.automation.AutomationNode} node | 66 * @param {chrome.automation.AutomationNode} node |
65 * @return {boolean} | 67 * @return {boolean} |
66 */ | 68 */ |
67 AutomationPredicate.leafWithText = function(node) { | 69 AutomationPredicate.leafWithText = function(node) { |
68 return AutomationPredicate.leaf(node) && | 70 return AutomationPredicate.leaf(node) && |
69 !!(node.attributes.name || node.attributes.value); | 71 !!(node.attributes.name || node.attributes.value); |
70 }; | 72 }; |
71 | 73 |
72 /** | 74 /** |
73 * @param {chrome.automation.AutomationNode} first | 75 * @param {chrome.automation.AutomationNode} first |
74 * @param {chrome.automation.AutomationNode} second | 76 * @param {chrome.automation.AutomationNode} second |
75 * @return {boolean} | 77 * @return {boolean} |
76 */ | 78 */ |
77 AutomationPredicate.linebreak = function(first, second) { | 79 AutomationPredicate.linebreak = function(first, second) { |
78 // TODO(dtseng): Use next/previousOnLin once available. | 80 // TODO(dtseng): Use next/previousOnLin once available. |
79 var fl = first.location; | 81 var fl = first.location; |
80 var sl = second.location; | 82 var sl = second.location; |
81 return fl.top != sl.top || | 83 return fl.top != sl.top || |
82 (fl.top + fl.height != sl.top + sl.height); | 84 (fl.top + fl.height != sl.top + sl.height); |
83 }; | 85 }; |
OLD | NEW |