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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 } | 369 } |
370 }, | 370 }, |
371 expanded: { | 371 expanded: { |
372 on: { | 372 on: { |
373 msgId: 'aria_expanded_true' | 373 msgId: 'aria_expanded_true' |
374 }, | 374 }, |
375 off: { | 375 off: { |
376 msgId: 'aria_expanded_false' | 376 msgId: 'aria_expanded_false' |
377 } | 377 } |
378 }, | 378 }, |
379 pressed: { | |
380 on: { | |
381 msgId: 'aria_pressed_true' | |
382 }, | |
383 off: { | |
384 msgId: 'aria_pressed_false' | |
385 }, | |
386 omitted: { | |
387 msgId: 'aria_pressed_false' | |
388 } | |
389 }, | |
390 visited: { | 379 visited: { |
391 on: { | 380 on: { |
392 msgId: 'visited_state' | 381 msgId: 'visited_state' |
393 } | 382 } |
394 } | 383 } |
395 }; | 384 }; |
396 | 385 |
397 /** | 386 /** |
398 * Maps input types to message IDs. | 387 * Maps input types to message IDs. |
399 * @const {Object<string>} | 388 * @const {Object<string>} |
(...skipping 14 matching lines...) Expand all Loading... |
414 * @type {!Object<Object<Object<string>>>} | 403 * @type {!Object<Object<Object<string>>>} |
415 */ | 404 */ |
416 Output.RULES = { | 405 Output.RULES = { |
417 navigate: { | 406 navigate: { |
418 'default': { | 407 'default': { |
419 speak: '$name $value $state $role $description', | 408 speak: '$name $value $state $role $description', |
420 braille: '' | 409 braille: '' |
421 }, | 410 }, |
422 abstractContainer: { | 411 abstractContainer: { |
423 enter: '$nameFromNode $role $state $description', | 412 enter: '$nameFromNode $role $state $description', |
424 speak: '$name $value $state $role $description', | |
425 leave: '@exited_container($role)' | 413 leave: '@exited_container($role)' |
426 }, | 414 }, |
427 alert: { | 415 alert: { |
428 speak: '!doNotInterrupt $role $descendants' | 416 speak: '!doNotInterrupt $role $descendants $state' |
429 }, | 417 }, |
430 alertDialog: { | 418 alertDialog: { |
431 enter: '$nameFromNode $role $description', | 419 enter: '$nameFromNode $role $description', |
432 speak: '$name $role $descendants' | 420 speak: '$name $role $descendants $state' |
433 }, | 421 }, |
434 cell: { | 422 cell: { |
435 enter: '@cell_summary($tableCellRowIndex, $tableCellColumnIndex) ' + | 423 enter: '@cell_summary($tableCellRowIndex, $tableCellColumnIndex) ' + |
436 '$node(tableColumnHeader)', | 424 '$node(tableColumnHeader)', |
437 speak: '@cell_summary($tableCellRowIndex, $tableCellColumnIndex) ' + | 425 speak: '@cell_summary($tableCellRowIndex, $tableCellColumnIndex) ' + |
438 '$node(tableColumnHeader)' | 426 '$node(tableColumnHeader) $state' |
439 }, | 427 }, |
440 checkBox: { | 428 checkBox: { |
441 speak: '$if($checked, $earcon(CHECK_ON), $earcon(CHECK_OFF)) ' + | 429 speak: '$if($checked, $earcon(CHECK_ON), $earcon(CHECK_OFF)) ' + |
442 '$name $role $checked $description' | 430 '$name $role $checked $description $state' |
443 }, | 431 }, |
444 date: { | 432 date: { |
445 enter: '$nameFromNode $role $description', | 433 enter: '$nameFromNode $role $description' |
446 speak: '$name $value $state $role $description' | |
447 }, | 434 }, |
448 dialog: { | 435 dialog: { |
449 enter: '$nameFromNode $role $description' | 436 enter: '$nameFromNode $role $description' |
450 }, | 437 }, |
451 div: { | 438 div: { |
452 enter: '$nameFromNode', | 439 enter: '$nameFromNode', |
453 speak: '$name $description $descendants' | 440 speak: '$name $description $descendants' |
454 }, | 441 }, |
455 grid: { | 442 grid: { |
456 enter: '$nameFromNode $role $description' | 443 enter: '$nameFromNode $role $description' |
457 }, | 444 }, |
458 group: { | 445 group: { |
459 enter: '$nameFromNode $state $description', | 446 enter: '$nameFromNode $state $description', |
460 speak: '$nameOrDescendants $value $state $description', | 447 speak: '$nameOrDescendants $value $state $description', |
461 leave: '' | 448 leave: '' |
462 }, | 449 }, |
463 heading: { | 450 heading: { |
464 enter: '!relativePitch(hierarchicalLevel) ' + | 451 enter: '!relativePitch(hierarchicalLevel) ' + |
465 '$nameFromNode= @tag_h+$hierarchicalLevel', | 452 '$nameFromNode= @tag_h+$hierarchicalLevel', |
466 speak: '!relativePitch(hierarchicalLevel)' + | 453 speak: '!relativePitch(hierarchicalLevel)' + |
467 ' $nameOrDescendants= @tag_h+$hierarchicalLevel' | 454 ' $nameOrDescendants= @tag_h+$hierarchicalLevel $state' |
468 }, | 455 }, |
469 inlineTextBox: { | 456 inlineTextBox: { |
470 speak: '$name=' | 457 speak: '$name=' |
471 }, | 458 }, |
472 inputTime: { | 459 inputTime: { |
473 enter: '$nameFromNode $role $description', | 460 enter: '$nameFromNode $role $description' |
474 speak: '$name $value $state $role $description' | |
475 }, | 461 }, |
476 link: { | 462 link: { |
477 enter: '$nameFromNode= $if($visited, @visited_link, $role)', | 463 enter: '$nameFromNode= $role $state' |
478 speak: '$name= $if($visited, @visited_link, $role) $description' | |
479 }, | 464 }, |
480 list: { | 465 list: { |
481 enter: '$role @@list_with_items($countChildren(listItem))' | 466 enter: '$role @@list_with_items($countChildren(listItem))' |
482 }, | 467 }, |
483 listBox: { | 468 listBox: { |
484 enter: '$nameFromNode ' + | 469 enter: '$nameFromNode ' + |
485 '$role @@list_with_items($countChildren(listBoxOption)) ' + | 470 '$role @@list_with_items($countChildren(listBoxOption)) ' + |
486 '$description' | 471 '$description' |
487 }, | 472 }, |
488 listBoxOption: { | 473 listBoxOption: { |
489 speak: '$name $role @describe_index($indexInParent, $parentChildCount) ' + | 474 speak: '$name $role @describe_index($indexInParent, $parentChildCount) ' + |
490 '$description' | 475 '$description $state' |
491 }, | 476 }, |
492 listItem: { | 477 listItem: { |
493 enter: '$role' | 478 enter: '$role' |
494 }, | 479 }, |
495 menu: { | 480 menu: { |
496 enter: '$name $role', | 481 enter: '$name $role', |
497 speak: '$name $role @@list_with_items($countChildren(menuItem))' | 482 speak: '$name $role @@list_with_items($countChildren(menuItem)) $state' |
498 }, | 483 }, |
499 menuItem: { | 484 menuItem: { |
500 speak: '$name $role $if($haspopup, @has_submenu) ' + | 485 speak: '$name $role $if($haspopup, @has_submenu) ' + |
501 '@describe_index($indexInParent, $parentChildCount) ' + | 486 '@describe_index($indexInParent, $parentChildCount) ' + |
502 '$description' | 487 '$description $state' |
503 }, | 488 }, |
504 menuItemCheckBox: { | 489 menuItemCheckBox: { |
505 speak: '$if($checked, $earcon(CHECK_ON), $earcon(CHECK_OFF)) ' + | 490 speak: '$if($checked, $earcon(CHECK_ON), $earcon(CHECK_OFF)) ' + |
506 '$name $role $checked $description ' + | 491 '$name $role $checked $description ' + |
507 '@describe_index($indexInParent, $parentChildCount) ' | 492 '@describe_index($indexInParent, $parentChildCount) ' |
508 }, | 493 }, |
509 menuItemRadio: { | 494 menuItemRadio: { |
510 speak: '$if($checked, $earcon(CHECK_ON), $earcon(CHECK_OFF)) ' + | 495 speak: '$if($checked, $earcon(CHECK_ON), $earcon(CHECK_OFF)) ' + |
511 '$if($checked, @describe_radio_selected($name), ' + | 496 '$if($checked, @describe_radio_selected($name), ' + |
512 '@describe_radio_unselected($name)) $description ' + | 497 '@describe_radio_unselected($name)) $description ' + |
513 '@describe_index($indexInParent, $parentChildCount) ' | 498 '@describe_index($indexInParent, $parentChildCount) ' |
514 }, | 499 }, |
515 menuListOption: { | 500 menuListOption: { |
516 speak: '$name @role_menuitem ' + | 501 speak: '$name @role_menuitem ' + |
517 '@describe_index($indexInParent, $parentChildCount) $description' | 502 '@describe_index($indexInParent, $parentChildCount) $description' |
518 }, | 503 }, |
519 paragraph: { | 504 paragraph: { |
520 speak: '$descendants' | 505 speak: '$descendants' |
521 }, | 506 }, |
522 popUpButton: { | 507 popUpButton: { |
523 speak: '$value $name $role @aria_has_popup ' + | 508 speak: '$value $name $role @aria_has_popup ' + |
524 '$if($collapsed, @aria_expanded_false, @aria_expanded_true) ' + | 509 '$state $description' |
525 '$description' | |
526 }, | 510 }, |
527 radioButton: { | 511 radioButton: { |
528 speak: '$if($checked, $earcon(CHECK_ON), $earcon(CHECK_OFF)) ' + | 512 speak: '$if($checked, $earcon(CHECK_ON), $earcon(CHECK_OFF)) ' + |
529 '$if($checked, @describe_radio_selected($name), ' + | 513 '$if($checked, @describe_radio_selected($name), ' + |
530 '@describe_radio_unselected($name)) $description' | 514 '@describe_radio_unselected($name)) $description' |
531 }, | 515 }, |
532 radioGroup: { | 516 radioGroup: { |
533 enter: '$name $role $description' | 517 enter: '$name $role $description' |
534 }, | 518 }, |
535 rootWebArea: { | 519 rootWebArea: { |
536 enter: '$name', | 520 enter: '$name', |
537 speak: '$if($name, $name, $docUrl)' | 521 speak: '$if($name, $name, $docUrl)' |
538 }, | 522 }, |
539 region: { | 523 region: { |
540 speak: '$descendants' | 524 speak: '$descendants' |
541 }, | 525 }, |
542 row: { | 526 row: { |
543 enter: '$node(tableRowHeader)' | 527 enter: '$node(tableRowHeader)' |
544 }, | 528 }, |
545 rowHeader: { | 529 rowHeader: { |
546 speak: '$descendants' | 530 speak: '$descendants $state' |
547 }, | 531 }, |
548 slider: { | 532 slider: { |
549 speak: '$earcon(SLIDER) @describe_slider($value, $name) $description' | 533 speak: '$earcon(SLIDER) @describe_slider($value, $name) $description ' + |
| 534 '$state' |
550 }, | 535 }, |
551 staticText: { | 536 staticText: { |
552 speak: '$name=' | 537 speak: '$name=' |
553 }, | 538 }, |
554 tab: { | 539 tab: { |
555 speak: '@describe_tab($name)' | 540 speak: '@describe_tab($name) $state $description' |
556 }, | 541 }, |
557 table: { | 542 table: { |
558 enter: '@table_summary($name, $tableRowCount, $tableColumnCount) ' + | 543 enter: '@table_summary($name, $tableRowCount, $tableColumnCount) ' + |
559 '$node(tableHeader)' | 544 '$node(tableHeader)' |
560 }, | 545 }, |
561 tableHeaderContainer: { | 546 tableHeaderContainer: { |
562 speak: '$descendants' | 547 speak: '$descendants $state $description' |
563 }, | 548 }, |
564 textField: { | 549 textField: { |
565 speak: '$name $value $if($multiline, @tag_textarea, $if(' + | 550 speak: '$name $value $if($multiline, @tag_textarea, $if(' + |
566 '$inputType, $inputType, $role)) $description $state', | 551 '$inputType, $inputType, $role)) $description $state', |
567 braille: '' | 552 braille: '' |
568 }, | 553 }, |
569 toggleButton: { | 554 toggleButton: { |
570 speak: '$if($pressed, $earcon(CHECK_ON), $earcon(CHECK_OFF)) ' + | 555 speak: '$if($pressed, $earcon(CHECK_ON), $earcon(CHECK_OFF)) ' + |
571 '$name $role $pressed $description' | 556 '$name $role ' + |
| 557 '$if($pressed, @aria_pressed_true, @aria_pressed_false) ' + |
| 558 '$description $state' |
572 }, | 559 }, |
573 toolbar: { | 560 toolbar: { |
574 enter: '$name $role $description' | 561 enter: '$name $role $description' |
575 }, | 562 }, |
576 tree: { | 563 tree: { |
577 enter: '$name $role @@list_with_items($countChildren(treeItem))' | 564 enter: '$name $role @@list_with_items($countChildren(treeItem))' |
578 }, | 565 }, |
579 treeItem: { | 566 treeItem: { |
580 enter: '$role $expanded $collapsed ' + | 567 enter: '$role $expanded $collapsed ' + |
581 '@describe_index($indexInParent, $parentChildCount) ' + | 568 '@describe_index($indexInParent, $parentChildCount) ' + |
582 '@describe_depth($hierarchicalLevel)', | 569 '@describe_depth($hierarchicalLevel)', |
583 speak: '$name ' + | 570 speak: '$name ' + |
584 '$role $expanded $collapsed ' + | 571 '$role $state ' + |
585 '@describe_index($indexInParent, $parentChildCount) ' + | 572 '@describe_index($indexInParent, $parentChildCount) ' + |
586 '@describe_depth($hierarchicalLevel)' | 573 '@describe_depth($hierarchicalLevel)' |
587 }, | 574 }, |
588 window: { | 575 window: { |
589 enter: '@describe_window($name)', | 576 enter: '@describe_window($name)', |
590 speak: '@describe_window($name) $earcon(OBJECT_OPEN)' | 577 speak: '@describe_window($name) $earcon(OBJECT_OPEN)' |
591 } | 578 } |
592 }, | 579 }, |
593 menuStart: { | 580 menuStart: { |
594 'default': { | 581 'default': { |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1112 } | 1099 } |
1113 } else if (token == 'parentChildCount') { | 1100 } else if (token == 'parentChildCount') { |
1114 if (node.parent) { | 1101 if (node.parent) { |
1115 options.annotation.push(token); | 1102 options.annotation.push(token); |
1116 var count = node.parent.children.filter(function(child) { | 1103 var count = node.parent.children.filter(function(child) { |
1117 return node.role == child.role; | 1104 return node.role == child.role; |
1118 }).length; | 1105 }).length; |
1119 this.append_(buff, String(count)); | 1106 this.append_(buff, String(count)); |
1120 } | 1107 } |
1121 } else if (token == 'state') { | 1108 } else if (token == 'state') { |
1122 options.annotation.push(token); | |
1123 Object.getOwnPropertyNames(node.state).forEach(function(s) { | 1109 Object.getOwnPropertyNames(node.state).forEach(function(s) { |
1124 var stateInfo = Output.STATE_INFO_[s]; | 1110 var stateInfo = Output.STATE_INFO_[s]; |
1125 if (stateInfo && stateInfo.on) | 1111 if (stateInfo && stateInfo.on) |
1126 this.append_(buff, Msgs.getMsg(stateInfo.on.msgId), options); | 1112 this.format_(node, '@' + stateInfo.on.msgId, buff); |
1127 }.bind(this)); | 1113 }.bind(this)); |
1128 } else if (token == 'find') { | 1114 } else if (token == 'find') { |
1129 // Find takes two arguments: JSON query string and format string. | 1115 // Find takes two arguments: JSON query string and format string. |
1130 if (tree.firstChild) { | 1116 if (tree.firstChild) { |
1131 var jsonQuery = tree.firstChild.value; | 1117 var jsonQuery = tree.firstChild.value; |
1132 node = node.find( | 1118 node = node.find( |
1133 /** @type {Object}*/(JSON.parse(jsonQuery))); | 1119 /** @type {Object}*/(JSON.parse(jsonQuery))); |
1134 var formatString = tree.firstChild.nextSibling; | 1120 var formatString = tree.firstChild.nextSibling; |
1135 if (node) | 1121 if (node) |
1136 this.format_(node, formatString, buff); | 1122 this.format_(node, formatString, buff); |
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1707 break; | 1693 break; |
1708 } | 1694 } |
1709 earconFinder = earconFinder.parent; | 1695 earconFinder = earconFinder.parent; |
1710 } | 1696 } |
1711 } | 1697 } |
1712 return null; | 1698 return null; |
1713 } | 1699 } |
1714 }; | 1700 }; |
1715 | 1701 |
1716 }); // goog.scope | 1702 }); // goog.scope |
OLD | NEW |