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

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

Issue 1319093003: Use new earcons in ChromeVox Next. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@automation_node_id_fix_2
Patch Set: Update test expectations 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 msgId: 'role_math', 208 msgId: 'role_math',
209 inherits: 'abstractContainer' 209 inherits: 'abstractContainer'
210 }, 210 },
211 menu: { 211 menu: {
212 msgId: 'role_menu' 212 msgId: 'role_menu'
213 }, 213 },
214 menuBar: { 214 menuBar: {
215 msgId: 'role_menubar', 215 msgId: 'role_menubar',
216 }, 216 },
217 menuItem: { 217 menuItem: {
218 msgId: 'role_menuitem' 218 msgId: 'role_menuitem',
219 earconId: 'BUTTON'
219 }, 220 },
220 menuItemCheckBox: { 221 menuItemCheckBox: {
221 msgId: 'role_menuitemcheckbox' 222 msgId: 'role_menuitemcheckbox',
223 earconId: 'BUTTON'
222 }, 224 },
223 menuItemRadio: { 225 menuItemRadio: {
224 msgId: 'role_menuitemradio' 226 msgId: 'role_menuitemradio',
227 earconId: 'BUTTON'
225 }, 228 },
226 menuListOption: { 229 menuListOption: {
227 msgId: 'role_menuitem' 230 msgId: 'role_menuitem'
228 }, 231 },
229 menuListPopup: { 232 menuListPopup: {
230 msgId: 'role_menu' 233 msgId: 'role_menu'
231 }, 234 },
232 navigation: { 235 navigation: {
233 msgId: 'role_navigation', 236 msgId: 'role_navigation',
234 inherits: 'abstractContainer' 237 inherits: 'abstractContainer'
235 }, 238 },
236 note: { 239 note: {
237 msgId: 'role_note', 240 msgId: 'role_note',
238 inherits: 'abstractContainer' 241 inherits: 'abstractContainer'
239 }, 242 },
240 popUpButton: { 243 popUpButton: {
241 msgId: 'role_button', 244 msgId: 'role_button',
242 earcon: 'LISTBOX'
243 }, 245 },
244 radioButton: { 246 radioButton: {
245 msgId: 'role_radio' 247 msgId: 'role_radio'
246 }, 248 },
247 radioGroup: { 249 radioGroup: {
248 msgId: 'role_radiogroup', 250 msgId: 'role_radiogroup',
249 }, 251 },
250 region: { 252 region: {
251 msgId: 'role_region', 253 msgId: 'role_region',
252 inherits: 'abstractContainer' 254 inherits: 'abstractContainer'
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 * off: {msgId: string, earconId: string}, 316 * off: {msgId: string, earconId: string},
315 * omitted: {msgId: string, earconId: string}}>} 317 * omitted: {msgId: string, earconId: string}}>}
316 * on: info used to describe a state that is set to true. 318 * 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. 319 * off: info used to describe a state that is set to false.
318 * omitted: info used to describe a state that is undefined. 320 * omitted: info used to describe a state that is undefined.
319 * @private 321 * @private
320 */ 322 */
321 Output.STATE_INFO_ = { 323 Output.STATE_INFO_ = {
322 checked: { 324 checked: {
323 on: { 325 on: {
324 earconId: 'CHECK_ON',
325 msgId: 'checkbox_checked_state' 326 msgId: 'checkbox_checked_state'
326 }, 327 },
327 off: { 328 off: {
328 earconId: 'CHECK_OFF',
329 msgId: 'checkbox_unchecked_state' 329 msgId: 'checkbox_unchecked_state'
330 }, 330 },
331 omitted: { 331 omitted: {
332 earconId: 'CHECK_OFF',
333 msgId: 'checkbox_unchecked_state' 332 msgId: 'checkbox_unchecked_state'
334 } 333 }
335 }, 334 },
336 collapsed: { 335 collapsed: {
337 on: { 336 on: {
338 msgId: 'aria_expanded_false' 337 msgId: 'aria_expanded_false'
339 }, 338 },
340 off: { 339 off: {
341 msgId: 'aria_expanded_true' 340 msgId: 'aria_expanded_true'
342 } 341 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 alert: { 387 alert: {
389 speak: '!doNotInterrupt $role $descendants' 388 speak: '!doNotInterrupt $role $descendants'
390 }, 389 },
391 alertDialog: { 390 alertDialog: {
392 enter: '$name $role $descendants' 391 enter: '$name $role $descendants'
393 }, 392 },
394 cell: { 393 cell: {
395 enter: '@column_granularity $tableCellColumnIndex' 394 enter: '@column_granularity $tableCellColumnIndex'
396 }, 395 },
397 checkBox: { 396 checkBox: {
398 speak: '$name $role $checked' 397 speak: '$if($checked, $earcon(CHECK_ON), $earcon(CHECK_OFF)) ' +
398 '$name $role $checked'
399 }, 399 },
400 dialog: { 400 dialog: {
401 enter: '$name $role' 401 enter: '$name $role'
402 }, 402 },
403 div: { 403 div: {
404 enter: '$name', 404 enter: '$name',
405 speak: '$name' 405 speak: '$name'
406 }, 406 },
407 grid: { 407 grid: {
408 enter: '$name $role' 408 enter: '$name $role'
(...skipping 30 matching lines...) Expand all
439 '@describe_index($indexInParent, $parentChildCount)' 439 '@describe_index($indexInParent, $parentChildCount)'
440 }, 440 },
441 menuListOption: { 441 menuListOption: {
442 speak: '$name $value @role_menuitem ' + 442 speak: '$name $value @role_menuitem ' +
443 '@describe_index($indexInParent, $parentChildCount)' 443 '@describe_index($indexInParent, $parentChildCount)'
444 }, 444 },
445 paragraph: { 445 paragraph: {
446 speak: '$descendants' 446 speak: '$descendants'
447 }, 447 },
448 popUpButton: { 448 popUpButton: {
449 speak: '$value $name $role @aria_has_popup ' + 449 speak: '$earcon(POP_UP_BUTTON) $value $name $role @aria_has_popup ' +
450 '$if($collapsed, @aria_expanded_false, @aria_expanded_true)' 450 '$if($collapsed, @aria_expanded_false, @aria_expanded_true)'
451 }, 451 },
452 radioButton: { 452 radioButton: {
453 speak: '$if($checked, @describe_radio_selected($name), ' + 453 speak: '$if($checked, @describe_radio_selected($name), ' +
454 '@describe_radio_unselected($name))' 454 '@describe_radio_unselected($name))'
455 }, 455 },
456 radioGroup: { 456 radioGroup: {
457 enter: '$name $role' 457 enter: '$name $role'
458 }, 458 },
459 rootWebArea: { 459 rootWebArea: {
460 enter: '$name' 460 enter: '$name'
461 }, 461 },
462 row: { 462 row: {
463 enter: '@row_granularity $tableRowIndex' 463 enter: '@row_granularity $tableRowIndex'
464 }, 464 },
465 slider: { 465 slider: {
466 speak: '@describe_slider($value, $name) $help' 466 speak: '$earcon(SLIDER) @describe_slider($value, $name) $help'
467 }, 467 },
468 staticText: { 468 staticText: {
469 speak: '$value=' 469 speak: '$value='
470 }, 470 },
471 tab: { 471 tab: {
472 speak: '@describe_tab($name)' 472 speak: '@describe_tab($name)'
473 }, 473 },
474 textField: { 474 textField: {
475 speak: '$name $value $if(' + 475 speak: '$name $value $if(' +
476 '$inputType, $inputType, $role)', 476 '$inputType, $inputType, $role)',
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 return this; 672 return this;
673 }, 673 },
674 674
675 /** 675 /**
676 * Executes all specified output. 676 * Executes all specified output.
677 */ 677 */
678 go: function() { 678 go: function() {
679 // Speech. 679 // Speech.
680 var queueMode = cvox.QueueMode.FLUSH; 680 var queueMode = cvox.QueueMode.FLUSH;
681 this.speechBuffer_.forEach(function(buff, i, a) { 681 this.speechBuffer_.forEach(function(buff, i, a) {
682 if (buff.toString()) { 682 (function() {
683 (function() { 683 var scopedBuff = buff;
684 var scopedBuff = buff; 684 this.speechProperties_['startCallback'] = function() {
685 this.speechProperties_['startCallback'] = function() { 685 var actions = scopedBuff.getSpansInstanceOf(Output.Action);
686 var actions = scopedBuff.getSpansInstanceOf(Output.Action); 686 if (actions) {
687 if (actions) { 687 actions.forEach(function(a) {
688 actions.forEach(function(a) { 688 a.run();
689 a.run(); 689 });
690 }); 690 }
691 } 691 };
692 }; 692 }.bind(this)());
693 }.bind(this)());
694 693
695 if (this.speechEndCallback_ && i == a.length - 1) 694 if (this.speechEndCallback_ && i == a.length - 1)
696 this.speechProperties_['endCallback'] = this.speechEndCallback_; 695 this.speechProperties_['endCallback'] = this.speechEndCallback_;
697 else 696 else
698 this.speechProperties_['endCallback'] = null; 697 this.speechProperties_['endCallback'] = null;
699 cvox.ChromeVox.tts.speak( 698 cvox.ChromeVox.tts.speak(
700 buff.toString(), queueMode, this.speechProperties_); 699 buff.toString(), queueMode, this.speechProperties_);
701 queueMode = cvox.QueueMode.QUEUE; 700 queueMode = cvox.QueueMode.QUEUE;
702 }
703 }.bind(this)); 701 }.bind(this));
704 702
705 // Braille. 703 // Braille.
706 if (this.brailleBuffer_.length) { 704 if (this.brailleBuffer_.length) {
707 var buff = this.createBrailleOutput_(); 705 var buff = this.createBrailleOutput_();
708 var selSpan = 706 var selSpan =
709 buff.getSpanInstanceOf(Output.SelectionSpan); 707 buff.getSpanInstanceOf(Output.SelectionSpan);
710 var startIndex = -1, endIndex = -1; 708 var startIndex = -1, endIndex = -1;
711 if (selSpan) { 709 if (selSpan) {
712 // Casts ok, since the span is known to be in the spannable. 710 // Casts ok, since the span is known to be in the spannable.
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 var cond = tree.firstChild; 947 var cond = tree.firstChild;
950 var attrib = cond.value.slice(1); 948 var attrib = cond.value.slice(1);
951 if (node[attrib] || node.state[attrib]) 949 if (node[attrib] || node.state[attrib])
952 this.format_(node, cond.nextSibling, buff); 950 this.format_(node, cond.nextSibling, buff);
953 else 951 else
954 this.format_(node, cond.nextSibling.nextSibling, buff); 952 this.format_(node, cond.nextSibling.nextSibling, buff);
955 } else if (token == 'earcon') { 953 } else if (token == 'earcon') {
956 // Ignore unless we're generating speech output. 954 // Ignore unless we're generating speech output.
957 if (!this.formatOptions_.speech) 955 if (!this.formatOptions_.speech)
958 return; 956 return;
959 // Assumes there's existing output in our buffer.
960 var lastBuff = buff[buff.length - 1];
961 if (!lastBuff)
962 return;
963 957
964 lastBuff.setSpan( 958 options.annotation.push(
965 new Output.EarconAction(tree.firstChild.value), 0, 0); 959 new Output.EarconAction(tree.firstChild.value), 0, 0);
960 this.append_(buff, '', options);
966 } else if (token == 'countChildren') { 961 } else if (token == 'countChildren') {
967 var role = tree.firstChild.value; 962 var role = tree.firstChild.value;
968 var count = node.children.filter(function(e) { 963 var count = node.children.filter(function(e) {
969 return e.role == role; 964 return e.role == role;
970 }).length; 965 }).length;
971 this.append_(buff, String(count)); 966 this.append_(buff, String(count));
972 } 967 }
973 } 968 }
974 } else if (prefix == '@') { 969 } else if (prefix == '@') {
975 var isPluralized = (token[0] == '@'); 970 var isPluralized = (token[0] == '@');
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
1320 elem.end); 1315 elem.end);
1321 }); 1316 });
1322 spansToRemove.forEach(result.removeSpan.bind(result)); 1317 spansToRemove.forEach(result.removeSpan.bind(result));
1323 separator = Output.SPACE; 1318 separator = Output.SPACE;
1324 }); 1319 });
1325 return result; 1320 return result;
1326 } 1321 }
1327 }; 1322 };
1328 1323
1329 }); // goog.scope 1324 }); // goog.scope
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698