[Cherry-pick] Use -webkit-clip-path shapes to clip SVG elements
[Title] Use -webkit-clip-path shapes to clip SVG elements
[Issues] N/A
[Problem] N/A
[Solution] Cherry picked.
[Cherry-Picker] Sanghyup Lee <sh53.lee@samsung.com>
Use -webkit-clip-path shapes to clip SVG elements
https://bugs.webkit.org/show_bug.cgi?id=95620
Reviewed by Rob Buis.
Source/WebCore:
This patch adds a path segment for a BasicShape to a given Path object. This
path and it's wind rule are used to clip the context of the SVG element.
Tests: svg/clip-path/clip-path-shape-circle-1-expected.svg
svg/clip-path/clip-path-shape-circle-1.svg
svg/clip-path/clip-path-shape-circle-2-expected.svg
svg/clip-path/clip-path-shape-circle-2.svg
svg/clip-path/clip-path-shape-ellipse-1-expected.svg
svg/clip-path/clip-path-shape-ellipse-1.svg
svg/clip-path/clip-path-shape-ellipse-2-expected.svg
svg/clip-path/clip-path-shape-ellipse-2.svg
svg/clip-path/clip-path-shape-polygon-1-expected.svg
svg/clip-path/clip-path-shape-polygon-1.svg
svg/clip-path/clip-path-shape-polygon-2-expected.svg
svg/clip-path/clip-path-shape-polygon-2.svg
svg/clip-path/clip-path-shape-polygon-3-expected.svg
svg/clip-path/clip-path-shape-polygon-3.svg
svg/clip-path/clip-path-shape-rounded-rect-1-expected.svg
svg/clip-path/clip-path-shape-rounded-rect-1.svg
svg/clip-path/clip-path-shape-rounded-rect-2-expected.svg
svg/clip-path/clip-path-shape-rounded-rect-2.svg
* rendering/style/BasicShapes.cpp: Added helper functions that apply path segments to a given path.
(WebCore::BasicShapeRectangle::path):
(WebCore::BasicShapeCircle::path):
(WebCore::BasicShapeEllipse::path):
(WebCore::BasicShapePolygon::path):
* rendering/style/BasicShapes.h: Make BasicShape virtualized again, since new virtual functions were added.
(WebCore::BasicShape::~BasicShape):
(BasicShape):
(WebCore::BasicShape::windRule): Will return the wind rule of the shape - nonzero by default.
(WebCore::BasicShape::BasicShape):
(BasicShapeRectangle):
(WebCore::BasicShapeRectangle::type): Removed member variable and return type per inheriting class directly.
(WebCore::BasicShapeRectangle::BasicShapeRectangle):
(BasicShapeCircle):
(WebCore::BasicShapeCircle::type): Ditto.
(WebCore::BasicShapeCircle::BasicShapeCircle):
(BasicShapeEllipse):
(WebCore::BasicShapeEllipse::type): Ditto.
(WebCore::BasicShapeEllipse::BasicShapeEllipse):
(BasicShapePolygon):
(WebCore::BasicShapePolygon::windRule):
(WebCore::BasicShapePolygon::type): Ditto.
(WebCore::BasicShapePolygon::BasicShapePolygon):
* rendering/svg/SVGRenderingContext.cpp: If -webkit-clip-path was defined, clip the context to the shape.
Right now -webkit-clip-path overrides clip-path, so that people don't use both at the same time. Current
clip-path property will be replaced, once -webkit-clip-path gets unprefixed.
(WebCore::SVGRenderingContext::prepareToRenderSVGContent):
LayoutTests:
New tests to check behavior of -webkit-clip-path on SVG elements.
* svg/clip-path/clip-path-shape-circle-1-expected.svg: Added.
* svg/clip-path/clip-path-shape-circle-1.svg: Added.
* svg/clip-path/clip-path-shape-circle-2-expected.svg: Added.
* svg/clip-path/clip-path-shape-circle-2.svg: Added.
* svg/clip-path/clip-path-shape-ellipse-1-expected.svg: Added.
* svg/clip-path/clip-path-shape-ellipse-1.svg: Added.
* svg/clip-path/clip-path-shape-ellipse-2-expected.svg: Added.
* svg/clip-path/clip-path-shape-ellipse-2.svg: Added.
* svg/clip-path/clip-path-shape-polygon-1-expected.svg: Added.
* svg/clip-path/clip-path-shape-polygon-1.svg: Added.
* svg/clip-path/clip-path-shape-polygon-2-expected.svg: Added.
* svg/clip-path/clip-path-shape-polygon-2.svg: Added.
* svg/clip-path/clip-path-shape-polygon-3-expected.svg: Added.
* svg/clip-path/clip-path-shape-polygon-3.svg: Added.
* svg/clip-path/clip-path-shape-rounded-rect-1-expected.svg: Added.
* svg/clip-path/clip-path-shape-rounded-rect-1.svg: Added.
* svg/clip-path/clip-path-shape-rounded-rect-2-expected.svg: Added.
* svg/clip-path/clip-path-shape-rounded-rect-2.svg: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@127383
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
Conflicts:
LayoutTests/ChangeLog
Source/WebCore/ChangeLog
Change-Id: I0aabeb470a8c5915120a48745bc79747531ba8d3