Bug 479942 When physical space key is pressed, we should guarantee that it works as ' ' input key with any keyboard layout at handling shortcut key or access key r=karlt
authorMasayuki Nakano <masayuki@d-toybox.com>
Wed, 04 Jun 2014 10:44:47 +0900
changeset 206773 9a5636240f6c9e9cff3b201765f0832ace768db0
parent 206772 cd2ef9d646ff3fc822f5ea2150b5ba41ec888c77
child 206774 4b3198fb55a0fc79d53db08e4b3913e0afad7529
push id494
push userraliiev@mozilla.com
push dateMon, 25 Aug 2014 18:42:16 +0000
treeherdermozilla-release@a3cc3e46b571 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt
bugs479942
milestone32.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 479942 When physical space key is pressed, we should guarantee that it works as ' ' input key with any keyboard layout at handling shortcut key or access key r=karlt
content/base/src/nsContentUtils.cpp
--- a/content/base/src/nsContentUtils.cpp
+++ b/content/base/src/nsContentUtils.cpp
@@ -4634,16 +4634,26 @@ nsContentUtils::GetAccelKeyCandidates(ns
           continue;
 
         // Setting the alternative charCode candidates for retry without shift
         // key state only when the shift key is pressed.
         nsShortcutCandidate key(ch, true);
         aCandidates.AppendElement(key);
       }
     }
+
+    // Special case for "Space" key.  With some keyboard layouts, "Space" with
+    // or without Shift key causes non-ASCII space.  For such keyboard layouts,
+    // we should guarantee that the key press works as an ASCII white space key
+    // press.
+    if (nativeKeyEvent->mCodeNameIndex == CODE_NAME_INDEX_Space &&
+        nativeKeyEvent->charCode != static_cast<uint32_t>(' ')) {
+      nsShortcutCandidate spaceKey(static_cast<uint32_t>(' '), false);
+      aCandidates.AppendElement(spaceKey);
+    }
   } else {
     uint32_t charCode;
     aDOMKeyEvent->GetCharCode(&charCode);
     if (charCode) {
       nsShortcutCandidate key(charCode, false);
       aCandidates.AppendElement(key);
     }
   }
@@ -4676,16 +4686,24 @@ nsContentUtils::GetAccessKeyCandidates(W
         continue;
       if (IS_IN_BMP(ch[j]))
         ch[j] = ToLowerCase(char16_t(ch[j]));
       // Don't append the charCode that was already appended.
       if (aCandidates.IndexOf(ch[j]) == aCandidates.NoIndex)
         aCandidates.AppendElement(ch[j]);
     }
   }
+  // Special case for "Space" key.  With some keyboard layouts, "Space" with
+  // or without Shift key causes non-ASCII space.  For such keyboard layouts,
+  // we should guarantee that the key press works as an ASCII white space key
+  // press.
+  if (aNativeKeyEvent->mCodeNameIndex == CODE_NAME_INDEX_Space &&
+      aNativeKeyEvent->charCode != static_cast<uint32_t>(' ')) {
+    aCandidates.AppendElement(static_cast<uint32_t>(' '));
+  }
   return;
 }
 
 /* static */
 void
 nsContentUtils::AddScriptBlocker()
 {
   if (!sScriptBlockerCount) {