mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-26 20:30:41 +00:00
Bug 1488803 - Don't allocate PendingAction twice. r=masayuki
--HG-- extra : histedit_source : 2197a1ddf204b19e1ecd3cf5142fe22e0a2aa04e
This commit is contained in:
parent
fedf18933b
commit
82b98972c8
@ -5279,14 +5279,15 @@ TSFTextStore::InsertTextAtSelectionInternal(const nsAString& aInsertStr,
|
||||
TS_SELECTION_ACP oldSelection = contentForTSF.Selection().ACP();
|
||||
if (!mComposition.IsComposing()) {
|
||||
// Use a temporary composition to contain the text
|
||||
PendingAction* compositionStart = mPendingActions.AppendElement();
|
||||
PendingAction* compositionStart = mPendingActions.AppendElements(2);
|
||||
PendingAction* compositionEnd = compositionStart + 1;
|
||||
|
||||
compositionStart->mType = PendingAction::Type::eCompositionStart;
|
||||
compositionStart->mSelectionStart = oldSelection.acpStart;
|
||||
compositionStart->mSelectionLength =
|
||||
oldSelection.acpEnd - oldSelection.acpStart;
|
||||
compositionStart->mAdjustSelection = false;
|
||||
|
||||
PendingAction* compositionEnd = mPendingActions.AppendElement();
|
||||
compositionEnd->mType = PendingAction::Type::eCompositionEnd;
|
||||
compositionEnd->mData = aInsertStr;
|
||||
compositionEnd->mSelectionStart = compositionStart->mSelectionStart;
|
||||
@ -5515,10 +5516,13 @@ TSFTextStore::RecordCompositionEndAction()
|
||||
}
|
||||
// When only setting selection is necessary, we should append it.
|
||||
if (pendingAction.mAdjustSelection) {
|
||||
LONG selectionStart = pendingAction.mSelectionStart;
|
||||
LONG selectionLength = pendingAction.mSelectionLength;
|
||||
|
||||
PendingAction* setSelection = mPendingActions.AppendElement();
|
||||
setSelection->mType = PendingAction::Type::eSetSelection;
|
||||
setSelection->mSelectionStart = pendingAction.mSelectionStart;
|
||||
setSelection->mSelectionLength = pendingAction.mSelectionLength;
|
||||
setSelection->mSelectionStart = selectionStart;
|
||||
setSelection->mSelectionLength = selectionLength;
|
||||
setSelection->mSelectionReversed = false;
|
||||
}
|
||||
// Remove the redundant pending composition.
|
||||
|
Loading…
x
Reference in New Issue
Block a user