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

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

Issue 1362223003: Improve braille related message descriptions and clean up message handling in Chromevox. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@inputtypeexception
Patch Set: Move another braille message to Msgs.Untranslated Created 5 years, 2 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 Provides output services for ChromeVox. 6 * @fileoverview Provides output services for ChromeVox.
7 */ 7 */
8 8
9 goog.provide('Output'); 9 goog.provide('Output');
10 goog.provide('Output.EventType'); 10 goog.provide('Output.EventType');
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 * @const {Object<{msgId: string, 85 * @const {Object<{msgId: string,
86 * earconId: (string|undefined), 86 * earconId: (string|undefined),
87 * inherits: (string|undefined)}>} 87 * inherits: (string|undefined)}>}
88 * msgId: the message id of the role. 88 * msgId: the message id of the role.
89 * earconId: an optional earcon to play when encountering the role. 89 * earconId: an optional earcon to play when encountering the role.
90 * inherits: inherits rules from this role. 90 * inherits: inherits rules from this role.
91 * @private 91 * @private
92 */ 92 */
93 Output.ROLE_INFO_ = { 93 Output.ROLE_INFO_ = {
94 alert: { 94 alert: {
95 msgId: 'aria_role_alert', 95 msgId: 'role_alert',
96 earconId: 'ALERT_NONMODAL', 96 earconId: 'ALERT_NONMODAL',
97 }, 97 },
98 alertDialog: { 98 alertDialog: {
99 msgId: 'aria_role_alertdialog' 99 msgId: 'role_alertdialog'
100 }, 100 },
101 article: { 101 article: {
102 msgId: 'aria_role_article', 102 msgId: 'role_article',
103 inherits: 'abstractContainer' 103 inherits: 'abstractContainer'
104 }, 104 },
105 application: { 105 application: {
106 msgId: 'aria_role_application', 106 msgId: 'role_application',
107 inherits: 'abstractContainer' 107 inherits: 'abstractContainer'
108 }, 108 },
109 banner: { 109 banner: {
110 msgId: 'aria_role_banner', 110 msgId: 'role_banner',
111 inherits: 'abstractContainer' 111 inherits: 'abstractContainer'
112 }, 112 },
113 button: { 113 button: {
114 msgId: 'tag_button', 114 msgId: 'role_button',
115 earconId: 'BUTTON' 115 earconId: 'BUTTON'
116 }, 116 },
117 buttonDropDown: { 117 buttonDropDown: {
118 msgId: 'tag_button', 118 msgId: 'role_button',
119 earconId: 'BUTTON' 119 earconId: 'BUTTON'
120 }, 120 },
121 cell: { 121 cell: {
122 msgId: 'aria_role_gridcell' 122 msgId: 'role_gridcell'
123 }, 123 },
124 checkBox: { 124 checkBox: {
125 msgId: 'input_type_checkbox' 125 msgId: 'role_checkbox'
126 }, 126 },
127 columnHeader: { 127 columnHeader: {
128 msgId: 'aria_role_columnheader', 128 msgId: 'role_columnheader',
129 inherits: 'abstractContainer' 129 inherits: 'abstractContainer'
130 }, 130 },
131 comboBox: { 131 comboBox: {
132 msgId: 'aria_role_combobox' 132 msgId: 'role_combobox'
133 }, 133 },
134 complementary: { 134 complementary: {
135 msgId: 'aria_role_complementary', 135 msgId: 'role_complementary',
136 inherits: 'abstractContainer' 136 inherits: 'abstractContainer'
137 }, 137 },
138 contentInfo: { 138 contentInfo: {
139 msgId: 'aria_role_contentinfo', 139 msgId: 'role_contentinfo',
140 inherits: 'abstractContainer' 140 inherits: 'abstractContainer'
141 }, 141 },
142 date: { 142 date: {
143 msgId: 'input_type_date', 143 msgId: 'input_type_date',
144 inherits: 'abstractContainer' 144 inherits: 'abstractContainer'
145 }, 145 },
146 definition: { 146 definition: {
147 msgId: 'aria_role_definition', 147 msgId: 'role_definition',
148 inherits: 'abstractContainer' 148 inherits: 'abstractContainer'
149 }, 149 },
150 dialog: { 150 dialog: {
151 msgId: 'dialog' 151 msgId: 'role_dialog'
152 }, 152 },
153 directory: { 153 directory: {
154 msgId: 'aria_role_directory', 154 msgId: 'role_directory',
155 inherits: 'abstractContainer' 155 inherits: 'abstractContainer'
156 }, 156 },
157 document: { 157 document: {
158 msgId: 'aria_role_document', 158 msgId: 'role_document',
159 inherits: 'abstractContainer' 159 inherits: 'abstractContainer'
160 }, 160 },
161 form: { 161 form: {
162 msgId: 'aria_role_form', 162 msgId: 'role_form',
163 inherits: 'abstractContainer' 163 inherits: 'abstractContainer'
164 }, 164 },
165 grid: { 165 grid: {
166 msgId: 'aria_role_grid' 166 msgId: 'role_grid'
167 }, 167 },
168 group: { 168 group: {
169 msgId: 'aria_role_group' 169 msgId: 'role_group'
170 }, 170 },
171 heading: { 171 heading: {
172 msgId: 'aria_role_heading', 172 msgId: 'role_heading',
173 }, 173 },
174 image: { 174 image: {
175 msgId: 'aria_role_img', 175 msgId: 'role_img',
176 }, 176 },
177 inputTime: { 177 inputTime: {
178 msgId: 'input_type_time', 178 msgId: 'input_type_time',
179 inherits: 'abstractContainer' 179 inherits: 'abstractContainer'
180 }, 180 },
181 link: { 181 link: {
182 msgId: 'tag_link', 182 msgId: 'role_link',
183 earconId: 'LINK' 183 earconId: 'LINK'
184 }, 184 },
185 listBox: { 185 listBox: {
186 msgId: 'aria_role_listbox', 186 msgId: 'role_listbox',
187 earconId: 'LISTBOX' 187 earconId: 'LISTBOX'
188 }, 188 },
189 listBoxOption: { 189 listBoxOption: {
190 msgId: 'aria_role_listitem', 190 msgId: 'role_listitem',
191 earconId: 'LIST_ITEM' 191 earconId: 'LIST_ITEM'
192 }, 192 },
193 listItem: { 193 listItem: {
194 msgId: 'aria_role_listitem', 194 msgId: 'role_listitem',
195 earconId: 'LIST_ITEM' 195 earconId: 'LIST_ITEM'
196 }, 196 },
197 log: { 197 log: {
198 msgId: 'aria_role_log', 198 msgId: 'role_log',
199 }, 199 },
200 main: { 200 main: {
201 msgId: 'aria_role_main', 201 msgId: 'role_main',
202 inherits: 'abstractContainer' 202 inherits: 'abstractContainer'
203 }, 203 },
204 marquee: { 204 marquee: {
205 msgId: 'aria_role_marquee', 205 msgId: 'role_marquee',
206 }, 206 },
207 math: { 207 math: {
208 msgId: 'aria_role_math', 208 msgId: 'role_math',
209 inherits: 'abstractContainer' 209 inherits: 'abstractContainer'
210 }, 210 },
211 menu: { 211 menu: {
212 msgId: 'aria_role_menu' 212 msgId: 'role_menu'
213 }, 213 },
214 menuBar: { 214 menuBar: {
215 msgId: 'aria_role_menubar', 215 msgId: 'role_menubar',
216 }, 216 },
217 menuItem: { 217 menuItem: {
218 msgId: 'aria_role_menuitem' 218 msgId: 'role_menuitem'
219 }, 219 },
220 menuItemCheckBox: { 220 menuItemCheckBox: {
221 msgId: 'aria_role_menuitemcheckbox' 221 msgId: 'role_menuitemcheckbox'
222 }, 222 },
223 menuItemRadio: { 223 menuItemRadio: {
224 msgId: 'aria_role_menuitemradio' 224 msgId: 'role_menuitemradio'
225 }, 225 },
226 menuListOption: { 226 menuListOption: {
227 msgId: 'aria_role_menuitem' 227 msgId: 'role_menuitem'
228 }, 228 },
229 menuListPopup: { 229 menuListPopup: {
230 msgId: 'aria_role_menu' 230 msgId: 'role_menu'
231 }, 231 },
232 navigation: { 232 navigation: {
233 msgId: 'aria_role_navigation', 233 msgId: 'role_navigation',
234 inherits: 'abstractContainer' 234 inherits: 'abstractContainer'
235 }, 235 },
236 note: { 236 note: {
237 msgId: 'aria_role_note', 237 msgId: 'role_note',
238 inherits: 'abstractContainer' 238 inherits: 'abstractContainer'
239 }, 239 },
240 popUpButton: { 240 popUpButton: {
241 msgId: 'tag_button', 241 msgId: 'role_button',
242 earcon: 'LISTBOX' 242 earcon: 'LISTBOX'
243 }, 243 },
244 radioButton: { 244 radioButton: {
245 msgId: 'input_type_radio' 245 msgId: 'role_radio'
246 }, 246 },
247 radioGroup: { 247 radioGroup: {
248 msgId: 'aria_role_radiogroup', 248 msgId: 'role_radiogroup',
249 }, 249 },
250 region: { 250 region: {
251 msgId: 'aria_role_region', 251 msgId: 'role_region',
252 inherits: 'abstractContainer' 252 inherits: 'abstractContainer'
253 }, 253 },
254 rowHeader: { 254 rowHeader: {
255 msgId: 'aria_role_rowheader', 255 msgId: 'role_rowheader',
256 inherits: 'abstractContainer' 256 inherits: 'abstractContainer'
257 }, 257 },
258 scrollBar: { 258 scrollBar: {
259 msgId: 'aria_role_scrollbar', 259 msgId: 'role_scrollbar',
260 }, 260 },
261 search: { 261 search: {
262 msgId: 'aria_role_search', 262 msgId: 'role_search',
263 inherits: 'abstractContainer' 263 inherits: 'abstractContainer'
264 }, 264 },
265 separator: { 265 separator: {
266 msgId: 'aria_role_separator', 266 msgId: 'role_separator',
267 inherits: 'abstractContainer' 267 inherits: 'abstractContainer'
268 }, 268 },
269 spinButton: { 269 spinButton: {
270 msgId: 'aria_role_spinbutton', 270 msgId: 'role_spinbutton',
271 earconId: 'LISTBOX' 271 earconId: 'LISTBOX'
272 }, 272 },
273 status: { 273 status: {
274 msgId: 'aria_role_status' 274 msgId: 'role_status'
275 }, 275 },
276 tab: { 276 tab: {
277 msgId: 'aria_role_tab' 277 msgId: 'role_tab'
278 }, 278 },
279 tabList: { 279 tabList: {
280 msgId: 'aria_role_tablist' 280 msgId: 'role_tablist'
281 }, 281 },
282 tabPanel: { 282 tabPanel: {
283 msgId: 'aria_role_tabpanel' 283 msgId: 'role_tabpanel'
284 }, 284 },
285 textBox: { 285 textBox: {
286 msgId: 'input_type_text', 286 msgId: 'input_type_text',
287 earconId: 'EDITABLE_TEXT' 287 earconId: 'EDITABLE_TEXT'
288 }, 288 },
289 textField: { 289 textField: {
290 msgId: 'input_type_text', 290 msgId: 'input_type_text',
291 earconId: 'EDITABLE_TEXT' 291 earconId: 'EDITABLE_TEXT'
292 }, 292 },
293 time: { 293 time: {
294 msgId: 'tag_time', 294 msgId: 'tag_time',
295 inherits: 'abstractContainer' 295 inherits: 'abstractContainer'
296 }, 296 },
297 timer: { 297 timer: {
298 msgId: 'aria_role_timer' 298 msgId: 'role_timer'
299 }, 299 },
300 toolbar: { 300 toolbar: {
301 msgId: 'aria_role_toolbar' 301 msgId: 'role_toolbar'
302 }, 302 },
303 tree: { 303 tree: {
304 msgId: 'aria_role_tree' 304 msgId: 'role_tree'
305 }, 305 },
306 treeItem: { 306 treeItem: {
307 msgId: 'aria_role_treeitem' 307 msgId: 'role_treeitem'
308 } 308 }
309 }; 309 };
310 310
311 /** 311 /**
312 * Metadata about supported automation states. 312 * Metadata about supported automation states.
313 * @const {!Object<{on: {msgId: string, earconId: string}, 313 * @const {!Object<{on: {msgId: string, earconId: string},
314 * off: {msgId: string, earconId: string}, 314 * off: {msgId: string, earconId: string},
315 * omitted: {msgId: string, earconId: string}}>} 315 * omitted: {msgId: string, earconId: string}}>}
316 * on: info used to describe a state that is set to true. 316 * on: info used to describe a state that is set to true.
317 * off: info used to describe a state that is set to false. 317 * off: info used to describe a state that is set to false.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 } 356 }
357 }; 357 };
358 358
359 /** 359 /**
360 * Maps input types to message IDs. 360 * Maps input types to message IDs.
361 * @const {Object<string>} 361 * @const {Object<string>}
362 * @private 362 * @private
363 */ 363 */
364 Output.INPUT_TYPE_MESSAGE_IDS_ = { 364 Output.INPUT_TYPE_MESSAGE_IDS_ = {
365 'email': 'input_type_email', 365 'email': 'input_type_email',
366 'file': 'input_type_file',
367 'number': 'input_type_number', 366 'number': 'input_type_number',
368 'password': 'input_type_password', 367 'password': 'input_type_password',
369 'search': 'input_type_search', 368 'search': 'input_type_search',
370 'tel': 'input_type_tel', 369 'tel': 'input_type_number',
371 'text': 'input_type_text', 370 'text': 'input_type_text',
372 'url': 'input_type_url', 371 'url': 'input_type_url',
373 }; 372 };
374 373
375 /** 374 /**
376 * Rules specifying format of AutomationNodes for output. 375 * Rules specifying format of AutomationNodes for output.
377 * @type {!Object<Object<Object<string>>>} 376 * @type {!Object<Object<Object<string>>>}
378 */ 377 */
379 Output.RULES = { 378 Output.RULES = {
380 navigate: { 379 navigate: {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 enter: '$role' 432 enter: '$role'
434 }, 433 },
435 menu: { 434 menu: {
436 enter: '$name $role @@list_with_items($countChildren(menuItem))' 435 enter: '$name $role @@list_with_items($countChildren(menuItem))'
437 }, 436 },
438 menuItem: { 437 menuItem: {
439 speak: '$name $role $if($haspopup, @has_submenu) ' + 438 speak: '$name $role $if($haspopup, @has_submenu) ' +
440 '@describe_index($indexInParent, $parentChildCount)' 439 '@describe_index($indexInParent, $parentChildCount)'
441 }, 440 },
442 menuListOption: { 441 menuListOption: {
443 speak: '$name $value @aria_role_menuitem ' + 442 speak: '$name $value @role_menuitem ' +
444 '@describe_index($indexInParent, $parentChildCount)' 443 '@describe_index($indexInParent, $parentChildCount)'
445 }, 444 },
446 paragraph: { 445 paragraph: {
447 speak: '$descendants' 446 speak: '$descendants'
448 }, 447 },
449 popUpButton: { 448 popUpButton: {
450 speak: '$value $name $role @aria_has_popup ' + 449 speak: '$value $name $role @aria_has_popup ' +
451 '$if($collapsed, @aria_expanded_false, @aria_expanded_true)' 450 '$if($collapsed, @aria_expanded_false, @aria_expanded_true)'
452 }, 451 },
453 radioButton: { 452 radioButton: {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 menuListValueChanged: { 505 menuListValueChanged: {
507 'default': { 506 'default': {
508 speak: '$value $name ' + 507 speak: '$value $name ' +
509 '$find({"state": {"selected": true, "invisible": false}}, ' + 508 '$find({"state": {"selected": true, "invisible": false}}, ' +
510 '@describe_index($indexInParent, $parentChildCount)) ' 509 '@describe_index($indexInParent, $parentChildCount)) '
511 } 510 }
512 }, 511 },
513 alert: { 512 alert: {
514 default: { 513 default: {
515 speak: '!doNotInterrupt ' + 514 speak: '!doNotInterrupt ' +
516 '@aria_role_alert $name $earcon(ALERT_NONMODAL) $descendants' 515 '@role_alert $name $earcon(ALERT_NONMODAL) $descendants'
517 } 516 }
518 } 517 }
519 }; 518 };
520 519
521 /** 520 /**
522 * Custom actions performed while rendering an output string. 521 * Custom actions performed while rendering an output string.
523 * @constructor 522 * @constructor
524 */ 523 */
525 Output.Action = function() { 524 Output.Action = function() {
526 }; 525 };
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 var prev = null; 887 var prev = null;
889 if (node) 888 if (node)
890 prev = cursors.Range.fromNode(node); 889 prev = cursors.Range.fromNode(node);
891 this.range_(subrange, prev, 'navigate', buff); 890 this.range_(subrange, prev, 'navigate', buff);
892 } else if (token == 'role') { 891 } else if (token == 'role') {
893 options.annotation.push(token); 892 options.annotation.push(token);
894 var msg = node.role; 893 var msg = node.role;
895 var info = Output.ROLE_INFO_[node.role]; 894 var info = Output.ROLE_INFO_[node.role];
896 if (info) { 895 if (info) {
897 if (this.formatOptions_.braille) 896 if (this.formatOptions_.braille)
898 msg = cvox.ChromeVox.msgs.getMsg(info.msgId + '_brl'); 897 msg = Msgs.getMsg(info.msgId + '_brl');
899 else 898 else
900 msg = cvox.ChromeVox.msgs.getMsg(info.msgId); 899 msg = Msgs.getMsg(info.msgId);
901 } else { 900 } else {
902 console.error('Missing role info for ' + node.role); 901 console.error('Missing role info for ' + node.role);
903 } 902 }
904 this.append_(buff, msg, options); 903 this.append_(buff, msg, options);
905 } else if (token == 'inputType') { 904 } else if (token == 'inputType') {
906 if (!node.inputType) 905 if (!node.inputType)
907 return; 906 return;
908 options.annotation.push(token); 907 options.annotation.push(token);
909 var msgId = Output.INPUT_TYPE_MESSAGE_IDS_[node.inputType] || 908 var msgId = Output.INPUT_TYPE_MESSAGE_IDS_[node.inputType] ||
910 'input_type_text'; 909 'input_type_text';
911 if (this.formatOptions_.braille) 910 if (this.formatOptions_.braille)
912 msgId = msgId + '_brl'; 911 msgId = msgId + '_brl';
913 this.append_(buff, cvox.ChromeVox.msgs.getMsg(msgId), options); 912 this.append_(buff, Msgs.getMsg(msgId), options);
914 } else if (token == 'tableRowIndex' || 913 } else if (token == 'tableRowIndex' ||
915 token == 'tableCellColumnIndex') { 914 token == 'tableCellColumnIndex') {
916 var value = node[token]; 915 var value = node[token];
917 if (!value) 916 if (!value)
918 return; 917 return;
919 value = String(value + 1); 918 value = String(value + 1);
920 options.annotation.push(token); 919 options.annotation.push(token);
921 this.append_(buff, value, options); 920 this.append_(buff, value, options);
922 } else if (node[token] !== undefined) { 921 } else if (node[token] !== undefined) {
923 options.annotation.push(token); 922 options.annotation.push(token);
(...skipping 11 matching lines...) Expand all
935 resolvedInfo = node.state[token] ? stateInfo.on : stateInfo.off; 934 resolvedInfo = node.state[token] ? stateInfo.on : stateInfo.off;
936 if (!resolvedInfo) 935 if (!resolvedInfo)
937 return; 936 return;
938 if (this.formatOptions_.speech && resolvedInfo.earconId) { 937 if (this.formatOptions_.speech && resolvedInfo.earconId) {
939 options.annotation.push( 938 options.annotation.push(
940 new Output.EarconAction(resolvedInfo.earconId)); 939 new Output.EarconAction(resolvedInfo.earconId));
941 } 940 }
942 var msgId = 941 var msgId =
943 this.formatOptions_.braille ? resolvedInfo.msgId + '_brl' : 942 this.formatOptions_.braille ? resolvedInfo.msgId + '_brl' :
944 resolvedInfo.msgId; 943 resolvedInfo.msgId;
945 var msg = cvox.ChromeVox.msgs.getMsg(msgId); 944 var msg = Msgs.getMsg(msgId);
946 this.append_(buff, msg, options); 945 this.append_(buff, msg, options);
947 } else if (tree.firstChild) { 946 } else if (tree.firstChild) {
948 // Custom functions. 947 // Custom functions.
949 if (token == 'if') { 948 if (token == 'if') {
950 var cond = tree.firstChild; 949 var cond = tree.firstChild;
951 var attrib = cond.value.slice(1); 950 var attrib = cond.value.slice(1);
952 if (node[attrib] || node.state[attrib]) 951 if (node[attrib] || node.state[attrib])
953 this.format_(node, cond.nextSibling, buff); 952 this.format_(node, cond.nextSibling, buff);
954 else 953 else
955 this.format_(node, cond.nextSibling.nextSibling, buff); 954 this.format_(node, cond.nextSibling.nextSibling, buff);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 if (curArg.value[0] != '$') { 991 if (curArg.value[0] != '$') {
993 console.error('Unexpected value: ' + curArg.value); 992 console.error('Unexpected value: ' + curArg.value);
994 return; 993 return;
995 } 994 }
996 var msgBuff = []; 995 var msgBuff = [];
997 this.format_(node, curArg, msgBuff); 996 this.format_(node, curArg, msgBuff);
998 msgArgs = msgArgs.concat(msgBuff); 997 msgArgs = msgArgs.concat(msgBuff);
999 curArg = curArg.nextSibling; 998 curArg = curArg.nextSibling;
1000 } 999 }
1001 } 1000 }
1002 var msg = cvox.ChromeVox.msgs.getMsg(msgId, msgArgs); 1001 var msg = Msgs.getMsg(msgId, msgArgs);
1003 try { 1002 try {
1004 if (this.formatOptions_.braille) 1003 if (this.formatOptions_.braille)
1005 msg = cvox.ChromeVox.msgs.getMsg(msgId + '_brl', msgArgs) || msg; 1004 msg = Msgs.getMsg(msgId + '_brl', msgArgs) || msg;
1006 } catch(e) {} 1005 } catch(e) {}
1007 1006
1008 if (!msg) { 1007 if (!msg) {
1009 console.error('Could not get message ' + msgId); 1008 console.error('Could not get message ' + msgId);
1010 return; 1009 return;
1011 } 1010 }
1012 1011
1013 if (isPluralized) { 1012 if (isPluralized) {
1014 var arg = tree.firstChild; 1013 var arg = tree.firstChild;
1015 if (!arg || arg.nextSibling) { 1014 if (!arg || arg.nextSibling) {
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1321 elem.end); 1320 elem.end);
1322 }); 1321 });
1323 spansToRemove.forEach(result.removeSpan.bind(result)); 1322 spansToRemove.forEach(result.removeSpan.bind(result));
1324 separator = Output.SPACE; 1323 separator = Output.SPACE;
1325 }); 1324 });
1326 return result; 1325 return result;
1327 } 1326 }
1328 }; 1327 };
1329 1328
1330 }); // goog.scope 1329 }); // goog.scope
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698