Chromium Code Reviews| Index: chrome/browser/resources/chromeos/chromevox/cvox2/background/automation_util.js |
| diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/automation_util.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/automation_util.js |
| index d5d9956f345141a1a4dd2edde5f88132d37f01f4..c12054dc0ac98f9739c1f2b41a9d102739cac192 100644 |
| --- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/automation_util.js |
| +++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/automation_util.js |
| @@ -88,8 +88,12 @@ AutomationUtil.findNextSubtree = function(cur, dir) { |
| while (cur) { |
| var next = dir == Dir.BACKWARD ? |
| cur.previousSibling : cur.nextSibling; |
| + if (!AutomationUtil.isInSameTree(cur, next)) |
| + return null; |
| if (next) |
| return next; |
| + if (!AutomationUtil.isInSameTree(cur, cur.parent)) |
| + return null; |
| cur = cur.parent; |
| } |
| }; |
| @@ -164,6 +168,10 @@ AutomationUtil.getAncestors = function(node) { |
| var candidate = node; |
| while (candidate) { |
| ret.push(candidate); |
| + |
| + if (!AutomationUtil.isInSameTree(candidate, candidate.parent)) |
| + break; |
| + |
| candidate = candidate.parent; |
| } |
| return ret.reverse(); |
| @@ -226,4 +234,17 @@ AutomationUtil.getDirection = function(nodeA, nodeB) { |
| return divA.indexInParent <= divB.indexInParent ? Dir.FORWARD : Dir.BACKWARD; |
| }; |
| + /** |
|
dmazzoni
2015/01/28 23:05:21
nit: indentation
David Tseng
2015/01/29 00:33:51
Done.
|
| + * Determines whether the two given nodes come from the same tree source. |
| + * @param {AutomationNode} a |
| + * @param {AutomationNode} b |
| + * @return {boolean} |
| + */ |
| +AutomationUtil.isInSameTree = function(a, b) { |
| + if (!a || !b) |
| + return true; |
| + |
| + return a.root === b.root; |
| +}; |
| + |
| }); // goog.scope |