| 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 The entry point for all ChromeVox2 related code for the | 6 * @fileoverview The entry point for all ChromeVox2 related code for the |
| 7 * background page. | 7 * background page. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 goog.provide('Background'); | 10 goog.provide('Background'); |
| (...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 if (prevRange && prevRange.start.node) { | 779 if (prevRange && prevRange.start.node) { |
| 780 var entered = AutomationUtil.getUniqueAncestors( | 780 var entered = AutomationUtil.getUniqueAncestors( |
| 781 prevRange.start.node, start); | 781 prevRange.start.node, start); |
| 782 var embeddedObject = entered.find(function(f) { | 782 var embeddedObject = entered.find(function(f) { |
| 783 return f.role == RoleType.embeddedObject; }); | 783 return f.role == RoleType.embeddedObject; }); |
| 784 if (embeddedObject) | 784 if (embeddedObject) |
| 785 embeddedObject.focus(); | 785 embeddedObject.focus(); |
| 786 } | 786 } |
| 787 | 787 |
| 788 // Next, try to focus the start or end node. | 788 // Next, try to focus the start or end node. |
| 789 if (isFocusableLinkOrControl(start)) { | 789 if (!AutomationPredicate.structuralContainer(start) && |
| 790 start.state.focusable) { |
| 790 if (!start.state.focused) | 791 if (!start.state.focused) |
| 791 start.focus(); | 792 start.focus(); |
| 792 return; | 793 return; |
| 793 } else if (isFocusableLinkOrControl(end)) { | 794 } else if (!AutomationPredicate.structuralContainer(end) && |
| 795 end.state.focusable) { |
| 794 if (!end.state.focused) | 796 if (!end.state.focused) |
| 795 end.focus(); | 797 end.focus(); |
| 796 return; | 798 return; |
| 797 } | 799 } |
| 798 | 800 |
| 799 // If a common ancestor of |start| and |end| is a link, focus that. | 801 // If a common ancestor of |start| and |end| is a link, focus that. |
| 800 var ancestor = AutomationUtil.getLeastCommonAncestor(start, end); | 802 var ancestor = AutomationUtil.getLeastCommonAncestor(start, end); |
| 801 while (ancestor && ancestor.root == start.root) { | 803 while (ancestor && ancestor.root == start.root) { |
| 802 if (isFocusableLinkOrControl(ancestor)) { | 804 if (isFocusableLinkOrControl(ancestor)) { |
| 803 if (!ancestor.state.focused) | 805 if (!ancestor.state.focused) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 825 return new RegExp('^(' + globs.map(function(glob) { | 827 return new RegExp('^(' + globs.map(function(glob) { |
| 826 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&') | 828 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&') |
| 827 .replace(/\*/g, '.*') | 829 .replace(/\*/g, '.*') |
| 828 .replace(/\?/g, '.'); | 830 .replace(/\?/g, '.'); |
| 829 }).join('|') + ')$'); | 831 }).join('|') + ')$'); |
| 830 }; | 832 }; |
| 831 | 833 |
| 832 new Background(); | 834 new Background(); |
| 833 | 835 |
| 834 }); // goog.scope | 836 }); // goog.scope |
| OLD | NEW |