Bug 1321245 - Request native key bindings for delayed keypress events. r=smaug
authorJessica Jong <jjong@mozilla.com>
Fri, 02 Dec 2016 00:41:00 -0500
changeset 325179 d0055028cd1f20936a79307a71da7635e39aa229
parent 325178 ba62b4bebebfc30b3863d9b1fe220cff9c42f6f1
child 325180 c7fa5ee09c1a2dbde0593ead08478fd397ba652f
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewerssmaug
bugs1321245
milestone53.0a1
Bug 1321245 - Request native key bindings for delayed keypress events. r=smaug
layout/base/PresShell.cpp
widget/BasicEvents.h
widget/PuppetWidget.cpp
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -9913,16 +9913,17 @@ PresShell::DelayedKeyEvent::DelayedKeyEv
   DelayedInputEvent()
 {
   WidgetKeyboardEvent* keyEvent =
     new WidgetKeyboardEvent(aEvent->IsTrusted(),
                             aEvent->mMessage,
                             aEvent->mWidget);
   keyEvent->AssignKeyEventData(*aEvent, false);
   keyEvent->mFlags.mIsSynthesizedForTests = aEvent->mFlags.mIsSynthesizedForTests;
+  keyEvent->mFlags.mIsSuppressedOrDelayed = true;
   mEvent = keyEvent;
 }
 
 // Start of DEBUG only code
 
 #ifdef DEBUG
 
 static void
--- a/widget/BasicEvents.h
+++ b/widget/BasicEvents.h
@@ -127,19 +127,22 @@ public:
   // was registered as a passive listener.
   bool mInPassiveListener: 1;
   // If mComposed is true, the event fired by nodes in shadow DOM can cross the
   // boundary of shadow DOM and light DOM.
   bool mComposed : 1;
   // Similar to mComposed. Set it to true to allow events cross the boundary
   // between native non-anonymous content and native anonymouse content
   bool mComposedInNativeAnonymousContent : 1;
-  // True if the event is suppressed or delayed. This is used when parent side
-  // process the key event after content side, parent side may drop the key
-  // event if it was suppressed or delayed in content side.
+  // Set to true for events which are suppressed or delayed so that later a
+  // DelayedEvent of it is dispatched. This is used when parent side process
+  // the key event after content side, and may drop the event if the event
+  // was suppressed or delayed in contents side.
+  // It is also set to true for the events (in a DelayedInputEvent), which will
+  // be dispatched afterwards.
   bool mIsSuppressedOrDelayed : 1;
 
   // If the event is being handled in target phase, returns true.
   inline bool InTargetPhase() const
   {
     return (mInBubblingPhase && mInCapturePhase);
   }
 
--- a/widget/PuppetWidget.cpp
+++ b/widget/PuppetWidget.cpp
@@ -321,17 +321,18 @@ PuppetWidget::DispatchEvent(WidgetGUIEve
 #ifdef DEBUG
   debug_DumpEvent(stdout, event->mWidget, event, "PuppetWidget", 0);
 #endif
 
   MOZ_ASSERT(!mChild || mChild->mWindowType == eWindowType_popup,
              "Unexpected event dispatch!");
 
   AutoCacheNativeKeyCommands autoCache(this);
-  if (event->mFlags.mIsSynthesizedForTests && !mNativeKeyCommandsValid) {
+  if ((event->mFlags.mIsSynthesizedForTests ||
+       event->mFlags.mIsSuppressedOrDelayed) && !mNativeKeyCommandsValid) {
     WidgetKeyboardEvent* keyEvent = event->AsKeyboardEvent();
     if (keyEvent) {
       mTabChild->RequestNativeKeyBindings(&autoCache, keyEvent);
     }
   }
 
   if (event->mClass == eCompositionEventClass) {
     // Store the latest native IME context of parent process's widget or