Bug 1304540 part 2: Use nsCOMPtr/RefPtr (and their forget() API) instead of manual NS_ADDREF macros, in a few files within layout. r=mats

MozReview-Commit-ID: SrJNtbwc1B

--HG--
extra : rebase_source : 2fd086157bf4d8d16effe18037258a3bf12623fc
This commit is contained in:
Daniel Holbert 2016-09-21 15:41:26 -07:00
parent 2a6754c4c7
commit c31ad35f39
5 changed files with 8 additions and 17 deletions

View File

@ -125,9 +125,7 @@ NS_CreateFrameTraversal(nsIFrameTraversal** aResult)
NS_ENSURE_ARG_POINTER(aResult);
nsCOMPtr<nsIFrameTraversal> t = new nsFrameTraversal();
*aResult = t;
NS_ADDREF(*aResult);
t.forget(aResult);
return NS_OK;
}

View File

@ -1512,15 +1512,14 @@ PresShell::GetSelection(RawSelectionType aRawSelectionType,
if (!aSelection || !mSelection)
return NS_ERROR_NULL_POINTER;
*aSelection =
nsCOMPtr<nsISelection> selection =
mSelection->GetSelection(ToSelectionType(aRawSelectionType));
if (!(*aSelection)) {
if (!selection) {
return NS_ERROR_INVALID_ARG;
}
NS_ADDREF(*aSelection);
selection.forget(aSelection);
return NS_OK;
}

View File

@ -1737,7 +1737,7 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
mStyleCause = nullptr;
}
NS_ADDREF(shell);
nsCOMPtr<nsIPresShell> shellKungFuDeathGrip(shell);
mStyleFlushObservers.RemoveElement(shell);
RestyleManagerHandle restyleManager =
shell->GetPresContext()->RestyleManager();
@ -1750,8 +1750,6 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
if (presContext) {
presContext->NotifyFontFaceSetOnRefresh();
}
NS_RELEASE(shell);
mNeedToRecomputeVisibility = true;
}
@ -1779,7 +1777,7 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
mReflowCause = nullptr;
}
NS_ADDREF(shell);
nsCOMPtr<nsIPresShell> shellKungFuDeathGrip(shell);
mLayoutFlushObservers.RemoveElement(shell);
shell->mReflowScheduled = false;
shell->mSuppressInterruptibleReflows = false;
@ -1793,8 +1791,6 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
if (presContext) {
presContext->NotifyFontFaceSetOnRefresh();
}
NS_RELEASE(shell);
mNeedToRecomputeVisibility = true;
}

View File

@ -329,8 +329,7 @@ nsContentDLF::CreateBlankDocument(nsILoadGroup *aLoadGroup,
blankDoc->SetDocumentCharacterSetSource(kCharsetFromDocTypeDefault);
blankDoc->SetDocumentCharacterSet(NS_LITERAL_CSTRING("UTF-8"));
*aDocument = blankDoc;
NS_ADDREF(*aDocument);
blankDoc.forget(aDocument);
}
return rv;
}

View File

@ -1913,8 +1913,7 @@ GetFontGroupForFrame(nsIFrame* aFrame, float aFontSizeInflation,
// Populate outparam before we return:
if (aOutFontMetrics) {
*aOutFontMetrics = metrics;
NS_ADDREF(*aOutFontMetrics);
metrics.forget(aOutFontMetrics);
}
// XXX this is a bit bogus, we're releasing 'metrics' so the
// returned font-group might actually be torn down, although because