Make CreateRenderingContext() return error for a null surface and add error handling to callers. b=362201 r+sr=vladimir

This commit is contained in:
mats.palmgren@bredband.net 2007-05-12 06:06:16 -07:00
parent 6b0092f0a1
commit b3b5d084fc
4 changed files with 11 additions and 4 deletions

View File

@ -321,6 +321,9 @@ nsThebesDeviceContext::CreateRenderingContext(nsIWidget *aWidget,
nsRefPtr<gfxASurface> surface(aWidget->GetThebesSurface());
if (surface)
rv = pContext->Init(this, surface);
else
rv = NS_ERROR_FAILURE;
if (NS_SUCCEEDED(rv)) {
aContext = pContext;
NS_ADDREF(aContext);

View File

@ -3410,7 +3410,9 @@ PresShell::CreateRenderingContext(nsIFrame *aFrame,
}
*aResult = result;
result->Translate(offset.x, offset.y);
if (NS_SUCCEEDED(rv)) {
result->Translate(offset.x, offset.y);
}
return rv;
}

View File

@ -160,9 +160,11 @@ inFlasher::DrawElementOutline(nsIDOMElement* aElement)
while (frame) {
nsCOMPtr<nsIRenderingContext> rcontext;
presShell->CreateRenderingContext(frame, getter_AddRefs(rcontext));
nsRect rect(nsPoint(0,0), frame->GetSize());
nsresult rv =
presShell->CreateRenderingContext(frame, getter_AddRefs(rcontext));
NS_ENSURE_SUCCESS(rv, rv);
nsRect rect(nsPoint(0,0), frame->GetSize());
if (mInvert) {
rcontext->InvertRect(rect);
}

View File

@ -1740,9 +1740,9 @@ nsChildView::Idle()
gfxASurface*
nsChildView::GetThebesSurface()
{
if (!mTempThebesSurface) {
mTempThebesSurface = new gfxQuartzSurface(gfxSize(1, 1), gfxASurface::ImageFormatARGB32);
NS_ENSURE_TRUE(mTempThebesSurface.get(), nsnull); // OOM
}
gfxASurface *surf = mTempThebesSurface.get();