| OLD | NEW |
| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 /** | 91 /** |
| 92 * Delimiter to use between output values. | 92 * Delimiter to use between output values. |
| 93 * @type {string} | 93 * @type {string} |
| 94 */ | 94 */ |
| 95 Output.SPACE = ' '; | 95 Output.SPACE = ' '; |
| 96 | 96 |
| 97 /** | 97 /** |
| 98 * Metadata about supported automation roles. | 98 * Metadata about supported automation roles. |
| 99 * @const {Object<{msgId: string, | 99 * @const {Object<{msgId: string, |
| 100 * earconId: (string|undefined), | 100 * earconId: (string|undefined), |
| 101 * inherits: (string|undefined)}>} | 101 * inherits: (string|undefined), |
| 102 * ignoreAncestry: (boolean|undefined)}>} |
| 102 * msgId: the message id of the role. | 103 * msgId: the message id of the role. |
| 103 * earconId: an optional earcon to play when encountering the role. | 104 * earconId: an optional earcon to play when encountering the role. |
| 104 * inherits: inherits rules from this role. | 105 * inherits: inherits rules from this role. |
| 106 * ignoreAncestry: don't output ancestry changes when encountering this role. |
| 105 * @private | 107 * @private |
| 106 */ | 108 */ |
| 107 Output.ROLE_INFO_ = { | 109 Output.ROLE_INFO_ = { |
| 108 alert: { | 110 alert: { |
| 109 msgId: 'role_alert', | 111 msgId: 'role_alert', |
| 110 earconId: 'ALERT_NONMODAL' | 112 earconId: 'ALERT_NONMODAL' |
| 111 }, | 113 }, |
| 112 alertDialog: { | 114 alertDialog: { |
| 113 msgId: 'role_alertdialog' | 115 msgId: 'role_alertdialog' |
| 114 }, | 116 }, |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 inherits: 'abstractContainer' | 218 inherits: 'abstractContainer' |
| 217 }, | 219 }, |
| 218 marquee: { | 220 marquee: { |
| 219 msgId: 'role_marquee', | 221 msgId: 'role_marquee', |
| 220 }, | 222 }, |
| 221 math: { | 223 math: { |
| 222 msgId: 'role_math', | 224 msgId: 'role_math', |
| 223 inherits: 'abstractContainer' | 225 inherits: 'abstractContainer' |
| 224 }, | 226 }, |
| 225 menu: { | 227 menu: { |
| 226 msgId: 'role_menu', | 228 msgId: 'role_menu' |
| 227 earconId: 'LISTBOX', | |
| 228 }, | 229 }, |
| 229 menuBar: { | 230 menuBar: { |
| 230 msgId: 'role_menubar', | 231 msgId: 'role_menubar', |
| 231 }, | 232 }, |
| 232 menuItem: { | 233 menuItem: { |
| 233 msgId: 'role_menuitem', | 234 msgId: 'role_menuitem', |
| 234 earconId: 'BUTTON' | 235 ignoreAncestry: true |
| 235 }, | 236 }, |
| 236 menuItemCheckBox: { | 237 menuItemCheckBox: { |
| 237 msgId: 'role_menuitemcheckbox', | 238 msgId: 'role_menuitemcheckbox', |
| 238 earconId: 'BUTTON' | 239 ignoreAncestry: true |
| 239 }, | 240 }, |
| 240 menuItemRadio: { | 241 menuItemRadio: { |
| 241 msgId: 'role_menuitemradio', | 242 msgId: 'role_menuitemradio', |
| 242 earconId: 'BUTTON' | 243 ignoreAncestry: true |
| 243 }, | 244 }, |
| 244 menuListOption: { | 245 menuListOption: { |
| 245 msgId: 'role_menuitem' | 246 msgId: 'role_menuitem', |
| 247 ignoreAncestry: true |
| 246 }, | 248 }, |
| 247 menuListPopup: { | 249 menuListPopup: { |
| 248 msgId: 'role_menu' | 250 msgId: 'role_menu' |
| 249 }, | 251 }, |
| 250 navigation: { | 252 navigation: { |
| 251 msgId: 'role_navigation', | 253 msgId: 'role_navigation', |
| 252 inherits: 'abstractContainer' | 254 inherits: 'abstractContainer' |
| 253 }, | 255 }, |
| 254 note: { | 256 note: { |
| 255 msgId: 'role_note', | 257 msgId: 'role_note', |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 }, | 467 }, |
| 466 menu: { | 468 menu: { |
| 467 enter: '$name $role', | 469 enter: '$name $role', |
| 468 speak: '$name $role @@list_with_items($countChildren(menuItem))' | 470 speak: '$name $role @@list_with_items($countChildren(menuItem))' |
| 469 }, | 471 }, |
| 470 menuItem: { | 472 menuItem: { |
| 471 speak: '$name $role $if($haspopup, @has_submenu) ' + | 473 speak: '$name $role $if($haspopup, @has_submenu) ' + |
| 472 '@describe_index($indexInParent, $parentChildCount) ' + | 474 '@describe_index($indexInParent, $parentChildCount) ' + |
| 473 '$description' | 475 '$description' |
| 474 }, | 476 }, |
| 477 menuItemCheckBox: { |
| 478 speak: '$if($checked, $earcon(CHECK_ON), $earcon(CHECK_OFF)) ' + |
| 479 '$name $role $checked $description ' + |
| 480 '@describe_index($indexInParent, $parentChildCount) ' |
| 481 }, |
| 482 menuItemRadio: { |
| 483 speak: '$if($checked, $earcon(CHECK_ON), $earcon(CHECK_OFF)) ' + |
| 484 '$if($checked, @describe_radio_selected($name), ' + |
| 485 '@describe_radio_unselected($name)) $description ' + |
| 486 '@describe_index($indexInParent, $parentChildCount) ' |
| 487 }, |
| 475 menuListOption: { | 488 menuListOption: { |
| 476 speak: '$name @role_menuitem ' + | 489 speak: '$name @role_menuitem ' + |
| 477 '@describe_index($indexInParent, $parentChildCount) $description' | 490 '@describe_index($indexInParent, $parentChildCount) $description' |
| 478 }, | 491 }, |
| 479 paragraph: { | 492 paragraph: { |
| 480 speak: '$descendants' | 493 speak: '$descendants' |
| 481 }, | 494 }, |
| 482 popUpButton: { | 495 popUpButton: { |
| 483 speak: '$value $name $role @aria_has_popup ' + | 496 speak: '$value $name $role @aria_has_popup ' + |
| 484 '$if($collapsed, @aria_expanded_false, @aria_expanded_true) ' + | 497 '$if($collapsed, @aria_expanded_false, @aria_expanded_true) ' + |
| 485 '$description' | 498 '$description' |
| 486 }, | 499 }, |
| 487 radioButton: { | 500 radioButton: { |
| 488 speak: '$if($checked, @describe_radio_selected($name), ' + | 501 speak: '$if($checked, $earcon(CHECK_ON), $earcon(CHECK_OFF)) ' + |
| 502 '$if($checked, @describe_radio_selected($name), ' + |
| 489 '@describe_radio_unselected($name)) $description' | 503 '@describe_radio_unselected($name)) $description' |
| 490 }, | 504 }, |
| 491 radioGroup: { | 505 radioGroup: { |
| 492 enter: '$name $role $description' | 506 enter: '$name $role $description' |
| 493 }, | 507 }, |
| 494 rootWebArea: { | 508 rootWebArea: { |
| 495 enter: '$name', | 509 enter: '$name', |
| 496 speak: '$if($name, $name, $docUrl)' | 510 speak: '$if($name, $name, $docUrl)' |
| 497 }, | 511 }, |
| 498 region: { | 512 region: { |
| (...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1313 }, | 1327 }, |
| 1314 | 1328 |
| 1315 /** | 1329 /** |
| 1316 * @param {!AutomationNode} node | 1330 * @param {!AutomationNode} node |
| 1317 * @param {!AutomationNode} prevNode | 1331 * @param {!AutomationNode} prevNode |
| 1318 * @param {EventType|Output.EventType} type | 1332 * @param {EventType|Output.EventType} type |
| 1319 * @param {!Array<Spannable>} buff | 1333 * @param {!Array<Spannable>} buff |
| 1320 * @private | 1334 * @private |
| 1321 */ | 1335 */ |
| 1322 ancestry_: function(node, prevNode, type, buff) { | 1336 ancestry_: function(node, prevNode, type, buff) { |
| 1337 // Check to see if ancestry output is ignored. |
| 1338 if (Output.ROLE_INFO_[node.role] && |
| 1339 Output.ROLE_INFO_[node.role].ignoreAncestry) |
| 1340 return; |
| 1341 |
| 1323 var prevUniqueAncestors = | 1342 var prevUniqueAncestors = |
| 1324 AutomationUtil.getUniqueAncestors(node, prevNode); | 1343 AutomationUtil.getUniqueAncestors(node, prevNode); |
| 1325 var uniqueAncestors = AutomationUtil.getUniqueAncestors(prevNode, node); | 1344 var uniqueAncestors = AutomationUtil.getUniqueAncestors(prevNode, node); |
| 1326 | 1345 |
| 1327 // First, look up the event type's format block. | 1346 // First, look up the event type's format block. |
| 1328 // Navigate is the default event. | 1347 // Navigate is the default event. |
| 1329 var eventBlock = Output.RULES[type] || Output.RULES['navigate']; | 1348 var eventBlock = Output.RULES[type] || Output.RULES['navigate']; |
| 1330 | 1349 |
| 1331 var getMergedRoleBlock = function(role) { | 1350 var getMergedRoleBlock = function(role) { |
| 1332 var parentRole = (Output.ROLE_INFO_[role] || {}).inherits; | 1351 var parentRole = (Output.ROLE_INFO_[role] || {}).inherits; |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1623 break; | 1642 break; |
| 1624 } | 1643 } |
| 1625 earconFinder = earconFinder.parent; | 1644 earconFinder = earconFinder.parent; |
| 1626 } | 1645 } |
| 1627 } | 1646 } |
| 1628 return null; | 1647 return null; |
| 1629 } | 1648 } |
| 1630 }; | 1649 }; |
| 1631 | 1650 |
| 1632 }); // goog.scope | 1651 }); // goog.scope |
| OLD | NEW |