Bug 1351148 Part9: Resend a MouseEnterIntoWidget event to TabChild when it's ready to handle input events. r=smaug.

MozReview-Commit-ID: IXPTRyJe1tk
This commit is contained in:
Stone Shih 2017-07-24 10:46:40 +08:00
Родитель 1b13c3deba
Коммит f04c0ccafa
2 изменённых файлов: 29 добавлений и 1 удалений

Просмотреть файл

@ -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<bool> 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<bool> ret = SendSynthMouseMoveEvent(aEvent, guid, blockId);

Просмотреть файл

@ -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);
};