Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 /** | |
| 6 * @fileoverview ChromeVox braille commands. | |
| 7 */ | |
| 8 | |
| 9 goog.provide('BrailleCommandHandler'); | |
| 10 | |
| 11 goog.require('ChromeVoxState'); | |
| 12 goog.require('CommandHandler'); | |
| 13 | |
| 14 | |
| 15 goog.scope(function() { | |
| 16 /** | |
| 17 * Maps a dot pattern to a command. | |
| 18 * @type {!Object<number, string>} | |
| 19 */ | |
| 20 BrailleCommandHandler.DOT_PATTERN_TO_COMMAND = { | |
| 21 }; | |
| 22 | |
| 23 /** | |
| 24 * Makes a dot pattern given a list of dots numbered from 1 to 8 arranged in a | |
| 25 * braille cell (a 2 x 4 dot grid). | |
| 26 * @param {Array<number>} dots The dots to be set in the returned pattern. | |
| 27 * @return {number} | |
| 28 */ | |
| 29 BrailleCommandHandler.makeDotPattern = function(dots) { | |
| 30 return dots.reduce(function(p, c) { | |
| 31 return p | (1 << c - 1); | |
| 32 }, 0); | |
| 33 }; | |
| 34 | |
| 35 /** | |
| 36 * Perform a braille command based on a dot pattern from a chord. | |
| 37 * @param {number} dots Braille dot pattern | |
| 38 */ | |
| 39 BrailleCommandHandler.onBrailleCommand = function(dots) { | |
| 40 var command = BrailleCommandHandler.DOT_PATTERN_TO_COMMAND[dots]; | |
| 41 if (command) | |
| 42 CommandHandler.onCommand(command); | |
| 43 }; | |
| 44 | |
| 45 /** | |
| 46 * @private | |
| 47 */ | |
| 48 BrailleCommandHandler.init_ = function() { | |
| 49 var map = function(dots, command) { | |
| 50 BrailleCommandHandler.DOT_PATTERN_TO_COMMAND[ | |
| 51 BrailleCommandHandler.makeDotPattern(dots)] = command; | |
| 52 }; | |
| 53 | |
| 54 map([2, 3], 'previousGroup'); | |
|
dmazzoni
2016/11/01 16:22:37
Would it be possible to put this mapping into next
David Tseng
2016/11/01 20:11:59
I would like to eventually move away from the way
| |
| 55 map([5, 6], 'nextGroup'); | |
| 56 map([1], 'previousObject'); | |
| 57 map([4], 'nextObject'); | |
| 58 map([2], 'previousWord'); | |
| 59 map([5], 'nextWord'); | |
| 60 map([3], 'previousCharacter'); | |
| 61 map([6], 'nextCharacter'); | |
| 62 map([1, 2, 3], 'jumpToTop'); | |
| 63 map([4, 5, 6], 'jumpToBottom'); | |
| 64 | |
| 65 map([1, 4], 'fullyDescribe'); | |
| 66 map([1, 3, 4], 'contextMenu'); | |
| 67 map([1, 2, 3, 5], 'readFromHere'); | |
| 68 map([2, 3, 4], 'toggleSelection'); | |
| 69 | |
| 70 // Forward jump. | |
| 71 map([1, 2], 'nextButton'); | |
| 72 map([1, 5], 'nextEditText'); | |
| 73 map([1, 2, 4], 'nextFormField'); | |
| 74 map([1, 2, 5], 'nextHeading'); | |
| 75 map([4, 5], 'nextLink'); | |
| 76 map([2, 3, 4, 5], 'nextTable'); | |
| 77 | |
| 78 // Backward jump. | |
| 79 map([1, 2, 7], 'previousButton'); | |
| 80 map([1, 5, 7], 'previousEditText'); | |
| 81 map([1, 2, 4, 7], 'previousFormField'); | |
| 82 map([1, 2, 5, 7], 'previousHeading'); | |
| 83 map([4, 5, 7], 'previousLink'); | |
| 84 map([2, 3, 4, 5, 7], 'previousTable'); | |
| 85 | |
| 86 map([8], 'forceClickOnCurrentItem'); | |
| 87 map([3, 4], 'toggleSearchWidget'); | |
| 88 | |
| 89 // Question. | |
| 90 map([1, 4, 5, 6], 'toggleKeyboardHelp'); | |
| 91 }; | |
| 92 | |
| 93 BrailleCommandHandler.init_(); | |
| 94 | |
| 95 }); // goog.scope | |
| OLD | NEW |