2010-03-12 20:43:59 +00:00
|
|
|
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
|
|
<defs>
|
2010-10-08 Nikolas Zimmermann <nzimmermann@rim.com>
Reviewed by Dirk Schulze.
gradient stroke on lines does not work
https://bugs.webkit.org/show_bug.cgi?id=40985
Correct handling of invalid fill/stroke paint servers / colors according to SVG 1.1 2nd Edition.
Perfectly matches Opera, and now lets us pass three of the new tests.
Fix incorrect svg/custom/invalid-fill* tests:
-> If there's an invalid fill URI, but no fallback specified, it is as if fill="black" was specified. (invalid-fill.svg)
-> If there's an invalid fill color, but no fallback specified, it is as if fill="none" was specified. (invalid-fill-hex.svg)
Needed to refactor some of the gradient/pattern code to properly handle fallback paint servers.
As side effect, we're allowing gradients with gradientUnits="userSpaceOnUse" to apply on 1d objects (lines) again, per SVG 1.1 2nd edition.
Tests: svg/W3C-SVG-1.1-SE/pservers-pattern-03-f.svg
svg/W3C-SVG-1.1-SE/pservers-grad-17-b.svg
svg/W3C-SVG-1.1-SE/pservers-grad-20-b.svg
* rendering/RenderSVGResource.cpp: Rewrite fill/stroke paint resource requests, share all code between the similar functions.
(WebCore::requestPaintingResource):
(WebCore::RenderSVGResource::fillPaintingResource):
(WebCore::RenderSVGResource::strokePaintingResource):
* rendering/RenderSVGResource.h:
* rendering/RenderSVGResourceGradient.cpp: Split collecting gradient properties from building the gradient. We don't need to build it, if it's not applyable (eg. on 1d lines).
(WebCore::RenderSVGResourceGradient::RenderSVGResourceGradient):
(WebCore::RenderSVGResourceGradient::removeAllClientsFromCache):
(WebCore::clipToTextMask):
(WebCore::RenderSVGResourceGradient::applyResource):
* rendering/RenderSVGResourceGradient.h: Stop storing boundingBoxMode & gradientTransform in each GradientData object, it's enough to just store it in the gradient resource, once.
* rendering/RenderSVGResourceLinearGradient.cpp:
(WebCore::RenderSVGResourceLinearGradient::collectGradientAttributes): Splitted from buildGradient.
(WebCore::RenderSVGResourceLinearGradient::buildGradient):
* rendering/RenderSVGResourceLinearGradient.h:
(WebCore::RenderSVGResourceLinearGradient::boundingBoxMode): Return bounding box mode information, from m_attributes instead of storing in gradientData.
(WebCore::RenderSVGResourceLinearGradient::calculateGradientTransform): Ditto.
* rendering/RenderSVGResourcePattern.cpp: Split collecting pattern properties from building the pattern. We don't need to build it, if it's not applyable (eg. on 1d lines).
(WebCore::RenderSVGResourcePattern::RenderSVGResourcePattern):
(WebCore::RenderSVGResourcePattern::removeAllClientsFromCache):
(WebCore::RenderSVGResourcePattern::applyResource):
(WebCore::RenderSVGResourcePattern::buildTileImageTransform):
* rendering/RenderSVGResourcePattern.h:
* rendering/RenderSVGResourceRadialGradient.cpp:
(WebCore::RenderSVGResourceRadialGradient::collectGradientAttributes):
(WebCore::RenderSVGResourceRadialGradient::buildGradient):
* rendering/RenderSVGResourceRadialGradient.h:
(WebCore::RenderSVGResourceRadialGradient::boundingBoxMode):
(WebCore::RenderSVGResourceRadialGradient::calculateGradientTransform):
* rendering/SVGRenderTreeAsText.cpp: Adapt to change, that fill/strokePaintingResource now take a Color& fallbackColor parameter.
(WebCore::writeStyle):
(WebCore::writeSVGResourceContainer):
* rendering/svg/RenderSVGPath.cpp:
(WebCore::RenderSVGPath::fillContains): Ditto.
(WebCore::RenderSVGPath::strokeContains): Ditto.
(WebCore::RenderSVGPath::fillAndStrokePath): Properly handle fallback color, if an existing (!) paint server failed to apply.
* rendering/svg/SVGInlineTextBox.cpp:
(WebCore::SVGInlineTextBox::acquirePaintingResource): Ditto.
* svg/SVGLinearGradientElement.cpp:
(WebCore::SVGLinearGradientElement::collectGradientAttributes): Pass LinearGradientAttributes by reference, instead of returning a copy.
* svg/SVGLinearGradientElement.h: Rename collectGradientProperties to collectGradientAttributes.
* svg/SVGPatternElement.cpp:
(WebCore::SVGPatternElement::collectPatternAttributes): Pass PatternAttributes by reference, instead of returning.
* svg/SVGPatternElement.h: Rename collectPatternProperties to collectPatternAttributes.
* svg/SVGRadialGradientElement.cpp:
(WebCore::SVGRadialGradientElement::collectGradientAttributes): Pass RadialGradientAttributes by reference, instead of returning a copy.
* svg/SVGRadialGradientElement.h: Rename collectGradientProperties to collectGradientAttributes.
2010-10-08 Nikolas Zimmermann <nzimmermann@rim.com>
Reviewed by Dirk Schulze.
gradient stroke on lines does not work
https://bugs.webkit.org/show_bug.cgi?id=40985
* platform/mac-leopard/svg/W3C-SVG-1.1/pservers-grad-17-b-expected.checksum:
* platform/mac-leopard/svg/W3C-SVG-1.1/pservers-grad-17-b-expected.png:
* platform/mac-leopard/svg/custom/dominant-baseline-hanging-expected.checksum:
* platform/mac-leopard/svg/custom/dominant-baseline-hanging-expected.png:
* platform/mac-leopard/svg/custom/invalid-fill-expected.checksum:
* platform/mac-leopard/svg/custom/invalid-fill-expected.png:
* platform/mac-leopard/svg/custom/invalid-fill-hex-expected.checksum:
* platform/mac-leopard/svg/custom/invalid-fill-hex-expected.png:
* platform/mac/svg/W3C-SVG-1.1-SE: Added.
* platform/mac/svg/W3C-SVG-1.1-SE/pservers-grad-17-b-expected.checksum: Added.
* platform/mac/svg/W3C-SVG-1.1-SE/pservers-grad-17-b-expected.png: Added.
* platform/mac/svg/W3C-SVG-1.1-SE/pservers-grad-17-b-expected.txt: Added.
* platform/mac/svg/W3C-SVG-1.1-SE/pservers-grad-20-b-expected.checksum: Added.
* platform/mac/svg/W3C-SVG-1.1-SE/pservers-grad-20-b-expected.png: Added.
* platform/mac/svg/W3C-SVG-1.1-SE/pservers-grad-20-b-expected.txt: Added.
* platform/mac/svg/W3C-SVG-1.1-SE/pservers-pattern-03-f-expected.checksum: Added.
* platform/mac/svg/W3C-SVG-1.1-SE/pservers-pattern-03-f-expected.png: Added.
* platform/mac/svg/W3C-SVG-1.1-SE/pservers-pattern-03-f-expected.txt: Added.
* platform/mac/svg/W3C-SVG-1.1/pservers-grad-17-b-expected.txt:
* platform/mac/svg/custom/dominant-baseline-hanging-expected.txt:
* platform/mac/svg/custom/gradient-with-1d-boundingbox-expected.checksum:
* platform/mac/svg/custom/gradient-with-1d-boundingbox-expected.png:
* platform/mac/svg/custom/invalid-fill-expected.txt:
* platform/mac/svg/custom/invalid-fill-hex-expected.txt:
* svg/W3C-SVG-1.1-SE: Added.
* svg/W3C-SVG-1.1-SE/pservers-grad-17-b.svg: Added.
* svg/W3C-SVG-1.1-SE/pservers-grad-20-b.svg: Added.
* svg/W3C-SVG-1.1-SE/pservers-pattern-03-f.svg: Added.
* svg/custom/gradient-with-1d-boundingbox-expected.txt:
* svg/custom/gradient-with-1d-boundingbox.svg: Add new test covering gradientUnits="userSpaceOnUse" on 1d lines, which is explicitely allowed.
* svg/custom/invalid-fill-hex.svg: Fix invalid test, fill="none", is the default if the given fill color is invalid, according to SVG 1.1 2nd Edition.
* svg/custom/invalid-fill.svg: Update test comments, that we match Opera in both tests, and the new SVG 1.1 2nd Edition specification.
Canonical link: https://commits.webkit.org/60014@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@69413 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2010-10-08 18:33:34 +00:00
|
|
|
<linearGradient id="gradient1">
|
|
|
|
<stop offset="0" stop-color="red"/>
|
|
|
|
<stop offset="1" stop-color="green"/>
|
|
|
|
</linearGradient>
|
|
|
|
|
|
|
|
<radialGradient id="gradient2" gradientUnits="userSpaceOnUse" cx="0" cy="0" r="9">
|
|
|
|
<stop offset="0" stop-color="red" />
|
|
|
|
<stop offset="1" stop-color="red" stop-opacity="0" />
|
|
|
|
</radialGradient>
|
2010-03-12 20:43:59 +00:00
|
|
|
</defs>
|
2010-10-08 Nikolas Zimmermann <nzimmermann@rim.com>
Reviewed by Dirk Schulze.
gradient stroke on lines does not work
https://bugs.webkit.org/show_bug.cgi?id=40985
Correct handling of invalid fill/stroke paint servers / colors according to SVG 1.1 2nd Edition.
Perfectly matches Opera, and now lets us pass three of the new tests.
Fix incorrect svg/custom/invalid-fill* tests:
-> If there's an invalid fill URI, but no fallback specified, it is as if fill="black" was specified. (invalid-fill.svg)
-> If there's an invalid fill color, but no fallback specified, it is as if fill="none" was specified. (invalid-fill-hex.svg)
Needed to refactor some of the gradient/pattern code to properly handle fallback paint servers.
As side effect, we're allowing gradients with gradientUnits="userSpaceOnUse" to apply on 1d objects (lines) again, per SVG 1.1 2nd edition.
Tests: svg/W3C-SVG-1.1-SE/pservers-pattern-03-f.svg
svg/W3C-SVG-1.1-SE/pservers-grad-17-b.svg
svg/W3C-SVG-1.1-SE/pservers-grad-20-b.svg
* rendering/RenderSVGResource.cpp: Rewrite fill/stroke paint resource requests, share all code between the similar functions.
(WebCore::requestPaintingResource):
(WebCore::RenderSVGResource::fillPaintingResource):
(WebCore::RenderSVGResource::strokePaintingResource):
* rendering/RenderSVGResource.h:
* rendering/RenderSVGResourceGradient.cpp: Split collecting gradient properties from building the gradient. We don't need to build it, if it's not applyable (eg. on 1d lines).
(WebCore::RenderSVGResourceGradient::RenderSVGResourceGradient):
(WebCore::RenderSVGResourceGradient::removeAllClientsFromCache):
(WebCore::clipToTextMask):
(WebCore::RenderSVGResourceGradient::applyResource):
* rendering/RenderSVGResourceGradient.h: Stop storing boundingBoxMode & gradientTransform in each GradientData object, it's enough to just store it in the gradient resource, once.
* rendering/RenderSVGResourceLinearGradient.cpp:
(WebCore::RenderSVGResourceLinearGradient::collectGradientAttributes): Splitted from buildGradient.
(WebCore::RenderSVGResourceLinearGradient::buildGradient):
* rendering/RenderSVGResourceLinearGradient.h:
(WebCore::RenderSVGResourceLinearGradient::boundingBoxMode): Return bounding box mode information, from m_attributes instead of storing in gradientData.
(WebCore::RenderSVGResourceLinearGradient::calculateGradientTransform): Ditto.
* rendering/RenderSVGResourcePattern.cpp: Split collecting pattern properties from building the pattern. We don't need to build it, if it's not applyable (eg. on 1d lines).
(WebCore::RenderSVGResourcePattern::RenderSVGResourcePattern):
(WebCore::RenderSVGResourcePattern::removeAllClientsFromCache):
(WebCore::RenderSVGResourcePattern::applyResource):
(WebCore::RenderSVGResourcePattern::buildTileImageTransform):
* rendering/RenderSVGResourcePattern.h:
* rendering/RenderSVGResourceRadialGradient.cpp:
(WebCore::RenderSVGResourceRadialGradient::collectGradientAttributes):
(WebCore::RenderSVGResourceRadialGradient::buildGradient):
* rendering/RenderSVGResourceRadialGradient.h:
(WebCore::RenderSVGResourceRadialGradient::boundingBoxMode):
(WebCore::RenderSVGResourceRadialGradient::calculateGradientTransform):
* rendering/SVGRenderTreeAsText.cpp: Adapt to change, that fill/strokePaintingResource now take a Color& fallbackColor parameter.
(WebCore::writeStyle):
(WebCore::writeSVGResourceContainer):
* rendering/svg/RenderSVGPath.cpp:
(WebCore::RenderSVGPath::fillContains): Ditto.
(WebCore::RenderSVGPath::strokeContains): Ditto.
(WebCore::RenderSVGPath::fillAndStrokePath): Properly handle fallback color, if an existing (!) paint server failed to apply.
* rendering/svg/SVGInlineTextBox.cpp:
(WebCore::SVGInlineTextBox::acquirePaintingResource): Ditto.
* svg/SVGLinearGradientElement.cpp:
(WebCore::SVGLinearGradientElement::collectGradientAttributes): Pass LinearGradientAttributes by reference, instead of returning a copy.
* svg/SVGLinearGradientElement.h: Rename collectGradientProperties to collectGradientAttributes.
* svg/SVGPatternElement.cpp:
(WebCore::SVGPatternElement::collectPatternAttributes): Pass PatternAttributes by reference, instead of returning.
* svg/SVGPatternElement.h: Rename collectPatternProperties to collectPatternAttributes.
* svg/SVGRadialGradientElement.cpp:
(WebCore::SVGRadialGradientElement::collectGradientAttributes): Pass RadialGradientAttributes by reference, instead of returning a copy.
* svg/SVGRadialGradientElement.h: Rename collectGradientProperties to collectGradientAttributes.
2010-10-08 Nikolas Zimmermann <nzimmermann@rim.com>
Reviewed by Dirk Schulze.
gradient stroke on lines does not work
https://bugs.webkit.org/show_bug.cgi?id=40985
* platform/mac-leopard/svg/W3C-SVG-1.1/pservers-grad-17-b-expected.checksum:
* platform/mac-leopard/svg/W3C-SVG-1.1/pservers-grad-17-b-expected.png:
* platform/mac-leopard/svg/custom/dominant-baseline-hanging-expected.checksum:
* platform/mac-leopard/svg/custom/dominant-baseline-hanging-expected.png:
* platform/mac-leopard/svg/custom/invalid-fill-expected.checksum:
* platform/mac-leopard/svg/custom/invalid-fill-expected.png:
* platform/mac-leopard/svg/custom/invalid-fill-hex-expected.checksum:
* platform/mac-leopard/svg/custom/invalid-fill-hex-expected.png:
* platform/mac/svg/W3C-SVG-1.1-SE: Added.
* platform/mac/svg/W3C-SVG-1.1-SE/pservers-grad-17-b-expected.checksum: Added.
* platform/mac/svg/W3C-SVG-1.1-SE/pservers-grad-17-b-expected.png: Added.
* platform/mac/svg/W3C-SVG-1.1-SE/pservers-grad-17-b-expected.txt: Added.
* platform/mac/svg/W3C-SVG-1.1-SE/pservers-grad-20-b-expected.checksum: Added.
* platform/mac/svg/W3C-SVG-1.1-SE/pservers-grad-20-b-expected.png: Added.
* platform/mac/svg/W3C-SVG-1.1-SE/pservers-grad-20-b-expected.txt: Added.
* platform/mac/svg/W3C-SVG-1.1-SE/pservers-pattern-03-f-expected.checksum: Added.
* platform/mac/svg/W3C-SVG-1.1-SE/pservers-pattern-03-f-expected.png: Added.
* platform/mac/svg/W3C-SVG-1.1-SE/pservers-pattern-03-f-expected.txt: Added.
* platform/mac/svg/W3C-SVG-1.1/pservers-grad-17-b-expected.txt:
* platform/mac/svg/custom/dominant-baseline-hanging-expected.txt:
* platform/mac/svg/custom/gradient-with-1d-boundingbox-expected.checksum:
* platform/mac/svg/custom/gradient-with-1d-boundingbox-expected.png:
* platform/mac/svg/custom/invalid-fill-expected.txt:
* platform/mac/svg/custom/invalid-fill-hex-expected.txt:
* svg/W3C-SVG-1.1-SE: Added.
* svg/W3C-SVG-1.1-SE/pservers-grad-17-b.svg: Added.
* svg/W3C-SVG-1.1-SE/pservers-grad-20-b.svg: Added.
* svg/W3C-SVG-1.1-SE/pservers-pattern-03-f.svg: Added.
* svg/custom/gradient-with-1d-boundingbox-expected.txt:
* svg/custom/gradient-with-1d-boundingbox.svg: Add new test covering gradientUnits="userSpaceOnUse" on 1d lines, which is explicitely allowed.
* svg/custom/invalid-fill-hex.svg: Fix invalid test, fill="none", is the default if the given fill color is invalid, according to SVG 1.1 2nd Edition.
* svg/custom/invalid-fill.svg: Update test comments, that we match Opera in both tests, and the new SVG 1.1 2nd Edition specification.
Canonical link: https://commits.webkit.org/60014@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@69413 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2010-10-08 18:33:34 +00:00
|
|
|
|
|
|
|
<!-- Gradients with objectBoundingBox units can't be applied to 1d objects -->
|
|
|
|
<line x1="20" x2="220" y1="50" y2="50" stroke="url(#gradient1) #0f0" stroke-width="20"/>
|
|
|
|
|
|
|
|
<!-- Gradients with userSpaceOnUse units can be applied to 1d objects -->
|
|
|
|
<g transform="translate(120, 100)">
|
|
|
|
<line x1="-9" y1="0" x2="9" y2="0" stroke="url(#gradient2)" />
|
|
|
|
<line x1="0" y1="-9" x2="0" y2="9" stroke="url(#gradient2)" />
|
|
|
|
<line x1="-9" y1="0" x2="9" y2="0" stroke="url(#gradient2)" transform="rotate(45)" />
|
|
|
|
<line x1="-9" y1="0" x2="9" y2="0" stroke="url(#gradient2)" transform="rotate(-45)" />
|
|
|
|
</g>
|
|
|
|
|
|
|
|
<text x="140" y="150" text-anchor="middle">You should see a green line, and a red star</text>
|
2010-03-12 20:43:59 +00:00
|
|
|
</svg>
|