| 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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 * off: {msgId: string, earconId: string}, | 313 * off: {msgId: string, earconId: string}, |
| 314 * omitted: {msgId: string, earconId: string}}>} | 314 * omitted: {msgId: string, earconId: string}}>} |
| 315 * on: info used to describe a state that is set to true. | 315 * on: info used to describe a state that is set to true. |
| 316 * off: info used to describe a state that is set to false. | 316 * off: info used to describe a state that is set to false. |
| 317 * omitted: info used to describe a state that is undefined. | 317 * omitted: info used to describe a state that is undefined. |
| 318 * @private | 318 * @private |
| 319 */ | 319 */ |
| 320 Output.STATE_INFO_ = { | 320 Output.STATE_INFO_ = { |
| 321 checked: { | 321 checked: { |
| 322 on: { | 322 on: { |
| 323 earconId: 'CHECK_ON', | |
| 324 msgId: 'checkbox_checked_state' | 323 msgId: 'checkbox_checked_state' |
| 325 }, | 324 }, |
| 326 off: { | 325 off: { |
| 327 earconId: 'CHECK_OFF', | |
| 328 msgId: 'checkbox_unchecked_state' | 326 msgId: 'checkbox_unchecked_state' |
| 329 }, | 327 }, |
| 330 omitted: { | 328 omitted: { |
| 331 earconId: 'CHECK_OFF', | |
| 332 msgId: 'checkbox_unchecked_state' | 329 msgId: 'checkbox_unchecked_state' |
| 333 } | 330 } |
| 334 }, | 331 }, |
| 335 collapsed: { | 332 collapsed: { |
| 336 on: { | 333 on: { |
| 337 msgId: 'aria_expanded_false' | 334 msgId: 'aria_expanded_false' |
| 338 }, | 335 }, |
| 339 off: { | 336 off: { |
| 340 msgId: 'aria_expanded_true' | 337 msgId: 'aria_expanded_true' |
| 341 } | 338 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 372 alert: { | 369 alert: { |
| 373 speak: '!doNotInterrupt $role $descendants' | 370 speak: '!doNotInterrupt $role $descendants' |
| 374 }, | 371 }, |
| 375 alertDialog: { | 372 alertDialog: { |
| 376 enter: '$name $role $descendants' | 373 enter: '$name $role $descendants' |
| 377 }, | 374 }, |
| 378 cell: { | 375 cell: { |
| 379 enter: '@column_granularity $tableCellColumnIndex' | 376 enter: '@column_granularity $tableCellColumnIndex' |
| 380 }, | 377 }, |
| 381 checkBox: { | 378 checkBox: { |
| 382 speak: '$name $role $checked' | 379 speak: '$if($checked, $earcon(CHECK_ON), $earcon(CHECK_OFF)) ' + |
| 380 '$name $role $checked' |
| 383 }, | 381 }, |
| 384 dialog: { | 382 dialog: { |
| 385 enter: '$name $role' | 383 enter: '$name $role' |
| 386 }, | 384 }, |
| 387 grid: { | 385 grid: { |
| 388 enter: '$name $role' | 386 enter: '$name $role' |
| 389 }, | 387 }, |
| 390 heading: { | 388 heading: { |
| 391 enter: '@tag_h+$hierarchicalLevel', | 389 enter: '@tag_h+$hierarchicalLevel', |
| 392 speak: '@tag_h+$hierarchicalLevel $nameOrDescendants=' | 390 speak: '@tag_h+$hierarchicalLevel $nameOrDescendants=' |
| (...skipping 26 matching lines...) Expand all Loading... |
| 419 '@describe_index($indexInParent, $parentChildCount)' | 417 '@describe_index($indexInParent, $parentChildCount)' |
| 420 }, | 418 }, |
| 421 menuListOption: { | 419 menuListOption: { |
| 422 speak: '$name $value @aria_role_menuitem ' + | 420 speak: '$name $value @aria_role_menuitem ' + |
| 423 '@describe_index($indexInParent, $parentChildCount)' | 421 '@describe_index($indexInParent, $parentChildCount)' |
| 424 }, | 422 }, |
| 425 paragraph: { | 423 paragraph: { |
| 426 speak: '$descendants' | 424 speak: '$descendants' |
| 427 }, | 425 }, |
| 428 popUpButton: { | 426 popUpButton: { |
| 429 speak: '$value $name $role @aria_has_popup ' + | 427 speak: '$EARCON(POP_UP_BUTTON) $value $name $role @aria_has_popup ' + |
| 430 '$if($collapsed, @aria_expanded_false, @aria_expanded_true)' | 428 '$if($collapsed, @aria_expanded_false, @aria_expanded_true)' |
| 431 }, | 429 }, |
| 432 radioButton: { | 430 radioButton: { |
| 433 speak: '$if($checked, @describe_radio_selected($name), ' + | 431 speak: '$if($checked, @describe_radio_selected($name), ' + |
| 434 '@describe_radio_unselected($name))' | 432 '@describe_radio_unselected($name))' |
| 435 }, | 433 }, |
| 436 radioGroup: { | 434 radioGroup: { |
| 437 enter: '$name $role' | 435 enter: '$name $role' |
| 438 }, | 436 }, |
| 439 rootWebArea: { | 437 rootWebArea: { |
| 440 enter: '$name' | 438 enter: '$name' |
| 441 }, | 439 }, |
| 442 row: { | 440 row: { |
| 443 enter: '@row_granularity $tableRowIndex' | 441 enter: '@row_granularity $tableRowIndex' |
| 444 }, | 442 }, |
| 445 slider: { | 443 slider: { |
| 446 speak: '@describe_slider($value, $name) $help' | 444 speak: '$earcon(SLIDER) @describe_slider($value, $name) $help' |
| 447 }, | 445 }, |
| 448 staticText: { | 446 staticText: { |
| 449 speak: '$value $name' | 447 speak: '$value $name' |
| 450 }, | 448 }, |
| 451 tab: { | 449 tab: { |
| 452 speak: '@describe_tab($name)' | 450 speak: '@describe_tab($name)' |
| 453 }, | 451 }, |
| 454 textField: { | 452 textField: { |
| 455 speak: '$name $value $if(' + | 453 speak: '$name $value $if(' + |
| 456 '$inputType, @input_type_+$inputType, @input_type_text)', | 454 '$inputType, @input_type_+$inputType, @input_type_text)', |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 return this; | 652 return this; |
| 655 }, | 653 }, |
| 656 | 654 |
| 657 /** | 655 /** |
| 658 * Executes all specified output. | 656 * Executes all specified output. |
| 659 */ | 657 */ |
| 660 go: function() { | 658 go: function() { |
| 661 // Speech. | 659 // Speech. |
| 662 var queueMode = cvox.QueueMode.FLUSH; | 660 var queueMode = cvox.QueueMode.FLUSH; |
| 663 this.speechBuffer_.forEach(function(buff, i, a) { | 661 this.speechBuffer_.forEach(function(buff, i, a) { |
| 664 if (buff.toString()) { | 662 (function() { |
| 665 (function() { | 663 var scopedBuff = buff; |
| 666 var scopedBuff = buff; | 664 this.speechProperties_['startCallback'] = function() { |
| 667 this.speechProperties_['startCallback'] = function() { | 665 var actions = scopedBuff.getSpansInstanceOf(Output.Action); |
| 668 var actions = scopedBuff.getSpansInstanceOf(Output.Action); | 666 if (actions) { |
| 669 if (actions) { | 667 actions.forEach(function(a) { |
| 670 actions.forEach(function(a) { | 668 a.run(); |
| 671 a.run(); | 669 }); |
| 672 }); | 670 } |
| 673 } | 671 }; |
| 674 }; | 672 }.bind(this)()); |
| 675 }.bind(this)()); | |
| 676 | 673 |
| 677 if (this.speechEndCallback_ && i == a.length - 1) | 674 if (this.speechEndCallback_ && i == a.length - 1) |
| 678 this.speechProperties_['endCallback'] = this.speechEndCallback_; | 675 this.speechProperties_['endCallback'] = this.speechEndCallback_; |
| 679 else | 676 else |
| 680 this.speechProperties_['endCallback'] = null; | 677 this.speechProperties_['endCallback'] = null; |
| 681 cvox.ChromeVox.tts.speak( | 678 cvox.ChromeVox.tts.speak( |
| 682 buff.toString(), queueMode, this.speechProperties_); | 679 buff.toString(), queueMode, this.speechProperties_); |
| 683 queueMode = cvox.QueueMode.QUEUE; | 680 queueMode = cvox.QueueMode.QUEUE; |
| 684 } | |
| 685 }.bind(this)); | 681 }.bind(this)); |
| 686 | 682 |
| 687 // Braille. | 683 // Braille. |
| 688 if (this.brailleBuffer_.length) { | 684 if (this.brailleBuffer_.length) { |
| 689 var buff = this.createBrailleOutput_(); | 685 var buff = this.createBrailleOutput_(); |
| 690 var selSpan = | 686 var selSpan = |
| 691 buff.getSpanInstanceOf(Output.SelectionSpan); | 687 buff.getSpanInstanceOf(Output.SelectionSpan); |
| 692 var startIndex = -1, endIndex = -1; | 688 var startIndex = -1, endIndex = -1; |
| 693 if (selSpan) { | 689 if (selSpan) { |
| 694 // Casts ok, since the span is known to be in the spannable. | 690 // Casts ok, since the span is known to be in the spannable. |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 921 var cond = tree.firstChild; | 917 var cond = tree.firstChild; |
| 922 var attrib = cond.value.slice(1); | 918 var attrib = cond.value.slice(1); |
| 923 if (node[attrib] || node.state[attrib]) | 919 if (node[attrib] || node.state[attrib]) |
| 924 this.format_(node, cond.nextSibling, buff); | 920 this.format_(node, cond.nextSibling, buff); |
| 925 else | 921 else |
| 926 this.format_(node, cond.nextSibling.nextSibling, buff); | 922 this.format_(node, cond.nextSibling.nextSibling, buff); |
| 927 } else if (token == 'earcon') { | 923 } else if (token == 'earcon') { |
| 928 // Ignore unless we're generating speech output. | 924 // Ignore unless we're generating speech output. |
| 929 if (!this.formatOptions_.speech) | 925 if (!this.formatOptions_.speech) |
| 930 return; | 926 return; |
| 931 // Assumes there's existing output in our buffer. | |
| 932 var lastBuff = buff[buff.length - 1]; | |
| 933 if (!lastBuff) | |
| 934 return; | |
| 935 | 927 |
| 936 lastBuff.setSpan( | 928 options.annotation.push( |
| 937 new Output.EarconAction(tree.firstChild.value), 0, 0); | 929 new Output.EarconAction(tree.firstChild.value), 0, 0); |
| 930 this.append_(buff, '', options); |
| 938 } else if (token == 'countChildren') { | 931 } else if (token == 'countChildren') { |
| 939 var role = tree.firstChild.value; | 932 var role = tree.firstChild.value; |
| 940 var count = node.children.filter(function(e) { | 933 var count = node.children.filter(function(e) { |
| 941 return e.role == role; | 934 return e.role == role; |
| 942 }).length; | 935 }).length; |
| 943 this.append_(buff, String(count)); | 936 this.append_(buff, String(count)); |
| 944 } | 937 } |
| 945 } | 938 } |
| 946 } else if (prefix == '@') { | 939 } else if (prefix == '@') { |
| 947 var isPluralized = (token[0] == '@'); | 940 var isPluralized = (token[0] == '@'); |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1292 elem.end); | 1285 elem.end); |
| 1293 }); | 1286 }); |
| 1294 spansToRemove.forEach(result.removeSpan.bind(result)); | 1287 spansToRemove.forEach(result.removeSpan.bind(result)); |
| 1295 separator = Output.SPACE; | 1288 separator = Output.SPACE; |
| 1296 }); | 1289 }); |
| 1297 return result; | 1290 return result; |
| 1298 } | 1291 } |
| 1299 }; | 1292 }; |
| 1300 | 1293 |
| 1301 }); // goog.scope | 1294 }); // goog.scope |
| OLD | NEW |