diff --git a/content/canvas/src/CanvasRenderingContext2D.cpp b/content/canvas/src/CanvasRenderingContext2D.cpp index 42b2093647e..4a6fe1a15a7 100644 --- a/content/canvas/src/CanvasRenderingContext2D.cpp +++ b/content/canvas/src/CanvasRenderingContext2D.cpp @@ -1455,6 +1455,7 @@ CanvasRenderingContext2D::CreatePattern(const HTMLImageOrCanvasOrVideoElement& e // Ignore nullptr cairo surfaces! See bug 666312. if (!res.mSurface->CairoSurface() || res.mSurface->CairoStatus()) { + error.Throw(NS_ERROR_NOT_AVAILABLE); return nullptr; } diff --git a/content/canvas/test/Makefile.in b/content/canvas/test/Makefile.in index 4a97a534bc4..1f639ea8e5f 100644 --- a/content/canvas/test/Makefile.in +++ b/content/canvas/test/Makefile.in @@ -106,6 +106,7 @@ MOCHITEST_FILES = \ test_bug753758.html \ test_bug764125.html \ test_bug856472.html \ + test_bug866575.html \ test_drawImage_edge_cases.html \ test_drawImage_document_domain.html \ test_mozDashOffset.html \ diff --git a/content/canvas/test/test_bug866575.html b/content/canvas/test/test_bug866575.html new file mode 100644 index 00000000000..cdb2dc9c61a --- /dev/null +++ b/content/canvas/test/test_bug866575.html @@ -0,0 +1,34 @@ + + + + + Test for Bug 866575 + + + + +Mozilla Bug 866575 +

+ +
+
+
+ + diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index f3e9cb63cb9..c9357047e52 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -4654,6 +4654,9 @@ nsLayoutUtils::SurfaceFromElement(HTMLCanvasElement* aElement, surf = gfxPlatform::GetPlatform()->CreateOffscreenSurface(size, gfxASurface::CONTENT_COLOR_ALPHA); } + if (!surf) + return result; + nsRefPtr ctx = new gfxContext(surf); // XXX shouldn't use the external interface, but maybe we can layerify this uint32_t flags = premultAlpha ? HTMLCanvasElement::RenderFlagPremultAlpha : 0;