mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1202703 - Part 1 - CreateRenderingContext can fail. r=mattwoodrow
This commit is contained in:
parent
c882274c2c
commit
88a57634ca
@ -413,9 +413,11 @@ nsDeviceContext::CreateRenderingContext()
|
|||||||
gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(printingSurface,
|
gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(printingSurface,
|
||||||
gfx::IntSize(mWidth, mHeight));
|
gfx::IntSize(mWidth, mHeight));
|
||||||
|
|
||||||
|
// This can legitimately happen - CreateDrawTargetForSurface will fail
|
||||||
|
// to create a draw target if the size is too large, for instance.
|
||||||
if (!dt) {
|
if (!dt) {
|
||||||
gfxCriticalError() << "Failed to create draw target in device context sized " << mWidth << "x" << mHeight << " and pointers " << hexa(mPrintingSurface) << " and " << hexa(printingSurface);
|
gfxCriticalNote << "Failed to create draw target in device context sized " << mWidth << "x" << mHeight << " and pointers " << hexa(mPrintingSurface) << " and " << hexa(printingSurface);
|
||||||
MOZ_CRASH("Cannot CreateDrawTargetForSurface");
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef XP_MACOSX
|
#ifdef XP_MACOSX
|
||||||
|
@ -2910,11 +2910,15 @@ PresShell::CreateReferenceRenderingContext()
|
|||||||
if (mPresContext->IsScreen()) {
|
if (mPresContext->IsScreen()) {
|
||||||
rc = new gfxContext(gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget());
|
rc = new gfxContext(gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget());
|
||||||
} else {
|
} else {
|
||||||
// We assume the devCtx has positive width and height for this call
|
// We assume the devCtx has positive width and height for this call.
|
||||||
|
// However, width and height, may be outside of the reasonable range
|
||||||
|
// so rc may still be null.
|
||||||
rc = devCtx->CreateRenderingContext();
|
rc = devCtx->CreateRenderingContext();
|
||||||
|
if (!rc) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MOZ_ASSERT(rc, "shouldn't break promise to return non-null");
|
|
||||||
return rc.forget();
|
return rc.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8969,6 +8973,7 @@ PresShell::DoReflow(nsIFrame* target, bool aInterruptible)
|
|||||||
|
|
||||||
nsIFrame* rootFrame = mFrameConstructor->GetRootFrame();
|
nsIFrame* rootFrame = mFrameConstructor->GetRootFrame();
|
||||||
|
|
||||||
|
// CreateReferenceRenderingContext can return nullptr
|
||||||
nsRenderingContext rcx(CreateReferenceRenderingContext());
|
nsRenderingContext rcx(CreateReferenceRenderingContext());
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@ -10902,6 +10907,7 @@ nsIPresShell::SyncWindowProperties(nsView* aView)
|
|||||||
{
|
{
|
||||||
nsIFrame* frame = aView->GetFrame();
|
nsIFrame* frame = aView->GetFrame();
|
||||||
if (frame && mPresContext) {
|
if (frame && mPresContext) {
|
||||||
|
// CreateReferenceRenderingContext can return nullptr
|
||||||
nsRenderingContext rcx(CreateReferenceRenderingContext());
|
nsRenderingContext rcx(CreateReferenceRenderingContext());
|
||||||
nsContainerFrame::SyncWindowProperties(mPresContext, frame, aView, &rcx, 0);
|
nsContainerFrame::SyncWindowProperties(mPresContext, frame, aView, &rcx, 0);
|
||||||
}
|
}
|
||||||
|
@ -645,6 +645,7 @@ nsSimplePageSequenceFrame::PrePrintNextPage(nsITimerCallback* aCallback, bool* a
|
|||||||
mCalledBeginPage = true;
|
mCalledBeginPage = true;
|
||||||
|
|
||||||
nsRefPtr<gfxContext> renderingContext = dc->CreateRenderingContext();
|
nsRefPtr<gfxContext> renderingContext = dc->CreateRenderingContext();
|
||||||
|
NS_ENSURE_TRUE(renderingContext, NS_ERROR_OUT_OF_MEMORY);
|
||||||
|
|
||||||
nsRefPtr<gfxASurface> renderingSurface =
|
nsRefPtr<gfxASurface> renderingSurface =
|
||||||
renderingContext->CurrentSurface();
|
renderingContext->CurrentSurface();
|
||||||
@ -773,7 +774,11 @@ nsSimplePageSequenceFrame::PrintNextPage()
|
|||||||
|
|
||||||
PR_PL(("SeqFr::PrintNextPage -> %p PageNo: %d", pf, mPageNum));
|
PR_PL(("SeqFr::PrintNextPage -> %p PageNo: %d", pf, mPageNum));
|
||||||
|
|
||||||
nsRenderingContext renderingContext(dc->CreateRenderingContext());
|
// CreateRenderingContext can fail
|
||||||
|
nsRefPtr<gfxContext> gCtx = dc->CreateRenderingContext();
|
||||||
|
NS_ENSURE_TRUE(gCtx, NS_ERROR_OUT_OF_MEMORY);
|
||||||
|
|
||||||
|
nsRenderingContext renderingContext(gCtx);
|
||||||
|
|
||||||
nsRect drawingRect(nsPoint(0, 0), currentPage->GetSize());
|
nsRect drawingRect(nsPoint(0, 0), currentPage->GetSize());
|
||||||
nsRegion drawingRegion(drawingRect);
|
nsRegion drawingRegion(drawingRect);
|
||||||
|
@ -2484,7 +2484,12 @@ nsPrintEngine::DoPrint(nsPrintObject * aPO)
|
|||||||
// temporarily creating rendering context
|
// temporarily creating rendering context
|
||||||
// which is needed to find the selection frames
|
// which is needed to find the selection frames
|
||||||
// mPrintDC must have positive width and height for this call
|
// mPrintDC must have positive width and height for this call
|
||||||
nsRenderingContext rc(mPrt->mPrintDC->CreateRenderingContext());
|
|
||||||
|
// CreateRenderingContext can fail for large dimensions
|
||||||
|
nsRefPtr<gfxContext> gCtx = mPrt->mPrintDC->CreateRenderingContext();
|
||||||
|
NS_ENSURE_TRUE(gCtx, NS_ERROR_OUT_OF_MEMORY);
|
||||||
|
|
||||||
|
nsRenderingContext rc(gCtx);
|
||||||
|
|
||||||
// find the starting and ending page numbers
|
// find the starting and ending page numbers
|
||||||
// via the selection
|
// via the selection
|
||||||
|
Loading…
Reference in New Issue
Block a user