Bug 1405832 - part 1: ContentCacheInParent::RequestIMEToCommitComposition() should increment mPendingEventsNeedingAck itself if it treat the request handled synchronously without actually requesting IME to commit composition r?m_kato
This is a simple bug of ContentCacheInParent. When
ContentCacheInParent::RequestIMEToCommitComposition() returns true,
PuppetWidget::RequestIMEToCommitComposition() will send
eCompositionCommitRequestHandled pseudo event message back to the main process.
This causes counting down mPendingEventsNeedingAck in
ContentCacheInParent::OnEventNeedingAckHandled(). Therefore, in the normal
path, ContentCacheInParent::OnCompositionEvent() increments it for receiving
the pseudo event message.
However, if the tab parent has already lost focus,
RequestIMEToCommitComposition() returns true without requesting native IME to
commit composition. So, ContentCacheInParent::OnCompositionEvent() cannot
increment mPendingEventsNeedingAck for coming
eCompositionCommitRequestHandled. Therefore, RequestIMEToCommitComposition()
needs to increment mPendingEventsNeedingAck by itself when it won't request
IME to commit composition but it returns true.
MozReview-Commit-ID: 4Alwfy8avB
--- a/widget/ContentCache.cpp
+++ b/widget/ContentCache.cpp
@@ -1318,16 +1318,21 @@ ContentCacheInParent::RequestIMEToCommit
// Use the latest composition string which may not be handled in the
// remote process for avoiding data loss.
#ifdef MOZ_CRASHREPORTER
mRequestIMEToCommitCompositionResults.
AppendElement(RequestIMEToCommitCompositionResult::
eReceivedAfterTabParentBlur);
#endif // #ifdef MOZ_CRASHREPORTER
aCommittedString = mCompositionString;
+ // After we return true from here, i.e., without actually requesting IME
+ // to commit composition, we will receive eCompositionCommitRequestHandled
+ // pseudo event message from the remote process. So, we need to increment
+ // mPendingEventsNeedingAck here.
+ mPendingEventsNeedingAck++;
return true;
}
RefPtr<TextComposition> composition =
IMEStateManager::GetTextCompositionFor(aWidget);
if (NS_WARN_IF(!composition)) {
MOZ_LOG(sContentCacheLog, LogLevel::Warning,
(" 0x%p RequestToCommitComposition(), "