OLD | NEW |
1 /* This Source Code Form is subject to the terms of the Mozilla Public | 1 /* This Source Code Form is subject to the terms of the Mozilla Public |
2 * License, v. 2.0. If a copy of the MPL was not distributed with this | 2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 | 4 |
5 Cu.import("resource://gre/modules/Services.jsm"); | 5 Cu.import("resource://gre/modules/Services.jsm"); |
6 | 6 |
7 let validModifiers = | 7 let validModifiers = Object.create(null); |
8 { | 8 validModifiers.ACCEL = null; |
9 ACCEL: null, | 9 validModifiers.CTRL = "control"; |
10 CTRL: "control", | 10 validModifiers.CONTROL = "control"; |
11 CONTROL: "control", | 11 validModifiers.SHIFT = "shift"; |
12 SHIFT: "shift", | 12 validModifiers.ALT = "alt"; |
13 ALT: "alt", | 13 validModifiers.META = "meta"; |
14 META: "meta", | |
15 __proto__: null | |
16 }; | |
17 | 14 |
18 /** | 15 /** |
19 * Sets the correct value of validModifiers.ACCEL. | 16 * Sets the correct value of validModifiers.ACCEL. |
20 */ | 17 */ |
21 function initAccelKey() | 18 function initAccelKey() |
22 { | 19 { |
23 validModifiers.ACCEL = "control"; | 20 validModifiers.ACCEL = "control"; |
24 try | 21 try |
25 { | 22 { |
26 let accelKey = Services.prefs.getIntPref("ui.key.accelKey"); | 23 let accelKey = Services.prefs.getIntPref("ui.key.accelKey"); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 _existingShortcuts: null, | 56 _existingShortcuts: null, |
60 | 57 |
61 /** | 58 /** |
62 * Sets up _existingShortcuts property for a window. | 59 * Sets up _existingShortcuts property for a window. |
63 */ | 60 */ |
64 _initExistingShortcuts: function(/**ChromeWindow*/ window) | 61 _initExistingShortcuts: function(/**ChromeWindow*/ window) |
65 { | 62 { |
66 if (!validModifiers.ACCEL) | 63 if (!validModifiers.ACCEL) |
67 initAccelKey(); | 64 initAccelKey(); |
68 | 65 |
69 this._existingShortcuts = {__proto__: null}; | 66 this._existingShortcuts = Object.create(null); |
70 | 67 |
71 let keys = window.document.getElementsByTagName("key"); | 68 let keys = window.document.getElementsByTagName("key"); |
72 for (let i = 0; i < keys.length; i++) | 69 for (let i = 0; i < keys.length; i++) |
73 { | 70 { |
74 let key = keys[i]; | 71 let key = keys[i]; |
75 let keyData = | 72 let keyData = |
76 { | 73 { |
77 shift: false, | 74 shift: false, |
78 meta: false, | 75 meta: false, |
79 alt: false, | 76 alt: false, |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 return false; | 203 return false; |
207 if (key.meta != event.metaKey || key.control != event.ctrlKey) | 204 if (key.meta != event.metaKey || key.control != event.ctrlKey) |
208 return false; | 205 return false; |
209 | 206 |
210 if (key.char && event.charCode && String.fromCharCode(event.charCode).toUpperC
ase() == key.char) | 207 if (key.char && event.charCode && String.fromCharCode(event.charCode).toUpperC
ase() == key.char) |
211 return true; | 208 return true; |
212 if (key.code && event.keyCode && event.keyCode == key.code) | 209 if (key.code && event.keyCode && event.keyCode == key.code) |
213 return true; | 210 return true; |
214 return false; | 211 return false; |
215 }; | 212 }; |
OLD | NEW |