Commit b30d73b5 authored by simon.fraser@apple.com's avatar simon.fraser@apple.com
Browse files

2010-04-27 Simon Fraser <simon.fraser@apple.com>

        Reviewed by the inimitable Dan Bernstein.

        SVG as background image renders incorrectly after zooming
        https://bugs.webkit.org/show_bug.cgi?id=38215

        When doing a partial redraw of an SVGImage used as a CSS background
        image, we're limited to drawing the entire Frame, clipped to the dirty rect.
        Because of this, we need to fix up the CTM so that the origin is at the
        top left of the unclipped image, rather than the top left of the
        portion being redrawn.

        Test: fast/images/svg-background-partial-redraw.html

        * svg/graphics/SVGImage.cpp:
        (WebCore::SVGImage::draw):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@58375 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1fcfaa52
2010-04-27 Simon Fraser <simon.fraser@apple.com>
Reviewed by the inimitable Dan Bernstein.
SVG as background image renders incorrectly after zooming
https://bugs.webkit.org/show_bug.cgi?id=38215
Testcase for a partial redraw of an element using an untiled SVG background image.
* fast/images/resources/circle.svg: Added.
* fast/images/svg-background-partial-redraw.html: Added.
* platform/mac/fast/images/svg-background-partial-redraw-expected.checksum: Added.
* platform/mac/fast/images/svg-background-partial-redraw-expected.png: Added.
* platform/mac/fast/images/svg-background-partial-redraw-expected.txt: Added.
2010-04-27 Yuzo Fujishima <yuzo@google.com>
 
Reviewed by David Hyatt.
......
<?xml version="1.0"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200">
<circle cx="50%" cy="50%" r="80" style="fill:blue;" />
</svg>
<!DOCTYPE html>
<html>
<head>
<title>SVG img and bg test</title>
<style type="text/css" media="screen">
div {
-webkit-box-sizing: border-box;
}
#test
{
position: relative;
height: 200px;
width: 200px;
background: url('resources/circle.svg') 0 0 no-repeat;
border: 1px solid black;
}
#revealer {
position: absolute;
top: 100px;
left: 0;
height: 100px;
width: 200px;
background-color: red;
}
#test.revealed > #revealer {
display: none;
}
#test:hover > #revealer {
display: block;
}
</style>
<script type="text/javascript" charset="utf-8">
function doTest()
{
document.body.offsetTop;
if (window.layoutTestController)
layoutTestController.display();
document.getElementById('test').className = 'revealed';
}
window.addEventListener('load', doTest, false)
</script>
</head>
<body>
<p>You should continue see a full blue circle when part of the element is redrawn (hover to test interactively).</p>
<div id="test">
<div id="revealer"></div>
</div>
</body>
</html>
\ No newline at end of file
d357341bc60819627f5dc60959356504
\ No newline at end of file
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x258
RenderBlock {HTML} at (0,0) size 800x258
RenderBody {BODY} at (8,16) size 784x234
RenderBlock {P} at (0,0) size 784x18
RenderText {#text} at (0,0) size 667x18
text run at (0,0) width 667: "You should continue see a full blue circle when part of the element is redrawn (hover to test interactively)."
layer at (8,50) size 200x200
RenderBlock (relative positioned) {DIV} at (0,34) size 200x200 [border: (1px solid #000000)]
2010-04-27 Simon Fraser <simon.fraser@apple.com>
Reviewed by the inimitable Dan Bernstein.
SVG as background image renders incorrectly after zooming
https://bugs.webkit.org/show_bug.cgi?id=38215
When doing a partial redraw of an SVGImage used as a CSS background
image, we're limited to drawing the entire Frame, clipped to the dirty rect.
Because of this, we need to fix up the CTM so that the origin is at the
top left of the unclipped image, rather than the top left of the
portion being redrawn.
Test: fast/images/svg-background-partial-redraw.html
* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::draw):
2010-04-27 Yuzo Fujishima <yuzo@google.com>
 
Reviewed by David Hyatt.
......@@ -186,13 +186,22 @@ void SVGImage::draw(GraphicsContext* context, const FloatRect& dstRect, const Fl
context->clip(enclosingIntRect(dstRect));
if (compositeOp != CompositeSourceOver)
context->beginTransparencyLayer(1);
context->translate(dstRect.location().x(), dstRect.location().y());
context->scale(FloatSize(dstRect.width() / srcRect.width(), dstRect.height() / srcRect.height()));
FloatSize scale(dstRect.width() / srcRect.width(), dstRect.height() / srcRect.height());
// We can only draw the entire frame, clipped to the rect we want. So compute where the top left
// of the image would be if we were drawing without clipping, and translate accordingly.
FloatSize topLeftOffset(srcRect.location().x() * scale.width(), srcRect.location().y() * scale.height());
FloatPoint destOffset = dstRect.location() - topLeftOffset;
context->translate(destOffset.x(), destOffset.y());
context->scale(scale);
view->resize(size());
if (view->needsLayout())
view->layout();
view->paint(context, IntRect(0, 0, view->width(), view->height()));
if (compositeOp != CompositeSourceOver)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment