зеркало из https://github.com/mozilla/pjs.git
re-fix bug 166147 - autoinitialize mRefCnt to 0 for more efficient constructors
r=dougt, sr=jag, this time including some CSS stuff that has 31-bit refcounts.
This commit is contained in:
Родитель
bae29568d0
Коммит
2eb51aa759
|
@ -75,14 +75,16 @@ void nsCSSRule::operator delete(void* ptr)
|
|||
}
|
||||
|
||||
nsCSSRule::nsCSSRule(void)
|
||||
: mSheet(nsnull),
|
||||
: mRefCnt(0),
|
||||
mSheet(nsnull),
|
||||
mParentRule(nsnull)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
nsCSSRule::nsCSSRule(const nsCSSRule& aCopy)
|
||||
: mSheet(aCopy.mSheet),
|
||||
: mRefCnt(0),
|
||||
mSheet(aCopy.mSheet),
|
||||
mParentRule(aCopy.mParentRule)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
|
|
|
@ -1767,6 +1767,7 @@ MOZ_DECL_CTOR_COUNTER(CSSStyleSheetImpl)
|
|||
|
||||
CSSStyleSheetImpl::CSSStyleSheetImpl()
|
||||
: nsICSSStyleSheet(),
|
||||
mRefCnt(0),
|
||||
mTitle(),
|
||||
mMedia(nsnull),
|
||||
mFirstChild(nsnull),
|
||||
|
@ -1788,6 +1789,7 @@ CSSStyleSheetImpl::CSSStyleSheetImpl()
|
|||
|
||||
CSSStyleSheetImpl::CSSStyleSheetImpl(const CSSStyleSheetImpl& aCopy)
|
||||
: nsICSSStyleSheet(),
|
||||
mRefCnt(0),
|
||||
mTitle(aCopy.mTitle),
|
||||
mMedia(nsnull),
|
||||
mFirstChild(nsnull),
|
||||
|
|
|
@ -297,6 +297,7 @@ void HTMLCSSStyleSheetImpl::operator delete(void* ptr)
|
|||
|
||||
HTMLCSSStyleSheetImpl::HTMLCSSStyleSheetImpl()
|
||||
: nsIHTMLCSSStyleSheet(),
|
||||
mRefCnt(0),
|
||||
mURL(nsnull),
|
||||
mDocument(nsnull),
|
||||
mFirstLineRule(nsnull),
|
||||
|
|
|
@ -858,6 +858,7 @@ void HTMLStyleSheetImpl::operator delete(void* ptr)
|
|||
|
||||
HTMLStyleSheetImpl::HTMLStyleSheetImpl(void)
|
||||
: nsIHTMLStyleSheet(),
|
||||
mRefCnt(0),
|
||||
mURL(nsnull),
|
||||
mDocument(nsnull),
|
||||
mLinkRule(nsnull),
|
||||
|
|
|
@ -610,7 +610,7 @@ NS_IMPL_ADDREF(nsXULAttributes);
|
|||
nsrefcnt
|
||||
nsXULAttributes::Release()
|
||||
{
|
||||
mRefCnt--;
|
||||
--mRefCnt;
|
||||
NS_LOG_RELEASE(this, mRefCnt, "nsXULAttributes");
|
||||
if (mRefCnt == 0) {
|
||||
mRefCnt = 1; // stabilize (necessary for this class?)
|
||||
|
|
|
@ -208,10 +208,10 @@ public:
|
|||
nsIURI* aDocumentURI,
|
||||
nsISupportsArray* aNodeInfos) = 0;
|
||||
|
||||
void AddRef() { mRefCnt++; };
|
||||
void AddRef() { ++mRefCnt; };
|
||||
void Release()
|
||||
{
|
||||
mRefCnt--;
|
||||
--mRefCnt;
|
||||
if (mRefCnt == 0)
|
||||
delete this;
|
||||
};
|
||||
|
|
|
@ -75,14 +75,16 @@ void nsCSSRule::operator delete(void* ptr)
|
|||
}
|
||||
|
||||
nsCSSRule::nsCSSRule(void)
|
||||
: mSheet(nsnull),
|
||||
: mRefCnt(0),
|
||||
mSheet(nsnull),
|
||||
mParentRule(nsnull)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
nsCSSRule::nsCSSRule(const nsCSSRule& aCopy)
|
||||
: mSheet(aCopy.mSheet),
|
||||
: mRefCnt(0),
|
||||
mSheet(aCopy.mSheet),
|
||||
mParentRule(aCopy.mParentRule)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
|
|
|
@ -1767,6 +1767,7 @@ MOZ_DECL_CTOR_COUNTER(CSSStyleSheetImpl)
|
|||
|
||||
CSSStyleSheetImpl::CSSStyleSheetImpl()
|
||||
: nsICSSStyleSheet(),
|
||||
mRefCnt(0),
|
||||
mTitle(),
|
||||
mMedia(nsnull),
|
||||
mFirstChild(nsnull),
|
||||
|
@ -1788,6 +1789,7 @@ CSSStyleSheetImpl::CSSStyleSheetImpl()
|
|||
|
||||
CSSStyleSheetImpl::CSSStyleSheetImpl(const CSSStyleSheetImpl& aCopy)
|
||||
: nsICSSStyleSheet(),
|
||||
mRefCnt(0),
|
||||
mTitle(aCopy.mTitle),
|
||||
mMedia(nsnull),
|
||||
mFirstChild(nsnull),
|
||||
|
|
|
@ -297,6 +297,7 @@ void HTMLCSSStyleSheetImpl::operator delete(void* ptr)
|
|||
|
||||
HTMLCSSStyleSheetImpl::HTMLCSSStyleSheetImpl()
|
||||
: nsIHTMLCSSStyleSheet(),
|
||||
mRefCnt(0),
|
||||
mURL(nsnull),
|
||||
mDocument(nsnull),
|
||||
mFirstLineRule(nsnull),
|
||||
|
|
|
@ -858,6 +858,7 @@ void HTMLStyleSheetImpl::operator delete(void* ptr)
|
|||
|
||||
HTMLStyleSheetImpl::HTMLStyleSheetImpl(void)
|
||||
: nsIHTMLStyleSheet(),
|
||||
mRefCnt(0),
|
||||
mURL(nsnull),
|
||||
mDocument(nsnull),
|
||||
mLinkRule(nsnull),
|
||||
|
|
|
@ -432,7 +432,7 @@ nsrefcnt nsViewManager::Release(void)
|
|||
delete this;
|
||||
return 0;
|
||||
}
|
||||
mRefCnt--;
|
||||
--mRefCnt;
|
||||
return mRefCnt;
|
||||
}
|
||||
|
||||
|
|
|
@ -85,7 +85,26 @@ extern "C" NS_COM void NS_CheckThreadSafe(void* owningThread,
|
|||
|
||||
#endif // !(defined(NS_DEBUG) && defined(NS_MT_SUPPORTED))
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
class nsAutoRefCnt {
|
||||
|
||||
public:
|
||||
nsAutoRefCnt() : mValue(0) {}
|
||||
nsAutoRefCnt(nsrefcnt aValue) : mValue(aValue) {}
|
||||
|
||||
// only support prefix increment/decrement
|
||||
nsrefcnt operator++() { return ++mValue; }
|
||||
nsrefcnt operator--() { return --mValue; }
|
||||
|
||||
nsrefcnt operator=(nsrefcnt aValue) { return (mValue = aValue); }
|
||||
operator nsrefcnt() const { return mValue; }
|
||||
private:
|
||||
// do not define these to enforce the faster prefix notation
|
||||
nsrefcnt operator++(int);
|
||||
nsrefcnt operator--(int);
|
||||
nsrefcnt mValue;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Declare the reference count variable and the implementations of the
|
||||
|
@ -99,7 +118,7 @@ public: \
|
|||
NS_IMETHOD_(nsrefcnt) AddRef(void); \
|
||||
NS_IMETHOD_(nsrefcnt) Release(void); \
|
||||
protected: \
|
||||
nsrefcnt mRefCnt; \
|
||||
nsAutoRefCnt mRefCnt; \
|
||||
NS_DECL_OWNINGTHREAD \
|
||||
public:
|
||||
|
||||
|
@ -110,7 +129,7 @@ public:
|
|||
* Initialize the reference count variable. Add this to each and every
|
||||
* constructor you implement.
|
||||
*/
|
||||
#define NS_INIT_ISUPPORTS() (mRefCnt = 0, NS_IMPL_OWNINGTHREAD())
|
||||
#define NS_INIT_ISUPPORTS() (NS_IMPL_OWNINGTHREAD())
|
||||
|
||||
/**
|
||||
* Use this macro to implement the AddRef method for a given <i>_class</i>
|
||||
|
|
|
@ -145,7 +145,7 @@ nsNativeAppSupportBase::CreateSplashScreen( nsISplashScreen **splash ) {
|
|||
// Standard implementations of AddRef/Release/QueryInterface.
|
||||
NS_IMETHODIMP_(nsrefcnt)
|
||||
nsNativeAppSupportBase::AddRef() {
|
||||
mRefCnt++;
|
||||
++mRefCnt;
|
||||
return mRefCnt;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче