Bug 1438497 part 2 - Do not report bindings which are cached in XUL prototype cache. r=bholley
MozReview-Commit-ID: 7ZqQswt7QtA
--- a/dom/xbl/nsBindingManager.cpp
+++ b/dom/xbl/nsBindingManager.cpp
@@ -27,16 +27,19 @@
#include "nsIStreamListener.h"
#include "ChildIterator.h"
#include "nsITimer.h"
#include "nsXBLBinding.h"
#include "nsXBLPrototypeBinding.h"
#include "nsXBLDocumentInfo.h"
#include "mozilla/dom/XBLChildrenElement.h"
+#ifdef MOZ_XUL
+#include "nsXULPrototypeCache.h"
+#endif
#ifdef MOZ_OLD_STYLE
#include "nsIStyleRuleProcessor.h"
#include "nsRuleProcessorData.h"
#endif
#include "nsIWeakReference.h"
#include "nsWrapperCacheInlines.h"
@@ -1125,16 +1128,29 @@ nsBindingManager::SizeOfIncludingThis(Ma
SHALLOW_SIZE_INCLUDING(mBoundContentSet);
SHALLOW_SIZE_INCLUDING(mWrapperTable);
SHALLOW_SIZE_INCLUDING(mLoadingDocTable);
#undef SHALLOW_SIZE_INCLUDING
n += mAttachedStack.ShallowSizeOfExcludingThis(aMallocSizeOf);
if (mDocumentTable) {
n += mDocumentTable->ShallowSizeOfIncludingThis(aMallocSizeOf);
+#ifdef MOZ_XUL
+ nsXULPrototypeCache* cache = nsXULPrototypeCache::GetInstance();
+ StyleBackendType backendType = mDocument->GetStyleBackendType();
+#endif
for (auto iter = mDocumentTable->Iter(); !iter.Done(); iter.Next()) {
nsXBLDocumentInfo* docInfo = iter.UserData();
+#ifdef MOZ_XUL
+ nsXBLDocumentInfo* cachedInfo =
+ cache->GetXBLDocumentInfo(iter.Key(), backendType);
+ if (cachedInfo == docInfo) {
+ // If this binding has been cached, skip it since it can be
+ // reused by other documents.
+ continue;
+ }
+#endif
n += docInfo->SizeOfIncludingThis(aMallocSizeOf);
}
}
return n;
}