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

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

Issue 2380073005: Support group and wrapping navigation. (Closed)
Patch Set: Update test expectations. Created 4 years, 2 months 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 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 rootPred = AutomationPredicate.root;
202 var speechProps = {}; 202 var speechProps = {};
203 var skipSync = false;
203 switch (command) { 204 switch (command) {
204 case 'nextCharacter': 205 case 'nextCharacter':
205 speechProps['phoneticCharacters'] = true; 206 speechProps['phoneticCharacters'] = true;
206 current = current.move(cursors.Unit.CHARACTER, Dir.FORWARD); 207 current = current.move(cursors.Unit.CHARACTER, Dir.FORWARD);
207 break; 208 break;
208 case 'previousCharacter': 209 case 'previousCharacter':
209 speechProps['phoneticCharacters'] = true; 210 speechProps['phoneticCharacters'] = true;
210 current = current.move(cursors.Unit.CHARACTER, Dir.BACKWARD); 211 current = current.move(cursors.Unit.CHARACTER, Dir.BACKWARD);
211 break; 212 break;
212 case 'nextWord': 213 case 'nextWord':
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 predErrorMsg = 'no_previous_landmark'; 385 predErrorMsg = 'no_previous_landmark';
385 break; 386 break;
386 case 'right': 387 case 'right':
387 case 'nextObject': 388 case 'nextObject':
388 current = current.move(cursors.Unit.NODE, Dir.FORWARD); 389 current = current.move(cursors.Unit.NODE, Dir.FORWARD);
389 break; 390 break;
390 case 'left': 391 case 'left':
391 case 'previousObject': 392 case 'previousObject':
392 current = current.move(cursors.Unit.NODE, Dir.BACKWARD); 393 current = current.move(cursors.Unit.NODE, Dir.BACKWARD);
393 break; 394 break;
395 case 'previousGroup':
396 skipSync = true;
397 dir = Dir.BACKWARD;
398 pred = AutomationPredicate.group;
399 break;
400 case 'nextGroup':
401 skipSync = true;
402 dir = Dir.FORWARD;
403 pred = AutomationPredicate.group;
404 break;
394 case 'jumpToTop': 405 case 'jumpToTop':
395 var node = AutomationUtil.findNodePost( 406 var node = AutomationUtil.findNodePost(
396 current.start.node.root, Dir.FORWARD, AutomationPredicate.leaf); 407 current.start.node.root, Dir.FORWARD, AutomationPredicate.leaf);
397 if (node) 408 if (node)
398 current = cursors.Range.fromNode(node); 409 current = cursors.Range.fromNode(node);
399 break; 410 break;
400 case 'jumpToBottom': 411 case 'jumpToBottom':
401 var node = AutomationUtil.findNodePost( 412 var node = AutomationUtil.findNodePost(
402 current.start.node.root, Dir.BACKWARD, AutomationPredicate.leaf); 413 current.start.node.root, Dir.BACKWARD, AutomationPredicate.leaf);
403 if (node) 414 if (node)
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 default: 647 default:
637 return true; 648 return true;
638 } 649 }
639 650
640 if (pred) { 651 if (pred) {
641 var bound = current.getBound(dir).node; 652 var bound = current.getBound(dir).node;
642 if (bound) { 653 if (bound) {
643 var node = AutomationUtil.findNextNode( 654 var node = AutomationUtil.findNextNode(
644 bound, dir, pred, {skipInitialAncestry: true}); 655 bound, dir, pred, {skipInitialAncestry: true});
645 656
646 if (node) { 657 if (node && !skipSync) {
647 node = AutomationUtil.findNodePre( 658 node = AutomationUtil.findNodePre(
648 node, Dir.FORWARD, AutomationPredicate.object) || 659 node, Dir.FORWARD, AutomationPredicate.object) ||
649 node; 660 node;
650 } 661 }
651 662
652 if (node) { 663 if (node) {
653 current = cursors.Range.fromNode(node); 664 current = cursors.Range.fromNode(node);
654 } else { 665 } else {
655 if (predErrorMsg) { 666 cvox.ChromeVox.earcons.playEarcon(cvox.Earcon.WRAP);
667 var root = AutomationUtil.getTopLevelRoot(bound) || bound.root;
668 if (dir == Dir.FORWARD) {
669 bound = root;
670 } else {
671 bound = AutomationUtil.findNodePost(
672 root, dir, AutomationPredicate.leaf) || bound;
673 }
674 node = AutomationUtil.findNextNode(
675 bound, dir, pred, {skipInitialAncestry: true});
676
677 if (node && !skipSync) {
678 node = AutomationUtil.findNodePre(
679 node, Dir.FORWARD, AutomationPredicate.object) || node;
680 }
681
682 if (node) {
683 current = cursors.Range.fromNode(node);
684 } else if (predErrorMsg) {
656 cvox.ChromeVox.tts.speak( 685 cvox.ChromeVox.tts.speak(
657 Msgs.getMsg(predErrorMsg), cvox.QueueMode.FLUSH); 686 Msgs.getMsg(predErrorMsg), cvox.QueueMode.FLUSH);
687 return false;
658 } 688 }
659 return false;
660 } 689 }
661 } 690 }
662 } 691 }
663 692
664 if (current) 693 if (current)
665 ChromeVoxState.instance.navigateToRange(current, undefined, speechProps); 694 ChromeVoxState.instance.navigateToRange(current, undefined, speechProps);
666 695
667 return false; 696 return false;
668 }; 697 };
669 698
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 break; 739 break;
711 } 740 }
712 if (announcement) { 741 if (announcement) {
713 cvox.ChromeVox.tts.speak( 742 cvox.ChromeVox.tts.speak(
714 announcement, cvox.QueueMode.FLUSH, 743 announcement, cvox.QueueMode.FLUSH,
715 cvox.AbstractTts.PERSONALITY_ANNOTATION); 744 cvox.AbstractTts.PERSONALITY_ANNOTATION);
716 } 745 }
717 }; 746 };
718 747
719 }); // goog.scope 748 }); // goog.scope
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698