Bug 501496 part.2 Don't dispatch keypress events if defaultPrevent() of the keydown event is called on GTK r=smaug+karlt
authorMasayuki Nakano <masayuki@d-toybox.com>
Thu, 25 Jul 2013 15:09:28 +0900
changeset 152199 d41fb45a0523f5deb7de4e11579826d41cd5a9d8
parent 152198 32862e87f64c3ff9f782f906589cad9f8061238d
child 152200 48788ac2e02f29d8b0e39dcdb8c95ac30e8b7657
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs501496
milestone25.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 501496 part.2 Don't dispatch keypress events if defaultPrevent() of the keydown event is called on GTK r=smaug+karlt
widget/gtk2/nsWindow.cpp
--- a/widget/gtk2/nsWindow.cpp
+++ b/widget/gtk2/nsWindow.cpp
@@ -2933,17 +2933,17 @@ nsWindow::OnKeyPressEvent(GdkEventKey *a
     // Dispatch keydown event always.  At auto repeating, we should send
     // KEYDOWN -> KEYPRESS -> KEYDOWN -> KEYPRESS ... -> KEYUP
     // However, old distributions (e.g., Ubuntu 9.10) sent native key
     // release event, so, on such platform, the DOM events will be:
     // KEYDOWN -> KEYPRESS -> KEYUP -> KEYDOWN -> KEYPRESS -> KEYUP...
 
     bool isKeyDownCancelled = false;
     if (DispatchKeyDownEvent(aEvent, &isKeyDownCancelled) &&
-        MOZ_UNLIKELY(mIsDestroyed)) {
+        (MOZ_UNLIKELY(mIsDestroyed) || isKeyDownCancelled)) {
         return TRUE;
     }
 
     // If a keydown event handler causes to enable IME, i.e., it moves
     // focus from IME unusable content to IME usable editor, we should
     // send the native key event to IME for the first input on the editor.
     if (!IMEWasEnabled && mIMModule && mIMModule->IsEnabled()) {
         // Notice our keydown event was already dispatched.  This prevents
@@ -2994,20 +2994,16 @@ nsWindow::OnKeyPressEvent(GdkEventKey *a
         case GDK_F14:
             return DispatchContentCommandEvent(NS_CONTENT_COMMAND_UNDO);
     }
 #endif /* ! AIX */
 #endif /* MOZ_X11 */
 
     nsKeyEvent event(true, NS_KEY_PRESS, this);
     KeymapWrapper::InitKeyEvent(event, aEvent);
-    if (isKeyDownCancelled) {
-      // If prevent default set for onkeydown, do the same for onkeypress
-      event.mFlags.mDefaultPrevented = true;
-    }
 
     // before we dispatch a key, check if it's the context menu key.
     // If so, send a context menu key event instead.
     if (is_context_menu_key(event)) {
         nsMouseEvent contextMenuEvent(true, NS_CONTEXTMENU, this,
                                       nsMouseEvent::eReal,
                                       nsMouseEvent::eContextMenuKey);