Bug 606360: Don't double-count full-page-zoom factor when drawing SVG <image> element. r=longsonr a=blocking-final+

This commit is contained in:
Daniel Holbert 2010-10-22 15:55:04 -07:00
Родитель 9a0330ab1e
Коммит 3e762699d5
7 изменённых файлов: 43 добавлений и 5 удалений

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

@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
viewBox="0 0 20 20">
<image width="10" height="10" xlink:href="blueRect10x10.png"/>
</svg>

После

Ширина:  |  Высота:  |  Размер: 186 B

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

@ -0,0 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
viewBox="0 0 20 20"
reftest-zoom="1.5">
<title>Testcase to ensure that full-page-zoom doesn't actually zoom raster
images, when we have a viewBox applied.</title>
<image width="10" height="10" xlink:href="blueRect10x10.png"/>
</svg>

После

Ширина:  |  Высота:  |  Размер: 344 B

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

@ -0,0 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
viewBox="0 0 20 20"
reftest-zoom="0.5">
<title>Testcase to ensure that full-page-zoom doesn't actually zoom raster
images, when we have a viewBox applied.</title>
<image width="10" height="10" xlink:href="blueRect10x10.png"/>
</svg>

После

Ширина:  |  Высота:  |  Размер: 344 B

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

@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<image width="15" height="15" xlink:href="blueRect10x10.png"/>
</svg>

После

Ширина:  |  Высота:  |  Размер: 161 B

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

@ -0,0 +1,7 @@
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
reftest-zoom="1.5">
<title>Testcase to ensure that full-page-zoom will zoom raster
images the right amount.</title>
<image width="10" height="10" xlink:href="blueRect10x10.png"/>
</svg>

После

Ширина:  |  Высота:  |  Размер: 292 B

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

@ -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 <image> with preserveAspectRatio
# NOTE: The reference cases in the following tests trigger 20 assertions each

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

@ -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 <image>, 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());
}