From 6a38312b768341fb41e7b51a8a7d49b4ea6b8a3e Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Wed, 16 Mar 2016 13:47:49 +0900 Subject: [PATCH] Bug 1137561 part.5 TextEventDispatcher should decide if keypress events should be fired for specific keys r=m_kato --- widget/TextEventDispatcher.cpp | 5 +++++ widget/windows/KeyboardLayout.cpp | 12 ------------ 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/widget/TextEventDispatcher.cpp b/widget/TextEventDispatcher.cpp index 58e9da0b4619..c6f0ddf99d2d 100644 --- a/widget/TextEventDispatcher.cpp +++ b/widget/TextEventDispatcher.cpp @@ -527,6 +527,11 @@ TextEventDispatcher::MaybeDispatchKeypressEvents( return false; } + // If the key shouldn't cause keypress events, don't fire them. + if (!aKeyboardEvent.ShouldCauseKeypressEvents()) { + return false; + } + // If the key isn't a printable key or just inputting one character or // no character, we should dispatch only one keypress. Otherwise, i.e., // if the key is a printable key and inputs multiple characters, keypress diff --git a/widget/windows/KeyboardLayout.cpp b/widget/windows/KeyboardLayout.cpp index 0f6cd7e6d3bc..df9691f255d1 100644 --- a/widget/windows/KeyboardLayout.cpp +++ b/widget/windows/KeyboardLayout.cpp @@ -1514,18 +1514,6 @@ NativeKey::HandleKeyDownMessage(bool* aEventDispatched) const return defaultPrevented; } - // Don't dispatch keypress event for modifier keys. - switch (mDOMKeyCode) { - case NS_VK_SHIFT: - case NS_VK_CONTROL: - case NS_VK_ALT: - case NS_VK_CAPS_LOCK: - case NS_VK_NUM_LOCK: - case NS_VK_SCROLL_LOCK: - case NS_VK_WIN: - return defaultPrevented; - } - if (defaultPrevented) { DispatchPluginEventsAndDiscardsCharMessages(); return true;