Bug 1376424 - part1: TabChild should notify TabParent of "request to commit composition" handled r=m_kato

The problem is, only when requesting IME to commit or cancel composition is handled synchronously, TabParent does not send the dispatched eCompositionCommit(AsIs) event to the remote process.  Therefore, TabParent (and ContentCacheInParent) never receives  the message from the remote process.

This patch makes TabChild notifies TabParent of eCompositionCommitRequestHandled special event message after TabChild dispatches eCompositionCommit into the DOM tree.  Then, ContentCacheInParent should decrease mPendingCompositionCount and mPendingEventsNeedingAck as usual composition event messages.

MozReview-Commit-ID: 7ec5HPiE687

--HG--
extra : rebase_source : a9366abf6f8feec2d6ac639fd37f5b5c6ddd9586
This commit is contained in:
Masayuki Nakano 2017-06-27 23:41:12 +09:00
parent a6f874fcf1
commit 71bb543ee5
4 changed files with 21 additions and 4 deletions

View File

@ -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<nsIWidget> widget = GetWidget();
if (!widget) {
return IPC_OK();
}
// While calling OnEventNeedingAckHandled(), TabParent *might* be destroyed
// since it may send notifications to IME.

View File

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

View File

@ -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.

View File

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