Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(495)

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js

Issue 2509093002: Try focusing embeddedObject first unconditionally (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 }, 759 },
760 760
761 /** 761 /**
762 * @param {!cursors.Range} range 762 * @param {!cursors.Range} range
763 * @param {cursors.Range} prevRange 763 * @param {cursors.Range} prevRange
764 * @private 764 * @private
765 */ 765 */
766 setFocusToRange_: function(range, prevRange) { 766 setFocusToRange_: function(range, prevRange) {
767 var start = range.start.node; 767 var start = range.start.node;
768 var end = range.end.node; 768 var end = range.end.node;
769
770 // First, see if we've crossed a root. Remove once webview handles focus
771 // correctly.
772 if (prevRange && prevRange.start.node && start) {
773 var entered = AutomationUtil.getUniqueAncestors(
774 prevRange.start.node, start);
775 var embeddedObject = entered.find(function(f) {
776 return f.role == RoleType.embeddedObject; });
777 if (embeddedObject && !embeddedObject.state.focused)
778 embeddedObject.focus();
779 }
780
769 if (start.state.focused || end.state.focused) 781 if (start.state.focused || end.state.focused)
770 return; 782 return;
771 783
772 var isFocusableLinkOrControl = function(node) { 784 var isFocusableLinkOrControl = function(node) {
773 return node.state.focusable && 785 return node.state.focusable &&
774 AutomationPredicate.linkOrControl(node); 786 AutomationPredicate.linkOrControl(node);
775 }; 787 };
776 788
777 // First, see if we've crossed a root. Remove once webview handles focus
778 // correctly.
779 if (prevRange && prevRange.start.node) {
780 var entered = AutomationUtil.getUniqueAncestors(
781 prevRange.start.node, start);
782 var embeddedObject = entered.find(function(f) {
783 return f.role == RoleType.embeddedObject; });
784 if (embeddedObject)
785 embeddedObject.focus();
786 }
787
788 // Next, try to focus the start or end node. 789 // Next, try to focus the start or end node.
789 if (!AutomationPredicate.structuralContainer(start) && 790 if (!AutomationPredicate.structuralContainer(start) &&
790 start.state.focusable) { 791 start.state.focusable) {
791 if (!start.state.focused) 792 if (!start.state.focused)
792 start.focus(); 793 start.focus();
793 return; 794 return;
794 } else if (!AutomationPredicate.structuralContainer(end) && 795 } else if (!AutomationPredicate.structuralContainer(end) &&
795 end.state.focusable) { 796 end.state.focusable) {
796 if (!end.state.focused) 797 if (!end.state.focused)
797 end.focus(); 798 end.focus();
(...skipping 29 matching lines...) Expand all
827 return new RegExp('^(' + globs.map(function(glob) { 828 return new RegExp('^(' + globs.map(function(glob) {
828 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&') 829 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&')
829 .replace(/\*/g, '.*') 830 .replace(/\*/g, '.*')
830 .replace(/\?/g, '.'); 831 .replace(/\?/g, '.');
831 }).join('|') + ')$'); 832 }).join('|') + ')$');
832 }; 833 };
833 834
834 new Background(); 835 new Background();
835 836
836 }); // goog.scope 837 }); // goog.scope
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698