[Cherry-pick] Use -webkit-clip-path shapes to clip SVG elements
authorkrit@webkit.org <krit@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 2 Sep 2012 00:15:33 +0000 (00:15 +0000)
committerGerrit Code Review <gerrit2@kim11>
Wed, 27 Mar 2013 06:14:47 +0000 (15:14 +0900)
commitdd7d2b0768bc3e49c0a0190e0b856c9591ed9898
tree207c3ba2e92c8821a9b0bbdebfe61fcd4071b616
parent10bd6bc3b6b702f544440b751c0e5b20e7f9f14c
[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
21 files changed:
LayoutTests/svg/clip-path/clip-path-shape-circle-1-expected.svg [new file with mode: 0644]
LayoutTests/svg/clip-path/clip-path-shape-circle-1.svg [new file with mode: 0644]
LayoutTests/svg/clip-path/clip-path-shape-circle-2-expected.svg [new file with mode: 0644]
LayoutTests/svg/clip-path/clip-path-shape-circle-2.svg [new file with mode: 0644]
LayoutTests/svg/clip-path/clip-path-shape-ellipse-1-expected.svg [new file with mode: 0644]
LayoutTests/svg/clip-path/clip-path-shape-ellipse-1.svg [new file with mode: 0644]
LayoutTests/svg/clip-path/clip-path-shape-ellipse-2-expected.svg [new file with mode: 0644]
LayoutTests/svg/clip-path/clip-path-shape-ellipse-2.svg [new file with mode: 0644]
LayoutTests/svg/clip-path/clip-path-shape-polygon-1-expected.svg [new file with mode: 0644]
LayoutTests/svg/clip-path/clip-path-shape-polygon-1.svg [new file with mode: 0644]
LayoutTests/svg/clip-path/clip-path-shape-polygon-2-expected.svg [new file with mode: 0644]
LayoutTests/svg/clip-path/clip-path-shape-polygon-2.svg [new file with mode: 0644]
LayoutTests/svg/clip-path/clip-path-shape-polygon-3-expected.svg [new file with mode: 0644]
LayoutTests/svg/clip-path/clip-path-shape-polygon-3.svg [new file with mode: 0644]
LayoutTests/svg/clip-path/clip-path-shape-rounded-rect-1-expected.svg [new file with mode: 0644]
LayoutTests/svg/clip-path/clip-path-shape-rounded-rect-1.svg [new file with mode: 0644]
LayoutTests/svg/clip-path/clip-path-shape-rounded-rect-2-expected.svg [new file with mode: 0644]
LayoutTests/svg/clip-path/clip-path-shape-rounded-rect-2.svg [new file with mode: 0644]
Source/WebCore/rendering/style/BasicShapes.cpp
Source/WebCore/rendering/style/BasicShapes.h
Source/WebCore/rendering/svg/SVGRenderingContext.cpp