Bug 1237216 TSFTextStore should forget redundant pending composition events for Korean TIPs r=emk

This commit is contained in:
Masayuki Nakano 2016-01-18 16:29:02 +09:00
parent 181a3bca12
commit 3bb367b6ca
2 changed files with 29 additions and 1 deletions

View File

@ -4099,6 +4099,7 @@ TSFTextStore::RecordCompositionStartAction(ITfCompositionView* aComposition,
}
lockedContent.StartComposition(aComposition, *action, aPreserveSelection);
action->mData = mComposition.mString;
MOZ_LOG(sTextStoreLog, LogLevel::Info,
("TSF: 0x%p TSFTextStore::RecordCompositionStartAction() succeeded: "
@ -4137,6 +4138,33 @@ TSFTextStore::RecordCompositionEndAction()
}
lockedContent.EndComposition(*action);
// If this composition was restart but the composition doesn't modify
// anything, we should remove the pending composition for preventing to
// dispatch redundant composition events.
for (size_t i = mPendingActions.Length(), j = 1; i > 0; --i, ++j) {
PendingAction& pendingAction = mPendingActions[i - 1];
if (pendingAction.mType == PendingAction::COMPOSITION_START) {
if (pendingAction.mData != action->mData) {
break;
}
// When only setting selection is necessary, we should append it.
if (pendingAction.mAdjustSelection) {
PendingAction* setSelection = mPendingActions.AppendElement();
setSelection->mType = PendingAction::SET_SELECTION;
setSelection->mSelectionStart = pendingAction.mSelectionStart;
setSelection->mSelectionLength = pendingAction.mSelectionLength;
setSelection->mSelectionReversed = false;
}
// Remove the redundant pending composition.
mPendingActions.RemoveElementsAt(i - 1, j);
MOZ_LOG(sTextStoreLog, LogLevel::Info,
("TSF: 0x%p TSFTextStore::RecordCompositionEndAction(), "
"succeeded, but the composition was canceled due to redundant",
this));
return S_OK;
}
}
MOZ_LOG(sTextStoreLog, LogLevel::Info,
("TSF: 0x%p TSFTextStore::RecordCompositionEndAction(), succeeded",
this));

View File

@ -518,7 +518,7 @@ protected:
// For compositionstart and selectionset
LONG mSelectionStart;
LONG mSelectionLength;
// For compositionupdate and compositionend
// For compositionstart, compositionupdate and compositionend
nsString mData;
// For compositionupdate
RefPtr<TextRangeArray> mRanges;