Bug 1137561 part.5 TextEventDispatcher should decide if keypress events should be fired for specific keys r=m_kato
authorMasayuki Nakano <masayuki@d-toybox.com>
Wed, 16 Mar 2016 13:47:49 +0900
changeset 328768 b8d76794d055c60fc478896d47189e0581aae31f
parent 328767 545efe0fba8180b3443cbd9a21d7a60dcb68bfaf
child 328769 3b5b23d624d3c3f107dfde59aebe94ea03a9480e
push id1146
push userCallek@gmail.com
push dateMon, 25 Jul 2016 16:35:44 +0000
treeherdermozilla-release@a55778f9cd5a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersm_kato
bugs1137561
milestone48.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 1137561 part.5 TextEventDispatcher should decide if keypress events should be fired for specific keys r=m_kato
widget/TextEventDispatcher.cpp
widget/windows/KeyboardLayout.cpp
--- a/widget/TextEventDispatcher.cpp
+++ b/widget/TextEventDispatcher.cpp
@@ -522,16 +522,21 @@ TextEventDispatcher::MaybeDispatchKeypre
                        nsEventStatus& aStatus,
                        void* aData)
 {
   // If the key event was consumed, keypress event shouldn't be fired.
   if (aStatus == nsEventStatus_eConsumeNoDefault) {
     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
   // event should be dispatched the count of inputting characters times.
   size_t keypressCount =
     aKeyboardEvent.mKeyNameIndex != KEY_NAME_INDEX_USE_STRING ?
       1 : std::max(static_cast<nsAString::size_type>(1),
                    aKeyboardEvent.mKeyValue.Length());
--- a/widget/windows/KeyboardLayout.cpp
+++ b/widget/windows/KeyboardLayout.cpp
@@ -1509,28 +1509,16 @@ NativeKey::HandleKeyDownMessage(bool* aE
 
   RedirectedKeyDownMessageManager::Forget();
 
   // If the key was processed by IME, we shouldn't dispatch keypress event.
   if (mOriginalVirtualKeyCode == VK_PROCESSKEY) {
     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;
   }
 
   // If we won't be getting a WM_CHAR, WM_SYSCHAR or WM_DEADCHAR, synthesize a
   // keypress for almost all keys
   if (NeedsToHandleWithoutFollowingCharMessages()) {