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

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

Issue 2446293002: Complete checked state announcements and clarify state usage (Closed)
Patch Set: Rebase tests. 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 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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 tree: { 336 tree: {
337 msgId: 'role_tree' 337 msgId: 'role_tree'
338 }, 338 },
339 treeItem: { 339 treeItem: {
340 msgId: 'role_treeitem' 340 msgId: 'role_treeitem'
341 } 341 }
342 }; 342 };
343 343
344 /** 344 /**
345 * Metadata about supported automation states. 345 * Metadata about supported automation states.
346 * @const {!Object<{on: {msgId: string, earconId: string}, 346 * @const {!Object<string, {on: {msgId: string, earconId: string},
347 * off: {msgId: string, earconId: string}, 347 * off: {msgId: string, earconId: string},
348 * omitted: {msgId: string, earconId: string}}>} 348 * isRoleSpecific: (boolean|undefined)}>}
349 * on: info used to describe a state that is set to true. 349 * on: info used to describe a state that is set to true.
350 * off: info used to describe a state that is set to false. 350 * off: info used to describe a state that is set to undefined.
351 * omitted: info used to describe a state that is undefined. 351 * isRoleSpecific: info used for specific roles.
352 * @private 352 * @private
353 */ 353 */
354 Output.STATE_INFO_ = { 354 Output.STATE_INFO_ = {
355 checked: { 355 busy: {on: {msgId: 'busy_state'}},
356 on: { 356 collapsed: {on: {msgId: 'aria_expanded_false'}},
357 msgId: 'checkbox_checked_state' 357 default: {on: {msgId: 'default_state'}},
358 }, 358 disabled: {on: {msgId: 'aria_disabled_true'}},
359 off: { 359 expanded: {on: {msgId: 'aria_expanded_true'}},
360 msgId: 'checkbox_unchecked_state' 360 multiselectable: {on: {msgId: 'aria_multiselectable_true'}},
361 }, 361 pressed: {
362 omitted: { 362 isRoleSpecific: true,
363 msgId: 'checkbox_unchecked_state' 363 on: {msgId: 'aria_pressed_true'},
364 } 364 off: {msgId: 'aria_pressed_false'}
365 }, 365 },
366 collapsed: { 366 required: {on: {msgId: 'aria_required_true'}},
367 on: { 367 selected: {on: {msgId: 'aria_selected_true'}},
368 msgId: 'aria_expanded_false' 368 visited: {on: {msgId: 'visited_state'}}
369 },
370 off: {
371 msgId: 'aria_expanded_true'
372 }
373 },
374 disabled: {
375 on: {
376 msgId: 'aria_disabled_true'
377 }
378 },
379 expanded: {
380 on: {
381 msgId: 'aria_expanded_true'
382 },
383 off: {
384 msgId: 'aria_expanded_false'
385 }
386 },
387 visited: {
388 on: {
389 msgId: 'visited_state'
390 }
391 }
392 }; 369 };
393 370
394 /** 371 /**
395 * Maps input types to message IDs. 372 * Maps input types to message IDs.
396 * @const {Object<string>} 373 * @const {Object<string>}
397 * @private 374 * @private
398 */ 375 */
399 Output.INPUT_TYPE_MESSAGE_IDS_ = { 376 Output.INPUT_TYPE_MESSAGE_IDS_ = {
400 'email': 'input_type_email', 377 'email': 'input_type_email',
401 'number': 'input_type_number', 378 'number': 'input_type_number',
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 textField: { 543 textField: {
567 speak: '$name $value $if($multiline, @tag_textarea, $if(' + 544 speak: '$name $value $if($multiline, @tag_textarea, $if(' +
568 '$inputType, $inputType, $role)) $description $state', 545 '$inputType, $inputType, $role)) $description $state',
569 braille: '' 546 braille: ''
570 }, 547 },
571 timer: { 548 timer: {
572 speak: '$nameFromNode $descendants $value $state $description' 549 speak: '$nameFromNode $descendants $value $state $description'
573 }, 550 },
574 toggleButton: { 551 toggleButton: {
575 speak: '$if($pressed, $earcon(CHECK_ON), $earcon(CHECK_OFF)) ' + 552 speak: '$if($pressed, $earcon(CHECK_ON), $earcon(CHECK_OFF)) ' +
576 '$name $role ' + 553 '$name $role $pressed $description $state'
577 '$if($pressed, @aria_pressed_true, @aria_pressed_false) ' +
578 '$description $state'
579 }, 554 },
580 toolbar: { 555 toolbar: {
581 enter: '$name $role $description' 556 enter: '$name $role $description'
582 }, 557 },
583 tree: { 558 tree: {
584 enter: '$name $role @@list_with_items($countChildren(treeItem))' 559 enter: '$name $role @@list_with_items($countChildren(treeItem))'
585 }, 560 },
586 treeItem: { 561 treeItem: {
587 enter: '$role $expanded $collapsed ' + 562 enter: '$role $expanded $collapsed ' +
588 '@describe_index($indexInParent, $parentChildCount) ' + 563 '@describe_index($indexInParent, $parentChildCount) ' +
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 this.append_(buff, String(count)); 1089 this.append_(buff, String(count));
1115 } 1090 }
1116 } else if (token == 'parentChildCount') { 1091 } else if (token == 'parentChildCount') {
1117 if (node.parent) { 1092 if (node.parent) {
1118 options.annotation.push(token); 1093 options.annotation.push(token);
1119 var count = node.parent.children.filter(function(child) { 1094 var count = node.parent.children.filter(function(child) {
1120 return node.role == child.role; 1095 return node.role == child.role;
1121 }).length; 1096 }).length;
1122 this.append_(buff, String(count)); 1097 this.append_(buff, String(count));
1123 } 1098 }
1099 } else if (token == 'checked') {
1100 var msg;
1101 var ariaChecked = node.htmlAttributes['aria-checked'];
1102 switch (ariaChecked) {
1103 case 'mixed':
1104 msg = 'aria_checked_mixed';
1105 break;
1106 case 'true':
1107 msg = 'aria_checked_true';
1108 break;
1109 case 'false':
1110 msg = 'aria_checked_false';
1111 break;
1112 default:
1113 msg =
1114 node.state.checked ? 'aria_checked_true' : 'aria_checked_false';
1115 }
1116 this.format_(node, '@' + msg, buff);
1124 } else if (token == 'state') { 1117 } else if (token == 'state') {
1125 Object.getOwnPropertyNames(node.state).forEach(function(s) { 1118 Object.getOwnPropertyNames(node.state).forEach(function(s) {
1126 var stateInfo = Output.STATE_INFO_[s]; 1119 var stateInfo = Output.STATE_INFO_[s];
1127 if (stateInfo && stateInfo.on) 1120 if (stateInfo && !stateInfo.isRoleSpecific && stateInfo.on)
1128 this.format_(node, '@' + stateInfo.on.msgId, buff); 1121 this.format_(node, '@' + stateInfo.on.msgId, buff);
1129 }.bind(this)); 1122 }.bind(this));
1130 } else if (token == 'find') { 1123 } else if (token == 'find') {
1131 // Find takes two arguments: JSON query string and format string. 1124 // Find takes two arguments: JSON query string and format string.
1132 if (tree.firstChild) { 1125 if (tree.firstChild) {
1133 var jsonQuery = tree.firstChild.value; 1126 var jsonQuery = tree.firstChild.value;
1134 node = node.find( 1127 node = node.find(
1135 /** @type {Object}*/(JSON.parse(jsonQuery))); 1128 /** @type {Object}*/(JSON.parse(jsonQuery)));
1136 var formatString = tree.firstChild.nextSibling; 1129 var formatString = tree.firstChild.nextSibling;
1137 if (node) 1130 if (node)
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1219 } else if (node[token] !== undefined) { 1212 } else if (node[token] !== undefined) {
1220 options.annotation.push(token); 1213 options.annotation.push(token);
1221 var value = node[token]; 1214 var value = node[token];
1222 if (typeof value == 'number') 1215 if (typeof value == 'number')
1223 value = String(value); 1216 value = String(value);
1224 this.append_(buff, value, options); 1217 this.append_(buff, value, options);
1225 } else if (Output.STATE_INFO_[token]) { 1218 } else if (Output.STATE_INFO_[token]) {
1226 options.annotation.push('state'); 1219 options.annotation.push('state');
1227 var stateInfo = Output.STATE_INFO_[token]; 1220 var stateInfo = Output.STATE_INFO_[token];
1228 var resolvedInfo = {}; 1221 var resolvedInfo = {};
1229 if (node.state[token] === undefined) 1222 resolvedInfo = node.state[token] ? stateInfo.on : stateInfo.off;
1230 resolvedInfo = stateInfo.omitted;
1231 else
1232 resolvedInfo = node.state[token] ? stateInfo.on : stateInfo.off;
1233 if (!resolvedInfo) 1223 if (!resolvedInfo)
1234 return; 1224 return;
1235 if (this.formatOptions_.speech && resolvedInfo.earconId) { 1225 if (this.formatOptions_.speech && resolvedInfo.earconId) {
1236 options.annotation.push( 1226 options.annotation.push(
1237 new Output.EarconAction(resolvedInfo.earconId)); 1227 new Output.EarconAction(resolvedInfo.earconId));
1238 } 1228 }
1239 var msgId = 1229 var msgId =
1240 this.formatOptions_.braille ? resolvedInfo.msgId + '_brl' : 1230 this.formatOptions_.braille ? resolvedInfo.msgId + '_brl' :
1241 resolvedInfo.msgId; 1231 resolvedInfo.msgId;
1242 var msg = Msgs.getMsg(msgId); 1232 var msg = Msgs.getMsg(msgId);
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
1771 /** 1761 /**
1772 * Gets the output buffer for braille. 1762 * Gets the output buffer for braille.
1773 * @return {!Spannable} 1763 * @return {!Spannable}
1774 */ 1764 */
1775 get brailleOutputForTest() { 1765 get brailleOutputForTest() {
1776 return this.createBrailleOutput_(); 1766 return this.createBrailleOutput_();
1777 } 1767 }
1778 }; 1768 };
1779 1769
1780 }); // goog.scope 1770 }); // goog.scope
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698