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:46:01 -07:00
Родитель 21cf779916
Коммит 50e884b393
3 изменённых файлов: 31 добавлений и 1 удалений

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

@ -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;
}

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

@ -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();

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

@ -47,6 +47,8 @@
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsTraceRefcnt.h"
#include "nsDOMMemoryReporter.h"
class nsString;
class nsCString;
@ -224,6 +226,21 @@ 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);
if (mState.mInHeap) {
size += GetLength() * Is2b() ? sizeof(*m2b) : sizeof(*m1b);
}
return size;
}
private:
void ReleaseText();