Bug 106327 - Change shortcut label of VK_RETURN to "Enter" on Win/Unix. r=enndeakin, r=Gijs
authorThomas Duellmann <bugzilla2007@duellmann24.net>
Thu, 04 Jan 2018 13:50:30 +0200
changeset 397995 86275396a96b
parent 397994 134e8f9868a1
child 397996 2150458a2e9d
push id33197
push userarchaeopteryx@coole-files.de
push dateFri, 05 Jan 2018 22:34:03 +0000
treeherdermozilla-central@56c1eb9c065a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersenndeakin, Gijs
bugs106327
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 106327 - Change shortcut label of VK_RETURN to "Enter" on Win/Unix. r=enndeakin, r=Gijs
layout/xul/nsMenuFrame.cpp
toolkit/locales/en-US/chrome/global-platform/mac/platformKeys.properties
toolkit/locales/en-US/chrome/global-platform/unix/platformKeys.properties
toolkit/locales/en-US/chrome/global-platform/win/platformKeys.properties
toolkit/locales/en-US/chrome/global/keys.properties
toolkit/modules/ShortcutUtils.jsm
--- a/layout/xul/nsMenuFrame.cpp
+++ b/layout/xul/nsMenuFrame.cpp
@@ -1100,19 +1100,21 @@ nsMenuFrame::BuildAcceleratorText(bool a
       keyElement->GetAttr(kNameSpaceID_None, nsGkAtoms::keycode, keyCode);
       ToUpperCase(keyCode);
 
       nsresult rv;
       nsCOMPtr<nsIStringBundleService> bundleService =
         mozilla::services::GetStringBundleService();
       if (bundleService) {
         nsCOMPtr<nsIStringBundle> bundle;
-        rv = bundleService->CreateBundle("chrome://global/locale/keys.properties",
-                                         getter_AddRefs(bundle));
-
+        rv = bundleService->CreateBundle(
+               keyCode.EqualsLiteral("VK_RETURN")
+                 ? "chrome://global-platform/locale/platformKeys.properties"
+                 : "chrome://global/locale/keys.properties",
+               getter_AddRefs(bundle));
         if (NS_SUCCEEDED(rv) && bundle) {
           nsAutoString keyName;
           rv = bundle->GetStringFromName(NS_ConvertUTF16toUTF8(keyCode).get(),
                                          keyName);
           if (NS_SUCCEEDED(rv)) {
             accelString = keyName;
           }
         }
--- a/toolkit/locales/en-US/chrome/global-platform/mac/platformKeys.properties
+++ b/toolkit/locales/en-US/chrome/global-platform/mac/platformKeys.properties
@@ -1,25 +1,30 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-#mac
-#this file defines the on screen display names for the various modifier keys
-#these are used in XP menus to show keyboard shortcuts
+# Platform: Mac
+# This file defines the on-screen display names for the various modifier keys
+# and the Return key (VK_RETURN).
+# These are used in XP menus to show keyboard shortcuts.
 
-#the shift key - open up arrow symbol (ctrl-e)
+# The Shift key - open up arrow symbol (ctrl-e)
 VK_SHIFT=\u21e7
 
-#the command key - clover leaf symbol (ctrl-q)
+# The Command key - clover leaf symbol (ctrl-q)
 VK_META=\u2318
 
-#the win key - never generated by native key event
+# The Win key - never generated by native key event
 VK_WIN=win
 
-#the option/alt key - splitting tracks symbol (ctrl-g)
+# The Option/Alt key - splitting tracks symbol (ctrl-g)
 VK_ALT=\u2325
 
-#the control key. hat symbol (ctrl-f)
+# The Control key - hat symbol (ctrl-f)
 VK_CONTROL=\u2303
 
-#the separator character used between modifiers (none on Mac OS)
+# The Return key (on the main keyboard or numpad):
+# "Enter" on Windows/Unix, "Return" on Mac
+VK_RETURN=Return
+
+# The separator character used between modifiers (none on Mac OS)
 MODIFIER_SEPARATOR=
--- a/toolkit/locales/en-US/chrome/global-platform/unix/platformKeys.properties
+++ b/toolkit/locales/en-US/chrome/global-platform/unix/platformKeys.properties
@@ -1,25 +1,30 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-#default
-#this file defines the on screen display names for the various modifier keys
-#these are used in XP menus to show keyboard shortcuts
+# Platform: Unix
+# This file defines the on-screen display names for the various modifier keys
+# and the Enter key (VK_RETURN).
+# These are used in XP menus to show keyboard shortcuts.
 
-#the shift key
+# The Shift key
 VK_SHIFT=Shift
 
-#the command key
+# The Command key
 VK_META=Meta
 
-#the win key (Super key and Hyper keys are mapped to DOM Win key)
+# The Win key (Super key and Hyper keys are mapped to DOM Win key)
 VK_WIN=Win
 
-#the alt key
+# The Alt key
 VK_ALT=Alt
 
-#the control key
+# The Control key
 VK_CONTROL=Ctrl
 
-#the separator character used between modifiers 
+# The Enter key (on the main keyboard or numpad):
+# "Enter" on Windows/Unix, "Return" on Mac
+VK_RETURN=Enter
+
+# The separator character used between modifiers
 MODIFIER_SEPARATOR=+
--- a/toolkit/locales/en-US/chrome/global-platform/win/platformKeys.properties
+++ b/toolkit/locales/en-US/chrome/global-platform/win/platformKeys.properties
@@ -1,25 +1,30 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-#default
-#this file defines the on screen display names for the various modifier keys
-#these are used in XP menus to show keyboard shortcuts
+# Platform: Windows
+# This file defines the on-screen display names for the various modifier keys
+# and the Enter key (VK_RETURN).
+# These are used in XP menus to show keyboard shortcuts.
 
-#the shift key
+# The Shift key
 VK_SHIFT=Shift
 
-#the command key
+# The Command key
 VK_META=Meta
 
-#the win key
+# The Win key
 VK_WIN=Win
 
-#the alt key
+# The Alt key
 VK_ALT=Alt
 
-#the control key
+# The Control key
 VK_CONTROL=Ctrl
 
-#the separator character used between modifiers 
+# The Enter key (on the main keyboard or numpad):
+# "Enter" on Windows/Unix, "Return" on Mac
+VK_RETURN=Enter
+
+# The separator character used between modifiers
 MODIFIER_SEPARATOR=+
--- a/toolkit/locales/en-US/chrome/global/keys.properties
+++ b/toolkit/locales/en-US/chrome/global/keys.properties
@@ -52,17 +52,16 @@ VK_PAGE_DOWN=Page Down
 # Enter, backspace, and Tab might have both glyphs and text
 # if the keyboards usually have a glyph,
 # if there is a meaningful translation,
 # or if keyboards are localized
 # then translate them or insert the appropriate glyph
 # otherwise you should probably just translate the glyph regions
 
 # LOCALIZATION NOTE : BLOCK maybe GLYPHS
-VK_RETURN=Return
 VK_TAB=Tab
 VK_BACK=Backspace
 VK_DELETE=Del
 # LOCALIZATION NOTE : BLOCK end maybe GLYPHS
 # LOCALIZATION NOTE : BLOCK typing state keys
 VK_HOME=Home
 VK_END=End
 
--- a/toolkit/modules/ShortcutUtils.jsm
+++ b/toolkit/modules/ShortcutUtils.jsm
@@ -83,19 +83,21 @@ var ShortcutUtils = {
     if (haveCloverLeaf) {
       elemString += PlatformKeys.GetStringFromName("VK_META") +
         PlatformKeys.GetStringFromName("MODIFIER_SEPARATOR");
     }
 
     let key;
     let keyCode = aElemKey.getAttribute("keycode");
     if (keyCode) {
+      keyCode = keyCode.toUpperCase();
       try {
-        // Some keys might not exist in the locale file, which will throw:
-        key = Keys.GetStringFromName(keyCode.toUpperCase());
+        let bundle = keyCode == "VK_RETURN" ? PlatformKeys : Keys;
+        // Some keys might not exist in the locale file, which will throw.
+        key = bundle.GetStringFromName(keyCode);
       } catch (ex) {
         Cu.reportError("Error finding " + keyCode + ": " + ex);
         key = keyCode.replace(/^VK_/, "");
       }
     } else {
       key = aElemKey.getAttribute("key");
       key = key.toUpperCase();
     }