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

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

Issue 2479893002: Revert of Use setSequentialFocusNavigationStartingPoint in ChromeVox (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
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 * @param {!cursors.Range} range 760 * @param {!cursors.Range} range
761 * @private 761 * @private
762 */ 762 */
763 setFocusToRange_: function(range) { 763 setFocusToRange_: function(range) {
764 var start = range.start.node; 764 var start = range.start.node;
765 var end = range.end.node; 765 var end = range.end.node;
766 if (start.state.focused || end.state.focused) 766 if (start.state.focused || end.state.focused)
767 return; 767 return;
768 768
769 var isFocusableLinkOrControl = function(node) { 769 // Iframes, when focused, causes the child webArea to fire focus
770 return node.state.focusable && 770 // event. This can result in getting stuck when navigating
771 AutomationPredicate.linkOrControl(node); 771 // backward.
772 var isFocusable = function(node) {
773 return node.role != RoleType.iframe &&
774 node.state.focusable &&
775 !node.state.focused &&
776 !AutomationPredicate.structuralContainer(node);
772 }; 777 };
773 778 if (isFocusable(start)) {
774 // First, try to focus the start or end node. 779 start.focus();
775 if (isFocusableLinkOrControl(start)) {
776 if (!start.state.focused)
777 start.focus();
778 return; 780 return;
779 } else if (isFocusableLinkOrControl(end)) { 781 }
780 if (!end.state.focused) 782 if (isFocusable(end)) {
781 end.focus(); 783 end.focus();
782 return; 784 return;
783 } 785 }
784 786
785 // If a common ancestor of |start| and |end| is a link, focus that. 787 // TODO(dmazzoni): Set sequential focus.
786 var ancestor = AutomationUtil.getLeastCommonAncestor(start, end);
787 while (ancestor && ancestor.root == start.root) {
788 if (isFocusableLinkOrControl(ancestor)) {
789 if (!ancestor.state.focused)
790 ancestor.focus();
791 return;
792 }
793 ancestor = ancestor.parent;
794 }
795
796 // If nothing is focusable, set the sequential focus navigation starting
797 // point, which ensures that the next time you press Tab, you'll reach
798 // the next or previous focusable node from |start|.
799 start.setSequentialFocusNavigationStartingPoint();
800 } 788 }
801 }; 789 };
802 790
803 /** 791 /**
804 * Converts a list of globs, as used in the extension manifest, to a regular 792 * Converts a list of globs, as used in the extension manifest, to a regular
805 * expression that matches if and only if any of the globs in the list matches. 793 * expression that matches if and only if any of the globs in the list matches.
806 * @param {!Array<string>} globs 794 * @param {!Array<string>} globs
807 * @return {!RegExp} 795 * @return {!RegExp}
808 * @private 796 * @private
809 */ 797 */
810 Background.globsToRegExp_ = function(globs) { 798 Background.globsToRegExp_ = function(globs) {
811 return new RegExp('^(' + globs.map(function(glob) { 799 return new RegExp('^(' + globs.map(function(glob) {
812 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&') 800 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&')
813 .replace(/\*/g, '.*') 801 .replace(/\*/g, '.*')
814 .replace(/\?/g, '.'); 802 .replace(/\?/g, '.');
815 }).join('|') + ')$'); 803 }).join('|') + ')$');
816 }; 804 };
817 805
818 new Background(); 806 new Background();
819 807
820 }); // goog.scope 808 }); // goog.scope
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698