[svg] SVGResources applied to Text with Incorrect Transformations in non-CG Implement...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Jun 2012 12:18:15 +0000 (12:18 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Jun 2012 12:18:15 +0000 (12:18 +0000)
commitbdc8df00af47dc4626192387a5df798b1d278d95
treec65f57b77628dee14172c4f6f4bb72b306ee42c8
parent4be8acca288073398a14fea9e5a5b43a5e3b66b0
[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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@120314 268f45cc-cd09-0410-ab3c-d52691b4dbfc
14 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/chromium/TestExpectations
LayoutTests/svg/transforms/transformed-text-fill-gradient-expected.html [new file with mode: 0644]
LayoutTests/svg/transforms/transformed-text-fill-gradient.html [new file with mode: 0644]
LayoutTests/svg/transforms/transformed-text-fill-pattern-expected.html [new file with mode: 0644]
LayoutTests/svg/transforms/transformed-text-fill-pattern.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/svg/RenderSVGInlineText.cpp
Source/WebCore/rendering/svg/RenderSVGResourceContainer.cpp
Source/WebCore/rendering/svg/RenderSVGResourceContainer.h
Source/WebCore/rendering/svg/RenderSVGResourceGradient.cpp
Source/WebCore/rendering/svg/RenderSVGResourcePattern.cpp
Source/WebCore/rendering/svg/SVGRenderingContext.cpp
Source/WebCore/rendering/svg/SVGRenderingContext.h