Bug 1198385 - Use MFBT guard macros in the editor guard objects; r=froydnj

This commit is contained in:
Ehsan Akhgari 2015-08-25 14:04:12 -04:00
Родитель f7bed16ad7
Коммит a20e95ba8f
2 изменённых файлов: 49 добавлений и 16 удалений

Просмотреть файл

@ -31,9 +31,11 @@ using namespace mozilla::dom;
* nsAutoSelectionReset
*****************************************************************************/
nsAutoSelectionReset::nsAutoSelectionReset(Selection* aSel, nsEditor* aEd)
nsAutoSelectionReset::nsAutoSelectionReset(Selection* aSel, nsEditor* aEd
MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
: mSel(nullptr), mEd(nullptr)
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
if (!aSel || !aEd) return; // not much we can do, bail.
if (aEd->ArePreservingSelection()) return; // we already have initted mSavedSel, so this must be nested call.
mSel = aSel;
@ -66,8 +68,9 @@ nsAutoSelectionReset::Abort()
* some helper classes for iterating the dom tree
*****************************************************************************/
nsDOMIterator::nsDOMIterator(nsINode& aNode)
nsDOMIterator::nsDOMIterator(nsINode& aNode MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
mIter = NS_NewContentIterator();
DebugOnly<nsresult> res = mIter->Init(&aNode);
MOZ_ASSERT(NS_SUCCEEDED(res));
@ -80,8 +83,9 @@ nsDOMIterator::Init(nsRange& aRange)
return mIter->Init(&aRange);
}
nsDOMIterator::nsDOMIterator()
nsDOMIterator::nsDOMIterator(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_IN_IMPL)
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
}
nsDOMIterator::~nsDOMIterator()
@ -102,7 +106,8 @@ nsDOMIterator::AppendList(const nsBoolDomIterFunctor& functor,
}
}
nsDOMSubtreeIterator::nsDOMSubtreeIterator()
nsDOMSubtreeIterator::nsDOMSubtreeIterator(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_IN_IMPL)
: nsDOMIterator(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_TO_PARENT)
{
}

Просмотреть файл

@ -14,6 +14,7 @@
#include "nsIDOMNode.h"
#include "nsIEditor.h"
#include "nscore.h"
#include "mozilla/GuardObjects.h"
class nsIAtom;
class nsIContentIterator;
@ -34,10 +35,22 @@ class MOZ_STACK_CLASS nsAutoPlaceHolderBatch
{
private:
nsCOMPtr<nsIEditor> mEd;
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
public:
nsAutoPlaceHolderBatch( nsIEditor *aEd, nsIAtom *atom) : mEd(do_QueryInterface(aEd))
{ if (mEd) mEd->BeginPlaceHolderTransaction(atom); }
~nsAutoPlaceHolderBatch() { if (mEd) mEd->EndPlaceHolderTransaction(); }
nsAutoPlaceHolderBatch(nsIEditor *aEd, nsIAtom *atom MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
: mEd(do_QueryInterface(aEd))
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
if (mEd) {
mEd->BeginPlaceHolderTransaction(atom);
}
}
~nsAutoPlaceHolderBatch()
{
if (mEd) {
mEd->EndPlaceHolderTransaction();
}
}
};
/***************************************************************************
@ -47,8 +60,13 @@ class MOZ_STACK_CLASS nsAutoPlaceHolderBatch
*/
class MOZ_STACK_CLASS nsAutoEditBatch : public nsAutoPlaceHolderBatch
{
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
public:
explicit nsAutoEditBatch( nsIEditor *aEd) : nsAutoPlaceHolderBatch(aEd,nullptr) {}
explicit nsAutoEditBatch(nsIEditor *aEd MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
: nsAutoPlaceHolderBatch(aEd, nullptr)
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
}
~nsAutoEditBatch() {}
};
@ -62,10 +80,11 @@ class MOZ_STACK_CLASS nsAutoSelectionReset
/** ref-counted reference to the selection that we are supposed to restore */
nsRefPtr<mozilla::dom::Selection> mSel;
nsEditor *mEd; // non-owning ref to nsEditor
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
public:
/** constructor responsible for remembering all state needed to restore aSel */
nsAutoSelectionReset(mozilla::dom::Selection* aSel, nsEditor* aEd);
nsAutoSelectionReset(mozilla::dom::Selection* aSel, nsEditor* aEd MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
/** destructor restores mSel to its former state */
~nsAutoSelectionReset();
@ -82,9 +101,11 @@ class MOZ_STACK_CLASS nsAutoRules
public:
nsAutoRules(nsEditor *ed, EditAction action,
nsIEditor::EDirection aDirection) :
mEd(ed), mDoNothing(false)
nsIEditor::EDirection aDirection
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
: mEd(ed), mDoNothing(false)
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
if (mEd && !mEd->mAction) // mAction will already be set if this is nested call
{
mEd->StartOperation(action, aDirection);
@ -102,6 +123,7 @@ class MOZ_STACK_CLASS nsAutoRules
protected:
nsEditor *mEd;
bool mDoNothing;
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
};
@ -113,8 +135,10 @@ class MOZ_STACK_CLASS nsAutoTxnsConserveSelection
{
public:
explicit nsAutoTxnsConserveSelection(nsEditor *ed) : mEd(ed), mOldState(true)
explicit nsAutoTxnsConserveSelection(nsEditor *ed MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
: mEd(ed), mOldState(true)
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
if (mEd)
{
mOldState = mEd->GetShouldTxnSetSelection();
@ -133,6 +157,7 @@ class MOZ_STACK_CLASS nsAutoTxnsConserveSelection
protected:
nsEditor *mEd;
bool mOldState;
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
};
/***************************************************************************
@ -142,8 +167,9 @@ class MOZ_STACK_CLASS nsAutoUpdateViewBatch
{
public:
explicit nsAutoUpdateViewBatch(nsEditor *ed) : mEd(ed)
explicit nsAutoUpdateViewBatch(nsEditor *ed MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : mEd(ed)
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
NS_ASSERTION(mEd, "null mEd pointer!");
if (mEd)
@ -158,6 +184,7 @@ class MOZ_STACK_CLASS nsAutoUpdateViewBatch
protected:
nsEditor *mEd;
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
};
/******************************************************************************
@ -173,9 +200,9 @@ class nsBoolDomIterFunctor
class MOZ_STACK_CLASS nsDOMIterator
{
public:
nsDOMIterator();
nsDOMIterator(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM);
explicit nsDOMIterator(nsINode& aNode);
explicit nsDOMIterator(nsINode& aNode MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
virtual ~nsDOMIterator();
nsresult Init(nsRange& aRange);
@ -184,12 +211,13 @@ class MOZ_STACK_CLASS nsDOMIterator
nsTArray<mozilla::OwningNonNull<nsINode>>& arrayOfNodes) const;
protected:
nsCOMPtr<nsIContentIterator> mIter;
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
};
class MOZ_STACK_CLASS nsDOMSubtreeIterator : public nsDOMIterator
{
public:
nsDOMSubtreeIterator();
nsDOMSubtreeIterator(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM);
virtual ~nsDOMSubtreeIterator();
nsresult Init(nsRange& aRange);