Title: [141624] trunk
Revision
141624
Author
k...@webkit.org
Date
2013-02-01 12:11:41 -0800 (Fri, 01 Feb 2013)

Log Message

[canvas] Add more constructors to Path
https://bugs.webkit.org/show_bug.cgi?id=108587

Patch by Dirk Schulze <k...@webkit.org> on 2013-01-31
Reviewed by Dean Jackson.

Source/WebCore:

Add more constructors to Path object to make it possible
to copy Path objects and parse SVG strings into a Path
object that can be used on the canvas context afterwards.

Test: fast/canvas/canvas-path-constructors.html

* html/canvas/DOMPath.h: New constructors for Path.
(WebCore::DOMPath::create):
(WebCore::DOMPath::DOMPath):
* html/canvas/DOMPath.idl: Ditto.

LayoutTests:

Add tests for new constructors of Path objects.
Since the feature is behind a flag, the test is skipped on
all platforms for now.

* fast/canvas/canvas-path-constructors-expected.txt: Added.
* fast/canvas/canvas-path-constructors.html: Added.
* fast/canvas/script-tests/canvas-path-constructors.js: Added.
* platform/chromium/TestExpectations:
* platform/efl/TestExpectations:
* platform/gtk/TestExpectations:
* platform/mac/TestExpectations:
* platform/win/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (141623 => 141624)


--- trunk/LayoutTests/ChangeLog	2013-02-01 20:11:15 UTC (rev 141623)
+++ trunk/LayoutTests/ChangeLog	2013-02-01 20:11:41 UTC (rev 141624)
@@ -1,3 +1,23 @@
+2013-01-31  Dirk Schulze  <k...@webkit.org>
+
+        [canvas] Add more constructors to Path
+        https://bugs.webkit.org/show_bug.cgi?id=108587
+
+        Reviewed by Dean Jackson.
+
+        Add tests for new constructors of Path objects.
+        Since the feature is behind a flag, the test is skipped on
+        all platforms for now.
+
+        * fast/canvas/canvas-path-constructors-expected.txt: Added.
+        * fast/canvas/canvas-path-constructors.html: Added.
+        * fast/canvas/script-tests/canvas-path-constructors.js: Added.
+        * platform/chromium/TestExpectations:
+        * platform/efl/TestExpectations:
+        * platform/gtk/TestExpectations:
+        * platform/mac/TestExpectations:
+        * platform/win/TestExpectations:
+
 2013-02-01  Mike West  <mk...@chromium.org>
 
         Remove call to SecurityOrigin::canAccessDatabase from IDB constructor.

Added: trunk/LayoutTests/fast/canvas/canvas-path-constructors-expected.txt (0 => 141624)


--- trunk/LayoutTests/fast/canvas/canvas-path-constructors-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/canvas/canvas-path-constructors-expected.txt	2013-02-01 20:11:41 UTC (rev 141624)
@@ -0,0 +1,27 @@
+Test different constructors of Path.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Test constructor Path().
+PASS imgdata[4] is 255
+PASS imgdata[5] is 255
+PASS imgdata[6] is 0
+PASS imgdata[7] is 255
+
+Test constructor Path(DOMString) which takes a SVG data string.
+PASS imgdata[4] is 0
+PASS imgdata[5] is 0
+PASS imgdata[6] is 255
+PASS imgdata[7] is 255
+
+Test constructor Path(Path) which takes another Path object.
+PASS imgdata[4] is 0
+PASS imgdata[5] is 128
+PASS imgdata[6] is 0
+PASS imgdata[7] is 255
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/canvas/canvas-path-constructors.html (0 => 141624)


--- trunk/LayoutTests/fast/canvas/canvas-path-constructors.html	                        (rev 0)
+++ trunk/LayoutTests/fast/canvas/canvas-path-constructors.html	2013-02-01 20:11:41 UTC (rev 141624)
@@ -0,0 +1,10 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script src=""
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/fast/canvas/script-tests/canvas-path-constructors.js (0 => 141624)


--- trunk/LayoutTests/fast/canvas/script-tests/canvas-path-constructors.js	                        (rev 0)
+++ trunk/LayoutTests/fast/canvas/script-tests/canvas-path-constructors.js	2013-02-01 20:11:41 UTC (rev 141624)
@@ -0,0 +1,47 @@
+description("Test different constructors of Path.");
+var ctx = document.createElement('canvas').getContext('2d');
+
+debug("Test constructor Path().")
+ctx.beginPath();
+var p1 = new Path();
+p1.rect(0,0,100,100);
+ctx.fillStyle = 'yellow';
+ctx.currentPath = p1;
+ctx.fill();
+var imageData = ctx.getImageData(0, 0, 100, 100);
+var imgdata = imageData.data;
+shouldBe("imgdata[4]", "255");
+shouldBe("imgdata[5]", "255");
+shouldBe("imgdata[6]", "0");
+shouldBe("imgdata[7]", "255");
+debug("");
+
+debug("Test constructor Path(DOMString) which takes a SVG data string.")
+ctx.beginPath();
+var p2 = new Path("M100,0L200,0L200,100L100,100z");
+ctx.currentPath = p2;
+ctx.fillStyle = 'blue';
+ctx.fill();
+imageData = ctx.getImageData(100, 0, 100, 100);
+imgdata = imageData.data;
+shouldBe("imgdata[4]", "0");
+shouldBe("imgdata[5]", "0");
+shouldBe("imgdata[6]", "255");
+shouldBe("imgdata[7]", "255");
+debug("");
+
+debug("Test constructor Path(Path) which takes another Path object.")
+ctx.beginPath();
+var p3 = new Path(p1);
+ctx.translate(200,0);
+ctx.currentPath = p3;
+ctx.fillStyle = 'green';
+ctx.translate(-200,0);
+ctx.fill();
+imageData = ctx.getImageData(200, 0, 100, 100);
+imgdata = imageData.data;
+shouldBe("imgdata[4]", "0");
+shouldBe("imgdata[5]", "128");
+shouldBe("imgdata[6]", "0");
+shouldBe("imgdata[7]", "255");
+debug("");
\ No newline at end of file

Modified: trunk/LayoutTests/platform/chromium/TestExpectations (141623 => 141624)


--- trunk/LayoutTests/platform/chromium/TestExpectations	2013-02-01 20:11:15 UTC (rev 141623)
+++ trunk/LayoutTests/platform/chromium/TestExpectations	2013-02-01 20:11:41 UTC (rev 141624)
@@ -4238,10 +4238,6 @@
 webkit.org/b/107508 platform/chromium/fast/forms/calendar-picker/calendar-picker-appearance-step.html [ ImageOnlyFailure Pass ]
 webkit.org/b/107508 platform/chromium/fast/forms/calendar-picker/calendar-picker-appearance.html [ ImageOnlyFailure Pass ]
 
-# Rebaseline after currentPath
-webkit.org/b/108246 fast/canvas/canvas-currentPath.html [ Failure ]
-webkit.org/b/108246 platform/chromium/virtual/gpu/fast/canvas/canvas-currentPath.html [ Failure ]
-
 # Broken by Skia flag changes in r139445
 crbug.com/169550 [ Debug ] fast/lists/big-list-marker.html [ Crash ]
 crbug.com/169550 [ Debug ] platform/chromium/virtual/deferred/fast/images/icon-decoding.html [ Crash ]
@@ -4283,8 +4279,13 @@
 webkit.org/b/105574 editing/input/reveal-caret-of-multiline-contenteditable.html [ Failure ]
 webkit.org/b/105574 editing/input/reveal-caret-of-multiline-input.html [ Failure ]
 
-webkit.org/b/97333 fast/canvas/canvas-path-object.html [ Failure ]
-webkit.org/b/97333 platform/chromium/virtual/gpu/fast/canvas/canvas-path-object.html [ Failure ]
+# Needs rebaseline after enabling CANVAS_PATH.
+webkit.org/b/108508 fast/canvas/canvas-path-constructors.html [ Failure ]
+webkit.org/b/108508 platform/chromium/virtual/gpu/fast/canvas/canvas-path-constructors.html [ Failure ]
+webkit.org/b/108508 fast/canvas/canvas-path-object.html [ Failure ]
+webkit.org/b/108508 platform/chromium/virtual/gpu/fast/canvas/canvas-path-object.html [ Failure ]
+webkit.org/b/108508 fast/canvas/canvas-currentPath.html [ Failure ]
+webkit.org/b/108508 platform/chromium/virtual/gpu/fast/canvas/canvas-currentPath.html [ Failure ]
 
 # This is won't fix, as the debug and release versions differ.
 webkit.org/b/99138 [ Debug SnowLeopard ] svg/custom/foreign-object-skew.svg [ ImageOnlyFailure ]

Modified: trunk/LayoutTests/platform/efl/TestExpectations (141623 => 141624)


--- trunk/LayoutTests/platform/efl/TestExpectations	2013-02-01 20:11:15 UTC (rev 141623)
+++ trunk/LayoutTests/platform/efl/TestExpectations	2013-02-01 20:11:41 UTC (rev 141624)
@@ -1819,6 +1819,7 @@
 inspector/editor/text-editor-word-jumps.html
 
 # Remove from list after enabling CANVAS_PATH
+webkit.org/b/108508 fast/canvas/canvas-path-constructors.html [ Failure ]
 webkit.org/b/108508 fast/canvas/canvas-currentPath.html [ Failure ]
 
 # Test fails on JSC platforms due to GC timing problems

Modified: trunk/LayoutTests/platform/gtk/TestExpectations (141623 => 141624)


--- trunk/LayoutTests/platform/gtk/TestExpectations	2013-02-01 20:11:15 UTC (rev 141623)
+++ trunk/LayoutTests/platform/gtk/TestExpectations	2013-02-01 20:11:41 UTC (rev 141624)
@@ -1368,6 +1368,7 @@
 
 # Remove from list after enabling CANVAS_PATH
 webkit.org/b/108508 fast/canvas/canvas-currentPath.html [ Failure ]
+webkit.org/b/108508 fast/canvas/canvas-path-constructors.html [ Failure ]
 
 # volume is reset when mediaelement.src is modified
 webkit.org/b/103893 media/video-volume.html [ Failure ]

Modified: trunk/LayoutTests/platform/mac/TestExpectations (141623 => 141624)


--- trunk/LayoutTests/platform/mac/TestExpectations	2013-02-01 20:11:15 UTC (rev 141623)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2013-02-01 20:11:41 UTC (rev 141624)
@@ -143,6 +143,7 @@
 
 # Remove from list after enabling CANVAS_PATH
 fast/canvas/canvas-currentPath.html
+fast/canvas/canvas-path-constructors.html
 
 # This port doesn't support DeviceMotion or DeviceOrientation.
 fast/dom/DeviceMotion

Modified: trunk/LayoutTests/platform/win/TestExpectations (141623 => 141624)


--- trunk/LayoutTests/platform/win/TestExpectations	2013-02-01 20:11:15 UTC (rev 141623)
+++ trunk/LayoutTests/platform/win/TestExpectations	2013-02-01 20:11:41 UTC (rev 141624)
@@ -46,6 +46,7 @@
 
 # Remove from list after enabling CANVAS_PATH
 fast/canvas/canvas-currentPath.html
+fast/canvas/canvas-path-constructors.html
 
 # Needs rebaseline after bug 97217 is fixed
 # https://bugs.webkit.org/show_bug.cgi?id=97325

Modified: trunk/Source/WebCore/ChangeLog (141623 => 141624)


--- trunk/Source/WebCore/ChangeLog	2013-02-01 20:11:15 UTC (rev 141623)
+++ trunk/Source/WebCore/ChangeLog	2013-02-01 20:11:41 UTC (rev 141624)
@@ -1,3 +1,21 @@
+2013-01-31  Dirk Schulze  <k...@webkit.org>
+
+        [canvas] Add more constructors to Path
+        https://bugs.webkit.org/show_bug.cgi?id=108587
+
+        Reviewed by Dean Jackson.
+
+        Add more constructors to Path object to make it possible
+        to copy Path objects and parse SVG strings into a Path
+        object that can be used on the canvas context afterwards.
+
+        Test: fast/canvas/canvas-path-constructors.html
+
+        * html/canvas/DOMPath.h: New constructors for Path.
+        (WebCore::DOMPath::create):
+        (WebCore::DOMPath::DOMPath):
+        * html/canvas/DOMPath.idl: Ditto.
+
 2013-02-01  Zan Dobersek  <zdober...@igalia.com>
 
         [GTK] Add WTFURL source files to the build

Modified: trunk/Source/WebCore/html/canvas/DOMPath.h (141623 => 141624)


--- trunk/Source/WebCore/html/canvas/DOMPath.h	2013-02-01 20:11:15 UTC (rev 141623)
+++ trunk/Source/WebCore/html/canvas/DOMPath.h	2013-02-01 20:11:41 UTC (rev 141624)
@@ -30,6 +30,9 @@
 
 #if ENABLE(CANVAS_PATH)
 #include "CanvasPathMethods.h"
+#if ENABLE(SVG)
+#include "SVGPathUtilities.h"
+#endif
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
 
@@ -39,6 +42,9 @@
     WTF_MAKE_NONCOPYABLE(DOMPath); WTF_MAKE_FAST_ALLOCATED;
 public:
     static PassRefPtr<DOMPath> create() { return adoptRef(new DOMPath); }
+    static PassRefPtr<DOMPath> create(const String& pathData) { return adoptRef(new DOMPath(pathData)); }
+    static PassRefPtr<DOMPath> create(DOMPath* path) { return adoptRef(new DOMPath(path)); }
+
     static PassRefPtr<DOMPath> create(const Path& path) { return adoptRef(new DOMPath(path)); }
 
     const Path& path() const { return m_path; }
@@ -51,6 +57,18 @@
     {
         m_path = path;
     }
+    DOMPath(DOMPath* path)
+        : CanvasPathMethods()
+    {
+        m_path = path->path();
+    }
+#if ENABLE(SVG)
+    DOMPath(const String& pathData)
+        : CanvasPathMethods()
+    {
+        buildPathFromString(pathData, m_path);
+    }
+#endif
 };
 }
 #endif

Modified: trunk/Source/WebCore/html/canvas/DOMPath.idl (141623 => 141624)


--- trunk/Source/WebCore/html/canvas/DOMPath.idl	2013-02-01 20:11:15 UTC (rev 141623)
+++ trunk/Source/WebCore/html/canvas/DOMPath.idl	2013-02-01 20:11:41 UTC (rev 141624)
@@ -28,6 +28,10 @@
 
 interface [
     Constructor,
+    Constructor(in DOMPath path),
+#if defined(ENABLE_SVG) && ENABLE_SVG
+    Constructor(in DOMString text),
+#endif
     Conditional=CANVAS_PATH,
     InterfaceName=Path
 ] DOMPath {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to