Bug 670962 - Make nsGenericDOMDataNode and nsTextFragment participate to the DOM Memory Reporter. r=jst

This commit is contained in:
Mounir Lamouri 2011-07-19 10:04:09 -07:00
parent fe35661680
commit f91f167ea8
3 changed files with 27 additions and 1 deletions

View File

@ -67,7 +67,7 @@
#include "pldhash.h"
#include "prprf.h"
namespace css = mozilla::css;
using namespace mozilla;
nsGenericDOMDataNode::nsGenericDOMDataNode(already_AddRefed<nsINodeInfo> aNodeInfo)
: nsIContent(aNodeInfo)
@ -1065,3 +1065,13 @@ nsGenericDOMDataNode::GetClassAttributeName() const
{
return nsnull;
}
PRInt64
nsGenericDOMDataNode::SizeOf() const
{
PRInt64 size = dom::MemoryReporter::GetBasicSize<nsGenericDOMDataNode,
nsIContent>(this);
size += mText.SizeOf() - sizeof(mText);
return size;
}

View File

@ -51,6 +51,7 @@
#include "nsGenericElement.h"
#include "nsCycleCollectionParticipant.h"
#include "nsContentUtils.h"
#include "nsDOMMemoryReporter.h"
#ifdef MOZ_SMIL
#include "nsISMILAttr.h"
@ -84,6 +85,8 @@ class nsGenericDOMDataNode : public nsIContent
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_DOM_MEMORY_REPORTER_SIZEOF
nsGenericDOMDataNode(already_AddRefed<nsINodeInfo> aNodeInfo);
virtual ~nsGenericDOMDataNode();

View File

@ -47,6 +47,8 @@
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsTraceRefcnt.h"
#include "nsDOMMemoryReporter.h"
class nsString;
class nsCString;
@ -224,6 +226,17 @@ public:
PRUint32 mLength : 29;
};
/**
* Returns the size taken in memory by this text fragment.
* @return the size taken in memory by this text fragment.
*/
PRInt64 SizeOf() const
{
PRInt64 size = sizeof(*this);
size += GetLength() * Is2b() ? sizeof(*m2b) : sizeof(*m1b);
return size;
}
private:
void ReleaseText();