diff --git a/content/smil/nsSMILInstanceTime.h b/content/smil/nsSMILInstanceTime.h index 6b05ace864d..b76e8764172 100644 --- a/content/smil/nsSMILInstanceTime.h +++ b/content/smil/nsSMILInstanceTime.h @@ -124,36 +124,7 @@ public: PRUint32 Serial() const { return mSerial; } void SetSerial(PRUint32 aIndex) { mSerial = aIndex; } - nsrefcnt AddRef() - { - if (mRefCnt == PR_UINT32_MAX) { - NS_WARNING("refcount overflow, leaking nsSMILInstanceTime"); - return mRefCnt; - } - NS_ASSERT_OWNINGTHREAD(_class); - NS_ABORT_IF_FALSE(_mOwningThread.GetThread() == PR_GetCurrentThread(), - "nsSMILInstanceTime addref isn't thread-safe!"); - ++mRefCnt; - NS_LOG_ADDREF(this, mRefCnt, "nsSMILInstanceTime", sizeof(*this)); - return mRefCnt; - } - - nsrefcnt Release() - { - if (mRefCnt == PR_UINT32_MAX) { - NS_WARNING("refcount overflow, leaking nsSMILInstanceTime"); - return mRefCnt; - } - NS_ABORT_IF_FALSE(_mOwningThread.GetThread() == PR_GetCurrentThread(), - "nsSMILInstanceTime release isn't thread-safe!"); - --mRefCnt; - NS_LOG_RELEASE(this, mRefCnt, "nsSMILInstanceTime"); - if (mRefCnt == 0) { - delete this; - return 0; - } - return mRefCnt; - } + NS_INLINE_DECL_REFCOUNTING(nsSMILInstanceTime) protected: void SetBaseInterval(nsSMILInterval* aBaseInterval); @@ -162,9 +133,6 @@ protected: nsSMILTimeValue mTime; - nsAutoRefCnt mRefCnt; - NS_DECL_OWNINGTHREAD - // Internal flags used for represent behaviour of different instance times` enum { // Indicates if this instance time should be removed when the owning timed diff --git a/content/xbl/src/nsXBLBinding.h b/content/xbl/src/nsXBLBinding.h index 492c9757ee5..d88633a7089 100644 --- a/content/xbl/src/nsXBLBinding.h +++ b/content/xbl/src/nsXBLBinding.h @@ -46,6 +46,7 @@ #include "nsClassHashtable.h" #include "nsTArray.h" #include "nsCycleCollectionParticipant.h" +#include "nsISupportsImpl.h" class nsXBLPrototypeBinding; class nsIContent; @@ -77,24 +78,7 @@ public: * which are queued to fire their constructors. */ - nsrefcnt AddRef() - { - ++mRefCnt; - NS_LOG_ADDREF(this, mRefCnt, "nsXBLBinding", sizeof(nsXBLBinding)); - return mRefCnt; - } - - nsrefcnt Release() - { - --mRefCnt; - NS_LOG_RELEASE(this, mRefCnt, "nsXBLBinding"); - if (mRefCnt == 0) { - mRefCnt = 1; - delete this; - return 0; - } - return mRefCnt; - } + NS_INLINE_DECL_REFCOUNTING(nsXBLBinding) NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(nsXBLBinding) @@ -172,7 +156,6 @@ public: // MEMBER VARIABLES protected: - nsAutoRefCnt mRefCnt; nsXBLPrototypeBinding* mPrototypeBinding; // Weak, but we're holding a ref to the docinfo nsCOMPtr mContent; // Strong. Our anonymous content stays around with us. nsRefPtr mNextBinding; // Strong. The derived binding owns the base class bindings. diff --git a/content/xbl/src/nsXBLInsertionPoint.cpp b/content/xbl/src/nsXBLInsertionPoint.cpp index 62e70319508..d3d0dc582fa 100644 --- a/content/xbl/src/nsXBLInsertionPoint.cpp +++ b/content/xbl/src/nsXBLInsertionPoint.cpp @@ -57,19 +57,6 @@ nsXBLInsertionPoint::~nsXBLInsertionPoint() } } -nsrefcnt -nsXBLInsertionPoint::Release() -{ - --mRefCnt; - NS_LOG_RELEASE(this, mRefCnt, "nsXBLInsertionPoint"); - if (mRefCnt == 0) { - mRefCnt = 1; - delete this; - return 0; - } - return mRefCnt; -} - NS_IMPL_CYCLE_COLLECTION_CLASS(nsXBLInsertionPoint) NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_NATIVE(nsXBLInsertionPoint) NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMARRAY(mElements) diff --git a/content/xbl/src/nsXBLInsertionPoint.h b/content/xbl/src/nsXBLInsertionPoint.h index c1f05045a4d..5ec9239bd3f 100644 --- a/content/xbl/src/nsXBLInsertionPoint.h +++ b/content/xbl/src/nsXBLInsertionPoint.h @@ -50,15 +50,7 @@ public: nsXBLInsertionPoint(nsIContent* aParentElement, PRUint32 aIndex, nsIContent* aDefContent); ~nsXBLInsertionPoint(); - nsrefcnt AddRef() - { - ++mRefCnt; - NS_LOG_ADDREF(this, mRefCnt, "nsXBLInsertionPoint", - sizeof(nsXBLInsertionPoint)); - return mRefCnt; - } - - nsrefcnt Release(); + NS_INLINE_DECL_REFCOUNTING(nsXBLInsertionPoint) NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(nsXBLInsertionPoint) @@ -90,7 +82,6 @@ public: void UnbindDefaultContent(); protected: - nsAutoRefCnt mRefCnt; nsIContent* mParentElement; // This ref is weak. The parent of the element. PRInt32 mIndex; // The index of this insertion point. -1 is a pseudo-point. nsCOMArray mElements; // An array of elements present at the insertion point. diff --git a/content/xbl/src/nsXBLPrototypeBinding.cpp b/content/xbl/src/nsXBLPrototypeBinding.cpp index 8b6e97d2b03..4f417c8e1c6 100644 --- a/content/xbl/src/nsXBLPrototypeBinding.cpp +++ b/content/xbl/src/nsXBLPrototypeBinding.cpp @@ -207,27 +207,12 @@ public: nsXBLInsertionPointEntry::ReleasePool(); } - nsrefcnt AddRef() { - ++mRefCnt; - NS_LOG_ADDREF(this, mRefCnt, "nsXBLInsertionPointEntry", sizeof(nsXBLInsertionPointEntry)); - return mRefCnt; - } - - nsrefcnt Release() { - --mRefCnt; - NS_LOG_RELEASE(this, mRefCnt, "nsXBLInsertionPointEntry"); - if (mRefCnt == 0) { - Destroy(this); - return 0; - } - return mRefCnt; - } + NS_INLINE_DECL_REFCOUNTING(nsXBLInsertionPointEntry) protected: nsCOMPtr mInsertionParent; nsCOMPtr mDefaultContent; PRUint32 mInsertionIndex; - nsAutoRefCnt mRefCnt; nsXBLInsertionPointEntry(nsIContent* aParent) : mInsertionParent(aParent), diff --git a/content/xslt/src/xslt/txMozillaStylesheetCompiler.cpp b/content/xslt/src/xslt/txMozillaStylesheetCompiler.cpp index daf93445616..2ab7c3f1179 100644 --- a/content/xslt/src/xslt/txMozillaStylesheetCompiler.cpp +++ b/content/xslt/src/xslt/txMozillaStylesheetCompiler.cpp @@ -404,14 +404,12 @@ public: txCompileObserver(txMozillaXSLTProcessor* aProcessor, nsILoadGroup* aLoadGroup); - TX_DECL_ACOMPILEOBSERVER; + TX_DECL_ACOMPILEOBSERVER + NS_INLINE_DECL_REFCOUNTING(txCompileObserver) nsresult startLoad(nsIURI* aUri, txStylesheetCompiler* aCompiler, nsIPrincipal* aSourcePrincipal); -protected: - nsAutoRefCnt mRefCnt; - private: nsRefPtr mProcessor; nsCOMPtr mLoadGroup; @@ -429,23 +427,6 @@ txCompileObserver::txCompileObserver(txMozillaXSLTProcessor* aProcessor, { } -nsrefcnt -txCompileObserver::AddRef() -{ - return ++mRefCnt; -} - -nsrefcnt -txCompileObserver::Release() -{ - if (--mRefCnt == 0) { - mRefCnt = 1; //stabilize - delete this; - return 0; - } - return mRefCnt; -} - nsresult txCompileObserver::loadURI(const nsAString& aUri, const nsAString& aReferrerUri, @@ -658,11 +639,11 @@ class txSyncCompileObserver : public txACompileObserver public: txSyncCompileObserver(txMozillaXSLTProcessor* aProcessor); - TX_DECL_ACOMPILEOBSERVER; + TX_DECL_ACOMPILEOBSERVER + NS_INLINE_DECL_REFCOUNTING(txSyncCompileObserver) protected: nsRefPtr mProcessor; - nsAutoRefCnt mRefCnt; }; txSyncCompileObserver::txSyncCompileObserver(txMozillaXSLTProcessor* aProcessor) @@ -670,23 +651,6 @@ txSyncCompileObserver::txSyncCompileObserver(txMozillaXSLTProcessor* aProcessor) { } -nsrefcnt -txSyncCompileObserver::AddRef() -{ - return ++mRefCnt; -} - -nsrefcnt -txSyncCompileObserver::Release() -{ - if (--mRefCnt == 0) { - mRefCnt = 1; //stabilize - delete this; - return 0; - } - return mRefCnt; -} - nsresult txSyncCompileObserver::loadURI(const nsAString& aUri, const nsAString& aReferrerUri, diff --git a/content/xslt/src/xslt/txStandaloneStylesheetCompiler.cpp b/content/xslt/src/xslt/txStandaloneStylesheetCompiler.cpp index 11347fbbfd0..f68ad544cca 100644 --- a/content/xslt/src/xslt/txStandaloneStylesheetCompiler.cpp +++ b/content/xslt/src/xslt/txStandaloneStylesheetCompiler.cpp @@ -64,7 +64,8 @@ class txDriver : public txACompileObserver const XML_Char *aSystemId, const XML_Char *aPublicId); - TX_DECL_ACOMPILEOBSERVER; + TX_DECL_ACOMPILEOBSERVER + NS_INLINE_DECL_REFCOUNTING(txDriver) nsRefPtr mCompiler; protected: @@ -73,7 +74,6 @@ class txDriver : public txACompileObserver // keep track of the nsresult returned by the handlers, expat forgets them nsresult mRV; XML_Parser mExpatParser; - nsAutoRefCnt mRefCnt; }; nsresult @@ -338,23 +338,6 @@ txDriver::createErrorString() * txACompileObserver implementation */ -nsrefcnt -txDriver::AddRef() -{ - return ++mRefCnt; -} - -nsrefcnt -txDriver::Release() -{ - if (--mRefCnt == 0) { - mRefCnt = 1; //stabilize - delete this; - return 0; - } - return mRefCnt; -} - void txDriver::onDoneCompiling(txStylesheetCompiler* aCompiler, nsresult aResult, const PRUnichar *aErrorText, const PRUnichar *aParam) diff --git a/content/xslt/src/xslt/txStylesheet.h b/content/xslt/src/xslt/txStylesheet.h index 5f6228f1fbe..cd159e8f730 100644 --- a/content/xslt/src/xslt/txStylesheet.h +++ b/content/xslt/src/xslt/txStylesheet.h @@ -44,6 +44,7 @@ #include "txList.h" #include "txXSLTPatterns.h" #include "nsTPtrArray.h" +#include "nsISupportsImpl.h" class txInstruction; class txToplevelItem; @@ -67,20 +68,8 @@ public: txStylesheet(); ~txStylesheet(); nsresult init(); - - nsrefcnt AddRef() - { - return ++mRefCnt; - } - nsrefcnt Release() - { - if (--mRefCnt == 0) { - mRefCnt = 1; //stabilize - delete this; - return 0; - } - return mRefCnt; - } + + NS_INLINE_DECL_REFCOUNTING(txStylesheet) txInstruction* findTemplate(const txXPathNode& aNode, const txExpandedName& aMode, @@ -159,9 +148,6 @@ private: nsTPtrArray& aFrameStripSpaceTests); nsresult addAttributeSet(txAttributeSetItem* aAttributeSetItem); - // Refcount - nsAutoRefCnt mRefCnt; - // List of ImportFrames txList mImportFrames; diff --git a/content/xslt/src/xslt/txStylesheetCompiler.cpp b/content/xslt/src/xslt/txStylesheetCompiler.cpp index 759c5cb4306..d0050683fd0 100644 --- a/content/xslt/src/xslt/txStylesheetCompiler.cpp +++ b/content/xslt/src/xslt/txStylesheetCompiler.cpp @@ -69,27 +69,6 @@ txStylesheetCompiler::txStylesheetCompiler(const nsAString& aStylesheetURI, mStatus = init(aStylesheetURI, aStylesheet, aInsertPosition); } -nsrefcnt -txStylesheetCompiler::AddRef() -{ - ++mRefCnt; - NS_LOG_ADDREF(this, mRefCnt, "txStylesheetCompiler", sizeof(*this)); - return mRefCnt; -} - -nsrefcnt -txStylesheetCompiler::Release() -{ - --mRefCnt; - NS_LOG_RELEASE(this, mRefCnt, "txStylesheetCompiler"); - if (mRefCnt == 0) { - mRefCnt = 1; //stabilize - delete this; - return 0; - } - return mRefCnt; -} - void txStylesheetCompiler::setBaseURI(const nsString& aBaseURI) { diff --git a/content/xslt/src/xslt/txStylesheetCompiler.h b/content/xslt/src/xslt/txStylesheetCompiler.h index fc23fb4d3d8..4d71484af26 100644 --- a/content/xslt/src/xslt/txStylesheetCompiler.h +++ b/content/xslt/src/xslt/txStylesheetCompiler.h @@ -77,8 +77,8 @@ public: class txACompileObserver { public: - virtual nsrefcnt AddRef() = 0; - virtual nsrefcnt Release() = 0; + virtual void AddRef() = 0; + virtual void Release() = 0; virtual nsresult loadURI(const nsAString& aUri, const nsAString& aReferrerUri, @@ -90,13 +90,11 @@ public: }; #define TX_DECL_ACOMPILEOBSERVER \ - nsrefcnt AddRef(); \ - nsrefcnt Release(); \ nsresult loadURI(const nsAString& aUri, const nsAString& aReferrerUri, \ txStylesheetCompiler* aCompiler); \ void onDoneCompiling(txStylesheetCompiler* aCompiler, nsresult aResult, \ const PRUnichar *aErrorText = nsnull, \ - const PRUnichar *aParam = nsnull) + const PRUnichar *aParam = nsnull); class txStylesheetCompilerState : public txIParseContext { @@ -215,8 +213,6 @@ public: txStylesheet* aStylesheet, txListIterator* aInsertPosition, txACompileObserver* aObserver); - virtual nsrefcnt AddRef(); - virtual nsrefcnt Release(); void setBaseURI(const nsString& aBaseURI); @@ -235,12 +231,8 @@ public: txStylesheet* getStylesheet(); - // txACompileObserver - nsresult loadURI(const nsAString& aUri, const nsAString& aReferrerUri, - txStylesheetCompiler* aCompiler); - void onDoneCompiling(txStylesheetCompiler* aCompiler, nsresult aResult, - const PRUnichar *aErrorText = nsnull, - const PRUnichar *aParam = nsnull); + TX_DECL_ACOMPILEOBSERVER + NS_INLINE_DECL_REFCOUNTING(txStylesheetCompiler) private: nsresult startElementInternal(PRInt32 aNamespaceID, nsIAtom* aLocalName, @@ -253,7 +245,6 @@ private: nsresult ensureNewElementContext(); nsresult maybeDoneCompiling(); - nsAutoRefCnt mRefCnt; nsString mCharacters; nsresult mStatus; }; diff --git a/content/xul/templates/src/nsRDFBinding.h b/content/xul/templates/src/nsRDFBinding.h index 2a8ab79973f..82ad20068dd 100644 --- a/content/xul/templates/src/nsRDFBinding.h +++ b/content/xul/templates/src/nsRDFBinding.h @@ -40,6 +40,7 @@ #include "nsAutoPtr.h" #include "nsIAtom.h" #include "nsIRDFResource.h" +#include "nsISupportsImpl.h" class nsXULTemplateResultRDF; class nsBindingValues; @@ -95,9 +96,6 @@ class RDFBindingSet { protected: - // results hold a reference to a binding set in their nsBindingValues fields - PRInt32 mRefCnt; - // the number of bindings PRInt32 mCount; @@ -107,8 +105,7 @@ protected: public: RDFBindingSet() - : mRefCnt(0), - mCount(0), + : mCount(0), mFirst(nsnull) { MOZ_COUNT_CTOR(RDFBindingSet); @@ -116,19 +113,7 @@ public: ~RDFBindingSet(); - PRInt32 AddRef() { - mRefCnt++; - NS_LOG_ADDREF(this, mRefCnt, "RDFBindingSet", sizeof(*this)); - return mRefCnt; - } - - PRInt32 Release() - { - PRInt32 refcnt = --mRefCnt; - NS_LOG_RELEASE(this, refcnt, "RDFBindingSet"); - if (refcnt == 0) delete this; - return refcnt; - } + NS_INLINE_DECL_REFCOUNTING(RDFBindingSet) PRInt32 Count() const { return mCount; }