Skip to content

Commit

Permalink
Bug 1380652 - ContentCacheInParent::RequestIMEToCommitComposition() s…
Browse files Browse the repository at this point in the history
…houldn't handle the request synchronously when its TabParent has already sent eCompositionCommit(AsIs) event of the composition r=m_kato

If ContentCacheInParent::RequestIMEToCommitComposition() returns true after its TabParent has already sent eCompositionCommit(AsIs) event, ContentCacheInParent::OnEventNeedingAckHandled() will receive both eCompositionCommit(AsIs) and eCompositionCommitRequestHandled for a composition.  Then, that causes making mPendingCompositionCount decreased twice.  That causes the crash.

So, even if its TabParent already lost focus, it should return false after its TabParent sent eCompositionCommit(AsIs).

MozReview-Commit-ID: 6OylQtc8kgC

--HG--
extra : rebase_source : 9d8f2ab2b25f129ddbca75fcc8fb4bc7c3a96e56
  • Loading branch information
masayuki-nakano committed Jul 21, 2017
1 parent 704bdf5 commit 22aa198
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions widget/ContentCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1253,6 +1253,15 @@ ContentCacheInParent::RequestIMEToCommitComposition(nsIWidget* aWidget,
return false;
}

// If there is no pending composition, we may have already sent
// eCompositionCommit(AsIs) event for the active composition. If so, the
// remote process will receive composition events which causes cleaning up
// TextComposition. So, this shouldn't do nothing and TextComposition
// should handle the request as it's handled asynchronously.
if (mIsPendingLastCommitEvent) {
return false;
}

// If TabParent which has IME focus was already changed to different one, the
// request shouldn't be sent to IME because it's too late.
if (!IMEStateManager::DoesTabParentHaveIMEFocus(&mTabParent)) {
Expand All @@ -1262,16 +1271,6 @@ ContentCacheInParent::RequestIMEToCommitComposition(nsIWidget* aWidget,
return true;
}

// Even if the remote process has IME focus and there is no pending
// composition, we may have already sent eCompositionCommit(AsIs) event
// to it. If so, the remote process will receive composition events
// which causes cleaning up TextComposition. So, this shouldn't do nothing
// and TextComposition should handle the request as it's handled
// asynchronously.
if (mIsPendingLastCommitEvent) {
return false;
}

RefPtr<TextComposition> composition =
IMEStateManager::GetTextCompositionFor(aWidget);
if (NS_WARN_IF(!composition)) {
Expand Down

0 comments on commit 22aa198

Please sign in to comment.