[Cherry-pick] -webkit-clip-path does not apply origin for polygon()
authorkrit@webkit.org <krit@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Sep 2012 03:57:56 +0000 (03:57 +0000)
committerGerrit Code Review <gerrit2@kim11>
Wed, 27 Mar 2013 06:15:27 +0000 (15:15 +0900)
[Title] -webkit-clip-path does not apply origin for polygon()
[Issues] N/A
[Problem] N/A
[Solution] Cherry picked.
[Cherry-Picker] Sanghyup Lee <sh53.lee@samsung.com>

-webkit-clip-path does not apply origin for polygon()
https://bugs.webkit.org/show_bug.cgi?id=95656

Reviewed by Tim Horton.

Source/WebCore:

The polygon() shape function did not apply origin of bouding box on created path. The shape was
not moved to the correct position.

Tests: svg/clip-path/clip-path-shape-polygon-relative-expected.svg
       svg/clip-path/clip-path-shape-polygon-relative.svg

* rendering/style/BasicShapes.cpp:
(WebCore::BasicShapePolygon::path): Apply origin of bounding box.

LayoutTests:

Check that the origin of the bounding box gets applied to the clip path.

* svg/clip-path/clip-path-shape-polygon-relative-expected.svg: Added.
* svg/clip-path/clip-path-shape-polygon-relative.svg: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@127548 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Conflicts:

LayoutTests/ChangeLog
Source/WebCore/ChangeLog

Change-Id: Id302fd04f2856653c8dfdfe52fa5b467856b3f79

LayoutTests/svg/clip-path/clip-path-shape-polygon-relative-expected.svg [new file with mode: 0644]
LayoutTests/svg/clip-path/clip-path-shape-polygon-relative.svg [new file with mode: 0644]
Source/WebCore/rendering/style/BasicShapes.cpp

diff --git a/LayoutTests/svg/clip-path/clip-path-shape-polygon-relative-expected.svg b/LayoutTests/svg/clip-path/clip-path-shape-polygon-relative-expected.svg
new file mode 100644 (file)
index 0000000..aaaa7bf
--- /dev/null
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+<rect x="50" y="50" width="200" height="200" fill="green"/>
+</svg>
\ No newline at end of file
diff --git a/LayoutTests/svg/clip-path/clip-path-shape-polygon-relative.svg b/LayoutTests/svg/clip-path/clip-path-shape-polygon-relative.svg
new file mode 100644 (file)
index 0000000..68ccaec
--- /dev/null
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+<rect x="50" y="50" width="200" height="200" fill="green" style="-webkit-clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%)"/>
+</svg>
\ No newline at end of file
index b5151f4..9b1245f 100644 (file)
@@ -82,11 +82,11 @@ void BasicShapePolygon::path(Path& path, const FloatRect& boundingBox)
     if (!length)
         return;
 
-    path.moveTo(FloatPoint(floatValueForLength(m_values.at(0), boundingBox.width()),
-                           floatValueForLength(m_values.at(1), boundingBox.width())));
+    path.moveTo(FloatPoint(floatValueForLength(m_values.at(0), boundingBox.width()) + boundingBox.x(),
+                           floatValueForLength(m_values.at(1), boundingBox.width()) + boundingBox.y()));
     for (size_t i = 2; i < length; i = i + 2) {
-        path.addLineTo(FloatPoint(floatValueForLength(m_values.at(i), boundingBox.width()),
-                                  floatValueForLength(m_values.at(i + 1), boundingBox.width())));
+        path.addLineTo(FloatPoint(floatValueForLength(m_values.at(i), boundingBox.width()) + boundingBox.x(),
+                                  floatValueForLength(m_values.at(i + 1), boundingBox.width()) + boundingBox.y()));
     }
     path.closeSubpath();
 }