Bug 996326: Make nsDeviceContext::CreateRenderingContext() return its result directly, instead of using outparam. r=roc

This commit is contained in:
Daniel Holbert 2014-04-14 20:15:01 -07:00
parent 5205d683d0
commit 20f62f5f5a
5 changed files with 17 additions and 21 deletions

View File

@ -377,8 +377,8 @@ nsDeviceContext::Init(nsIWidget *aWidget)
return NS_OK;
}
nsresult
nsDeviceContext::CreateRenderingContext(nsRenderingContext *&aContext)
already_AddRefed<nsRenderingContext>
nsDeviceContext::CreateRenderingContext()
{
nsRefPtr<gfxASurface> printingSurface = mPrintingSurface;
#ifdef XP_MACOSX
@ -400,10 +400,8 @@ nsDeviceContext::CreateRenderingContext(nsRenderingContext *&aContext)
pContext->Init(this, dt);
pContext->Scale(mPrintingScale, mPrintingScale);
aContext = pContext;
NS_ADDREF(aContext);
return NS_OK;
return pContext.forget();
}
nsresult

View File

@ -57,10 +57,10 @@ public:
/**
* Create a rendering context and initialize it. Only call this
* method on device contexts that were initialized for printing.
* @param aContext out parameter for new rendering context
* @return error status
*
* @return the new rendering context (guaranteed to be non-null)
*/
nsresult CreateRenderingContext(nsRenderingContext *&aContext);
already_AddRefed<nsRenderingContext> CreateRenderingContext();
/**
* Gets the number of app units in one CSS pixel; this number is global,

View File

@ -2907,7 +2907,7 @@ PresShell::GetReferenceRenderingContext()
rc = new nsRenderingContext();
rc->Init(devCtx, gfxPlatform::GetPlatform()->ScreenReferenceSurface());
} else {
devCtx->CreateRenderingContext(*getter_AddRefs(rc));
rc = devCtx->CreateRenderingContext();
}
return rc.forget();
}

View File

@ -591,9 +591,8 @@ nsSimplePageSequenceFrame::PrePrintNextPage(nsITimerCallback* aCallback, bool* a
mCalledBeginPage = true;
nsRefPtr<nsRenderingContext> renderingContext;
dc->CreateRenderingContext(*getter_AddRefs(renderingContext));
NS_ENSURE_TRUE(renderingContext, NS_ERROR_OUT_OF_MEMORY);
nsRefPtr<nsRenderingContext> renderingContext =
dc->CreateRenderingContext();
nsRefPtr<gfxASurface> renderingSurface =
renderingContext->ThebesContext()->CurrentSurface();
@ -722,9 +721,8 @@ nsSimplePageSequenceFrame::PrintNextPage()
PR_PL(("SeqFr::PrintNextPage -> %p PageNo: %d", pf, mPageNum));
nsRefPtr<nsRenderingContext> renderingContext;
dc->CreateRenderingContext(*getter_AddRefs(renderingContext));
NS_ENSURE_TRUE(renderingContext, NS_ERROR_OUT_OF_MEMORY);
nsRefPtr<nsRenderingContext> renderingContext =
dc->CreateRenderingContext();
nsRect drawingRect(nsPoint(0, 0), currentPage->GetSize());
nsRegion drawingRegion(drawingRect);

View File

@ -2265,8 +2265,8 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO)
fprintf(fd, "Title: %s\n", docStr.get());
fprintf(fd, "URL: %s\n", urlStr.get());
fprintf(fd, "--------------- Frames ----------------\n");
nsRefPtr<nsRenderingContext> renderingContext;
mPrt->mPrintDocDC->CreateRenderingContext(*getter_AddRefs(renderingContext));
nsRefPtr<nsRenderingContext> renderingContext =
mPrt->mPrintDocDC->CreateRenderingContext();
RootFrameList(aPO->mPresContext, fd, 0);
//DumpFrames(fd, aPO->mPresContext, renderingContext, theRootFrame, 0);
fprintf(fd, "---------------------------------------\n\n");
@ -2505,8 +2505,8 @@ nsPrintEngine::DoPrint(nsPrintObject * aPO)
poPresContext->SetIsRenderingOnlySelection(true);
// temporarily creating rendering context
// which is needed to find the selection frames
nsRefPtr<nsRenderingContext> rc;
mPrt->mPrintDC->CreateRenderingContext(*getter_AddRefs(rc));
nsRefPtr<nsRenderingContext> rc =
mPrt->mPrintDC->CreateRenderingContext();
// find the starting and ending page numbers
// via the selection
@ -3811,8 +3811,8 @@ void DumpLayoutData(char* aTitleStr,
fprintf(fd, "URL: %s\n", aURLStr?aURLStr:"");
fprintf(fd, "--------------- Frames ----------------\n");
fprintf(fd, "--------------- Frames ----------------\n");
nsRefPtr<nsRenderingContext> renderingContext;
aDC->CreateRenderingContext(*getter_AddRefs(renderingContext));
nsRefPtr<nsRenderingContext> renderingContext =
aDC->CreateRenderingContext();
RootFrameList(aPresContext, fd, 0);
//DumpFrames(fd, aPresContext, renderingContext, aRootFrame, 0);
fprintf(fd, "---------------------------------------\n\n");