Bug 682264 - Make EventListenerManager participate to the DOM Memory Reporter, r=volkmar,bz

This commit is contained in:
Olli Pettay 2011-08-27 01:39:00 +03:00
parent 80cce82231
commit 7532bbf6d5
8 changed files with 52 additions and 10 deletions

View File

@ -49,6 +49,7 @@
#include "nsDOMError.h"
#include "nsDOMString.h"
#include "jspubtd.h"
#include "nsDOMMemoryReporter.h"
class nsIContent;
class nsIDocument;
@ -281,8 +282,8 @@ private:
// IID for the nsINode interface
#define NS_INODE_IID \
{ 0xcdab747e, 0xa58f, 0x4b96, \
{ 0x8b, 0xae, 0x9d, 0x53, 0xe0, 0xa7, 0x8a, 0x74 } }
{ 0x5572c8a9, 0xbda9, 0x4b78, \
{ 0xb4, 0x1a, 0xdb, 0x1a, 0x83, 0xef, 0x53, 0x7e } }
/**
* An internal interface that abstracts some DOMNode-related parts that both
@ -295,9 +296,7 @@ class nsINode : public nsIDOMEventTarget,
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_INODE_IID)
virtual PRInt64 SizeOf() const {
return sizeof(*this);
}
NS_DECL_DOM_MEMORY_REPORTER_SIZEOF
friend class nsNodeUtils;
friend class nsNodeWeakReference;

View File

@ -8455,7 +8455,7 @@ nsDocument::CaretPositionFromPoint(float aX, float aY, nsIDOMCaretPosition** aCa
PRInt64
nsIDocument::SizeOf() const
{
PRInt64 size = sizeof(*this);
PRInt64 size = MemoryReporter::GetBasicSize<nsIDocument, nsINode>(this);
for (nsIContent* node = GetFirstChild(); node;
node = node->GetNextNode(this)) {

View File

@ -5402,6 +5402,20 @@ nsNSElementTearoff::MozMatchesSelector(const nsAString& aSelector, PRBool* aRetu
return rv;
}
PRInt64
nsINode::SizeOf() const
{
PRInt64 size = sizeof(*this);
nsEventListenerManager* elm =
const_cast<nsINode*>(this)->GetListenerManager(PR_FALSE);
if (elm) {
size += elm->SizeOf();
}
return size;
}
PRInt64
nsGenericElement::SizeOf() const
{

View File

@ -978,3 +978,18 @@ nsEventListenerManager::GetJSEventListener(nsIAtom *aEventName, jsval *vp)
*vp = OBJECT_TO_JSVAL(static_cast<JSObject*>(listener->GetHandler()));
}
PRInt64
nsEventListenerManager::SizeOf() const
{
PRInt64 size = sizeof(*this);
PRUint32 count = mListeners.Length();
for (PRUint32 i = 0; i < count; ++i) {
const nsListenerStruct& ls = mListeners.ElementAt(i);
size += sizeof(ls);
nsIJSEventListener* jsl = ls.GetJSListener();
if (jsl) {
size += jsl->SizeOf();
}
}
return size;
}

View File

@ -232,6 +232,7 @@ public:
*/
PRBool MayHaveTouchEventListener() { return mMayHaveTouchEventListener; }
PRInt64 SizeOf() const;
protected:
nsresult HandleEventSubType(nsListenerStruct* aListenerStruct,
nsIDOMEventListener* aListener,

View File

@ -10203,8 +10203,15 @@ nsGlobalWindow::SizeOf() const
{
PRInt64 size = sizeof(*this);
if (IsInnerWindow() && mDoc) {
size += mDoc->SizeOf();
if (IsInnerWindow()) {
nsEventListenerManager* elm =
const_cast<nsGlobalWindow*>(this)->GetListenerManager(PR_FALSE);
if (elm) {
size += elm->SizeOf();
}
if (mDoc) {
size += mDoc->SizeOf();
}
}
size += mNavigator ? mNavigator->SizeOf() : 0;

View File

@ -46,8 +46,8 @@ class nsIScriptObjectOwner;
class nsIAtom;
#define NS_IJSEVENTLISTENER_IID \
{ 0xb88fb066, 0xe9f8, 0x45d0, \
{ 0x92, 0x9a, 0x7d, 0xa8, 0x4c, 0x1f, 0xb5, 0xbc } }
{ 0x468406d2, 0xf6aa, 0x404f, \
{ 0x92, 0xa1, 0x53, 0xd1, 0x5f, 0x6e, 0x5e, 0x19 } }
// Implemented by script event listeners. Used to retrieve the
// script object corresponding to the event target and the handler itself.
@ -90,6 +90,7 @@ public:
// the right target.
virtual void SetHandler(void *aHandler) = 0;
virtual PRInt64 SizeOf() const = 0;
protected:
virtual ~nsIJSEventListener()
{

View File

@ -63,6 +63,11 @@ public:
// nsIJSEventListener
virtual void SetHandler(void *aHandler);
virtual PRInt64 SizeOf() const
{
return sizeof(*this);
}
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsJSEventListener)
protected: