Bug 1387956 (part 1) - Change |nsWindowSizes*| arguments to |nsWindowSizes&|. r=mccr8.

This makes it clear they are never null.

MozReview-Commit-ID: H4i8uqZs48H

--HG--
extra : rebase_source : c7ada64881f015c68eaee2fbfad901f806cab833
This commit is contained in:
Nicholas Nethercote 2017-08-10 14:13:22 +10:00
parent 7b702f3d00
commit 764c284800
11 changed files with 70 additions and 72 deletions

View File

@ -12389,32 +12389,32 @@ nsDocument::GetVisibilityState(nsAString& aState)
}
/* virtual */ void
nsIDocument::DocAddSizeOfExcludingThis(nsWindowSizes* aWindowSizes) const
nsIDocument::DocAddSizeOfExcludingThis(nsWindowSizes& aWindowSizes) const
{
aWindowSizes->mDOMOtherSize +=
nsINode::SizeOfExcludingThis(aWindowSizes->mState);
aWindowSizes.mDOMOtherSize +=
nsINode::SizeOfExcludingThis(aWindowSizes.mState);
if (mPresShell) {
mPresShell->AddSizeOfIncludingThis(aWindowSizes->mState.mMallocSizeOf,
&aWindowSizes->mArenaStats,
&aWindowSizes->mLayoutPresShellSize,
&aWindowSizes->mLayoutStyleSetsSize,
&aWindowSizes->mLayoutTextRunsSize,
&aWindowSizes->mLayoutPresContextSize,
&aWindowSizes->mLayoutFramePropertiesSize);
mPresShell->AddSizeOfIncludingThis(aWindowSizes.mState.mMallocSizeOf,
&aWindowSizes.mArenaStats,
&aWindowSizes.mLayoutPresShellSize,
&aWindowSizes.mLayoutStyleSetsSize,
&aWindowSizes.mLayoutTextRunsSize,
&aWindowSizes.mLayoutPresContextSize,
&aWindowSizes.mLayoutFramePropertiesSize);
}
aWindowSizes->mPropertyTablesSize +=
mPropertyTable.SizeOfExcludingThis(aWindowSizes->mState.mMallocSizeOf);
aWindowSizes.mPropertyTablesSize +=
mPropertyTable.SizeOfExcludingThis(aWindowSizes.mState.mMallocSizeOf);
for (uint32_t i = 0, count = mExtraPropertyTables.Length();
i < count; ++i) {
aWindowSizes->mPropertyTablesSize +=
aWindowSizes.mPropertyTablesSize +=
mExtraPropertyTables[i]->SizeOfIncludingThis(
aWindowSizes->mState.mMallocSizeOf);
aWindowSizes.mState.mMallocSizeOf);
}
if (EventListenerManager* elm = GetExistingListenerManager()) {
aWindowSizes->mDOMEventListenersCount += elm->ListenerCount();
aWindowSizes.mDOMEventListenersCount += elm->ListenerCount();
}
// Measurement of the following members may be added later if DMD finds it
@ -12423,9 +12423,9 @@ nsIDocument::DocAddSizeOfExcludingThis(nsWindowSizes* aWindowSizes) const
}
void
nsIDocument::DocAddSizeOfIncludingThis(nsWindowSizes* aWindowSizes) const
nsIDocument::DocAddSizeOfIncludingThis(nsWindowSizes& aWindowSizes) const
{
aWindowSizes->mDOMOtherSize += aWindowSizes->mState.mMallocSizeOf(this);
aWindowSizes.mDOMOtherSize += aWindowSizes.mState.mMallocSizeOf(this);
DocAddSizeOfExcludingThis(aWindowSizes);
}
@ -12456,7 +12456,7 @@ nsDocument::SizeOfExcludingThis(SizeOfState& aState) const
}
void
nsDocument::DocAddSizeOfExcludingThis(nsWindowSizes* aWindowSizes) const
nsDocument::DocAddSizeOfExcludingThis(nsWindowSizes& aWindowSizes) const
{
nsIDocument::DocAddSizeOfExcludingThis(aWindowSizes);
@ -12464,64 +12464,63 @@ nsDocument::DocAddSizeOfExcludingThis(nsWindowSizes* aWindowSizes) const
node;
node = node->GetNextNode(this))
{
size_t nodeSize = node->SizeOfIncludingThis(aWindowSizes->mState);
size_t nodeSize = node->SizeOfIncludingThis(aWindowSizes.mState);
size_t* p;
switch (node->NodeType()) {
case nsIDOMNode::ELEMENT_NODE:
p = &aWindowSizes->mDOMElementNodesSize;
p = &aWindowSizes.mDOMElementNodesSize;
break;
case nsIDOMNode::TEXT_NODE:
p = &aWindowSizes->mDOMTextNodesSize;
p = &aWindowSizes.mDOMTextNodesSize;
break;
case nsIDOMNode::CDATA_SECTION_NODE:
p = &aWindowSizes->mDOMCDATANodesSize;
p = &aWindowSizes.mDOMCDATANodesSize;
break;
case nsIDOMNode::COMMENT_NODE:
p = &aWindowSizes->mDOMCommentNodesSize;
p = &aWindowSizes.mDOMCommentNodesSize;
break;
default:
p = &aWindowSizes->mDOMOtherSize;
p = &aWindowSizes.mDOMOtherSize;
break;
}
*p += nodeSize;
if (EventListenerManager* elm = node->GetExistingListenerManager()) {
aWindowSizes->mDOMEventListenersCount += elm->ListenerCount();
aWindowSizes.mDOMEventListenersCount += elm->ListenerCount();
}
}
aWindowSizes->mStyleSheetsSize +=
aWindowSizes.mStyleSheetsSize +=
SizeOfOwnedSheetArrayExcludingThis(mStyleSheets,
aWindowSizes->mState.mMallocSizeOf);
aWindowSizes.mState.mMallocSizeOf);
// Note that we do not own the sheets pointed to by mOnDemandBuiltInUASheets
// (the nsLayoutStyleSheetCache singleton does).
aWindowSizes->mStyleSheetsSize +=
aWindowSizes.mStyleSheetsSize +=
mOnDemandBuiltInUASheets.ShallowSizeOfExcludingThis(
aWindowSizes->mState.mMallocSizeOf);
aWindowSizes.mState.mMallocSizeOf);
for (auto& sheetArray : mAdditionalSheets) {
aWindowSizes->mStyleSheetsSize +=
aWindowSizes.mStyleSheetsSize +=
SizeOfOwnedSheetArrayExcludingThis(sheetArray,
aWindowSizes->mState.mMallocSizeOf);
aWindowSizes.mState.mMallocSizeOf);
}
// Lumping in the loader with the style-sheets size is not ideal,
// but most of the things in there are in fact stylesheets, so it
// doesn't seem worthwhile to separate it out.
aWindowSizes->mStyleSheetsSize +=
CSSLoader()->SizeOfIncludingThis(aWindowSizes->mState.mMallocSizeOf);
aWindowSizes.mStyleSheetsSize +=
CSSLoader()->SizeOfIncludingThis(aWindowSizes.mState.mMallocSizeOf);
aWindowSizes->mDOMOtherSize += mAttrStyleSheet
? mAttrStyleSheet->DOMSizeOfIncludingThis(
aWindowSizes->mState.mMallocSizeOf)
: 0;
aWindowSizes.mDOMOtherSize += mAttrStyleSheet
? mAttrStyleSheet->DOMSizeOfIncludingThis(
aWindowSizes.mState.mMallocSizeOf)
: 0;
aWindowSizes->mDOMOtherSize +=
mStyledLinks.ShallowSizeOfExcludingThis(
aWindowSizes->mState.mMallocSizeOf);
aWindowSizes.mDOMOtherSize +=
mStyledLinks.ShallowSizeOfExcludingThis(aWindowSizes.mState.mMallocSizeOf);
aWindowSizes->mDOMOtherSize +=
mIdentifierMap.SizeOfExcludingThis(aWindowSizes->mState.mMallocSizeOf);
aWindowSizes.mDOMOtherSize +=
mIdentifierMap.SizeOfExcludingThis(aWindowSizes.mState.mMallocSizeOf);
// Measurement of the following members may be added later if DMD finds it
// is worthwhile:

View File

@ -983,7 +983,7 @@ public:
// to notify window when the page was first visited.
void MaybeActiveMediaComponents();
virtual void DocAddSizeOfExcludingThis(nsWindowSizes* aWindowSizes) const override;
virtual void DocAddSizeOfExcludingThis(nsWindowSizes& aWindowSizes) const override;
// DocAddSizeOfIncludingThis is inherited from nsIDocument.
virtual nsIDOMNode* AsDOMNode() override { return this; }

View File

@ -13579,17 +13579,16 @@ nsGlobalWindow::DisableTimeChangeNotifications()
}
void
nsGlobalWindow::AddSizeOfIncludingThis(nsWindowSizes* aWindowSizes) const
nsGlobalWindow::AddSizeOfIncludingThis(nsWindowSizes& aWindowSizes) const
{
aWindowSizes->mDOMOtherSize += aWindowSizes->mState.mMallocSizeOf(this);
aWindowSizes.mDOMOtherSize += aWindowSizes.mState.mMallocSizeOf(this);
if (IsInnerWindow()) {
EventListenerManager* elm = GetExistingListenerManager();
if (elm) {
aWindowSizes->mDOMOtherSize +=
elm->SizeOfIncludingThis(aWindowSizes->mState.mMallocSizeOf);
aWindowSizes->mDOMEventListenersCount +=
elm->ListenerCount();
aWindowSizes.mDOMOtherSize +=
elm->SizeOfIncludingThis(aWindowSizes.mState.mMallocSizeOf);
aWindowSizes.mDOMEventListenersCount += elm->ListenerCount();
}
if (mDoc) {
// Multiple global windows can share a document. So only measure the
@ -13603,32 +13602,32 @@ nsGlobalWindow::AddSizeOfIncludingThis(nsWindowSizes* aWindowSizes) const
}
if (mNavigator) {
aWindowSizes->mDOMOtherSize +=
mNavigator->SizeOfIncludingThis(aWindowSizes->mState.mMallocSizeOf);
aWindowSizes.mDOMOtherSize +=
mNavigator->SizeOfIncludingThis(aWindowSizes.mState.mMallocSizeOf);
}
aWindowSizes->mDOMEventTargetsSize +=
aWindowSizes.mDOMEventTargetsSize +=
mEventTargetObjects.ShallowSizeOfExcludingThis(
aWindowSizes->mState.mMallocSizeOf);
aWindowSizes.mState.mMallocSizeOf);
for (auto iter = mEventTargetObjects.ConstIter(); !iter.Done(); iter.Next()) {
DOMEventTargetHelper* et = iter.Get()->GetKey();
if (nsCOMPtr<nsISizeOfEventTarget> iSizeOf = do_QueryObject(et)) {
aWindowSizes->mDOMEventTargetsSize +=
aWindowSizes.mDOMEventTargetsSize +=
iSizeOf->SizeOfEventTargetIncludingThis(
aWindowSizes->mState.mMallocSizeOf);
aWindowSizes.mState.mMallocSizeOf);
}
if (EventListenerManager* elm = et->GetExistingListenerManager()) {
aWindowSizes->mDOMEventListenersCount += elm->ListenerCount();
aWindowSizes.mDOMEventListenersCount += elm->ListenerCount();
}
++aWindowSizes->mDOMEventTargetsCount;
++aWindowSizes.mDOMEventTargetsCount;
}
if (IsInnerWindow() && mPerformance) {
aWindowSizes->mDOMPerformanceUserEntries =
mPerformance->SizeOfUserEntries(aWindowSizes->mState.mMallocSizeOf);
aWindowSizes->mDOMPerformanceResourceEntries =
mPerformance->SizeOfResourceEntries(aWindowSizes->mState.mMallocSizeOf);
aWindowSizes.mDOMPerformanceUserEntries =
mPerformance->SizeOfUserEntries(aWindowSizes.mState.mMallocSizeOf);
aWindowSizes.mDOMPerformanceResourceEntries =
mPerformance->SizeOfResourceEntries(aWindowSizes.mState.mMallocSizeOf);
}
}

View File

@ -716,7 +716,7 @@ public:
return sWindowsById;
}
void AddSizeOfIncludingThis(nsWindowSizes* aWindowSizes) const;
void AddSizeOfIncludingThis(nsWindowSizes& aWindowSizes) const;
// Inner windows only.
void AddEventTargetObject(mozilla::DOMEventTargetHelper* aObject);

View File

@ -2569,11 +2569,11 @@ public:
// SizeOfExcludingThis function. However, because nsIDocument objects can
// only appear at the top of the DOM tree, we have a specialized measurement
// function which returns multiple sizes.
virtual void DocAddSizeOfExcludingThis(nsWindowSizes* aWindowSizes) const;
virtual void DocAddSizeOfExcludingThis(nsWindowSizes& aWindowSizes) const;
// DocAddSizeOfIncludingThis doesn't need to be overridden by sub-classes
// because nsIDocument inherits from nsINode; see the comment above the
// declaration of nsINode::SizeOfIncludingThis.
virtual void DocAddSizeOfIncludingThis(nsWindowSizes* aWindowSizes) const;
virtual void DocAddSizeOfIncludingThis(nsWindowSizes& aWindowSizes) const;
bool MayHaveDOMMutationObservers()
{

View File

@ -53,13 +53,13 @@ AddNonJSSizeOfWindowAndItsDescendents(nsGlobalWindow* aWindow,
// Measure the window.
SizeOfState state(moz_malloc_size_of);
nsWindowSizes windowSizes(state);
aWindow->AddSizeOfIncludingThis(&windowSizes);
aWindow->AddSizeOfIncludingThis(windowSizes);
// Measure the inner window, if there is one.
nsGlobalWindow* inner = aWindow->IsOuterWindow() ? aWindow->GetCurrentInnerWindowInternal()
: nullptr;
if (inner) {
inner->AddSizeOfIncludingThis(&windowSizes);
inner->AddSizeOfIncludingThis(windowSizes);
}
windowSizes.addToTabSizes(aSizes);
@ -313,7 +313,7 @@ CollectWindowReports(nsGlobalWindow *aWindow,
// this window.
SizeOfState state(WindowsMallocSizeOf);
nsWindowSizes windowSizes(state);
aWindow->AddSizeOfIncludingThis(&windowSizes);
aWindow->AddSizeOfIncludingThis(windowSizes);
REPORT_SIZE("/dom/element-nodes", windowSizes.mDOMElementNodesSize,
"Memory used by the element nodes in a window's DOM.");

View File

@ -3731,7 +3731,7 @@ nsHTMLDocument::RemovedFromDocShell()
}
/* virtual */ void
nsHTMLDocument::DocAddSizeOfExcludingThis(nsWindowSizes* aWindowSizes) const
nsHTMLDocument::DocAddSizeOfExcludingThis(nsWindowSizes& aWindowSizes) const
{
nsDocument::DocAddSizeOfExcludingThis(aWindowSizes);

View File

@ -160,7 +160,7 @@ public:
return nsDocument::GetElementById(aElementId);
}
virtual void DocAddSizeOfExcludingThis(nsWindowSizes* aWindowSizes) const override;
virtual void DocAddSizeOfExcludingThis(nsWindowSizes& aWindowSizes) const override;
// DocAddSizeOfIncludingThis is inherited from nsIDocument.
virtual bool WillIgnoreCharsetOverride() override;

View File

@ -592,7 +592,7 @@ XMLDocument::EndLoad()
}
/* virtual */ void
XMLDocument::DocAddSizeOfExcludingThis(nsWindowSizes* aWindowSizes) const
XMLDocument::DocAddSizeOfExcludingThis(nsWindowSizes& aWindowSizes) const
{
nsDocument::DocAddSizeOfExcludingThis(aWindowSizes);
}

View File

@ -54,7 +54,7 @@ public:
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
bool aPreallocateChildren) const override;
virtual void DocAddSizeOfExcludingThis(nsWindowSizes* aWindowSizes) const override;
virtual void DocAddSizeOfExcludingThis(nsWindowSizes& aWindowSizes) const override;
// DocAddSizeOfIncludingThis is inherited from nsIDocument.

View File

@ -392,7 +392,7 @@ VectorImage::SizeOfSourceWithComputedFallback(SizeOfState& aState) const
}
nsWindowSizes windowSizes(aState);
doc->DocAddSizeOfIncludingThis(&windowSizes);
doc->DocAddSizeOfIncludingThis(windowSizes);
if (windowSizes.getTotalSize() == 0) {
// MallocSizeOf fails on this platform. Because we also use this method for