bug 441794: fix a mis-merged hunk, and some other miscellaneous tweaks
authorDaniel Brooks <db48x@db48x.net>
Thu, 17 Jul 2008 17:55:26 -0500
changeset 64879 3a694ee89c4976dc93af8bae3d36891f6cad07f0
parent 64878 ad7487807f77902d259d0c45cc390e820b38249a
child 64880 0880d891168a073be2675f46bc86138b7a3f0b68
push id1
push userclegnitto@mozilla.com
push dateTue, 12 Apr 2011 01:19:02 +0000
treeherdermozilla-aurora@0cfe6840e0a4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs441794
bug 441794: fix a mis-merged hunk, and some other miscellaneous tweaks
mobile/chrome/content/shortcuts.js
--- a/mobile/chrome/content/shortcuts.js
+++ b/mobile/chrome/content/shortcuts.js
@@ -36,16 +36,17 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 // TODO: need to make the listbox editable, and to save the changes to prefs
 // TODO: need ui to clear a shortcut; at present all keys typed while editing a
 //       key will be interpreted as an indication of what the user wants the
 //       shortcut to be. I think a little X button on the textbox will suffice.
 // TODO: see about grouping the keys into categories
+// TODO: move the shortcut editor to the prefs, if the prefs exist
 
 Components.utils.import("resource://gre/modules/JSON.jsm");
 
 const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
 
 function ShortcutEditor()
 {
     var prefsvc = Components.classes["@mozilla.org/preferences-service;1"]
@@ -136,16 +137,23 @@ function ShortcutEditor()
         // TODO: make this check more specific, once key elements implement a unique interface
         if (modifiers instanceof Components.interfaces.nsIDOMElement)
             return {
                 exists: true,
                 modifiers: getFlagsForModifiers(modifiers.getAttribute("modifiers")),
                 key: modifiers.getAttribute("key"),
                 keycode: modifiers.getAttribute("keycode")
             };
+        if (modifiers instanceof Components.interfaces.nsIDOMKeyEvent)
+            return {
+                exists: true,
+                modifiers: getEventModifiers(modifiers),
+                key: getEventKey(modifiers),
+                keycode: getEventKeyCode(modifiers)
+            };
         return {
             exists: !!(modifiers || key || keycode),
             modifiers: getFlagsForModifiers(modifiers),
             key: key,
             keycode: keycode
         };
     }
 
@@ -170,26 +178,26 @@ function ShortcutEditor()
             i += i;
         }
         return result;
     }
 
     function getEventKey(event)
     {
         if (event.charCode)
-            return String.fromCharCode(event.charCode);
+            return String.fromCharCode(event.charCode).toUpperCase();
     }
 
     function getEventKeyCode(event)
     {
         var keyCodeMap = { };
         var nsIDOMKeyEvent = Components.interfaces.nsIDOMKeyEvent;
         keyCodeMap[nsIDOMKeyEvent.DOM_VK_CANCEL] = "VK_CANCEL";
         keyCodeMap[nsIDOMKeyEvent.DOM_VK_HELP] = "VK_HELP";
-        keyCodeMap[nsIDOMKeyEvent.DOM_VK_BACK_SPACE] = "VK_BACK_SPACE";
+        keyCodeMap[nsIDOMKeyEvent.DOM_VK_BACK_SPACE] = "VK_BACK";
         keyCodeMap[nsIDOMKeyEvent.DOM_VK_TAB] = "VK_TAB";
         keyCodeMap[nsIDOMKeyEvent.DOM_VK_CLEAR] = "VK_CLEAR";
         keyCodeMap[nsIDOMKeyEvent.DOM_VK_RETURN] = "VK_RETURN";
         keyCodeMap[nsIDOMKeyEvent.DOM_VK_ENTER] = "VK_ENTER";
         keyCodeMap[nsIDOMKeyEvent.DOM_VK_SHIFT] = "VK_SHIFT";
         keyCodeMap[nsIDOMKeyEvent.DOM_VK_CONTROL] = "VK_CONTROL";
         keyCodeMap[nsIDOMKeyEvent.DOM_VK_ALT] = "VK_ALT";
         keyCodeMap[nsIDOMKeyEvent.DOM_VK_PAUSE] = "VK_PAUSE";