Bug 1347835 NativeKey should dispatch keypress events even if WM_KEYDOWN is processed by IME but followed by printable WM_(SYS)CHAR messages r=m_kato
Some IME may handle WM_KEYDOWN message before application and may set the keycode value to VK_PROCSSKEY but not do actually. Similarly, IME may handle WM_KEYDOWN message and replace following WM_CHAR messages with different characters. Therefore, even if WM_KEYDOWN message comes with VK_PROCESSKEY, NativeKey shouldn't stop dispatching keypress events if it detects following printable char messages. MozReview-Commit-ID: DcC2qgcLDrQ
This commit is contained in:
@@ -3020,6 +3020,16 @@ function* runKeyEventTests()
|
||||
modifiers:{}, chars:"a"},
|
||||
["a", "a", "F4"], "F4", nsIDOMKeyEvent.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);
|
||||
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);
|
||||
|
||||
// US
|
||||
// Alphabet
|
||||
yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_A,
|
||||
|
||||
@@ -2421,8 +2421,10 @@ NativeKey::HandleKeyDownMessage(bool* aEventDispatched) const
|
||||
|
||||
MOZ_ASSERT(!mWidget->Destroyed());
|
||||
|
||||
// If the key was processed by IME, we shouldn't dispatch keypress event.
|
||||
if (mOriginalVirtualKeyCode == VK_PROCESSKEY) {
|
||||
// If the key was processed by IME and didn't cause WM_(SYS)CHAR messages, we
|
||||
// shouldn't dispatch keypress event.
|
||||
if (mOriginalVirtualKeyCode == VK_PROCESSKEY &&
|
||||
!IsFollowedByPrintableCharOrSysCharMessage()) {
|
||||
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
|
||||
("%p NativeKey::HandleKeyDownMessage(), not dispatching keypress "
|
||||
"event because the key was already handled by IME, defaultPrevented=%s",
|
||||
|
||||
Reference in New Issue
Block a user