Bug 1448282 - TSFTextStore should append a pending action for dispatching keyboard event into the queue if OnUpdateComposition() is called without new range r?m_kato draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Mon, 26 Mar 2018 15:07:59 +0900
changeset 772562 67827a5165321a5a5039e35f7565dfe1f9582e58
parent 772561 d561c3d1e96db4c9e861ff4a1097397979e017af
child 772591 7495ec97e4efb917fa0199dd830cda0df0ebf6ec
push id103954
push usermasayuki@d-toybox.com
push dateMon, 26 Mar 2018 12:27:55 +0000
reviewersm_kato
bugs1448282
milestone61.0a1
Bug 1448282 - TSFTextStore should append a pending action for dispatching keyboard event into the queue if OnUpdateComposition() is called without new range r?m_kato OnUpdateComposition() may be called without new range instance by some TIPs when they starts to modify composition string. At this timing, TSFTextStore should append a pending action for dispatching keyboard event into the queue. Without this patch, OnUpdateComposition() creates incomplete pending action for composition update and then, MaybeDispatchKeyboardEventAsProcessedByIME() appends pending action for dispatching keyboard event from another point immediately (e.g., from SetText()), then, finally, the caller of MaybeDispatchKeyboardEventAsProcessedByIME() appends another pending action for composition update with proper composition string. Therefore, the first pending action for composition update clears composition string before actually updating it with new composition string. In other words, new pending action for dispatching keyboard event splits a pending composition update. So, this patch prevents the splitting. MozReview-Commit-ID: 9pYO9pm3Vh9
widget/windows/TSFTextStore.cpp
--- a/widget/windows/TSFTextStore.cpp
+++ b/widget/windows/TSFTextStore.cpp
@@ -5320,16 +5320,23 @@ TSFTextStore::OnUpdateComposition(ITfCom
     MOZ_LOG(sTextStoreLog, LogLevel::Error,
       ("0x%p   TSFTextStore::OnUpdateComposition() FAILED due to "
        "different composition view specified", this));
     return E_UNEXPECTED;
   }
 
   // pRangeNew is null when the update is not complete
   if (!pRangeNew) {
+    MaybeDispatchKeyboardEventAsProcessedByIME();
+    if (mDestroyed) {
+      MOZ_LOG(sTextStoreLog, LogLevel::Error,
+        ("0x%p   TSFTextStore::OnUpdateComposition() FAILED due to "
+         "destroyed during dispatching a keyboard event", this));
+      return E_FAIL;
+    }
     PendingAction* action = LastOrNewPendingCompositionUpdate();
     action->mIncomplete = true;
     MOZ_LOG(sTextStoreLog, LogLevel::Info,
       ("0x%p   TSFTextStore::OnUpdateComposition() succeeded but "
        "not complete", this));
     return S_OK;
   }