haikuwebkit/LayoutTests/svg/custom/stroke-dash-array-pathLengt...

7 lines
295 B
XML
Raw Permalink Normal View History

[SVG2]: Implement support for the 'pathLength' attribute https://bugs.webkit.org/show_bug.cgi?id=72401 Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2020-01-15 Reviewed by Simon Fraser. LayoutTests/imported/w3c: * web-platform-tests/svg/types/scripted/SVGGeometryElement.isPointInStroke-01-expected.txt: Source/WebCore: The spec link is: https://svgwg.org/svg2-draft/paths.html#PathLengthAttribute The 'pathLength' attribute affects the calculations for text on a path, stroke dash offset and stroke dash array. 'pathLength' has no effect on percentage lengths. Tests: svg/custom/stroke-dash-array-pathLength.svg * rendering/svg/RenderSVGTextPath.cpp: (WebCore::RenderSVGTextPath::targetElement const): A helper function which returns the target element. Notice target element can't be used in this context unless it is a SVGGeometryElement. See pathFromGraphicsElement(). (WebCore::RenderSVGTextPath::layoutPath const): Use the new function targetElement(). (WebCore::RenderSVGTextPath::startOffset const): In SVGTextLayoutEngine::beginTextPathLayout(), we used to check whether startOffset is in the range [0, 1] to treat it as a percentage or not. This is of course wrong especially when using with 'pathLength'. So we need to return the SVGLengthValue to make the decision correctly. * rendering/svg/RenderSVGTextPath.h: * rendering/svg/SVGRenderSupport.cpp: (WebCore::SVGRenderSupport::applyStrokeStyleToContext): Apply 'pathLength' to the shape 'stroke-dashoffset' and 'stroke-dasharray' properties. * rendering/svg/SVGRenderTreeAsText.cpp: (WebCore::writeStyle): Add the 'pathLength' property to the shape stroke property. * rendering/svg/SVGTextLayoutEngine.cpp: (WebCore::SVGTextLayoutEngine::beginTextPathLayout): Apply 'pathLength' to the text path 'start-offset' property. LayoutTests: * TestExpectations: * platform/gtk/imported/w3c/web-platform-tests/svg/path/distance/pathLength-positive-expected.txt: * platform/gtk/imported/w3c/web-platform-tests/svg/path/distance/pathLength-positive-percentage-expected.txt: * platform/gtk/imported/w3c/web-platform-tests/svg/shapes/line-dasharray-expected.txt: * platform/gtk/imported/w3c/web-platform-tests/svg/shapes/reftests/pathlength-001-expected.txt: * platform/gtk/imported/w3c/web-platform-tests/svg/shapes/reftests/pathlength-002-expected.txt: * platform/gtk/imported/w3c/web-platform-tests/svg/shapes/reftests/pathlength-003-expected.txt: 'pathLength' is now included in the DRT of the stroke. Other tests will need to be rebaselined. * platform/ios-simulator/imported/w3c/web-platform-tests/svg/import/paths-dom-01-f-manual-expected.txt: * platform/ios-simulator/imported/w3c/web-platform-tests/svg/path/distance/pathLength-positive-expected.txt: * platform/ios-simulator/imported/w3c/web-platform-tests/svg/path/distance/pathLength-positive-percentage-expected.txt: * platform/ios-simulator/imported/w3c/web-platform-tests/svg/path/distance/pathLength-zero-expected.txt: * platform/ios-simulator/imported/w3c/web-platform-tests/svg/path/distance/pathLength-zero-percentage-expected.txt: * platform/ios-simulator/imported/w3c/web-platform-tests/svg/shapes/line-dasharray-expected.txt: * platform/ios-simulator/imported/w3c/web-platform-tests/svg/shapes/reftests/pathlength-001-expected.txt: * platform/ios-simulator/imported/w3c/web-platform-tests/svg/shapes/reftests/pathlength-002-expected.txt: * platform/ios-simulator/imported/w3c/web-platform-tests/svg/shapes/reftests/pathlength-003-expected.txt: * platform/ios-simulator/imported/w3c/web-platform-tests/svg/text/reftests/textpath-shape-001-expected.txt: * platform/mac/imported/w3c/web-platform-tests/svg/import/paths-dom-01-f-manual-expected.txt: * platform/mac/imported/w3c/web-platform-tests/svg/path/distance/pathLength-positive-expected.txt: * platform/mac/imported/w3c/web-platform-tests/svg/path/distance/pathLength-positive-percentage-expected.txt: * platform/mac/imported/w3c/web-platform-tests/svg/path/distance/pathLength-zero-expected.txt: * platform/mac/imported/w3c/web-platform-tests/svg/path/distance/pathLength-zero-percentage-expected.txt: * platform/mac/imported/w3c/web-platform-tests/svg/shapes/line-dasharray-expected.txt: * platform/mac/imported/w3c/web-platform-tests/svg/shapes/reftests/pathlength-001-expected.txt: * platform/mac/imported/w3c/web-platform-tests/svg/shapes/reftests/pathlength-002-expected.txt: * platform/mac/imported/w3c/web-platform-tests/svg/shapes/reftests/pathlength-003-expected.txt: * platform/mac/imported/w3c/web-platform-tests/svg/text/reftests/textpath-shape-001-expected.txt: 'pathLength' is now included in the DRT of the stroke. These tests were rendering incorrectly. With this patch, the rendering matches the rendering of other browsers. * platform/wpe/imported/w3c/web-platform-tests/svg/path/distance/pathLength-positive-expected.txt: * platform/wpe/imported/w3c/web-platform-tests/svg/path/distance/pathLength-positive-percentage-expected.txt: * platform/wpe/imported/w3c/web-platform-tests/svg/shapes/line-dasharray-expected.txt: * platform/wpe/imported/w3c/web-platform-tests/svg/shapes/reftests/pathlength-001-expected.txt: * platform/wpe/imported/w3c/web-platform-tests/svg/shapes/reftests/pathlength-002-expected.txt: * platform/wpe/imported/w3c/web-platform-tests/svg/shapes/reftests/pathlength-003-expected.txt: 'pathLength' is now included in the DRT of the stroke. Other tests will need to be rebaselined. * svg/custom/stroke-dash-array-pathLength-expected.svg: Added. * svg/custom/stroke-dash-array-pathLength.svg: Added. Canonical link: https://commits.webkit.org/219409@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254657 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-16 01:40:16 +00:00
<svg xmlns="http://www.w3.org/2000/svg">
<rect x="20" y="20" width="400" height="400" fill="blue"/>
<rect x="20" y="20" width="150" height="150" fill="white"/>
<rect x="270" y="270" width="150" height="150" fill="white"/>
<rect x="120" y="120" width="200" height="200" fill="green"/>
</svg>