| 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(); | 58 return !node.firstChild() || node.children().every(function(n) { |
| 59 return n.state.invisible; |
| 60 }); |
| 59 }; | 61 }; |
| 60 | 62 |
| 61 /** | 63 /** |
| 62 * @param {chrome.automation.AutomationNode} node | 64 * @param {chrome.automation.AutomationNode} node |
| 63 * @return {boolean} | 65 * @return {boolean} |
| 64 */ | 66 */ |
| 65 AutomationPredicate.leafWithText = function(node) { | 67 AutomationPredicate.leafWithText = function(node) { |
| 66 return AutomationPredicate.leaf(node) && | 68 return AutomationPredicate.leaf(node) && |
| 67 !!(node.attributes.name || node.attributes.value); | 69 !!(node.attributes.name || node.attributes.value); |
| 68 }; | 70 }; |
| 69 | 71 |
| 70 /** | 72 /** |
| 71 * @param {chrome.automation.AutomationNode} first | 73 * @param {chrome.automation.AutomationNode} first |
| 72 * @param {chrome.automation.AutomationNode} second | 74 * @param {chrome.automation.AutomationNode} second |
| 73 * @return {boolean} | 75 * @return {boolean} |
| 74 */ | 76 */ |
| 75 AutomationPredicate.linebreak = function(first, second) { | 77 AutomationPredicate.linebreak = function(first, second) { |
| 76 // TODO(dtseng): Use next/previousOnLin once available. | 78 // TODO(dtseng): Use next/previousOnLin once available. |
| 77 var fl = first.location; | 79 var fl = first.location; |
| 78 var sl = second.location; | 80 var sl = second.location; |
| 79 return fl.top != sl.top || | 81 return fl.top != sl.top || |
| 80 (fl.top + fl.height != sl.top + sl.height); | 82 (fl.top + fl.height != sl.top + sl.height); |
| 81 }; | 83 }; |
| OLD | NEW |