diff --git a/editor/libeditor/HTMLEditRules.cpp b/editor/libeditor/HTMLEditRules.cpp index 6d092b06b4f0..14a5c73cef7c 100644 --- a/editor/libeditor/HTMLEditRules.cpp +++ b/editor/libeditor/HTMLEditRules.cpp @@ -16,13 +16,14 @@ #include "mozilla/EditorUtils.h" #include "mozilla/HTMLEditor.h" #include "mozilla/MathAlgorithms.h" +#include "mozilla/Move.h" #include "mozilla/Preferences.h" +#include "mozilla/UniquePtr.h" #include "mozilla/Unused.h" #include "mozilla/dom/Selection.h" #include "mozilla/dom/Element.h" #include "mozilla/OwningNonNull.h" #include "mozilla/mozalloc.h" -#include "nsAutoPtr.h" #include "nsAString.h" #include "nsAlgorithm.h" #include "nsCRT.h" @@ -4499,20 +4500,21 @@ HTMLEditRules::CreateStyleForInsertText(Selection& aSelection, NS_ENSURE_STATE(rootElement); // process clearing any styles first - nsAutoPtr item(mHTMLEditor->mTypeInState->TakeClearProperty()); + UniquePtr item = + Move(mHTMLEditor->mTypeInState->TakeClearProperty()); while (item && node != rootElement) { NS_ENSURE_STATE(mHTMLEditor); nsresult rv = mHTMLEditor->ClearStyle(address_of(node), &offset, item->tag, &item->attr); NS_ENSURE_SUCCESS(rv, rv); - item = mHTMLEditor->mTypeInState->TakeClearProperty(); + item = Move(mHTMLEditor->mTypeInState->TakeClearProperty()); weDidSomething = true; } // then process setting any styles int32_t relFontSize = mHTMLEditor->mTypeInState->TakeRelativeFontSize(); - item = mHTMLEditor->mTypeInState->TakeSetProperty(); + item = Move(mHTMLEditor->mTypeInState->TakeSetProperty()); if (item || relFontSize) { // we have at least one style to add; make a new text node to insert style diff --git a/editor/libeditor/TypeInState.cpp b/editor/libeditor/TypeInState.cpp index ce43e5e4dc6d..840139feeddb 100644 --- a/editor/libeditor/TypeInState.cpp +++ b/editor/libeditor/TypeInState.cpp @@ -193,7 +193,7 @@ TypeInState::ClearProp(nsIAtom* aProp, * TakeClearProperty() hands back next property item on the clear list. * Caller assumes ownership of PropItem and must delete it. */ -PropItem* +UniquePtr TypeInState::TakeClearProperty() { size_t count = mClearedArray.Length(); @@ -204,14 +204,14 @@ TypeInState::TakeClearProperty() --count; // indices are zero based PropItem* propItem = mClearedArray[count]; mClearedArray.RemoveElementAt(count); - return propItem; + return UniquePtr(propItem); } /** * TakeSetProperty() hands back next poroperty item on the set list. * Caller assumes ownership of PropItem and must delete it. */ -PropItem* +UniquePtr TypeInState::TakeSetProperty() { size_t count = mSetArray.Length(); @@ -221,7 +221,7 @@ TypeInState::TakeSetProperty() count--; // indices are zero based PropItem* propItem = mSetArray[count]; mSetArray.RemoveElementAt(count); - return propItem; + return UniquePtr(propItem); } /** diff --git a/editor/libeditor/TypeInState.h b/editor/libeditor/TypeInState.h index 540b2d9c1194..e1b949508c22 100644 --- a/editor/libeditor/TypeInState.h +++ b/editor/libeditor/TypeInState.h @@ -6,6 +6,7 @@ #ifndef TypeInState_h #define TypeInState_h +#include "mozilla/UniquePtr.h" #include "nsCOMPtr.h" #include "nsCycleCollectionParticipant.h" #include "nsISelectionListener.h" @@ -63,13 +64,13 @@ public: * TakeClearProperty() hands back next property item on the clear list. * Caller assumes ownership of PropItem and must delete it. */ - PropItem* TakeClearProperty(); + UniquePtr TakeClearProperty(); /** * TakeSetProperty() hands back next property item on the set list. * Caller assumes ownership of PropItem and must delete it. */ - PropItem* TakeSetProperty(); + UniquePtr TakeSetProperty(); /** * TakeRelativeFontSize() hands back relative font value, which is then