Bug 1439507 - Add more XBL binding stuff to memory report. r?njn
MozReview-Commit-ID: F6wMYm7ifm9
--- a/dom/xbl/nsXBLPrototypeBinding.cpp
+++ b/dom/xbl/nsXBLPrototypeBinding.cpp
@@ -1712,16 +1712,18 @@ nsXBLPrototypeBinding::AppendStyleSheets
mResources->AppendStyleSheetsTo(aResult);
}
}
size_t
nsXBLPrototypeBinding::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
{
size_t n = aMallocSizeOf(this);
+ n += mPrototypeHandler
+ ? mPrototypeHandler->SizeOfIncludingThis(aMallocSizeOf) : 0;
n += mResources ? mResources->SizeOfIncludingThis(aMallocSizeOf) : 0;
if (mAttributeTable) {
n += mAttributeTable->ShallowSizeOfIncludingThis(aMallocSizeOf);
for (auto iter = mAttributeTable->Iter(); !iter.Done(); iter.Next()) {
InnerAttributeTable* table = iter.UserData();
n += table->ShallowSizeOfIncludingThis(aMallocSizeOf);
for (auto iter2 = table->Iter(); !iter2.Done(); iter2.Next()) {
@@ -1732,14 +1734,13 @@ nsXBLPrototypeBinding::SizeOfIncludingTh
n += mInterfaceTable.ShallowSizeOfExcludingThis(aMallocSizeOf);
n += mKeyHandlers.ShallowSizeOfExcludingThis(aMallocSizeOf);
// Measurement of the following members may be added later if DMD finds it
// is worthwhile:
// - mBindingURI
// - mAlternateBindingURI
- // - mPrototypeHandler
// - mBaseBindingURI
// - mImplementation
return n;
}
--- a/dom/xbl/nsXBLPrototypeHandler.cpp
+++ b/dom/xbl/nsXBLPrototypeHandler.cpp
@@ -1130,8 +1130,23 @@ nsXBLPrototypeHandler::Write(nsIObjectOu
rv = aStream->WriteWStringZ(nsDependentAtomString(mEventName).get());
NS_ENSURE_SUCCESS(rv, rv);
rv = aStream->Write32(mLineNumber);
NS_ENSURE_SUCCESS(rv, rv);
return aStream->WriteWStringZ(mHandlerText ? mHandlerText : u"");
}
+
+size_t
+nsXBLPrototypeHandler::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
+{
+ size_t n = 0;
+ for (const nsXBLPrototypeHandler* handler = this;
+ handler; handler = handler->mNextHandler) {
+ n += aMallocSizeOf(handler);
+ if (!(mType & NS_HANDLER_TYPE_XUL)) {
+ n += aMallocSizeOf(handler->mHandlerText);
+ }
+ n += mHandler ? aMallocSizeOf(handler->mHandler) : 0;
+ }
+ return n;
+}
--- a/dom/xbl/nsXBLPrototypeHandler.h
+++ b/dom/xbl/nsXBLPrototypeHandler.h
@@ -3,16 +3,17 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsXBLPrototypeHandler_h__
#define nsXBLPrototypeHandler_h__
#include "mozilla/EventForwards.h"
+#include "mozilla/MemoryReporting.h"
#include "nsAtom.h"
#include "nsString.h"
#include "nsCOMPtr.h"
#include "nsIController.h"
#include "nsAutoPtr.h"
#include "nsXBLEventHandler.h"
#include "nsIWeakReference.h"
#include "nsCycleCollectionParticipant.h"
@@ -167,16 +168,18 @@ public:
bool AllowUntrustedEvents()
{
return (mType & NS_HANDLER_ALLOW_UNTRUSTED) != 0;
}
nsresult Read(nsIObjectInputStream* aStream);
nsresult Write(nsIObjectOutputStream* aStream);
+ size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
+
public:
static uint32_t gRefCnt;
protected:
void Init() {
++gRefCnt;
if (gRefCnt == 1)
// Get the primary accelerator key.
--- a/dom/xbl/nsXBLPrototypeResources.cpp
+++ b/dom/xbl/nsXBLPrototypeResources.cpp
@@ -240,16 +240,19 @@ nsXBLPrototypeResources::AppendStyleShee
MOZ_DEFINE_MALLOC_SIZE_OF(ServoAuthorStylesMallocSizeOf)
MOZ_DEFINE_MALLOC_ENCLOSING_SIZE_OF(ServoAuthorStylesMallocEnclosingSizeOf)
size_t
nsXBLPrototypeResources::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
{
size_t n = aMallocSizeOf(this);
n += mStyleSheetList.ShallowSizeOfExcludingThis(aMallocSizeOf);
+ for (const auto& sheet : mStyleSheetList) {
+ n += sheet->SizeOfIncludingThis(aMallocSizeOf);
+ }
#ifdef MOZ_OLD_STYLE
n += mRuleProcessor ? mRuleProcessor->SizeOfIncludingThis(aMallocSizeOf) : 0;
#endif
n += mServoStyles ? Servo_AuthorStyles_SizeOfIncludingThis(
ServoAuthorStylesMallocSizeOf,
ServoAuthorStylesMallocEnclosingSizeOf,
mServoStyles.get()) : 0;
n += mStyleRuleMap ? mStyleRuleMap->SizeOfIncludingThis(aMallocSizeOf) : 0;