Bug 1486480. Add memory reporting for custom element data. r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D4350
This commit is contained in:
Boris Zbarsky
2018-08-27 19:20:53 +00:00
parent 880251c6d7
commit e2d8437e78
5 changed files with 128 additions and 2 deletions

View File

@@ -674,6 +674,14 @@ nsIContent::nsExtendedContentSlots::nsExtendedContentSlots()
nsIContent::nsExtendedContentSlots::~nsExtendedContentSlots() = default;
size_t
nsIContent::nsExtendedContentSlots::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
{
// For now, nothing to measure here. We don't actually own any of our
// members.
return 0;
}
FragmentOrElement::nsDOMSlots::nsDOMSlots()
: nsIContent::nsContentSlots(),
mDataset(nullptr)
@@ -725,8 +733,14 @@ size_t
FragmentOrElement::nsDOMSlots::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
{
size_t n = aMallocSizeOf(this);
if (OwnsExtendedSlots()) {
n += aMallocSizeOf(GetExtendedContentSlots());
nsExtendedContentSlots* extendedSlots = GetExtendedContentSlots();
if (extendedSlots) {
if (OwnsExtendedSlots()) {
n += aMallocSizeOf(extendedSlots);
}
n += extendedSlots->SizeOfExcludingThis(aMallocSizeOf);
}
if (mAttributeMap) {
@@ -800,6 +814,49 @@ FragmentOrElement::nsExtendedDOMSlots::TraverseExtendedSlots(nsCycleCollectionTr
}
}
size_t
FragmentOrElement::nsExtendedDOMSlots::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
{
size_t n = nsIContent::nsExtendedContentSlots::SizeOfExcludingThis(aMallocSizeOf);
// We own mSMILOverrideStyle but there seems to be no memory reporting on CSS
// declarations? At least report the memory the declaration takes up
// directly.
if (mSMILOverrideStyle) {
n += aMallocSizeOf(mSMILOverrideStyle);
}
// We don't really own mSMILOverrideStyleDeclaration. mSMILOverrideStyle owns
// it.
// We don't seem to have memory reporting for nsXULControllers. At least
// report the memory it's using directly.
if (mControllers) {
n += aMallocSizeOf(mControllers);
}
// We don't seem to have memory reporting for nsLabelsNodeList. At least
// report the memory it's using directly.
if (mLabelsList) {
n += aMallocSizeOf(mLabelsList);
}
// mShadowRoot should be handled during normal DOM tree memory reporting, just
// like kids, siblings, etc.
// We don't seem to have memory reporting for nsXBLBinding. At least
// report the memory it's using directly.
if (mXBLBinding) {
n += aMallocSizeOf(mXBLBinding);
}
if (mCustomElementData) {
n += mCustomElementData->SizeOfIncludingThis(aMallocSizeOf);
}
return n;
}
FragmentOrElement::FragmentOrElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
: nsIContent(aNodeInfo)
{