зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1337698 - Part 3. TypeInState should use UniquePtr. r=masayuki
MozReview-Commit-ID: K9UY83Nx1v3 --HG-- extra : rebase_source : e9177c1c31805288e04270b589300c8e49d59940 extra : amend_source : 91bea4e023031b1c1594799b8dbe70dc3fb5b6ed extra : histedit_source : 2ee5b839c0f8019d18586a1b07e06e122e7780ee
This commit is contained in:
Родитель
d84f1fef72
Коммит
894130bddc
|
@ -16,13 +16,14 @@
|
||||||
#include "mozilla/EditorUtils.h"
|
#include "mozilla/EditorUtils.h"
|
||||||
#include "mozilla/HTMLEditor.h"
|
#include "mozilla/HTMLEditor.h"
|
||||||
#include "mozilla/MathAlgorithms.h"
|
#include "mozilla/MathAlgorithms.h"
|
||||||
|
#include "mozilla/Move.h"
|
||||||
#include "mozilla/Preferences.h"
|
#include "mozilla/Preferences.h"
|
||||||
|
#include "mozilla/UniquePtr.h"
|
||||||
#include "mozilla/Unused.h"
|
#include "mozilla/Unused.h"
|
||||||
#include "mozilla/dom/Selection.h"
|
#include "mozilla/dom/Selection.h"
|
||||||
#include "mozilla/dom/Element.h"
|
#include "mozilla/dom/Element.h"
|
||||||
#include "mozilla/OwningNonNull.h"
|
#include "mozilla/OwningNonNull.h"
|
||||||
#include "mozilla/mozalloc.h"
|
#include "mozilla/mozalloc.h"
|
||||||
#include "nsAutoPtr.h"
|
|
||||||
#include "nsAString.h"
|
#include "nsAString.h"
|
||||||
#include "nsAlgorithm.h"
|
#include "nsAlgorithm.h"
|
||||||
#include "nsCRT.h"
|
#include "nsCRT.h"
|
||||||
|
@ -4499,20 +4500,21 @@ HTMLEditRules::CreateStyleForInsertText(Selection& aSelection,
|
||||||
NS_ENSURE_STATE(rootElement);
|
NS_ENSURE_STATE(rootElement);
|
||||||
|
|
||||||
// process clearing any styles first
|
// process clearing any styles first
|
||||||
nsAutoPtr<PropItem> item(mHTMLEditor->mTypeInState->TakeClearProperty());
|
UniquePtr<PropItem> item =
|
||||||
|
Move(mHTMLEditor->mTypeInState->TakeClearProperty());
|
||||||
while (item && node != rootElement) {
|
while (item && node != rootElement) {
|
||||||
NS_ENSURE_STATE(mHTMLEditor);
|
NS_ENSURE_STATE(mHTMLEditor);
|
||||||
nsresult rv =
|
nsresult rv =
|
||||||
mHTMLEditor->ClearStyle(address_of(node), &offset,
|
mHTMLEditor->ClearStyle(address_of(node), &offset,
|
||||||
item->tag, &item->attr);
|
item->tag, &item->attr);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
item = mHTMLEditor->mTypeInState->TakeClearProperty();
|
item = Move(mHTMLEditor->mTypeInState->TakeClearProperty());
|
||||||
weDidSomething = true;
|
weDidSomething = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// then process setting any styles
|
// then process setting any styles
|
||||||
int32_t relFontSize = mHTMLEditor->mTypeInState->TakeRelativeFontSize();
|
int32_t relFontSize = mHTMLEditor->mTypeInState->TakeRelativeFontSize();
|
||||||
item = mHTMLEditor->mTypeInState->TakeSetProperty();
|
item = Move(mHTMLEditor->mTypeInState->TakeSetProperty());
|
||||||
|
|
||||||
if (item || relFontSize) {
|
if (item || relFontSize) {
|
||||||
// we have at least one style to add; make a new text node to insert style
|
// we have at least one style to add; make a new text node to insert style
|
||||||
|
|
|
@ -193,7 +193,7 @@ TypeInState::ClearProp(nsIAtom* aProp,
|
||||||
* TakeClearProperty() hands back next property item on the clear list.
|
* TakeClearProperty() hands back next property item on the clear list.
|
||||||
* Caller assumes ownership of PropItem and must delete it.
|
* Caller assumes ownership of PropItem and must delete it.
|
||||||
*/
|
*/
|
||||||
PropItem*
|
UniquePtr<PropItem>
|
||||||
TypeInState::TakeClearProperty()
|
TypeInState::TakeClearProperty()
|
||||||
{
|
{
|
||||||
size_t count = mClearedArray.Length();
|
size_t count = mClearedArray.Length();
|
||||||
|
@ -204,14 +204,14 @@ TypeInState::TakeClearProperty()
|
||||||
--count; // indices are zero based
|
--count; // indices are zero based
|
||||||
PropItem* propItem = mClearedArray[count];
|
PropItem* propItem = mClearedArray[count];
|
||||||
mClearedArray.RemoveElementAt(count);
|
mClearedArray.RemoveElementAt(count);
|
||||||
return propItem;
|
return UniquePtr<PropItem>(propItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TakeSetProperty() hands back next poroperty item on the set list.
|
* TakeSetProperty() hands back next poroperty item on the set list.
|
||||||
* Caller assumes ownership of PropItem and must delete it.
|
* Caller assumes ownership of PropItem and must delete it.
|
||||||
*/
|
*/
|
||||||
PropItem*
|
UniquePtr<PropItem>
|
||||||
TypeInState::TakeSetProperty()
|
TypeInState::TakeSetProperty()
|
||||||
{
|
{
|
||||||
size_t count = mSetArray.Length();
|
size_t count = mSetArray.Length();
|
||||||
|
@ -221,7 +221,7 @@ TypeInState::TakeSetProperty()
|
||||||
count--; // indices are zero based
|
count--; // indices are zero based
|
||||||
PropItem* propItem = mSetArray[count];
|
PropItem* propItem = mSetArray[count];
|
||||||
mSetArray.RemoveElementAt(count);
|
mSetArray.RemoveElementAt(count);
|
||||||
return propItem;
|
return UniquePtr<PropItem>(propItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#ifndef TypeInState_h
|
#ifndef TypeInState_h
|
||||||
#define TypeInState_h
|
#define TypeInState_h
|
||||||
|
|
||||||
|
#include "mozilla/UniquePtr.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsCycleCollectionParticipant.h"
|
#include "nsCycleCollectionParticipant.h"
|
||||||
#include "nsISelectionListener.h"
|
#include "nsISelectionListener.h"
|
||||||
|
@ -63,13 +64,13 @@ public:
|
||||||
* TakeClearProperty() hands back next property item on the clear list.
|
* TakeClearProperty() hands back next property item on the clear list.
|
||||||
* Caller assumes ownership of PropItem and must delete it.
|
* Caller assumes ownership of PropItem and must delete it.
|
||||||
*/
|
*/
|
||||||
PropItem* TakeClearProperty();
|
UniquePtr<PropItem> TakeClearProperty();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TakeSetProperty() hands back next property item on the set list.
|
* TakeSetProperty() hands back next property item on the set list.
|
||||||
* Caller assumes ownership of PropItem and must delete it.
|
* Caller assumes ownership of PropItem and must delete it.
|
||||||
*/
|
*/
|
||||||
PropItem* TakeSetProperty();
|
UniquePtr<PropItem> TakeSetProperty();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TakeRelativeFontSize() hands back relative font value, which is then
|
* TakeRelativeFontSize() hands back relative font value, which is then
|
||||||
|
|
Загрузка…
Ссылка в новой задаче