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

Unified Diff: chrome/browser/resources/chromeos/chromevox/cvox2/background/braille_command_handler.js

Issue 2486293002: Add keyboard explorer improvements for braille (Closed)
Patch Set: Indents and braille cap cond Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/chromeos/chromevox/cvox2/background/braille_command_handler.js
diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/braille_command_handler.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/braille_command_handler.js
index 8ae609f0a0d6f4c8d99fa94c00fd6caa2b0a62be..b5345cabe3b170734ddd007ef60a1f1f0409412b 100644
--- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/braille_command_handler.js
+++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/braille_command_handler.js
@@ -8,10 +8,6 @@
goog.provide('BrailleCommandHandler');
-goog.require('ChromeVoxState');
-goog.require('CommandHandler');
-
-
goog.scope(function() {
/**
* Maps a dot pattern to a command.
@@ -33,13 +29,63 @@ BrailleCommandHandler.makeDotPattern = function(dots) {
};
/**
- * Perform a braille command based on a dot pattern from a chord.
- * @param {number} dots Braille dot pattern
+ * Gets a braille command based on a dot pattern from a chord.
+ * @param {number} dots
+ * @return {string?}
*/
-BrailleCommandHandler.onBrailleCommand = function(dots) {
+BrailleCommandHandler.getCommand = function(dots) {
var command = BrailleCommandHandler.DOT_PATTERN_TO_COMMAND[dots];
- if (command)
- CommandHandler.onCommand(command);
+ return command;
+};
+
+/**
+ * Gets a dot shortcut for a command.
+ * @param {string} command
+ * @param {boolean=} opt_chord True if the pattern comes from a chord.
+ * @return {string} The shortcut.
+ */
+BrailleCommandHandler.getDotShortcut = function(command, opt_chord) {
+ var commandDots = BrailleCommandHandler.getDots(command);
+ return BrailleCommandHandler.makeShortcutText(commandDots, opt_chord);
+};
+
+/**
+ * @param {number} pattern
+ * @param {boolean=} opt_chord
+ * @return {string}
+ */
+BrailleCommandHandler.makeShortcutText = function(pattern, opt_chord) {
+ var dots = [];
+ for (var shifter = 0; shifter <= 7; shifter++) {
+ if ((1 << shifter) & pattern)
+ dots.push(shifter + 1);
+ }
+ var msgid;
+ if (dots.length > 1)
+ msgid = 'braille_dots';
+ else if (dots.length == 1)
+ msgid = 'braille_dot';
+
+ if (msgid) {
+ var dotText = Msgs.getMsg(msgid, [dots.join('-')]);
+ if (opt_chord)
+ dotText = Msgs.getMsg('braille_chord', [dotText]);
+ return dotText;
+ }
+ return '';
+};
+
+/**
+ * @param {string} command
+ * @return {number} The dot pattern for |command|.
+ */
+BrailleCommandHandler.getDots = function(command) {
+ for (var key in BrailleCommandHandler.DOT_PATTERN_TO_COMMAND) {
+ key = parseInt(key, 10);
+ if (command == BrailleCommandHandler.DOT_PATTERN_TO_COMMAND[key])
+ return key;
+ }
+ return 0;
};
/**

Powered by Google App Engine
This is Rietveld 408576698