Bug 1051689 Ensure to complete the last pending action r=emk

This commit is contained in:
Masayuki Nakano 2014-08-12 00:17:18 +09:00
parent 49861055d6
commit 0ac6705f98
2 changed files with 17 additions and 8 deletions

View File

@ -963,14 +963,12 @@ nsTextStore::DidLockGranted()
mNativeCaretIsCreated = false; mNativeCaretIsCreated = false;
} }
if (IsReadWriteLocked()) { if (IsReadWriteLocked()) {
if (IsPendingCompositionUpdateIncomplete()) { // FreeCJ (TIP for Traditional Chinese) calls SetSelection() to set caret
// FreeCJ (TIP for Traditional Chinese) calls SetSelection() to set caret // to the start of composition string and insert a full width space for
// to the start of composition string and insert a full width space for // a placeholder with a call of SetText(). After that, it calls
// a placeholder with a call of SetText(). After that, it calls // OnUpdateComposition() without new range. Therefore, let's record the
// OnUpdateComposition() without new range. Therefore, let's record the // composition update information here.
// composition update information here. CompleteLastActionIfStillIncomplete();
RecordCompositionUpdateAction();
}
FlushPendingActions(); FlushPendingActions();
} }
@ -1787,6 +1785,7 @@ nsTextStore::SetSelectionInternal(const TS_SELECTION_ACP* pSelection,
return S_OK; return S_OK;
} }
CompleteLastActionIfStillIncomplete();
PendingAction* action = mPendingActions.AppendElement(); PendingAction* action = mPendingActions.AppendElement();
action->mType = PendingAction::SELECTION_SET; action->mType = PendingAction::SELECTION_SET;
action->mSelectionStart = pSelection->acpStart; action->mSelectionStart = pSelection->acpStart;
@ -2812,6 +2811,7 @@ nsTextStore::RecordCompositionStartAction(ITfCompositionView* pComposition,
return E_FAIL; return E_FAIL;
} }
CompleteLastActionIfStillIncomplete();
PendingAction* action = mPendingActions.AppendElement(); PendingAction* action = mPendingActions.AppendElement();
action->mType = PendingAction::COMPOSITION_START; action->mType = PendingAction::COMPOSITION_START;
action->mSelectionStart = start; action->mSelectionStart = start;
@ -2842,6 +2842,7 @@ nsTextStore::RecordCompositionEndAction()
MOZ_ASSERT(mComposition.IsComposing()); MOZ_ASSERT(mComposition.IsComposing());
CompleteLastActionIfStillIncomplete();
PendingAction* action = mPendingActions.AppendElement(); PendingAction* action = mPendingActions.AppendElement();
action->mType = PendingAction::COMPOSITION_END; action->mType = PendingAction::COMPOSITION_END;
action->mData = mComposition.mString; action->mData = mComposition.mString;

View File

@ -540,6 +540,14 @@ protected:
lastAction.mIncomplete; lastAction.mIncomplete;
} }
void CompleteLastActionIfStillIncomplete()
{
if (!IsPendingCompositionUpdateIncomplete()) {
return;
}
RecordCompositionUpdateAction();
}
// When On*Composition() is called without document lock, we need to flush // When On*Composition() is called without document lock, we need to flush
// the recorded actions at quitting the method. // the recorded actions at quitting the method.
// AutoPendingActionAndContentFlusher class is usedful for it. // AutoPendingActionAndContentFlusher class is usedful for it.