ported from UXP: Bug 1337698 - Use UniquePtr instead of nsAutoPtr in editor (32e4ad01)

This commit is contained in:
2022-04-12 16:28:53 +08:00
parent 364b306792
commit 8c1831c528
10 changed files with 32 additions and 44 deletions
+2 -6
View File
@@ -681,13 +681,10 @@ EditorBase::DoTransaction(nsITransaction* aTxn)
{
if (mPlaceHolderBatch && !mPlaceHolderTxn) {
nsCOMPtr<nsIAbsorbingTransaction> placeholderTransaction =
new PlaceholderTransaction();
new PlaceholderTransaction(*this, mPlaceHolderName, Move(mSelState));
// Save off weak reference to placeholder transaction
mPlaceHolderTxn = do_GetWeakReference(placeholderTransaction);
placeholderTransaction->Init(mPlaceHolderName, mSelState, this);
// placeholder txn took ownership of this pointer
mSelState = nullptr;
// QI to an nsITransaction since that's what DoTransaction() expects
nsCOMPtr<nsITransaction> transaction =
@@ -937,7 +934,7 @@ EditorBase::BeginPlaceHolderTransaction(nsIAtom* aName)
mPlaceHolderName = aName;
RefPtr<Selection> selection = GetSelection();
if (selection) {
mSelState = new SelectionState();
mSelState = MakeUnique<SelectionState>();
mSelState->SaveSelection(selection);
// Composition transaction can modify multiple nodes and it merges text
// node for ime into single text node.
@@ -1001,7 +998,6 @@ EditorBase::EndPlaceHolderTransaction()
if (mPlaceHolderName == nsGkAtoms::IMETxnName) {
mRangeUpdater.DropSelectionState(*mSelState);
}
delete mSelState;
mSelState = nullptr;
}
// We might have never made a placeholder if no action took place.