mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-05 15:28:39 +09:00
Don't allocate PendingAction twice.
This commit is contained in:
parent
22772136d7
commit
107ddd1148
1 changed files with 6 additions and 4 deletions
|
|
@ -4247,14 +4247,14 @@ 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::COMPOSITION_START;
|
||||
compositionStart->mSelectionStart = oldSelection.acpStart;
|
||||
compositionStart->mSelectionLength =
|
||||
oldSelection.acpEnd - oldSelection.acpStart;
|
||||
compositionStart->mAdjustSelection = false;
|
||||
|
||||
PendingAction* compositionEnd = mPendingActions.AppendElement();
|
||||
compositionEnd->mType = PendingAction::COMPOSITION_END;
|
||||
compositionEnd->mData = aInsertStr;
|
||||
|
||||
|
|
@ -4455,10 +4455,12 @@ 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::SET_SELECTION;
|
||||
setSelection->mSelectionStart = pendingAction.mSelectionStart;
|
||||
setSelection->mSelectionLength = pendingAction.mSelectionLength;
|
||||
setSelection->mSelectionStart = selectionStart;
|
||||
setSelection->mSelectionLength = selectionLength;
|
||||
setSelection->mSelectionReversed = false;
|
||||
}
|
||||
// Remove the redundant pending composition.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue