зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1328023 - Part 1. Don't use RangeUpdater except to composition transaction. r=masayuki
Part 3 fix of bug 1310912 is incorrect for not composition transaction. PlaceholderTransation is for saving and restoring current selection for undo. So we shouldn't use range updater to normal transaction. Composition transaction can modify multiple nodes and it merges text node for ime into single text node. So if current selection is into IME text node, it might be failed to restore selection by UndoTransaction. So we need update selection by range updater to work UndoTransaction. Also, CompositionTransaction::UndoTransaction will set selection after committed text. So at finally, selection will set correct position that composition transaction wants. MozReview-Commit-ID: 1NcH32YoKPQ --HG-- extra : rebase_source : 8a29ef3d4d4c64997416a8f3c7fd174766764ad3
This commit is contained in:
Родитель
be1de47b7b
Коммит
1f259574fb
|
@ -927,9 +927,16 @@ EditorBase::BeginPlaceHolderTransaction(nsIAtom* aName)
|
|||
if (selection) {
|
||||
mSelState = new SelectionState();
|
||||
mSelState->SaveSelection(selection);
|
||||
// Composition transaction can modify multiple nodes and it merges text
|
||||
// node for ime into single text node.
|
||||
// So if current selection is into IME text node, it might be failed
|
||||
// to restore selection by UndoTransaction.
|
||||
// So we need update selection by range updater.
|
||||
if (mPlaceHolderName == nsGkAtoms::IMETxnName) {
|
||||
mRangeUpdater.RegisterSelectionState(*mSelState);
|
||||
}
|
||||
}
|
||||
}
|
||||
mPlaceHolderBatch++;
|
||||
|
||||
return NS_OK;
|
||||
|
@ -979,7 +986,9 @@ EditorBase::EndPlaceHolderTransaction()
|
|||
if (mSelState) {
|
||||
// we saved the selection state, but never got to hand it to placeholder
|
||||
// (else we ould have nulled out this pointer), so destroy it to prevent leaks.
|
||||
if (mPlaceHolderName == nsGkAtoms::IMETxnName) {
|
||||
mRangeUpdater.DropSelectionState(*mSelState);
|
||||
}
|
||||
delete mSelState;
|
||||
mSelState = nullptr;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче