Bug 912858 part.2 Implement KeyboardEvent.key for printable keys on Windows r=jimm+smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Wed, 11 Dec 2013 01:14:54 +0900
changeset 159760 24417ae99937b8c31bb1eb92263df18b5a690b52
parent 159759 63a364842347743f711e4fe78a72ad6dff4315f6
child 159761 b0f32dd0f132f1d49dbef0bfb64eca44af97151a
push id25813
push userkwierso@gmail.com
push dateWed, 11 Dec 2013 00:42:57 +0000
treeherdermozilla-central@3ea3d3baa67b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm
bugs912858
milestone29.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 912858 part.2 Implement KeyboardEvent.key for printable keys on Windows r=jimm+smaug
widget/windows/KeyboardLayout.cpp
--- a/widget/windows/KeyboardLayout.cpp
+++ b/widget/windows/KeyboardLayout.cpp
@@ -942,16 +942,19 @@ NativeKey::InitKeyEvent(WidgetKeyboardEv
       aKeyEvent.mUniqueId = sUniqueKeyEventId;
       break;
     default:
       MOZ_CRASH("Invalid event message");
   }
 
   aKeyEvent.mIsRepeat = IsRepeat();
   aKeyEvent.mKeyNameIndex = mKeyNameIndex;
+  if (mKeyNameIndex == KEY_NAME_INDEX_USE_STRING) {
+    aKeyEvent.mKeyValue = mCommittedCharsAndModifiers.ToString();
+  }
   aKeyEvent.location = GetKeyLocation();
   aModKeyState.InitInputEvent(aKeyEvent);
 }
 
 bool
 NativeKey::DispatchKeyEvent(WidgetKeyboardEvent& aKeyEvent,
                             const MSG* aMsgSentToPlugin) const
 {
@@ -1663,16 +1666,19 @@ KeyboardLayout::InitNativeKey(NativeKey&
   int32_t virtualKeyIndex = GetKeyIndex(virtualKey);
 
   if (virtualKeyIndex < 0) {
     // Does not produce any printable characters, but still preserves the
     // dead-key state.
     return;
   }
 
+  MOZ_ASSERT(aNativeKey.mKeyNameIndex == KEY_NAME_INDEX_USE_STRING,
+    "Printable key's key name index must be KEY_NAME_INDEX_USE_STRING");
+
   bool isKeyDown = aNativeKey.IsKeyDownMessage();
   uint8_t shiftState =
     VirtualKey::ModifiersToShiftState(aModKeyState.GetModifiers());
 
   if (mVirtualKeys[virtualKeyIndex].IsDeadKey(shiftState)) {
     if ((isKeyDown && mActiveDeadKey < 0) ||
         (!isKeyDown && mActiveDeadKey == virtualKey)) {
       //  First dead key event doesn't generate characters.
@@ -2306,16 +2312,20 @@ KeyboardLayout::ConvertNativeKeyCodeToDO
   NS_WARNING(warning.get());
 #endif
   return 0;
 }
 
 KeyNameIndex
 KeyboardLayout::ConvertNativeKeyCodeToKeyNameIndex(uint8_t aVirtualKey) const
 {
+  if (IsPrintableCharKey(aVirtualKey)) {
+    return KEY_NAME_INDEX_USE_STRING;
+  }
+
 #define NS_NATIVE_KEY_TO_DOM_KEY_NAME_INDEX(aNativeKey, aKeyNameIndex)
 #define NS_JAPANESE_NATIVE_KEY_TO_DOM_KEY_NAME_INDEX(aNativeKey, aKeyNameIndex)
 #define NS_KOREAN_NATIVE_KEY_TO_DOM_KEY_NAME_INDEX(aNativeKey, aKeyNameIndex)
 #define NS_OTHER_NATIVE_KEY_TO_DOM_KEY_NAME_INDEX(aNativeKey, aKeyNameIndex)
 
   switch (aVirtualKey) {
 
 #undef NS_NATIVE_KEY_TO_DOM_KEY_NAME_INDEX
@@ -2323,19 +2333,16 @@ KeyboardLayout::ConvertNativeKeyCodeToKe
     case aNativeKey: return aKeyNameIndex;
 
 #include "NativeKeyToDOMKeyName.h"
 
 #undef NS_NATIVE_KEY_TO_DOM_KEY_NAME_INDEX
 #define NS_NATIVE_KEY_TO_DOM_KEY_NAME_INDEX(aNativeKey, aKeyNameIndex)
 
     default:
-      if (IsPrintableCharKey(aVirtualKey)) {
-        return KEY_NAME_INDEX_PrintableKey;
-      }
       break;
   }
 
   HKL layout = GetLayout();
   WORD langID = LOWORD(static_cast<HKL>(layout));
   WORD primaryLangID = PRIMARYLANGID(langID);
 
   if (primaryLangID == LANG_JAPANESE) {