| 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 = Object.create(null); | 7 let validModifiers = Object.create(null); |
| 8 validModifiers.ACCEL = null; | 8 validModifiers.ACCEL = null; |
| 9 validModifiers.CTRL = "control"; | 9 validModifiers.CTRL = "control"; |
| 10 validModifiers.CONTROL = "control"; | 10 validModifiers.CONTROL = "control"; |
| 11 validModifiers.SHIFT = "shift"; | 11 validModifiers.SHIFT = "shift"; |
| 12 validModifiers.ALT = "alt"; | 12 validModifiers.ALT = "alt"; |
| 13 validModifiers.META = "meta"; | 13 validModifiers.META = "meta"; |
| 14 | 14 |
| 15 let bindingsKeys = null; |
| 16 (function() |
| 17 { |
| 18 let request = new XMLHttpRequest(); |
| 19 request.open("GET", "chrome://global/content/platformHTMLBindings.xml"); |
| 20 request.addEventListener("load", () => |
| 21 { |
| 22 bindingsKeys = request.responseXML.getElementsByTagName("handler"); |
| 23 }); |
| 24 request.send(); |
| 25 })(); |
| 26 |
| 27 |
| 15 /** | 28 /** |
| 16 * Sets the correct value of validModifiers.ACCEL. | 29 * Sets the correct value of validModifiers.ACCEL. |
| 17 */ | 30 */ |
| 18 function initAccelKey() | 31 function initAccelKey() |
| 19 { | 32 { |
| 20 validModifiers.ACCEL = "control"; | 33 validModifiers.ACCEL = "control"; |
| 21 try | 34 try |
| 22 { | 35 { |
| 23 let accelKey = Services.prefs.getIntPref("ui.key.accelKey"); | 36 let accelKey = Services.prefs.getIntPref("ui.key.accelKey"); |
| 24 if (accelKey == Ci.nsIDOMKeyEvent.DOM_VK_CONTROL) | 37 if (accelKey == Ci.nsIDOMKeyEvent.DOM_VK_CONTROL) |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 /** | 71 /** |
| 59 * Sets up _existingShortcuts property for a window. | 72 * Sets up _existingShortcuts property for a window. |
| 60 */ | 73 */ |
| 61 _initExistingShortcuts: function(/**ChromeWindow*/ window) | 74 _initExistingShortcuts: function(/**ChromeWindow*/ window) |
| 62 { | 75 { |
| 63 if (!validModifiers.ACCEL) | 76 if (!validModifiers.ACCEL) |
| 64 initAccelKey(); | 77 initAccelKey(); |
| 65 | 78 |
| 66 this._existingShortcuts = Object.create(null); | 79 this._existingShortcuts = Object.create(null); |
| 67 | 80 |
| 68 let keys = window.document.getElementsByTagName("key"); | 81 let keys = Array.prototype.slice.apply(window.document.getElementsByTagName(
"key")); |
| 82 if (bindingsKeys) |
| 83 keys.push.apply(keys, bindingsKeys); |
| 69 for (let i = 0; i < keys.length; i++) | 84 for (let i = 0; i < keys.length; i++) |
| 70 { | 85 { |
| 71 let key = keys[i]; | 86 let key = keys[i]; |
| 72 let keyData = | 87 let keyData = |
| 73 { | 88 { |
| 74 shift: false, | 89 shift: false, |
| 75 meta: false, | 90 meta: false, |
| 76 alt: false, | 91 alt: false, |
| 77 control: false, | 92 control: false, |
| 78 char: null, | 93 char: null, |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 return false; | 218 return false; |
| 204 if (key.meta != event.metaKey || key.control != event.ctrlKey) | 219 if (key.meta != event.metaKey || key.control != event.ctrlKey) |
| 205 return false; | 220 return false; |
| 206 | 221 |
| 207 if (key.char && event.charCode && String.fromCharCode(event.charCode).toUpperC
ase() == key.char) | 222 if (key.char && event.charCode && String.fromCharCode(event.charCode).toUpperC
ase() == key.char) |
| 208 return true; | 223 return true; |
| 209 if (key.code && event.keyCode && event.keyCode == key.code) | 224 if (key.code && event.keyCode && event.keyCode == key.code) |
| 210 return true; | 225 return true; |
| 211 return false; | 226 return false; |
| 212 }; | 227 }; |
| OLD | NEW |