tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 951b69309879c42b1c33523d3aaf96a0d2f3c40b
parent bc71be21eca14b706c767ac876a06d05099fe2a6
Author: Andrew McCreight <continuation@gmail.com>
Date:   Mon,  8 Dec 2025 15:07:25 +0000

Bug 2003652, part 2 - Add comments explaining why this nsIURI memory reporting doesn't cause double counting. r=emilio,jwatt

Differential Revision: https://phabricator.services.mozilla.com/D274857

Diffstat:
Mdom/base/Link.cpp | 4++++
Mdom/html/HTMLImageElement.cpp | 5+++++
Mdom/html/HTMLLinkElement.cpp | 5+++++
Mdom/svg/SVGFEImageElement.cpp | 5+++++
Mdom/svg/SVGImageElement.cpp | 5+++++
Mdom/xul/nsXULElement.cpp | 5+++++
6 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/dom/base/Link.cpp b/dom/base/Link.cpp @@ -441,6 +441,10 @@ void Link::SetHrefAttribute(nsIURI* aURI) { size_t Link::SizeOfExcludingThis(mozilla::SizeOfState& aState) const { size_t n = 0; + // It is okay to include the size of mCachedURI here even though it might have + // strong references from elsewhere because the URI was created for this + // object, in nsGenericHTMLElement::GetURIAttr(). Only objects that created + // their own URI will call nsIURI::SizeOfIncludingThis(). if (mCachedURI) { n += mCachedURI->SizeOfIncludingThis(aState.mMallocSizeOf); } diff --git a/dom/html/HTMLImageElement.cpp b/dom/html/HTMLImageElement.cpp @@ -1159,6 +1159,11 @@ FetchPriority HTMLImageElement::GetFetchPriorityForImage() const { void HTMLImageElement::AddSizeOfExcludingThis(nsWindowSizes& aSizes, size_t* aNodeSize) const { nsGenericHTMLElement::AddSizeOfExcludingThis(aSizes, aNodeSize); + + // It is okay to include the size of mSrcURI here even though it might have + // strong references from elsewhere because the URI was created for this + // object, in nsImageLoadingContent::StringToURI(). Only objects that created + // their own URI will call nsIURI::SizeOfIncludingThis(). if (mSrcURI) { *aNodeSize += mSrcURI->SizeOfIncludingThis(aSizes.mState.mMallocSizeOf); } diff --git a/dom/html/HTMLLinkElement.cpp b/dom/html/HTMLLinkElement.cpp @@ -407,6 +407,11 @@ Maybe<LinkStyle::SheetInfo> HTMLLinkElement::GetStyleSheetInfo() { void HTMLLinkElement::AddSizeOfExcludingThis(nsWindowSizes& aSizes, size_t* aNodeSize) const { nsGenericHTMLElement::AddSizeOfExcludingThis(aSizes, aNodeSize); + + // It is okay to include the size of mCachedURI here even though it might have + // strong references from elsewhere because the URI was created for this + // object, in nsGenericHTMLElement::GetURIAttr(). Only objects that created + // their own URI will call nsIURI::SizeOfIncludingThis(). if (mCachedURI) { *aNodeSize += mCachedURI->SizeOfIncludingThis(aSizes.mState.mMallocSizeOf); } diff --git a/dom/svg/SVGFEImageElement.cpp b/dom/svg/SVGFEImageElement.cpp @@ -431,6 +431,11 @@ void SVGFEImageElement::NotifyImageContentChanged() { void SVGFEImageElement::AddSizeOfExcludingThis(nsWindowSizes& aSizes, size_t* aNodeSize) const { SVGElement::AddSizeOfExcludingThis(aSizes, aNodeSize); + + // It is okay to include the size of mSrcURI here even though it might have + // strong references from elsewhere because the URI was created for this + // object, in nsImageLoadingContent::StringToURI(). Only objects that created + // their own URI will call nsIURI::SizeOfIncludingThis(). if (mSrcURI) { *aNodeSize += mSrcURI->SizeOfIncludingThis(aSizes.mState.mMallocSizeOf); } diff --git a/dom/svg/SVGImageElement.cpp b/dom/svg/SVGImageElement.cpp @@ -338,6 +338,11 @@ void SVGImageElement::DidAnimateAttribute(int32_t aNameSpaceID, void SVGImageElement::AddSizeOfExcludingThis(nsWindowSizes& aSizes, size_t* aNodeSize) const { SVGElement::AddSizeOfExcludingThis(aSizes, aNodeSize); + + // It is okay to include the size of mSrcURI here even though it might have + // strong references from elsewhere because the URI was created for this + // object, in nsImageLoadingContent::StringToURI(). Only objects that created + // their own URI will call nsIURI::SizeOfIncludingThis(). if (mSrcURI) { *aNodeSize += mSrcURI->SizeOfIncludingThis(aSizes.mState.mMallocSizeOf); } diff --git a/dom/xul/nsXULElement.cpp b/dom/xul/nsXULElement.cpp @@ -2011,6 +2011,11 @@ void nsXULPrototypeScript::Set(JS::Stencil* aStencil) { mStencil = aStencil; } void nsXULPrototypeScript::AddSizeOfExcludingThis(nsWindowSizes& aSizes, size_t* aNodeSize) const { + // It is okay to include the size of mSrcURI here even though it might have + // strong references from elsewhere because the URI was created for this + // object, in XULContentSinkImpl::OpenScript() or + // nsXULPrototypeElement::Deserialize(). Only objects that created their own + // URI will call nsIURI::SizeOfIncludingThis(). if (mSrcURI) { *aNodeSize += mSrcURI->SizeOfIncludingThis(aSizes.mState.mMallocSizeOf); }