diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index b9a2feb9be5a..a8b69bb81a3e 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -173,6 +173,7 @@ TabParent::TabParent(nsIContentParent* aManager, , mHasPresented(false) , mHasBeforeUnload(false) , mIsReadyToHandleInputEvents(false) + , mIsMouseEnterIntoWidgetEventSuppressed(false) { MOZ_ASSERT(aManager); } @@ -1092,7 +1093,7 @@ TabParent::SendKeyEvent(const nsAString& aType, void TabParent::SendRealMouseEvent(WidgetMouseEvent& aEvent) { - if (mIsDestroyed || !mIsReadyToHandleInputEvents) { + if (mIsDestroyed) { return; } aEvent.mRefPoint += GetChildProcessOffset(); @@ -1113,11 +1114,33 @@ TabParent::SendRealMouseEvent(WidgetMouseEvent& aEvent) mTabSetsCursor = false; } } + if (!mIsReadyToHandleInputEvents) { + if (eMouseEnterIntoWidget == aEvent.mMessage) { + MOZ_ASSERT(!mIsMouseEnterIntoWidgetEventSuppressed); + mIsMouseEnterIntoWidgetEventSuppressed = true; + } else if (eMouseExitFromWidget == aEvent.mMessage) { + MOZ_ASSERT(mIsMouseEnterIntoWidgetEventSuppressed); + mIsMouseEnterIntoWidgetEventSuppressed = false; + } + return; + } ScrollableLayerGuid guid; uint64_t blockId; ApzAwareEventRoutingToChild(&guid, &blockId, nullptr); + if (mIsMouseEnterIntoWidgetEventSuppressed) { + // In the case that the TabParent suppressed the eMouseEnterWidget event due + // to its corresponding TabChild wasn't ready to handle it, we have to + // resend it when the TabChild is ready. + mIsMouseEnterIntoWidgetEventSuppressed = false; + WidgetMouseEvent localEvent(aEvent); + localEvent.mMessage = eMouseEnterIntoWidget; + DebugOnly ret = SendRealMouseButtonEvent(localEvent, guid, blockId); + NS_WARNING_ASSERTION(ret, "SendRealMouseButtonEvent(eMouseEnterIntoWidget) failed"); + MOZ_ASSERT(!ret || localEvent.HasBeenPostedToRemoteProcess()); + } + if (eMouseMove == aEvent.mMessage) { if (aEvent.mReason == WidgetMouseEvent::eSynthesized) { DebugOnly ret = SendSynthMouseMoveEvent(aEvent, guid, blockId); diff --git a/dom/ipc/TabParent.h b/dom/ipc/TabParent.h index f52a7d03b555..a2c81f6e42a9 100644 --- a/dom/ipc/TabParent.h +++ b/dom/ipc/TabParent.h @@ -786,6 +786,11 @@ private: // True when the remote browser is created and ready to handle input events. bool mIsReadyToHandleInputEvents; + // True if we suppress the eMouseEnterIntoWidget event due to the TabChild was + // not ready to handle it. We will resend it when the next time we fire a + // mouse event and the TabChild is ready. + bool mIsMouseEnterIntoWidgetEventSuppressed; + public: static TabParent* GetTabParentFromLayersId(uint64_t aLayersId); };