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 The entry point for all ChromeVox2 related code for the | 6 * @fileoverview The entry point for all ChromeVox2 related code for the |
7 * background page. | 7 * background page. |
8 */ | 8 */ |
9 | 9 |
10 goog.provide('Background'); | 10 goog.provide('Background'); |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
420 return true; | 420 return true; |
421 | 421 |
422 // Next/compat commands hereafter. | 422 // Next/compat commands hereafter. |
423 if (this.mode == ChromeVoxMode.CLASSIC) | 423 if (this.mode == ChromeVoxMode.CLASSIC) |
424 return true; | 424 return true; |
425 | 425 |
426 var current = this.currentRange_; | 426 var current = this.currentRange_; |
427 var dir = Dir.FORWARD; | 427 var dir = Dir.FORWARD; |
428 var pred = null; | 428 var pred = null; |
429 var predErrorMsg = undefined; | 429 var predErrorMsg = undefined; |
430 var rootPred = AutomationPredicate.root; | |
430 var speechProps = {}; | 431 var speechProps = {}; |
431 switch (command) { | 432 switch (command) { |
432 case 'nextCharacter': | 433 case 'nextCharacter': |
433 speechProps['phoneticCharacters'] = true; | 434 speechProps['phoneticCharacters'] = true; |
434 current = current.move(cursors.Unit.CHARACTER, Dir.FORWARD); | 435 current = current.move(cursors.Unit.CHARACTER, Dir.FORWARD); |
435 break; | 436 break; |
436 case 'previousCharacter': | 437 case 'previousCharacter': |
437 speechProps['phoneticCharacters'] = true; | 438 speechProps['phoneticCharacters'] = true; |
438 current = current.move(cursors.Unit.CHARACTER, Dir.BACKWARD); | 439 current = current.move(cursors.Unit.CHARACTER, Dir.BACKWARD); |
439 break; | 440 break; |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
789 description['Version'] = chrome.app.getDetails().version; | 790 description['Version'] = chrome.app.getDetails().version; |
790 description['Reproduction Steps'] = '%0a1.%0a2.%0a3.'; | 791 description['Reproduction Steps'] = '%0a1.%0a2.%0a3.'; |
791 for (var key in description) | 792 for (var key in description) |
792 url += key + ':%20' + description[key] + '%0a'; | 793 url += key + ':%20' + description[key] + '%0a'; |
793 chrome.tabs.create({url: url}); | 794 chrome.tabs.create({url: url}); |
794 return false; | 795 return false; |
795 case 'toggleBrailleCaptions': | 796 case 'toggleBrailleCaptions': |
796 cvox.BrailleCaptionsBackground.setActive( | 797 cvox.BrailleCaptionsBackground.setActive( |
797 !cvox.BrailleCaptionsBackground.isEnabled()); | 798 !cvox.BrailleCaptionsBackground.isEnabled()); |
798 return false; | 799 return false; |
800 case 'fullyDescribe': | |
801 var o = new Output(); | |
802 o.withContextFirst() | |
803 .withRichSpeechAndBraille(current, null, Output.EventType.NAVIGATE) | |
804 .go(); | |
805 return false; | |
806 | |
807 // Table commands. | |
808 case 'previousRow': | |
809 var tableOpts = {}; | |
dmazzoni
2016/07/13 23:38:28
Any reason not to make this more concise? t doesn'
David Tseng
2016/07/14 20:24:41
dir gets used in both places; the first is to calc
| |
810 tableOpts.row = true; | |
811 dir = Dir.BACKWARD; | |
812 tableOpts.dir = dir; | |
813 pred = AutomationPredicate.rowCol(current.start.node, tableOpts); | |
814 predErrorMsg = 'no_cell_above'; | |
815 rootPred = AutomationPredicate.table; | |
816 break; | |
817 case 'previousCol': | |
818 var tableOpts = {}; | |
819 tableOpts.col = true; | |
820 dir = Dir.BACKWARD; | |
821 tableOpts.dir = dir; | |
822 pred = AutomationPredicate.rowCol(current.start.node, tableOpts); | |
823 predErrorMsg = 'no_cell_left'; | |
824 rootPred = AutomationPredicate.table; | |
825 break; | |
826 case 'nextRow': | |
827 var tableOpts = {}; | |
828 tableOpts.row = true; | |
829 dir = Dir.FORWARD; | |
830 tableOpts.dir = dir; | |
831 pred = AutomationPredicate.rowCol(current.start.node, tableOpts); | |
832 predErrorMsg = 'no_cell_below'; | |
833 rootPred = AutomationPredicate.table; | |
834 break; | |
835 case 'nextCol': | |
836 var tableOpts = {}; | |
837 tableOpts.col = true; | |
838 dir = Dir.FORWARD; | |
839 tableOpts.dir = dir; | |
840 pred = AutomationPredicate.rowCol(current.start.node, tableOpts); | |
841 predErrorMsg = 'no_cell_right'; | |
842 rootPred = AutomationPredicate.table; | |
843 break; | |
844 case 'goToRowFirstCell': | |
845 var tableOpts = {}; | |
846 tableOpts.row = true; | |
847 tableOpts.end = true; | |
848 dir = Dir.BACKWARD; | |
849 tableOpts.dir = dir; | |
850 pred = AutomationPredicate.rowCol(current.start.node, tableOpts); | |
851 // Should not be outputted. | |
852 predErrorMsg = 'no_cell_left'; | |
853 rootPred = AutomationPredicate.table; | |
854 break; | |
855 case 'goToRowLastCell': | |
856 var tableOpts = {}; | |
857 tableOpts.row = true; | |
858 tableOpts.end = true; | |
859 dir = Dir.FORWARD; | |
860 tableOpts.dir = dir; | |
861 pred = AutomationPredicate.rowCol(current.start.node, tableOpts); | |
862 // Should not be outputted. | |
863 predErrorMsg = 'no_cell_right'; | |
864 rootPred = AutomationPredicate.table; | |
865 break; | |
866 case 'goToColFirstCell': | |
867 var tableOpts = {}; | |
868 tableOpts.col = true; | |
869 tableOpts.end = true; | |
870 dir = Dir.BACKWARD; | |
871 tableOpts.dir = dir; | |
872 pred = AutomationPredicate.rowCol(current.start.node, tableOpts); | |
873 // Should not be outputted. | |
874 predErrorMsg = 'no_cell_above'; | |
875 rootPred = AutomationPredicate.table; | |
876 break; | |
877 case 'goToColLastCell': | |
878 var tableOpts = {}; | |
879 tableOpts.col = true; | |
880 tableOpts.end = true; | |
881 dir = Dir.FORWARD; | |
882 tableOpts.dir = dir; | |
883 pred = AutomationPredicate.rowCol(current.start.node, tableOpts); | |
884 // Should not be outputted. | |
885 predErrorMsg = 'no_cell_below'; | |
886 rootPred = AutomationPredicate.table; | |
887 break; | |
888 case 'goToFirstCell': | |
889 var tableOpts = {}; | |
890 tableOpts.row = true; | |
891 tableOpts.col = true; | |
892 tableOpts.end = true; | |
893 dir = Dir.BACKWARD; | |
894 tableOpts.dir = dir; | |
895 pred = AutomationPredicate.rowCol(current.start.node, tableOpts); | |
896 // Should not be outputted. | |
897 predErrorMsg = 'no_cell_left'; | |
898 rootPred = AutomationPredicate.table; | |
899 break; | |
900 case 'goToLastCell': | |
901 var tableOpts = {}; | |
902 tableOpts.row = true; | |
903 tableOpts.col = true; | |
904 tableOpts.end = true; | |
905 dir = Dir.FORWARD; | |
906 tableOpts.dir = dir; | |
907 pred = AutomationPredicate.rowCol(current.start.node, tableOpts); | |
908 // Should not be outputted. | |
909 predErrorMsg = 'no_cell_right'; | |
910 rootPred = AutomationPredicate.table; | |
911 break; | |
799 default: | 912 default: |
800 return true; | 913 return true; |
801 } | 914 } |
802 | 915 |
803 if (pred) { | 916 if (pred) { |
804 var bound = current.getBound(dir).node; | 917 var bound = current.getBound(dir).node; |
805 if (bound) { | 918 if (bound) { |
806 var node = AutomationUtil.findNextNode( | 919 var node = AutomationUtil.findNextNode( |
807 bound, dir, pred, {skipInitialAncestry: true}); | 920 bound, dir, pred, {skipInitialAncestry: true, root: rootPred}); |
808 | 921 |
809 if (node) { | 922 if (node) { |
810 node = AutomationUtil.findNodePre( | 923 node = AutomationUtil.findNodePre( |
811 node, Dir.FORWARD, AutomationPredicate.object) || node; | 924 node, Dir.FORWARD, AutomationPredicate.object) || node; |
812 } | 925 } |
813 | 926 |
814 if (node) { | 927 if (node) { |
815 current = cursors.Range.fromNode(node); | 928 current = cursors.Range.fromNode(node); |
816 } else { | 929 } else { |
817 if (predErrorMsg) { | 930 if (predErrorMsg) { |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1231 return new RegExp('^(' + globs.map(function(glob) { | 1344 return new RegExp('^(' + globs.map(function(glob) { |
1232 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&') | 1345 return glob.replace(/[.+^$(){}|[\]\\]/g, '\\$&') |
1233 .replace(/\*/g, '.*') | 1346 .replace(/\*/g, '.*') |
1234 .replace(/\?/g, '.'); | 1347 .replace(/\?/g, '.'); |
1235 }).join('|') + ')$'); | 1348 }).join('|') + ')$'); |
1236 }; | 1349 }; |
1237 | 1350 |
1238 new Background(); | 1351 new Background(); |
1239 | 1352 |
1240 }); // goog.scope | 1353 }); // goog.scope |
OLD | NEW |