| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 ChromeVox commands. | 6 * @fileoverview ChromeVox commands. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 goog.provide('CommandHandler'); | 9 goog.provide('CommandHandler'); |
| 10 | 10 |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 if (!ChromeVoxState.instance.currentRange_) | 191 if (!ChromeVoxState.instance.currentRange_) |
| 192 return true; | 192 return true; |
| 193 | 193 |
| 194 // Next/compat commands hereafter. | 194 // Next/compat commands hereafter. |
| 195 if (ChromeVoxState.instance.mode == ChromeVoxMode.CLASSIC) return true; | 195 if (ChromeVoxState.instance.mode == ChromeVoxMode.CLASSIC) return true; |
| 196 | 196 |
| 197 var current = ChromeVoxState.instance.currentRange_; | 197 var current = ChromeVoxState.instance.currentRange_; |
| 198 var dir = Dir.FORWARD; | 198 var dir = Dir.FORWARD; |
| 199 var pred = null; | 199 var pred = null; |
| 200 var predErrorMsg = undefined; | 200 var predErrorMsg = undefined; |
| 201 var rootPred = AutomationPredicate.root; |
| 201 var speechProps = {}; | 202 var speechProps = {}; |
| 202 switch (command) { | 203 switch (command) { |
| 203 case 'nextCharacter': | 204 case 'nextCharacter': |
| 204 speechProps['phoneticCharacters'] = true; | 205 speechProps['phoneticCharacters'] = true; |
| 205 current = current.move(cursors.Unit.CHARACTER, Dir.FORWARD); | 206 current = current.move(cursors.Unit.CHARACTER, Dir.FORWARD); |
| 206 break; | 207 break; |
| 207 case 'previousCharacter': | 208 case 'previousCharacter': |
| 208 speechProps['phoneticCharacters'] = true; | 209 speechProps['phoneticCharacters'] = true; |
| 209 current = current.move(cursors.Unit.CHARACTER, Dir.BACKWARD); | 210 current = current.move(cursors.Unit.CHARACTER, Dir.BACKWARD); |
| 210 break; | 211 break; |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 new cursors.Cursor(root.focusObject, root.focusOffset)); | 460 new cursors.Cursor(root.focusObject, root.focusOffset)); |
| 460 var o = new Output() | 461 var o = new Output() |
| 461 .format('@end_selection') | 462 .format('@end_selection') |
| 462 .withSpeechAndBraille(sel, sel, Output.EventType.NAVIGATE) | 463 .withSpeechAndBraille(sel, sel, Output.EventType.NAVIGATE) |
| 463 .go(); | 464 .go(); |
| 464 } | 465 } |
| 465 ChromeVoxState.instance.pageSel_ = null; | 466 ChromeVoxState.instance.pageSel_ = null; |
| 466 return false; | 467 return false; |
| 467 } | 468 } |
| 468 break; | 469 break; |
| 470 case 'fullyDescribe': |
| 471 var o = new Output(); |
| 472 o.withContextFirst() |
| 473 .withRichSpeechAndBraille(current, null, Output.EventType.NAVIGATE) |
| 474 .go(); |
| 475 return false; |
| 476 |
| 477 // Table commands. |
| 478 case 'previousRow': |
| 479 dir = Dir.BACKWARD; |
| 480 var tableOpts = {row: true, dir: dir}; |
| 481 pred = AutomationPredicate.makeTableCellPredicate( |
| 482 current.start.node, tableOpts); |
| 483 predErrorMsg = 'no_cell_above'; |
| 484 rootPred = AutomationPredicate.table; |
| 485 break; |
| 486 case 'previousCol': |
| 487 dir = Dir.BACKWARD; |
| 488 var tableOpts = {col: true, dir: dir}; |
| 489 pred = AutomationPredicate.makeTableCellPredicate( |
| 490 current.start.node, tableOpts); |
| 491 predErrorMsg = 'no_cell_left'; |
| 492 rootPred = AutomationPredicate.row; |
| 493 break; |
| 494 case 'nextRow': |
| 495 dir = Dir.FORWARD; |
| 496 var tableOpts = {row: true, dir: dir}; |
| 497 pred = AutomationPredicate.makeTableCellPredicate( |
| 498 current.start.node, tableOpts); |
| 499 predErrorMsg = 'no_cell_below'; |
| 500 rootPred = AutomationPredicate.table; |
| 501 break; |
| 502 case 'nextCol': |
| 503 dir = Dir.FORWARD; |
| 504 var tableOpts = {col: true, dir: dir}; |
| 505 pred = AutomationPredicate.makeTableCellPredicate( |
| 506 current.start.node, tableOpts); |
| 507 predErrorMsg = 'no_cell_right'; |
| 508 rootPred = AutomationPredicate.row; |
| 509 break; |
| 510 case 'goToRowFirstCell': |
| 511 case 'goToRowLastCell': |
| 512 var node = current.start.node; |
| 513 while (node && node.role != RoleType.row) |
| 514 node = node.parent; |
| 515 if (!node) |
| 516 break; |
| 517 var end = AutomationUtil.findNodePost(node, |
| 518 command == 'goToRowLastCell' ? Dir.BACKWARD : Dir.FORWARD, |
| 519 AutomationPredicate.leaf); |
| 520 if (end) |
| 521 current = cursors.Range.fromNode(end); |
| 522 break; |
| 523 case 'goToColFirstCell': |
| 524 dir = Dir.FORWARD; |
| 525 var node = current.start.node; |
| 526 while (node && node.role != RoleType.table) |
| 527 node = node.parent; |
| 528 if (!node || !node.firstChild) |
| 529 return false; |
| 530 var tableOpts = {col: true, dir: dir, end: true}; |
| 531 pred = AutomationPredicate.makeTableCellPredicate( |
| 532 current.start.node, tableOpts); |
| 533 current = cursors.Range.fromNode(node.firstChild); |
| 534 // Should not be outputted. |
| 535 predErrorMsg = 'no_cell_above'; |
| 536 rootPred = AutomationPredicate.table; |
| 537 break; |
| 538 case 'goToColLastCell': |
| 539 dir = Dir.BACKWARD; |
| 540 var node = current.start.node; |
| 541 while (node && node.role != RoleType.table) |
| 542 node = node.parent; |
| 543 if (!node || !node.lastChild) |
| 544 return false; |
| 545 var tableOpts = {col: true, dir: dir, end: true}; |
| 546 pred = AutomationPredicate.makeTableCellPredicate( |
| 547 current.start.node, tableOpts); |
| 548 current = cursors.Range.fromNode(node.lastChild); |
| 549 // Should not be outputted. |
| 550 predErrorMsg = 'no_cell_below'; |
| 551 rootPred = AutomationPredicate.table; |
| 552 break; |
| 553 case 'goToFirstCell': |
| 554 case 'goToLastCell': |
| 555 node = current.start.node; |
| 556 while (node && node.role != RoleType.table) |
| 557 node = node.parent; |
| 558 if (!node) |
| 559 break; |
| 560 var end = AutomationUtil.findNodePost(node, |
| 561 command == 'goToLastCell' ? Dir.BACKWARD : Dir.FORWARD, |
| 562 AutomationPredicate.leaf); |
| 563 if (end) |
| 564 current = cursors.Range.fromNode(end); |
| 565 break; |
| 469 default: | 566 default: |
| 470 return true; | 567 return true; |
| 471 } | 568 } |
| 472 | 569 |
| 473 if (pred) { | 570 if (pred) { |
| 474 var bound = current.getBound(dir).node; | 571 var bound = current.getBound(dir).node; |
| 475 if (bound) { | 572 if (bound) { |
| 476 var node = AutomationUtil.findNextNode( | 573 var node = AutomationUtil.findNextNode( |
| 477 bound, dir, pred, {skipInitialAncestry: true}); | 574 bound, dir, pred, {skipInitialAncestry: true}); |
| 478 | 575 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 break; | 640 break; |
| 544 } | 641 } |
| 545 if (announcement) { | 642 if (announcement) { |
| 546 cvox.ChromeVox.tts.speak( | 643 cvox.ChromeVox.tts.speak( |
| 547 announcement, cvox.QueueMode.FLUSH, | 644 announcement, cvox.QueueMode.FLUSH, |
| 548 cvox.AbstractTts.PERSONALITY_ANNOTATION); | 645 cvox.AbstractTts.PERSONALITY_ANNOTATION); |
| 549 } | 646 } |
| 550 }; | 647 }; |
| 551 | 648 |
| 552 }); // goog.scope | 649 }); // goog.scope |
| OLD | NEW |