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
authorMasayuki Nakano <masayuki@d-toybox.com>
Wed, 01 Mar 2017 15:58:50 +0900
changeset 461556 73a1a183e75f3ae349647977689e800b9a173547
parent 461555 91585581ac42ed9a2cd5f9d00447213aedcc848b
child 461557 0c24a392e924c90e0b40764ceec147fc5af26288
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersm_kato
bugs1343451
milestone61.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 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;