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

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

Issue 2042083002: Add role lists to ChromeVox. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months 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 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 if (cvox.ChromeVox.isStickyPrefOn) 631 if (cvox.ChromeVox.isStickyPrefOn)
632 chrome.accessibilityPrivate.setKeyboardListener(true, true); 632 chrome.accessibilityPrivate.setKeyboardListener(true, true);
633 else 633 else
634 chrome.accessibilityPrivate.setKeyboardListener(true, false); 634 chrome.accessibilityPrivate.setKeyboardListener(true, false);
635 return false; 635 return false;
636 case 'passThroughMode': 636 case 'passThroughMode':
637 cvox.ChromeVox.passThroughMode = true; 637 cvox.ChromeVox.passThroughMode = true;
638 cvox.ChromeVox.tts.speak( 638 cvox.ChromeVox.tts.speak(
639 Msgs.getMsg('pass_through_key'), cvox.QueueMode.QUEUE); 639 Msgs.getMsg('pass_through_key'), cvox.QueueMode.QUEUE);
640 return true; 640 return true;
641 case 'openChromeVoxMenus': 641 case 'toggleKeyboardHelp':
642 this.startExcursion(); 642 this.startExcursion();
643 (new PanelCommand(PanelCommandType.OPEN_MENUS)).send(); 643 (new PanelCommand(PanelCommandType.OPEN_MENUS)).send();
644 return false; 644 return false;
645 case 'showHeadingsList':
646 this.startExcursion();
647 (new PanelCommand(PanelCommandType.OPEN_MENUS, 'role_heading')).send();
648 return false;
649 case 'showFormsList':
650 this.startExcursion();
651 (new PanelCommand(PanelCommandType.OPEN_MENUS, 'role_form')).send();
652 return false;
653 case 'showLandmarksList':
654 this.startExcursion();
655 (new PanelCommand(PanelCommandType.OPEN_MENUS, 'role_landmark')).send();
656 return false;
657 case 'showLinksList':
658 this.startExcursion();
659 (new PanelCommand(PanelCommandType.OPEN_MENUS, 'role_link')).send();
660 return false;
661 case 'showTablesList':
662 this.startExcursion();
663 (new PanelCommand(PanelCommandType.OPEN_MENUS, 'table_strategy'))
664 .send();
665 return false;
645 case 'toggleSearchWidget': 666 case 'toggleSearchWidget':
646 (new PanelCommand(PanelCommandType.SEARCH)).send(); 667 (new PanelCommand(PanelCommandType.SEARCH)).send();
647 return false; 668 return false;
648 case 'showKbExplorerPage': 669 case 'showKbExplorerPage':
649 var explorerPage = {url: 'chromevox/background/kbexplorer.html'}; 670 var explorerPage = {url: 'chromevox/background/kbexplorer.html'};
650 chrome.tabs.create(explorerPage); 671 chrome.tabs.create(explorerPage);
651 break; 672 break;
652 case 'decreaseTtsRate': 673 case 'decreaseTtsRate':
653 this.increaseOrDecreaseSpeechProperty_(cvox.AbstractTts.RATE, false); 674 this.increaseOrDecreaseSpeechProperty_(cvox.AbstractTts.RATE, false);
654 return false; 675 return false;
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 if (predErrorMsg) { 806 if (predErrorMsg) {
786 cvox.ChromeVox.tts.speak(Msgs.getMsg(predErrorMsg), 807 cvox.ChromeVox.tts.speak(Msgs.getMsg(predErrorMsg),
787 cvox.QueueMode.FLUSH); 808 cvox.QueueMode.FLUSH);
788 } 809 }
789 return false; 810 return false;
790 } 811 }
791 } 812 }
792 } 813 }
793 814
794 if (current) 815 if (current)
795 this.navigateToRange_(current); 816 this.navigateToRange(current);
796 817
797 return false; 818 return false;
798 }, 819 },
799 820
800 /** 821 /**
801 * Increase or decrease a speech property and make an announcement. 822 * Increase or decrease a speech property and make an announcement.
802 * @param {string} propertyName The name of the property to change. 823 * @param {string} propertyName The name of the property to change.
803 * @param {boolean} increase If true, increases the property value by one 824 * @param {boolean} increase If true, increases the property value by one
804 * step size, otherwise decreases. 825 * step size, otherwise decreases.
805 */ 826 */
(...skipping 16 matching lines...) Expand all
822 if (announcement) { 843 if (announcement) {
823 cvox.ChromeVox.tts.speak( 844 cvox.ChromeVox.tts.speak(
824 announcement, cvox.QueueMode.FLUSH, 845 announcement, cvox.QueueMode.FLUSH,
825 cvox.AbstractTts.PERSONALITY_ANNOTATION); 846 cvox.AbstractTts.PERSONALITY_ANNOTATION);
826 } 847 }
827 }, 848 },
828 849
829 /** 850 /**
830 * Navigate to the given range - it both sets the range and outputs it. 851 * Navigate to the given range - it both sets the range and outputs it.
831 * @param {!cursors.Range} range The new range. 852 * @param {!cursors.Range} range The new range.
853 * @param {boolean=} opt_focus Focus the range; defaults to true.
832 * @private 854 * @private
833 */ 855 */
834 navigateToRange_: function(range) { 856 navigateToRange: function(range, opt_focus) {
835 // TODO(dtseng): Figure out what it means to focus a range. 857 opt_focus = opt_focus === undefined ? true : opt_focus;
836 var actionNode = range.start.node;
837 if (actionNode.role == RoleType.inlineTextBox)
838 actionNode = actionNode.parent;
839 858
840 // Iframes, when focused, causes the child webArea to fire focus event. 859 if (opt_focus) {
841 // This can result in getting stuck when navigating backward. 860 // TODO(dtseng): Figure out what it means to focus a range.
842 if (actionNode.role != RoleType.iframe && !actionNode.state.focused && 861 var actionNode = range.start.node;
843 !AutomationPredicate.container(actionNode)) 862 if (actionNode.role == RoleType.inlineTextBox)
844 actionNode.focus(); 863 actionNode = actionNode.parent;
845 864
865 // Iframes, when focused, causes the child webArea to fire focus event.
866 // This can result in getting stuck when navigating backward.
867 if (actionNode.role != RoleType.iframe && !actionNode.state.focused &&
868 !AutomationPredicate.container(actionNode))
869 actionNode.focus();
870 }
846 var prevRange = this.currentRange_; 871 var prevRange = this.currentRange_;
847 this.setCurrentRange(range); 872 this.setCurrentRange(range);
848 873
849 range.select(); 874 range.select();
850 875
851 new Output().withRichSpeechAndBraille( 876 new Output().withRichSpeechAndBraille(
852 range, prevRange, Output.EventType.NAVIGATE) 877 range, prevRange, Output.EventType.NAVIGATE)
853 .withQueueMode(cvox.QueueMode.FLUSH) 878 .withQueueMode(cvox.QueueMode.FLUSH)
854 .go(); 879 .go();
855 }, 880 },
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 } else if (action == 'flushNextUtterance') { 1061 } else if (action == 'flushNextUtterance') {
1037 Output.flushNextSpeechUtterance(); 1062 Output.flushNextSpeechUtterance();
1038 } 1063 }
1039 break; 1064 break;
1040 } 1065 }
1041 }, 1066 },
1042 1067
1043 /** 1068 /**
1044 * Restore the range to the last range that was *not* in the ChromeVox 1069 * Restore the range to the last range that was *not* in the ChromeVox
1045 * panel. This is used when the ChromeVox Panel closes. 1070 * panel. This is used when the ChromeVox Panel closes.
1071 * @param {function()=} opt_callback
1046 * @private 1072 * @private
1047 */ 1073 */
1048 restoreCurrentRange_: function() { 1074 restoreCurrentRange_: function(opt_callback) {
1049 if (this.savedRange_) { 1075 if (this.savedRange_) {
1050 var node = this.savedRange_.start.node; 1076 var node = this.savedRange_.start.node;
1051 var containingWebView = node; 1077 var containingWebView = node;
1052 while (containingWebView && containingWebView.role != RoleType.webView) 1078 while (containingWebView && containingWebView.role != RoleType.webView)
1053 containingWebView = containingWebView.parent; 1079 containingWebView = containingWebView.parent;
1054 1080
1055 if (containingWebView) { 1081 if (containingWebView) {
1056 // Focusing the webView causes a focus change event which steals focus 1082 // Focusing the webView causes a focus change event which steals focus
1057 // away from the saved range. 1083 // away from the saved range.
1058 var saved = this.savedRange_; 1084 var saved = this.savedRange_;
1059 var setSavedRange = function(e) { 1085 var setSavedRange = function(e) {
1060 if (e.target.root == saved.start.node.root) 1086 if (e.target.root == saved.start.node.root) {
1061 this.navigateToRange_(saved); 1087 this.navigateToRange(saved, false);
1088 opt_callback && opt_callback();
1089 }
1062 node.root.removeEventListener(EventType.focus, setSavedRange, true); 1090 node.root.removeEventListener(EventType.focus, setSavedRange, true);
1063 }.bind(this); 1091 }.bind(this);
1064 node.root.addEventListener(EventType.focus, setSavedRange, true); 1092 node.root.addEventListener(EventType.focus, setSavedRange, true);
1065 containingWebView.focus(); 1093 containingWebView.focus();
1066 } 1094 }
1067 this.navigateToRange_(this.savedRange_); 1095 this.navigateToRange(this.savedRange_);
1068 this.savedRange_ = null; 1096 this.savedRange_ = null;
1069 } 1097 }
1070 }, 1098 },
1071 1099
1072 /** 1100 /**
1073 * Move ChromeVox without saving any ranges. 1101 * Move ChromeVox without saving any ranges.
1074 */ 1102 */
1075 startExcursion: function() { 1103 startExcursion: function() {
1076 this.inExcursion_ = true; 1104 this.inExcursion_ = true;
1077 }, 1105 },
1078 1106
1079 /** 1107 /**
1080 * Move ChromeVox back to the last saved range. 1108 * Move ChromeVox back to the last saved range.
1109 * @param {function()=} opt_callback Called when range has been restored.
1081 */ 1110 */
1082 endExcursion: function() { 1111 endExcursion: function(opt_callback) {
1083 this.inExcursion_ = false; 1112 this.inExcursion_ = false;
1084 this.restoreCurrentRange_(); 1113 this.restoreCurrentRange_(opt_callback);
1085 }, 1114 },
1086 1115
1087 /** 1116 /**
1088 * Move ChromeVox back to the last saved range. 1117 * Move ChromeVox back to the last saved range.
1089 */ 1118 */
1090 saveExcursion: function() { 1119 saveExcursion: function() {
1091 this.savedRange_ = 1120 this.savedRange_ =
1092 new cursors.Range(this.currentRange_.start, this.currentRange_.end); 1121 new cursors.Range(this.currentRange_.start, this.currentRange_.end);
1093 }, 1122 },
1094 1123
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&') 1175 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&')
1147 .replace(/\*/g, '.*') 1176 .replace(/\*/g, '.*')
1148 .replace(/\?/g, '.'); 1177 .replace(/\?/g, '.');
1149 }).join('|') + ')$'); 1178 }).join('|') + ')$');
1150 }; 1179 };
1151 1180
1152 /** @type {Background} */ 1181 /** @type {Background} */
1153 global.backgroundObj = new Background(); 1182 global.backgroundObj = new Background();
1154 1183
1155 }); // goog.scope 1184 }); // goog.scope
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698