Bug 1343451 - part 2: KeyboardLayout and NativeKey should use native key code value to check if the key event was handled by IME r?m_kato draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Wed, 01 Mar 2017 15:58:50 +0900
changeset 766627 5014c861df0e174a0174ce17ba44ae3babe42680
parent 766626 60ee152577c925075495c87beb6345e06c32f5f3
child 766628 9db6aee9190dfe66a5c245bd2cd5a9ba42b178ac
push id102374
push usermasayuki@d-toybox.com
push dateTue, 13 Mar 2018 06:34:13 +0000
reviewersm_kato
bugs1343451
milestone61.0a1
Bug 1343451 - part 2: KeyboardLayout and NativeKey should use native key code value to check if the key event was handled by IME r?m_kato On Windows, VK_PROCESSKEY key message is sent if the key event is handled by IME (in IMM mode or IMM-IME). Therefore, we can set WidgetKeyboardEvent::mKeyCode to NS_VK_PROCESSKEY and WidgetKeyboardEvent::mKeyNameIndex to KEY_NAME_INDEX_Process simply when we receive VK_PROCESSKEY. MozReview-Commit-ID: 9B8Q7rwfXYD
widget/NativeKeyToDOMKeyName.h
widget/tests/test_keycodes.xul
widget/windows/KeyboardLayout.cpp
--- a/widget/NativeKeyToDOMKeyName.h
+++ b/widget/NativeKeyToDOMKeyName.h
@@ -524,16 +524,19 @@ KEY_MAP_ANDROID (ModeChange, AKEYCODE_SW
 // NonConvert
 KEY_MAP_WIN     (NonConvert, VK_NONCONVERT)
 KEY_MAP_GTK     (NonConvert, GDK_Muhenkan)
 KEY_MAP_ANDROID (NonConvert, AKEYCODE_MUHENKAN)
 
 // PreviousCandidate
 KEY_MAP_GTK     (PreviousCandidate, GDK_PreviousCandidate) // OADG 109, Mae Koho
 
+// Process
+KEY_MAP_WIN     (Process, VK_PROCESSKEY)
+
 // SingleCandidate
 KEY_MAP_GTK     (SingleCandidate, GDK_SingleCandidate)
 
 /******************************************************************************
  * Keys specific to Korean keyboards
  ******************************************************************************/
 // HangulMode
 KEY_MAP_WIN_KOR (HangulMode, VK_HANGUL /* same as VK_KANA */)
--- a/widget/tests/test_keycodes.xul
+++ b/widget/tests/test_keycodes.xul
@@ -3018,20 +3018,20 @@ function* runKeyEventTests()
                    modifiers:{}, chars:"a"},
                   ["a", "a", "F4"], "F4", KeyboardEvent.DOM_VK_F4, "a", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD);
 
     // Even if key message is processed by IME, when the key causes inputting text,
     // keypress event(s) should be fired.
     const WIN_VK_PROCESSKEY_WITH_SC_A = WIN_VK_PROCESSKEY | 0x001E0000;
     yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_PROCESSKEY_WITH_SC_A,
                    modifiers:{}, chars:"a"},
-                  ["a", "a", "Unidentified" /* TODO: Process */], "KeyA", 0 /* TODO: 0xE5 */, "a", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD);
+                  ["a", "a", "Process"], "KeyA", KeyboardEvent.DOM_VK_PROCESSKEY, "a", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD);
     yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_PROCESSKEY_WITH_SC_A,
                    modifiers:{altKey:1}, chars:"a"},
-                  ["a", "a", "Unidentified" /* TODO: Process */], "KeyA", 0 /* TODO: 0xE5 */, "a", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD);
+                  ["a", "a", "Process"], "KeyA", KeyboardEvent.DOM_VK_PROCESSKEY, "a", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD);
 
     // US
     // Alphabet
     yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_A,
                    modifiers:{}, chars:"a"},
                   "a", "KeyA", KeyboardEvent.DOM_VK_A, "a", SHOULD_DELIVER_ALL, KeyboardEvent.DOM_KEY_LOCATION_STANDARD);
     yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_A,
                    modifiers:{shiftKey:1}, chars:"A"},
--- a/widget/windows/KeyboardLayout.cpp
+++ b/widget/windows/KeyboardLayout.cpp
@@ -4800,17 +4800,17 @@ KeyboardLayout::ConvertNativeKeyCodeToDO
     // We should keep consistency between Gecko on all platforms rather than
     // with other browsers since a lot of keyCode values are already different
     // between browsers.
     case VK_ABNT_C2:
       return NS_VK_SEPARATOR;
 
     // VK_PROCESSKEY means IME already consumed the key event.
     case VK_PROCESSKEY:
-      return 0;
+      return NS_VK_PROCESSKEY;
     // VK_PACKET is generated by SendInput() API, we don't need to
     // care this message as key event.
     case VK_PACKET:
       return 0;
     // If a key is not mapped to a virtual keycode, 0xFF is used.
     case 0xFF:
       NS_WARNING("The key is failed to be converted to a virtual keycode");
       return 0;