From 51edec70b6bbc67961971ed1a25a1534b0ee9087 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Tue, 4 Sep 2012 16:24:09 +1200 Subject: [PATCH] Bug 772726. Make nsCanvasRenderingContext2DAzure::DrawWindow use Azure content drawing if that's enabled. r=bas --- .../src/nsCanvasRenderingContext2DAzure.cpp | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/content/canvas/src/nsCanvasRenderingContext2DAzure.cpp b/content/canvas/src/nsCanvasRenderingContext2DAzure.cpp index 608a91a18b4f..5a9282d35d1d 100644 --- a/content/canvas/src/nsCanvasRenderingContext2DAzure.cpp +++ b/content/canvas/src/nsCanvasRenderingContext2DAzure.cpp @@ -3904,16 +3904,7 @@ nsCanvasRenderingContext2DAzure::DrawWindow(nsIDOMWindow* window, double x, return; } - nsRefPtr drawSurf; - GetThebesSurface(getter_AddRefs(drawSurf)); - - nsRefPtr thebes = new gfxContext(drawSurf); - EnsureTarget(); - Matrix matrix = mTarget->GetTransform(); - thebes->SetMatrix(gfxMatrix(matrix._11, matrix._12, matrix._21, - matrix._22, matrix._31, matrix._32)); - // We can't allow web apps to call this until we fix at least the // following potential security issues: // -- rendering cross-domain IFRAMEs and then extracting the results @@ -3928,8 +3919,9 @@ nsCanvasRenderingContext2DAzure::DrawWindow(nsIDOMWindow* window, double x, } // Flush layout updates - if (!(flags & nsIDOMCanvasRenderingContext2D::DRAWWINDOW_DO_NOT_FLUSH)) + if (!(flags & nsIDOMCanvasRenderingContext2D::DRAWWINDOW_DO_NOT_FLUSH)) { nsContentUtils::FlushLayoutForTree(window); + } nsRefPtr presContext; nsCOMPtr win = do_QueryInterface(window); @@ -3970,8 +3962,22 @@ nsCanvasRenderingContext2DAzure::DrawWindow(nsIDOMWindow* window, double x, renderDocFlags |= nsIPresShell::RENDER_ASYNC_DECODE_IMAGES; } + // gfxContext-over-Azure may modify the DrawTarget's transform, so + // save and restore it + Matrix matrix = mTarget->GetTransform(); + nsRefPtr thebes; + if (gfxPlatform::UseAzureContentDrawing()) { + thebes = new gfxContext(mTarget); + } else { + nsRefPtr drawSurf; + GetThebesSurface(getter_AddRefs(drawSurf)); + thebes = new gfxContext(drawSurf); + } + thebes->SetMatrix(gfxMatrix(matrix._11, matrix._12, matrix._21, + matrix._22, matrix._31, matrix._32)); unused << presContext->PresShell()-> RenderDocument(r, renderDocFlags, backgroundColor, thebes); + mTarget->SetTransform(matrix); // note that x and y are coordinates in the document that // we're drawing; x and y are drawn to 0,0 in current user