Bug 551298, patch C: Use NS_INLINE_DECL_REFCOUNTING in /layout/ directory. r=roc

This commit is contained in:
Daniel Holbert 2010-04-01 11:05:40 -07:00
Родитель d509dc0e16
Коммит f138b54154
4 изменённых файлов: 14 добавлений и 120 удалений

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

@ -506,8 +506,7 @@ nsCSSValue::URL::URL(nsIURI* aURI, nsStringBuffer* aString, nsIURI* aReferrer,
: mURI(aURI),
mString(aString),
mReferrer(aReferrer),
mOriginPrincipal(aOriginPrincipal),
mRefCnt(0)
mOriginPrincipal(aOriginPrincipal)
{
NS_PRECONDITION(aOriginPrincipal, "Must have an origin principal");
mString->AddRef();
@ -593,7 +592,6 @@ nsCSSValueGradient::nsCSSValueGradient(PRBool aIsRadial,
mBgPosY(eCSSUnit_None),
mAngle(eCSSUnit_None),
mRadialShape(eCSSUnit_None),
mRadialSize(eCSSUnit_None),
mRefCnt(0)
mRadialSize(eCSSUnit_None)
{
}

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

@ -51,6 +51,7 @@
#include "nsCRTGlue.h"
#include "nsStringBuffer.h"
#include "nsTArray.h"
#include "nsISupportsImpl.h"
class imgIRequest;
class nsIDocument;
@ -379,26 +380,9 @@ public:
nsCOMPtr<nsIURI> mReferrer;
nsCOMPtr<nsIPrincipal> mOriginPrincipal;
void AddRef() {
if (mRefCnt == PR_UINT32_MAX) {
NS_WARNING("refcount overflow, leaking nsCSSValue::URL");
return;
}
++mRefCnt;
NS_LOG_ADDREF(this, mRefCnt, "nsCSSValue::URL", sizeof(*this));
}
void Release() {
if (mRefCnt == PR_UINT32_MAX) {
NS_WARNING("refcount overflow, leaking nsCSSValue::URL");
return;
}
--mRefCnt;
NS_LOG_RELEASE(this, mRefCnt, "nsCSSValue::URL");
if (mRefCnt == 0)
delete this;
}
NS_INLINE_DECL_REFCOUNTING(URL)
protected:
nsrefcnt mRefCnt;
// not to be implemented
URL(const URL& aOther);
@ -420,25 +404,7 @@ public:
// Override AddRef and Release to not only log ourselves correctly, but
// also so that we delete correctly without a virtual destructor
void AddRef() {
if (mRefCnt == PR_UINT32_MAX) {
NS_WARNING("refcount overflow, leaking nsCSSValue::Image");
return;
}
++mRefCnt;
NS_LOG_ADDREF(this, mRefCnt, "nsCSSValue::Image", sizeof(*this));
}
void Release() {
if (mRefCnt == PR_UINT32_MAX) {
NS_WARNING("refcount overflow, leaking nsCSSValue::Image");
return;
}
--mRefCnt;
NS_LOG_RELEASE(this, mRefCnt, "nsCSSValue::Image");
if (mRefCnt == 0)
delete this;
}
NS_INLINE_DECL_REFCOUNTING(Image)
};
private:
@ -529,28 +495,9 @@ struct nsCSSValueGradient {
return !(*this == aOther);
}
void AddRef() {
if (mRefCnt == PR_UINT32_MAX) {
NS_WARNING("refcount overflow, leaking nsCSSValue::Gradient");
return;
}
++mRefCnt;
NS_LOG_ADDREF(this, mRefCnt, "nsCSSValue::Gradient", sizeof(*this));
}
void Release() {
if (mRefCnt == PR_UINT32_MAX) {
NS_WARNING("refcount overflow, leaking nsCSSValue::Gradient");
return;
}
--mRefCnt;
NS_LOG_RELEASE(this, mRefCnt, "nsCSSValue::Gradient");
if (mRefCnt == 0)
delete this;
}
NS_INLINE_DECL_REFCOUNTING(nsCSSValueGradient)
private:
nsrefcnt mRefCnt;
// not to be implemented
nsCSSValueGradient(const nsCSSValueGradient& aOther);
nsCSSValueGradient& operator=(const nsCSSValueGradient& aOther);
@ -588,6 +535,8 @@ struct nsCSSValue::Array {
return PR_TRUE;
}
// XXXdholbert This uses a 16-bit ref count to save space. Should we use
// a variant of NS_INLINE_DECL_REFCOUNTING that takes a type as an argument?
void AddRef() {
if (mRefCnt == PR_UINT16_MAX) {
NS_WARNING("refcount overflow, leaking nsCSSValue::Array");

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

@ -1317,7 +1317,6 @@ nsStyleGradient::nsStyleGradient(void)
: mShape(NS_STYLE_GRADIENT_SHAPE_LINEAR)
, mSize(NS_STYLE_GRADIENT_SIZE_FARTHEST_CORNER)
, mRepeating(PR_FALSE)
, mRefCnt(0)
{
}
@ -2318,26 +2317,6 @@ nsChangeHint nsStyleTextReset::MaxDifference()
}
#endif
// --------------------
// nsCSSShadowArray
// nsCSSShadowItem
//
nsrefcnt
nsCSSShadowArray::Release()
{
if (mRefCnt == PR_UINT32_MAX) {
NS_WARNING("refcount overflow, leaking object");
return mRefCnt;
}
mRefCnt--;
if (mRefCnt == 0) {
delete this;
return 0;
}
return mRefCnt;
}
// Allowed to return one of NS_STYLE_HINT_NONE, NS_STYLE_HINT_REFLOW
// or NS_STYLE_HINT_VISUAL. Currently we just return NONE or REFLOW, though.
// XXXbz can this not return a more specific hint? If that's ever

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

@ -163,38 +163,14 @@ public:
// stops are in the order specified in the stylesheet
nsTArray<nsStyleGradientStop> mStops;
nsrefcnt AddRef() {
if (mRefCnt == PR_UINT32_MAX) {
NS_WARNING("refcount overflow, leaking nsStyleGradient");
return mRefCnt;
}
++mRefCnt;
NS_LOG_ADDREF(this, mRefCnt, "nsStyleGradient", sizeof(*this));
return mRefCnt;
}
nsrefcnt Release() {
if (mRefCnt == PR_UINT32_MAX) {
NS_WARNING("refcount overflow, leaking nsStyleGradient");
return mRefCnt;
}
--mRefCnt;
NS_LOG_RELEASE(this, mRefCnt, "nsStyleGradient");
if (mRefCnt == 0) {
delete this;
return 0;
}
return mRefCnt;
}
PRBool operator==(const nsStyleGradient& aOther) const;
PRBool operator!=(const nsStyleGradient& aOther) const {
return !(*this == aOther);
};
private:
nsrefcnt mRefCnt;
NS_INLINE_DECL_REFCOUNTING(nsStyleGradient)
private:
~nsStyleGradient() {}
// Not to be implemented
@ -671,7 +647,7 @@ class nsCSSShadowArray {
}
nsCSSShadowArray(PRUint32 aArrayLen) :
mLength(aArrayLen), mRefCnt(0)
mLength(aArrayLen)
{
MOZ_COUNT_CTOR(nsCSSShadowArray);
for (PRUint32 i = 1; i < mLength; ++i) {
@ -687,15 +663,6 @@ class nsCSSShadowArray {
}
}
nsrefcnt AddRef() {
if (mRefCnt == PR_UINT32_MAX) {
NS_WARNING("refcount overflow, leaking object");
return mRefCnt;
}
return ++mRefCnt;
}
nsrefcnt Release();
PRUint32 Length() const { return mLength; }
nsCSSShadowItem* ShadowAt(PRUint32 i) {
NS_ABORT_IF_FALSE(i < mLength, "Accessing too high an index in the text shadow array!");
@ -706,9 +673,10 @@ class nsCSSShadowArray {
return &mArray[i];
}
NS_INLINE_DECL_REFCOUNTING(nsCSSShadowArray)
private:
PRUint32 mLength;
PRUint32 mRefCnt;
nsCSSShadowItem mArray[1]; // This MUST be the last item
};