diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index 767eb03491a4..8184d415ddb3 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -1809,10 +1809,9 @@ TabParent::RecvOnEventNeedingAckHandled(const EventMessage& aMessage) { // This is called when the child process receives WidgetCompositionEvent or // WidgetSelectionEvent. + // FYI: Don't check if widget is nullptr here because it's more important to + // notify mContentCahce of this than handling something in it. nsCOMPtr widget = GetWidget(); - if (!widget) { - return IPC_OK(); - } // While calling OnEventNeedingAckHandled(), TabParent *might* be destroyed // since it may send notifications to IME. diff --git a/widget/ContentCache.cpp b/widget/ContentCache.cpp index 87d5f45b796a..810e3b5b6233 100644 --- a/widget/ContentCache.cpp +++ b/widget/ContentCache.cpp @@ -1126,6 +1126,12 @@ ContentCacheInParent::OnCompositionEvent(const WidgetCompositionEvent& aEvent) MOZ_ASSERT(aEvent.mMessage == eCompositionChange || aEvent.mMessage == eCompositionCommit); *mCommitStringByRequest = aEvent.mData; + // We need to wait eCompositionCommitRequestHandled from the remote process + // in this case. Therefore, mPendingEventsNeedingAck needs to be + // incremented here. + if (!mWidgetHasComposition) { + mPendingEventsNeedingAck++; + } return false; } @@ -1165,7 +1171,8 @@ ContentCacheInParent::OnEventNeedingAckHandled(nsIWidget* aWidget, "aMessage=%s), mPendingEventsNeedingAck=%u, mPendingCompositionCount=%" PRIu8, this, aWidget, ToChar(aMessage), mPendingEventsNeedingAck, mPendingCompositionCount)); - if (WidgetCompositionEvent::IsFollowedByCompositionEnd(aMessage)) { + if (WidgetCompositionEvent::IsFollowedByCompositionEnd(aMessage) || + aMessage == eCompositionCommitRequestHandled) { MOZ_RELEASE_ASSERT(mPendingCompositionCount > 0); mPendingCompositionCount--; } diff --git a/widget/EventMessageList.h b/widget/EventMessageList.h index c42a4514e2ed..c5358671ab85 100644 --- a/widget/EventMessageList.h +++ b/widget/EventMessageList.h @@ -198,6 +198,14 @@ NS_EVENT_MESSAGE(eCompositionCommitAsIs) // After that, eCompositionEnd will be dispatched automatically. // Its mRanges should be nullptr. NS_EVENT_MESSAGE(eCompositionCommit) +// eCompositionCommitRequestHandled is NOT used with any Widget*Event. +// This is used only by PBrowser.OnEventNeedingAckHandled(). If active IME +// commits composition synchronously, TabParent returns the commit string +// to the remote process synchronously. Then, TabChild dispatches +// eCompositionCommit in the remote process. Finally, this message is sent +// to TabParent. (If IME commits composition asynchronously, this message is +// not used.) +NS_EVENT_MESSAGE(eCompositionCommitRequestHandled) // Following events are defined for deprecated DOM events which are using // InternalUIEvent class. diff --git a/widget/PuppetWidget.cpp b/widget/PuppetWidget.cpp index 643e6c2ca20d..edbc7b974b0d 100644 --- a/widget/PuppetWidget.cpp +++ b/widget/PuppetWidget.cpp @@ -653,6 +653,9 @@ PuppetWidget::RequestIMEToCommitComposition(bool aCancel) nsEventStatus status = nsEventStatus_eIgnore; DispatchEvent(&compositionCommitEvent, status); + Unused << + mTabChild->SendOnEventNeedingAckHandled(eCompositionCommitRequestHandled); + // NOTE: PuppetWidget might be destroyed already. return NS_OK; }