OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2011 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 // An object to implement keyboard overlay accessiblity. | |
6 var KeyboardOverlayAccessibilityHelper = { | |
7 // Returns true when ChromeVox is loaded and active, false otherwise. | |
8 cvoxIsActive: function() { | |
9 try { | |
10 if (cvox.Api.isChromeVoxActive()) | |
11 return true; | |
12 } catch (e) { | |
13 if (!(e instanceof ReferenceError)) | |
mazda
2011/08/16 05:15:46
The following check may work though I haven't test
hashimoto
2011/08/16 07:54:56
Thank you for the suggestion, fixed.
On 2011/08/1
| |
14 throw e; | |
15 } | |
16 return false; | |
17 }, | |
18 // Speaks given string when ChromeVox is active, do nothing otherwise. | |
19 maybeSpeak: function(textString, queueMode, properties) { | |
mazda
2011/08/16 05:15:46
This function can be private.
maybeSpeak_
hashimoto
2011/08/16 07:54:56
This method is removed in the new patch set
| |
20 if (this.cvoxIsActive()) | |
21 cvox.Api.speak(textString, queueMode, properties); | |
22 }, | |
23 // Stops speaking when ChromeVox is active, do nothing otherwise. | |
24 maybeStop: function() { | |
mazda
2011/08/16 05:15:46
Ditto
hashimoto
2011/08/16 07:54:56
This method is removed in the new patch set
| |
25 if (this.cvoxIsActive()) | |
26 cvox.Api.stop(); | |
27 }, | |
28 // Speaks given shortcut description. | |
29 maybeSpeakShortcut: function(keysText, shortcutText) { | |
mazda
2011/08/16 05:15:46
Ditto
hashimoto
2011/08/16 07:54:56
Made private
| |
30 keysText = keysText.toLowerCase(); // For correct pronunciation. | |
31 this.maybeSpeak(keysText, 1, {}); | |
32 this.maybeSpeak(shortcutText, 1, {}); | |
33 }, | |
34 // Speaks all the shortcut with the given modifiers. | |
35 maybeSpeakAllShortcuts: function(modifiers) { | |
mazda
2011/08/16 05:15:46
How about inserting early exit if cvoxIsActive ret
hashimoto
2011/08/16 07:54:56
Fixed.
| |
36 this.maybeStop(); | |
37 var keyboardGlyphData = getKeyboardGlyphData(); | |
38 var shortcutData = getShortcutData(); | |
39 var layout = getLayouts()[keyboardGlyphData.layoutName]; | |
40 var keysToShortcutText = {}; | |
41 for (var i = 0; i < layout.length; ++i) { | |
42 var identifier = remapIdentifier(layout[i][0]); | |
43 var keyData = keyboardGlyphData.keys[identifier]; | |
44 var keyLabel = getKeyLabel(keyData, modifiers); | |
45 var shortcutId = shortcutData[getAction(keyLabel, modifiers)]; | |
46 var shortcutText = templateData[shortcutId]; | |
47 var keysText = modifiers.concat(keyLabel).join(' + '); | |
48 if (shortcutText) | |
49 keysToShortcutText[keysText] = shortcutText; | |
50 } | |
51 for (var keysText in keysToShortcutText) { | |
52 this.maybeSpeakShortcut(keysText, keysToShortcutText[keysText]); | |
53 } | |
54 } | |
55 }; | |
OLD | NEW |