Bug 667883 - Implement nsAttrAndChildArray::SizeOf(). r=bz

This commit is contained in:
Mounir Lamouri 2011-07-12 16:56:01 +02:00
parent 14c6dacab7
commit bbef6d1373
5 changed files with 38 additions and 0 deletions

View File

@ -42,6 +42,7 @@
#include "nsIContent.h"
#include "nsEventStates.h"
#include "nsDOMMemoryReporter.h"
class nsEventStateManager;
class nsGlobalWindow;
@ -97,6 +98,8 @@ public:
{}
#endif // MOZILLA_INTERNAL_API
NS_DECL_AND_IMPL_DOM_MEMORY_REPORTER_SIZEOF(Element, nsIContent)
/**
* Method to get the full state of this element. See nsEventStates.h for
* the possible bits that could be set here.

View File

@ -847,3 +847,21 @@ nsAttrAndChildArray::SetChildAtPos(void** aPos, nsIContent* aChild,
next->mPreviousSibling = aChild;
}
}
PRInt64
nsAttrAndChildArray::SizeOf() const
{
PRInt64 size = sizeof(*this);
if (mImpl) {
// Don't add the size taken by *mMappedAttrs because it's shared.
// mBuffer cointains InternalAttr and nsIContent* (even if it's void**)
// so, we just have to compute the size of *mBuffer given that this object
// doesn't own the children list.
size += mImpl->mBufferSize * sizeof(*(mImpl->mBuffer)) + NS_IMPL_EXTRA_SIZE;
}
return size;
}

View File

@ -131,6 +131,8 @@ public:
!AttrSlotIsTaken(ATTRCHILD_ARRAY_MAX_ATTR_COUNT - 1);
}
PRInt64 SizeOf() const;
private:
nsAttrAndChildArray(const nsAttrAndChildArray& aOther); // Not to be implemented
nsAttrAndChildArray& operator=(const nsAttrAndChildArray& aOther); // Not to be implemented

View File

@ -146,6 +146,7 @@
#include "prprf.h"
#include "nsSVGFeatures.h"
#include "nsDOMMemoryReporter.h"
using namespace mozilla::dom;
namespace css = mozilla::css;
@ -5372,3 +5373,15 @@ nsNSElementTearoff::MozMatchesSelector(const nsAString& aSelector, PRBool* aRetu
return rv;
}
PRInt64
nsGenericElement::SizeOf() const
{
PRInt64 size = MemoryReporter::GetBasicSize<nsGenericElement, Element>(this);
size -= sizeof(mAttrsAndChildren);
size += mAttrsAndChildren.SizeOf();
return size;
}

View File

@ -240,6 +240,8 @@ public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_DOM_MEMORY_REPORTER_SIZEOF
/**
* Called during QueryInterface to give the binding manager a chance to
* get an interface for this element.