From 3e762699d59fc230ab22de15fd4612c194b2411b Mon Sep 17 00:00:00 2001 From: Daniel Holbert Date: Fri, 22 Oct 2010 15:55:04 -0700 Subject: [PATCH] Bug 606360: Don't double-count full-page-zoom factor when drawing SVG element. r=longsonr a=blocking-final+ --- layout/reftests/svg/image/image-zoom-01-ref.svg | 5 +++++ layout/reftests/svg/image/image-zoom-01a.svg | 8 ++++++++ layout/reftests/svg/image/image-zoom-01b.svg | 8 ++++++++ layout/reftests/svg/image/image-zoom-02-ref.svg | 4 ++++ layout/reftests/svg/image/image-zoom-02.svg | 7 +++++++ layout/reftests/svg/image/reftest.list | 3 +++ layout/svg/base/src/nsSVGImageFrame.cpp | 13 ++++++++----- 7 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 layout/reftests/svg/image/image-zoom-01-ref.svg create mode 100644 layout/reftests/svg/image/image-zoom-01a.svg create mode 100644 layout/reftests/svg/image/image-zoom-01b.svg create mode 100644 layout/reftests/svg/image/image-zoom-02-ref.svg create mode 100644 layout/reftests/svg/image/image-zoom-02.svg diff --git a/layout/reftests/svg/image/image-zoom-01-ref.svg b/layout/reftests/svg/image/image-zoom-01-ref.svg new file mode 100644 index 000000000000..49451529c02d --- /dev/null +++ b/layout/reftests/svg/image/image-zoom-01-ref.svg @@ -0,0 +1,5 @@ + + + diff --git a/layout/reftests/svg/image/image-zoom-01a.svg b/layout/reftests/svg/image/image-zoom-01a.svg new file mode 100644 index 000000000000..b77712a138e8 --- /dev/null +++ b/layout/reftests/svg/image/image-zoom-01a.svg @@ -0,0 +1,8 @@ + + Testcase to ensure that full-page-zoom doesn't actually zoom raster + images, when we have a viewBox applied. + + diff --git a/layout/reftests/svg/image/image-zoom-01b.svg b/layout/reftests/svg/image/image-zoom-01b.svg new file mode 100644 index 000000000000..7aff01d2bb43 --- /dev/null +++ b/layout/reftests/svg/image/image-zoom-01b.svg @@ -0,0 +1,8 @@ + + Testcase to ensure that full-page-zoom doesn't actually zoom raster + images, when we have a viewBox applied. + + diff --git a/layout/reftests/svg/image/image-zoom-02-ref.svg b/layout/reftests/svg/image/image-zoom-02-ref.svg new file mode 100644 index 000000000000..fca1d5703ee2 --- /dev/null +++ b/layout/reftests/svg/image/image-zoom-02-ref.svg @@ -0,0 +1,4 @@ + + + diff --git a/layout/reftests/svg/image/image-zoom-02.svg b/layout/reftests/svg/image/image-zoom-02.svg new file mode 100644 index 000000000000..6caf046558f3 --- /dev/null +++ b/layout/reftests/svg/image/image-zoom-02.svg @@ -0,0 +1,7 @@ + + Testcase to ensure that full-page-zoom will zoom raster + images the right amount. + + diff --git a/layout/reftests/svg/image/reftest.list b/layout/reftests/svg/image/reftest.list index 5f7bed9ee0a9..fb685ec4ddb5 100644 --- a/layout/reftests/svg/image/reftest.list +++ b/layout/reftests/svg/image/reftest.list @@ -14,6 +14,9 @@ == image-x-01.svg image-x-01-ref.svg == image-xy-01.svg image-xy-01-ref.svg == image-y-01.svg image-y-01-ref.svg +== image-zoom-01a.svg image-zoom-01-ref.svg +== image-zoom-01b.svg image-zoom-01-ref.svg +== image-zoom-02.svg image-zoom-02-ref.svg # Tests for with preserveAspectRatio # NOTE: The reference cases in the following tests trigger 20 assertions each diff --git a/layout/svg/base/src/nsSVGImageFrame.cpp b/layout/svg/base/src/nsSVGImageFrame.cpp index c4195eebde21..324534edaf61 100644 --- a/layout/svg/base/src/nsSVGImageFrame.cpp +++ b/layout/svg/base/src/nsSVGImageFrame.cpp @@ -255,10 +255,13 @@ nsSVGImageFrame::PaintSVG(nsSVGRenderState *aContext, nsSVGUtils::SetClipRect(ctx, GetCanvasTM(), clipRect); } - // NOTE: To ensure that |width| and |height| don't accidentally - // scale the user-unit size in SVG images, we apply those attributes - // via |destRect|, not via our gfxContext's transform. - ctx->Multiply(GetImageTransform()); + nscoord appUnitsPerDevPx = PresContext()->AppUnitsPerDevPixel(); + gfxFloat pageZoomFactor = + nsPresContext::AppUnitsToFloatCSSPixels(appUnitsPerDevPx); + + // NOTE: We need to cancel out the effects of Full-Page-Zoom, or else + // it'll get applied an extra time by DrawSingleUnscaledImage. + ctx->Multiply(GetImageTransform().Scale(pageZoomFactor, pageZoomFactor)); // fill-opacity doesn't affect , so if we're allowed to // optimize group opacity, the opacity used for compositing the @@ -274,7 +277,7 @@ nsSVGImageFrame::PaintSVG(nsSVGRenderState *aContext, nsRect dirtyRect; // only used if aDirtyRect is non-null if (aDirtyRect) { - dirtyRect = aDirtyRect->ToAppUnits(PresContext()->AppUnitsPerDevPixel()); + dirtyRect = aDirtyRect->ToAppUnits(appUnitsPerDevPx); // Adjust dirtyRect to match our local coordinate system. dirtyRect.MoveBy(-mRect.TopLeft()); }