haikuwebkit/LayoutTests/svg/transforms/transformed-text-fill-patte...

40 lines
1.4 KiB
HTML
Raw Permalink Normal View History

[svg] SVGResources applied to Text with Incorrect Transformations in non-CG Implementations https://bugs.webkit.org/show_bug.cgi?id=64966 Patch by Dominik Röttsches <dominik.rottsches@intel.com> on 2012-06-14 Reviewed by Nikolas Zimmermann. Source/WebCore: SVGInlineTextBox::paintTextWithShadows for non-CG implementations resets the scale aspect of the currently applied CTM. This leads to patterns and gradients being incorrectly downscaled. This way of resetting the CTM and drawing fonts "natively" scaled was introduced in r77485 to fix a number of issues with SVG font scaling. Unfortunately, this breaks scaling of patterns and gradients. To fix it, we need to push the transformation back into the pattern/gradient space transformation. Tests: svg/transforms/transformed-text-fill-gradient.html svg/transforms/transformed-text-fill-pattern.html * rendering/svg/RenderSVGInlineText.cpp: (WebCore::RenderSVGInlineText::computeNewScaledFontForStyle): Moving the scaling factor calculation out into SVGRenderingContext. * rendering/svg/RenderSVGResourceContainer.cpp: (WebCore::RenderSVGResourceContainer::shouldTransformOnTextPainting): Reusing the scaling factor calculation from SVGRenderingContext. (WebCore): * rendering/svg/RenderSVGResourceContainer.h: (RenderSVGResourceContainer): * rendering/svg/RenderSVGResourceGradient.cpp: (WebCore::RenderSVGResourceGradient::applyResource): If needed, push down transformation into gradient space. * rendering/svg/RenderSVGResourcePattern.cpp: (WebCore::RenderSVGResourcePattern::applyResource): If needed, push transformation into pattern space. * rendering/svg/SVGRenderingContext.cpp: (WebCore::SVGRenderingContext::calculateScreenFontSizeScalingFactor): Common scaling factor calculation for RenderSVGInlineText and RenderSVGResourceContainer. * rendering/svg/SVGRenderingContext.h: (SVGRenderingContext): LayoutTests: For Pattern: RefTest that compare a scaled rectangle with a scaled block of Ahem characters. The pattern or gradient should scale in the same way for the text and the rectangle. This approach needs a clipping path hack to work around micro gaps between Ahem characters due to rounding. For Gradient: Scaling text at two different scale factors and adjusting font size to yield the same effective text size. Gradient fill should be identical in both cases. * platform/chromium/TestExpectations: Added 3 tests that need rebaselining for text gradient fills. * svg/transforms/transformed-text-fill-gradient-expected.html: Added. * svg/transforms/transformed-text-fill-gradient.html: Added. * svg/transforms/transformed-text-fill-pattern-expected.html: Added. * svg/transforms/transformed-text-fill-pattern.html: Added. Canonical link: https://commits.webkit.org/106931@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@120314 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2012-06-14 12:18:15 +00:00
<html><body><svg width="1000" height="600" xmlns="http://www.w3.org/2000/svg">
<!-- The pattern needs to scale with the text in the same way it scales with rectangles. -->
<defs>
<pattern id="hatch" patternUnits="userSpaceOnUse" x="0" y="0" width="10" height="10">
<g style="fill:none; stroke:black; stroke-width:1">
<path d="M0,0 l10,10"/>
<path d="M10,0 l-10,10"/>
</g>
</pattern>
<style type="text/css"><![CDATA[
@font-face {
font-family: Ahem;
src: url(../../resources/Ahem.ttf);
}
.ahemblock {
font-family: Ahem;
font-size: 30px;
}
]]>
</style>
<!-- Masking away the micro-gaps between the Ahem characters that may occur due to rounding
which causes this test to fail on platforms that run reftests with zero tolerance. -->
<clipPath id="clipHack">
<rect x="3" y="0" width="24" height="600"></rect>
<rect x="33" y="10" width="24" height="600"></rect>
<rect x="63" y="0" width="24" height="600"></rect>
<rect x="93" y="0" width="24" height="600"></rect>
<rect x="123" y="0" width="24" height="600"></rect>
</clipPath>
</defs>
<g transform="scale(4)" clip-path="url(#clipHack)">
<text class="ahemblock" y="50" fill="url(#hatch)">AAAAA</text>
</g>
<g transform="scale(6)" clip-path="url(#clipHack)">
<text class="ahemblock" y="90" x="0" fill="url(#hatch)">AAAAA</text>
</g>
</svg>
</body>
</html>