diff --git a/widget/windows/nsTextStore.cpp b/widget/windows/nsTextStore.cpp index cb583d90395..22d1f79d4b5 100644 --- a/widget/windows/nsTextStore.cpp +++ b/widget/windows/nsTextStore.cpp @@ -963,14 +963,12 @@ nsTextStore::DidLockGranted() mNativeCaretIsCreated = false; } if (IsReadWriteLocked()) { - if (IsPendingCompositionUpdateIncomplete()) { - // FreeCJ (TIP for Traditional Chinese) calls SetSelection() to set caret - // to the start of composition string and insert a full width space for - // a placeholder with a call of SetText(). After that, it calls - // OnUpdateComposition() without new range. Therefore, let's record the - // composition update information here. - RecordCompositionUpdateAction(); - } + // FreeCJ (TIP for Traditional Chinese) calls SetSelection() to set caret + // to the start of composition string and insert a full width space for + // a placeholder with a call of SetText(). After that, it calls + // OnUpdateComposition() without new range. Therefore, let's record the + // composition update information here. + CompleteLastActionIfStillIncomplete(); FlushPendingActions(); } @@ -1787,6 +1785,7 @@ nsTextStore::SetSelectionInternal(const TS_SELECTION_ACP* pSelection, return S_OK; } + CompleteLastActionIfStillIncomplete(); PendingAction* action = mPendingActions.AppendElement(); action->mType = PendingAction::SELECTION_SET; action->mSelectionStart = pSelection->acpStart; @@ -2812,6 +2811,7 @@ nsTextStore::RecordCompositionStartAction(ITfCompositionView* pComposition, return E_FAIL; } + CompleteLastActionIfStillIncomplete(); PendingAction* action = mPendingActions.AppendElement(); action->mType = PendingAction::COMPOSITION_START; action->mSelectionStart = start; @@ -2842,6 +2842,7 @@ nsTextStore::RecordCompositionEndAction() MOZ_ASSERT(mComposition.IsComposing()); + CompleteLastActionIfStillIncomplete(); PendingAction* action = mPendingActions.AppendElement(); action->mType = PendingAction::COMPOSITION_END; action->mData = mComposition.mString; diff --git a/widget/windows/nsTextStore.h b/widget/windows/nsTextStore.h index 48aa3a464be..d88ba4ff321 100644 --- a/widget/windows/nsTextStore.h +++ b/widget/windows/nsTextStore.h @@ -540,6 +540,14 @@ protected: lastAction.mIncomplete; } + void CompleteLastActionIfStillIncomplete() + { + if (!IsPendingCompositionUpdateIncomplete()) { + return; + } + RecordCompositionUpdateAction(); + } + // When On*Composition() is called without document lock, we need to flush // the recorded actions at quitting the method. // AutoPendingActionAndContentFlusher class is usedful for it.