b=385584, crash with toDataURL on large canvas, r=stuart

This commit is contained in:
vladimir%pobox.com 2007-06-25 16:24:21 +00:00
Родитель b10693b5be
Коммит 8cf3c6cbb1
2 изменённых файлов: 19 добавлений и 7 удалений

Просмотреть файл

@ -720,6 +720,14 @@ nsCanvasRenderingContext2D::Render(nsIRenderingContext *rc)
{
nsresult rv = NS_OK;
if (!mSurface || !mCairo ||
cairo_surface_status(mSurface) != CAIRO_STATUS_SUCCESS ||
cairo_status(mCairo) != CAIRO_STATUS_SUCCESS)
return NS_ERROR_FAILURE;
if (!mThebesSurface)
return NS_ERROR_FAILURE;
gfxContext* ctx = (gfxContext*) rc->GetNativeGraphicData(nsIRenderingContext::NATIVE_THEBES_CONTEXT);
nsRefPtr<gfxPattern> pat = new gfxPattern(mThebesSurface);
@ -748,14 +756,12 @@ nsCanvasRenderingContext2D::GetInputStream(const nsACString& aMimeType,
const nsAString& aEncoderOptions,
nsIInputStream **aStream)
{
if (!mSurface || cairo_surface_status(mSurface) != CAIRO_STATUS_SUCCESS)
return NS_ERROR_FAILURE;
nsCString conid(NS_LITERAL_CSTRING("@mozilla.org/image/encoder;2?type="));
conid += aMimeType;
if (cairo_status(mCairo)) {
fprintf (stderr, "Cairo error! %d %s\n", cairo_status(mCairo), cairo_status_to_string(cairo_status(mCairo)));
fflush (stderr);
}
nsCOMPtr<imgIEncoder> encoder = do_CreateInstance(conid.get());
if (!encoder)
return NS_ERROR_FAILURE;

Просмотреть файл

@ -455,10 +455,16 @@ nsHTMLCanvasElement::GetContext(const nsAString& aContextId,
return NS_ERROR_INVALID_ARG;
rv = mCurrentContext->SetCanvasElement(this);
NS_ENSURE_SUCCESS(rv, rv);
if (NS_FAILED(rv)) {
mCurrentContext = nsnull;
return rv;
}
rv = UpdateContext();
NS_ENSURE_SUCCESS(rv, rv);
if (NS_FAILED(rv)) {
mCurrentContext = nsnull;
return rv;
}
mCurrentContextId.Assign(aContextId);
} else if (!mCurrentContextId.Equals(aContextId)) {