Bug 1015646 - Add a memory reporter for SVGPathElement's SVGAnimatedPathSegList member. r=njn

--HG--
extra : rebase_source : 5eda3e1104cc6a75ec38774c072e6e3e2b3d7b1b
This commit is contained in:
Jonathan Watt 2014-05-26 16:21:23 +01:00
parent bac4b9d1ef
commit 449ccf9316
6 changed files with 45 additions and 2 deletions

View File

@ -203,4 +203,14 @@ SVGAnimatedPathSegList::SMILAnimatedPathSegList::ClearAnimValue()
}
}
size_t
SVGAnimatedPathSegList::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
{
size_t total = mBaseVal.SizeOfExcludingThis(aMallocSizeOf);
if (mAnimVal) {
mAnimVal->SizeOfIncludingThis(aMallocSizeOf);
}
return total;
}
} // namespace mozilla

View File

@ -7,6 +7,7 @@
#define MOZILLA_SVGANIMATEDPATHSEGLIST_H__
#include "mozilla/Attributes.h"
#include "mozilla/MemoryReporting.h"
#include "nsAutoPtr.h"
#include "nsISMILAttr.h"
#include "SVGPathData.h"
@ -35,7 +36,7 @@ class SVGAnimationElement;
* DOMSVGPathSegList::InternalListWillChangeTo) and frees consumers from having
* to know or worry about wrappers (or forget about them!) for the most part.
*/
class SVGAnimatedPathSegList
class SVGAnimatedPathSegList MOZ_FINAL
{
// friends so that they can get write access to mBaseVal and mAnimVal
friend class DOMSVGPathSeg;
@ -88,6 +89,8 @@ public:
/// Callers own the returned nsISMILAttr
nsISMILAttr* ToSMILAttr(nsSVGElement* aElement);
size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const;
private:
// mAnimVal is a pointer to allow us to determine if we're being animated or

View File

@ -1164,3 +1164,15 @@ SVGPathData::GetMarkerPositioningData(nsTArray<nsSVGMark> *aMarks) const
}
}
size_t
SVGPathData::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
{
return mData.SizeOfExcludingThis(aMallocSizeOf);
}
size_t
SVGPathData::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
{
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
}

View File

@ -13,6 +13,7 @@
#include "nsIWeakReferenceUtils.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/gfx/Types.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/RefPtr.h"
#include "nsSVGElement.h"
#include "nsTArray.h"
@ -173,6 +174,10 @@ public:
const_iterator begin() const { return mData.Elements(); }
const_iterator end() const { return mData.Elements() + mData.Length(); }
// memory reporting methods
size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
// Access to methods that can modify objects of this type is deliberately
// limited. This is to reduce the chances of someone modifying objects of
// this type without taking the necessary steps to keep DOM wrappers in sync.
@ -232,7 +237,7 @@ protected:
* sync, so we can safely expose any protected base class methods required by
* the SMIL code.
*/
class SVGPathDataAndInfo : public SVGPathData
class SVGPathDataAndInfo MOZ_FINAL : public SVGPathData
{
public:
SVGPathDataAndInfo(nsSVGElement *aElement = nullptr)

View File

@ -46,6 +46,16 @@ SVGPathElement::SVGPathElement(already_AddRefed<nsINodeInfo>& aNodeInfo)
{
}
//----------------------------------------------------------------------
// memory reporting methods
size_t
SVGPathElement::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
{
return SVGPathElementBase::SizeOfExcludingThis(aMallocSizeOf) +
mD.SizeOfExcludingThis(aMallocSizeOf);
}
//----------------------------------------------------------------------
// nsIDOMNode methods

View File

@ -39,6 +39,9 @@ protected:
SVGPathElement(already_AddRefed<nsINodeInfo>& aNodeInfo);
public:
// DOM memory reporter participant
NS_DECL_SIZEOF_EXCLUDING_THIS
// nsIContent interface
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* name) const MOZ_OVERRIDE;