Bug 653497 - Once bug 335998 is fixed, SVGPathDataAndOwner::mElement leaks documents, r=dholbert

--HG--
extra : rebase_source : 76c024841265bbd2a0c2acecc5285074b23f4079
This commit is contained in:
Olli Pettay 2011-04-29 15:33:11 +03:00
Родитель ef06907e3d
Коммит 90f701853d
3 изменённых файлов: 24 добавлений и 15 удалений

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

@ -40,6 +40,7 @@
#include "SVGLength.h"
#include "nsTArray.h"
#include "nsSVGElement.h"
#include "nsIWeakReferenceUtils.h"
namespace mozilla {
@ -206,19 +207,20 @@ public:
{}
SVGLengthListAndInfo(nsSVGElement *aElement, PRUint8 aAxis, PRBool aCanZeroPadList)
: mElement(aElement)
: mElement(do_GetWeakReference(static_cast<nsINode*>(aElement)))
, mAxis(aAxis)
, mCanZeroPadList(aCanZeroPadList)
{}
void SetInfo(nsSVGElement *aElement, PRUint8 aAxis, PRBool aCanZeroPadList) {
mElement = aElement;
mElement = do_GetWeakReference(static_cast<nsINode*>(aElement));
mAxis = aAxis;
mCanZeroPadList = aCanZeroPadList;
}
nsSVGElement* Element() const {
return mElement; // .get();
nsCOMPtr<nsIContent> e = do_QueryReferent(mElement);
return static_cast<nsSVGElement*>(e.get());
}
PRUint8 Axis() const {
@ -291,10 +293,11 @@ public:
}
private:
// We must keep a strong reference to our element because we may belong to a
// We must keep a weak reference to our element because we may belong to a
// cached baseVal nsSMILValue. See the comments starting at:
// https://bugzilla.mozilla.org/show_bug.cgi?id=515116#c15
nsRefPtr<nsSVGElement> mElement;
// See also https://bugzilla.mozilla.org/show_bug.cgi?id=653497
nsWeakPtr mElement;
PRUint8 mAxis;
PRPackedBool mCanZeroPadList;
};

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

@ -40,6 +40,7 @@
#include "SVGPathSegUtils.h"
#include "nsTArray.h"
#include "nsSVGElement.h"
#include "nsIWeakReferenceUtils.h"
class gfxContext;
struct gfxMatrix;
@ -245,15 +246,16 @@ class SVGPathDataAndOwner : public SVGPathData
{
public:
SVGPathDataAndOwner(nsSVGElement *aElement = nsnull)
: mElement(aElement)
: mElement(do_GetWeakReference(static_cast<nsINode*>(aElement)))
{}
void SetElement(nsSVGElement *aElement) {
mElement = aElement;
mElement = do_GetWeakReference(static_cast<nsINode*>(aElement));
}
nsSVGElement* Element() const {
return mElement;
nsCOMPtr<nsIContent> e = do_QueryReferent(mElement);
return static_cast<nsSVGElement*>(e.get());
}
nsresult CopyFrom(const SVGPathDataAndOwner& rhs) {
@ -284,10 +286,11 @@ public:
using SVGPathData::end;
private:
// We must keep a strong reference to our element because we may belong to a
// We must keep a weak reference to our element because we may belong to a
// cached baseVal nsSMILValue. See the comments starting at:
// https://bugzilla.mozilla.org/show_bug.cgi?id=515116#c15
nsRefPtr<nsSVGElement> mElement;
// See also https://bugzilla.mozilla.org/show_bug.cgi?id=653497
nsWeakPtr mElement;
};
} // namespace mozilla

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

@ -40,6 +40,7 @@
#include "SVGPoint.h"
#include "nsTArray.h"
#include "nsSVGElement.h"
#include "nsIWeakReferenceUtils.h"
namespace mozilla {
@ -184,15 +185,16 @@ class SVGPointListAndInfo : public SVGPointList
public:
SVGPointListAndInfo(nsSVGElement *aElement = nsnull)
: mElement(aElement)
: mElement(do_GetWeakReference(static_cast<nsINode*>(aElement)))
{}
void SetInfo(nsSVGElement *aElement) {
mElement = aElement;
mElement = do_GetWeakReference(static_cast<nsINode*>(aElement));
}
nsSVGElement* Element() const {
return mElement;
nsCOMPtr<nsIContent> e = do_QueryReferent(mElement);
return static_cast<nsSVGElement*>(e.get());
}
nsresult CopyFrom(const SVGPointListAndInfo& rhs) {
@ -219,10 +221,11 @@ public:
}
private:
// We must keep a strong reference to our element because we may belong to a
// We must keep a weak reference to our element because we may belong to a
// cached baseVal nsSMILValue. See the comments starting at:
// https://bugzilla.mozilla.org/show_bug.cgi?id=515116#c15
nsRefPtr<nsSVGElement> mElement;
// See also https://bugzilla.mozilla.org/show_bug.cgi?id=653497
nsWeakPtr mElement;
};
} // namespace mozilla