Diff
Modified: trunk/LayoutTests/ChangeLog (165926 => 165927)
--- trunk/LayoutTests/ChangeLog 2014-03-19 22:21:51 UTC (rev 165926)
+++ trunk/LayoutTests/ChangeLog 2014-03-19 22:39:41 UTC (rev 165927)
@@ -1,3 +1,19 @@
+2014-03-19 Dirk Schulze <k...@webkit.org>
+
+ Implement isPointInPath and isPointInStroke with Path2D argument
+ https://bugs.webkit.org/show_bug.cgi?id=130473
+
+ Reviewed by Dean Jackson.
+
+ Test isPointInPath and isPointInStroke with Path2D argument.
+
+ * fast/canvas/canvas-path-isPointInPath-expected.txt: Added.
+ * fast/canvas/canvas-path-isPointInPath.html: Added.
+ * fast/canvas/canvas-path-isPointInStroke-expected.txt: Added.
+ * fast/canvas/canvas-path-isPointInStroke.html: Added.
+ * fast/canvas/script-tests/canvas-path-isPointInPath.js: Added.
+ * fast/canvas/script-tests/canvas-path-isPointInStroke.js: Added.
+
2014-03-19 Antti Koivisto <an...@apple.com>
Crash with long selector list
Added: trunk/LayoutTests/fast/canvas/canvas-path-isPointInPath-expected.txt (0 => 165927)
--- trunk/LayoutTests/fast/canvas/canvas-path-isPointInPath-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/canvas/canvas-path-isPointInPath-expected.txt 2014-03-19 22:39:41 UTC (rev 165927)
@@ -0,0 +1,30 @@
+Series of tests to ensure correct results of isPointInPath with Path2D argument.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS ctx.isPointInPath(path, 50, 50) is true
+PASS ctx.isPointInPath(path, NaN, 50) is false
+PASS ctx.isPointInPath(path, 50, NaN) is false
+PASS ctx.isPointInPath(path, 50, 50, 'nonzero') is true
+PASS ctx.isPointInPath(path, 50, 50, 'evenodd') is false
+PASS ctx.isPointInPath(path, 50, 50, 'nonzero') is false
+PASS ctx.isPointInPath(null, 50, 50) threw exception TypeError: Argument 3 ('winding') to CanvasRenderingContext2D.isPointInPath must be one of: "nonzero", "evenodd".
+PASS ctx.isPointInPath(null, 50, 50, 'nonzero') threw exception TypeError: Type error.
+PASS ctx.isPointInPath(null, 50, 50, 'evenodd') threw exception TypeError: Type error.
+PASS ctx.isPointInPath([], 50, 50) threw exception TypeError: Argument 3 ('winding') to CanvasRenderingContext2D.isPointInPath must be one of: "nonzero", "evenodd".
+PASS ctx.isPointInPath([], 50, 50, 'nonzero') threw exception TypeError: Type error.
+PASS ctx.isPointInPath([], 50, 50, 'evenodd') threw exception TypeError: Type error.
+PASS ctx.isPointInPath({}, 50, 50) threw exception TypeError: Argument 3 ('winding') to CanvasRenderingContext2D.isPointInPath must be one of: "nonzero", "evenodd".
+PASS ctx.isPointInPath({}, 50, 50, 'nonzero') threw exception TypeError: Type error.
+PASS ctx.isPointInPath({}, 50, 50, 'evenodd') threw exception TypeError: Type error.
+PASS ctx.isPointInPath('path2d', 50, 50, 'evenodd') threw exception TypeError: Type error.
+PASS ctx.isPointInPath(undefined, 50, 50, 'evenodd') threw exception TypeError: Type error.
+PASS ctx.isPointInPath(Number.MAX_VALUE, 50, 50, 'evenodd') threw exception TypeError: Type error.
+PASS ctx.isPointInPath(function() {}, 50, 50, 'evenodd') threw exception TypeError: Type error.
+PASS ctx.isPointInPath(false, 50, 50, 'evenodd') threw exception TypeError: Type error.
+PASS ctx.isPointInPath(new Date(), 50, 50, 'evenodd') threw exception TypeError: Type error.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/canvas/canvas-path-isPointInPath.html (0 => 165927)
--- trunk/LayoutTests/fast/canvas/canvas-path-isPointInPath.html (rev 0)
+++ trunk/LayoutTests/fast/canvas/canvas-path-isPointInPath.html 2014-03-19 22:39:41 UTC (rev 165927)
@@ -0,0 +1,11 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<canvas id="canvas" width="200" height="200"></canvas>
+<script src=""
+<script src=""
+</body>
+</html>
Added: trunk/LayoutTests/fast/canvas/canvas-path-isPointInStroke-expected.txt (0 => 165927)
--- trunk/LayoutTests/fast/canvas/canvas-path-isPointInStroke-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/canvas/canvas-path-isPointInStroke-expected.txt 2014-03-19 22:39:41 UTC (rev 165927)
@@ -0,0 +1,62 @@
+Series of tests to ensure correct results of isPointInStroke with Path2D argument.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS ctx.isPointInStroke(path,20,20) is true
+PASS ctx.isPointInStroke(path,120,20) is true
+PASS ctx.isPointInStroke(path,20,120) is true
+PASS ctx.isPointInStroke(path,120,120) is true
+PASS ctx.isPointInStroke(path,70,20) is true
+PASS ctx.isPointInStroke(path,20,70) is true
+PASS ctx.isPointInStroke(path,120,70) is true
+PASS ctx.isPointInStroke(path,70,120) is true
+PASS ctx.isPointInStroke(path,22,22) is false
+PASS ctx.isPointInStroke(path,118,22) is false
+PASS ctx.isPointInStroke(path,22,118) is false
+PASS ctx.isPointInStroke(path,118,118) is false
+PASS ctx.isPointInStroke(path,70,18) is false
+PASS ctx.isPointInStroke(path,122,70) is false
+PASS ctx.isPointInStroke(path,70,122) is false
+PASS ctx.isPointInStroke(path,18,70) is false
+PASS ctx.isPointInStroke(path,NaN,122) is false
+PASS ctx.isPointInStroke(path,18,NaN) is false
+PASS ctx.isPointInStroke(null,70,20) threw exception TypeError: Type error.
+PASS ctx.isPointInStroke([],20,70) threw exception TypeError: Type error.
+PASS ctx.isPointInStroke({},120,70) threw exception TypeError: Type error.
+PASS ctx.isPointInPath('path2d', 50, 50) threw exception TypeError: Argument 3 ('winding') to CanvasRenderingContext2D.isPointInPath must be one of: "nonzero", "evenodd".
+PASS ctx.isPointInPath(undefined, 50, 50) threw exception TypeError: Argument 3 ('winding') to CanvasRenderingContext2D.isPointInPath must be one of: "nonzero", "evenodd".
+PASS ctx.isPointInPath(Number.MAX_VALUE, 50, 50) threw exception TypeError: Argument 3 ('winding') to CanvasRenderingContext2D.isPointInPath must be one of: "nonzero", "evenodd".
+PASS ctx.isPointInPath(function() {}, 50, 50) threw exception TypeError: Argument 3 ('winding') to CanvasRenderingContext2D.isPointInPath must be one of: "nonzero", "evenodd".
+PASS ctx.isPointInPath(false, 50, 50) threw exception TypeError: Argument 3 ('winding') to CanvasRenderingContext2D.isPointInPath must be one of: "nonzero", "evenodd".
+PASS ctx.isPointInPath(new Date(), 50, 50) threw exception TypeError: Argument 3 ('winding') to CanvasRenderingContext2D.isPointInPath must be one of: "nonzero", "evenodd".
+PASS ctx.isPointInStroke(path,22,22) is true
+PASS ctx.isPointInStroke(path,118,22) is true
+PASS ctx.isPointInStroke(path,22,118) is true
+PASS ctx.isPointInStroke(path,118,118) is true
+PASS ctx.isPointInStroke(path,70,18) is true
+PASS ctx.isPointInStroke(path,122,70) is true
+PASS ctx.isPointInStroke(path,70,122) is true
+PASS ctx.isPointInStroke(path,18,70) is true
+PASS ctx.isPointInStroke(path,26,70) is false
+PASS ctx.isPointInStroke(path,70,26) is false
+PASS ctx.isPointInStroke(path,70,114) is false
+PASS ctx.isPointInStroke(path,114,70) is false
+PASS ctx.isPointInStroke(path,113,20) is false
+PASS ctx.isPointInStroke(path,113,20) is true
+PASS ctx.isPointInStroke(path,113,20) is false
+PASS ctx.isPointInStroke(path,112,10) is false
+PASS ctx.isPointInStroke(path,112,10) is true
+PASS ctx.isPointInStroke(path,117,10) is false
+PASS ctx.isPointInStroke(path,112,10) is true
+PASS ctx.isPointInStroke(path,117,10) is false
+PASS ctx.isPointInStroke(path,15,10) is true
+PASS ctx.isPointInStroke(path,25,10) is false
+PASS ctx.isPointInStroke(path,35,10) is true
+PASS ctx.isPointInStroke(path,15,10) is false
+PASS ctx.isPointInStroke(path,25,10) is true
+PASS ctx.isPointInStroke(path,35,10) is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/canvas/canvas-path-isPointInStroke.html (0 => 165927)
--- trunk/LayoutTests/fast/canvas/canvas-path-isPointInStroke.html (rev 0)
+++ trunk/LayoutTests/fast/canvas/canvas-path-isPointInStroke.html 2014-03-19 22:39:41 UTC (rev 165927)
@@ -0,0 +1,11 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<canvas id="canvas" width="200" height="200"></canvas>
+<script src=""
+<script src=""
+</body>
+</html>
Added: trunk/LayoutTests/fast/canvas/script-tests/canvas-path-isPointInPath.js (0 => 165927)
--- trunk/LayoutTests/fast/canvas/script-tests/canvas-path-isPointInPath.js (rev 0)
+++ trunk/LayoutTests/fast/canvas/script-tests/canvas-path-isPointInPath.js 2014-03-19 22:39:41 UTC (rev 165927)
@@ -0,0 +1,40 @@
+description("Series of tests to ensure correct results of isPointInPath with Path2D argument.");
+
+var ctx = document.createElement('canvas').getContext('2d');
+document.body.appendChild(ctx.canvas);
+
+var path = new Path2D();
+path.rect(0, 0, 100, 100);
+path.rect(25, 25, 50, 50);
+shouldBeTrue("ctx.isPointInPath(path, 50, 50)");
+shouldBeFalse("ctx.isPointInPath(path, NaN, 50)");
+shouldBeFalse("ctx.isPointInPath(path, 50, NaN)");
+
+path = new Path2D();
+path.rect(0, 0, 100, 100);
+path.rect(25, 25, 50, 50);
+shouldBeTrue("ctx.isPointInPath(path, 50, 50, 'nonzero')");
+
+path = new Path2D();
+path.rect(0, 0, 100, 100);
+path.rect(25, 25, 50, 50);
+shouldBeFalse("ctx.isPointInPath(path, 50, 50, 'evenodd')");
+
+ctx.translate(100,100);
+shouldBeFalse("ctx.isPointInPath(path, 50, 50, 'nonzero')");
+
+shouldThrow("ctx.isPointInPath(null, 50, 50)");
+shouldThrow("ctx.isPointInPath(null, 50, 50, 'nonzero')");
+shouldThrow("ctx.isPointInPath(null, 50, 50, 'evenodd')");
+shouldThrow("ctx.isPointInPath([], 50, 50)");
+shouldThrow("ctx.isPointInPath([], 50, 50, 'nonzero')");
+shouldThrow("ctx.isPointInPath([], 50, 50, 'evenodd')");
+shouldThrow("ctx.isPointInPath({}, 50, 50)");
+shouldThrow("ctx.isPointInPath({}, 50, 50, 'nonzero')");
+shouldThrow("ctx.isPointInPath({}, 50, 50, 'evenodd')");
+shouldThrow("ctx.isPointInPath('path2d', 50, 50, 'evenodd')");
+shouldThrow("ctx.isPointInPath(undefined, 50, 50, 'evenodd')");
+shouldThrow("ctx.isPointInPath(Number.MAX_VALUE, 50, 50, 'evenodd')");
+shouldThrow("ctx.isPointInPath(function() {}, 50, 50, 'evenodd')");
+shouldThrow("ctx.isPointInPath(false, 50, 50, 'evenodd')");
+shouldThrow("ctx.isPointInPath(new Date(), 50, 50, 'evenodd')");
\ No newline at end of file
Added: trunk/LayoutTests/fast/canvas/script-tests/canvas-path-isPointInStroke.js (0 => 165927)
--- trunk/LayoutTests/fast/canvas/script-tests/canvas-path-isPointInStroke.js (rev 0)
+++ trunk/LayoutTests/fast/canvas/script-tests/canvas-path-isPointInStroke.js 2014-03-19 22:39:41 UTC (rev 165927)
@@ -0,0 +1,91 @@
+description("Series of tests to ensure correct results of isPointInStroke with Path2D argument.");
+
+var ctx = document.createElement('canvas').getContext('2d');
+document.body.appendChild(ctx.canvas);
+
+ctx.strokeStyle = '#0ff';
+
+var path = new Path2D();
+path.rect(20,20,100,100);
+
+shouldBeTrue("ctx.isPointInStroke(path,20,20)");
+shouldBeTrue("ctx.isPointInStroke(path,120,20)");
+shouldBeTrue("ctx.isPointInStroke(path,20,120)");
+shouldBeTrue("ctx.isPointInStroke(path,120,120)");
+shouldBeTrue("ctx.isPointInStroke(path,70,20)");
+shouldBeTrue("ctx.isPointInStroke(path,20,70)");
+shouldBeTrue("ctx.isPointInStroke(path,120,70)");
+shouldBeTrue("ctx.isPointInStroke(path,70,120)");
+shouldBeFalse("ctx.isPointInStroke(path,22,22)");
+shouldBeFalse("ctx.isPointInStroke(path,118,22)");
+shouldBeFalse("ctx.isPointInStroke(path,22,118)");
+shouldBeFalse("ctx.isPointInStroke(path,118,118)");
+shouldBeFalse("ctx.isPointInStroke(path,70,18)");
+shouldBeFalse("ctx.isPointInStroke(path,122,70)");
+shouldBeFalse("ctx.isPointInStroke(path,70,122)");
+shouldBeFalse("ctx.isPointInStroke(path,18,70)");
+shouldBeFalse("ctx.isPointInStroke(path,NaN,122)");
+shouldBeFalse("ctx.isPointInStroke(path,18,NaN)");
+
+shouldThrow("ctx.isPointInStroke(null,70,20)");
+shouldThrow("ctx.isPointInStroke([],20,70)");
+shouldThrow("ctx.isPointInStroke({},120,70)");
+shouldThrow("ctx.isPointInPath('path2d', 50, 50)");
+shouldThrow("ctx.isPointInPath(undefined, 50, 50)");
+shouldThrow("ctx.isPointInPath(Number.MAX_VALUE, 50, 50)");
+shouldThrow("ctx.isPointInPath(function() {}, 50, 50)");
+shouldThrow("ctx.isPointInPath(false, 50, 50)");
+shouldThrow("ctx.isPointInPath(new Date(), 50, 50)");
+
+ctx.lineWidth = 10;
+shouldBeTrue("ctx.isPointInStroke(path,22,22)");
+shouldBeTrue("ctx.isPointInStroke(path,118,22)");
+shouldBeTrue("ctx.isPointInStroke(path,22,118)");
+shouldBeTrue("ctx.isPointInStroke(path,118,118)");
+shouldBeTrue("ctx.isPointInStroke(path,70,18)");
+shouldBeTrue("ctx.isPointInStroke(path,122,70)");
+shouldBeTrue("ctx.isPointInStroke(path,70,122)");
+shouldBeTrue("ctx.isPointInStroke(path,18,70)");
+shouldBeFalse("ctx.isPointInStroke(path,26,70)");
+shouldBeFalse("ctx.isPointInStroke(path,70,26)");
+shouldBeFalse("ctx.isPointInStroke(path,70,114)");
+shouldBeFalse("ctx.isPointInStroke(path,114,70)");
+
+path = new Path2D();
+path.moveTo(10,10);
+path.lineTo(110,20);
+path.lineTo(10,30);
+ctx.lineJoin = "bevel";
+shouldBeFalse("ctx.isPointInStroke(path,113,20)");
+
+ctx.miterLimit = 40.0;
+ctx.lineJoin = "miter";
+shouldBeTrue("ctx.isPointInStroke(path,113,20)");
+
+ctx.miterLimit = 2.0;
+shouldBeFalse("ctx.isPointInStroke(path,113,20)");
+
+path = new Path2D();
+path.moveTo(10,10);
+path.lineTo(110,10);
+ctx.lineCap = "butt";
+shouldBeFalse("ctx.isPointInStroke(path,112,10)");
+
+ctx.lineCap = "round";
+shouldBeTrue("ctx.isPointInStroke(path,112,10)");
+shouldBeFalse("ctx.isPointInStroke(path,117,10)");
+
+ctx.lineCap = "square";
+shouldBeTrue("ctx.isPointInStroke(path,112,10)");
+shouldBeFalse("ctx.isPointInStroke(path,117,10)");
+
+ctx.lineCap = "butt";
+ctx.setLineDash([10,10]);
+shouldBeTrue("ctx.isPointInStroke(path,15,10)");
+shouldBeFalse("ctx.isPointInStroke(path,25,10)");
+shouldBeTrue("ctx.isPointInStroke(path,35,10)");
+
+ctx.lineDashOffset = 10;
+shouldBeFalse("ctx.isPointInStroke(path,15,10)");
+shouldBeTrue("ctx.isPointInStroke(path,25,10)");
+shouldBeFalse("ctx.isPointInStroke(path,35,10)");
\ No newline at end of file
Modified: trunk/Source/WebCore/ChangeLog (165926 => 165927)
--- trunk/Source/WebCore/ChangeLog 2014-03-19 22:21:51 UTC (rev 165926)
+++ trunk/Source/WebCore/ChangeLog 2014-03-19 22:39:41 UTC (rev 165927)
@@ -1,3 +1,25 @@
+2014-03-19 Dirk Schulze <k...@webkit.org>
+
+ Implement isPointInPath and isPointInStroke with Path2D argument
+ https://bugs.webkit.org/show_bug.cgi?id=130473
+
+ Reviewed by Dean Jackson.
+
+ Implement isPointInPath and isPointInStroke for 2D Canvas contxts
+ with Path2D argument.
+
+
+ Tests: fast/canvas/canvas-path-isPointInPath.html
+ fast/canvas/canvas-path-isPointInStroke.html
+
+ * html/canvas/CanvasRenderingContext2D.cpp:
+ (WebCore::CanvasRenderingContext2D::isPointInPath):
+ (WebCore::CanvasRenderingContext2D::isPointInStroke):
+ (WebCore::CanvasRenderingContext2D::isPointInPathInternal):
+ (WebCore::CanvasRenderingContext2D::isPointInStrokeInternal):
+ * html/canvas/CanvasRenderingContext2D.h:
+ * html/canvas/CanvasRenderingContext2D.idl:
+
2014-03-13 Mark Hahnenberg <mhahnenb...@apple.com>
GC timer should intelligently choose between EdenCollections and FullCollections
Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp (165926 => 165927)
--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp 2014-03-19 22:21:51 UTC (rev 165926)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp 2014-03-19 22:39:41 UTC (rev 165927)
@@ -996,6 +996,28 @@
bool CanvasRenderingContext2D::isPointInPath(const float x, const float y, const String& windingRuleString)
{
+ return isPointInPathInternal(m_path, x, y, windingRuleString);
+}
+
+bool CanvasRenderingContext2D::isPointInStroke(const float x, const float y)
+{
+ return isPointInStrokeInternal(m_path, x, y);
+}
+
+#if ENABLE(CANVAS_PATH)
+bool CanvasRenderingContext2D::isPointInPath(DOMPath* path, const float x, const float y, const String& windingRuleString)
+{
+ return isPointInPathInternal(path->path(), x, y, windingRuleString);
+}
+
+bool CanvasRenderingContext2D::isPointInStroke(DOMPath* path, const float x, const float y)
+{
+ return isPointInStrokeInternal(path->path(), x, y);
+}
+#endif
+
+bool CanvasRenderingContext2D::isPointInPathInternal(const Path& path, float x, float y, const String& windingRuleString)
+{
GraphicsContext* c = drawingContext();
if (!c)
return false;
@@ -1012,11 +1034,10 @@
if (!parseWinding(windingRuleString, windRule))
return false;
- return m_path.contains(transformedPoint, windRule);
+ return path.contains(transformedPoint, windRule);
}
-
-bool CanvasRenderingContext2D::isPointInStroke(const float x, const float y)
+bool CanvasRenderingContext2D::isPointInStrokeInternal(const Path& path, float x, float y)
{
GraphicsContext* c = drawingContext();
if (!c)
@@ -1031,7 +1052,7 @@
return false;
CanvasStrokeStyleApplier applier(this);
- return m_path.strokeContains(&applier, transformedPoint);
+ return path.strokeContains(&applier, transformedPoint);
}
void CanvasRenderingContext2D::clearRect(float x, float y, float width, float height)
Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h (165926 => 165927)
--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h 2014-03-19 22:21:51 UTC (rev 165926)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h 2014-03-19 22:39:41 UTC (rev 165927)
@@ -144,6 +144,11 @@
bool isPointInPath(const float x, const float y, const String& winding = "nonzero");
bool isPointInStroke(const float x, const float y);
+#if ENABLE(CANVAS_PATH)
+ bool isPointInPath(DOMPath*, const float x, const float y, const String& winding = "nonzero");
+ bool isPointInStroke(DOMPath*, const float x, const float y);
+#endif
+
void clearRect(float x, float y, float width, float height);
void fillRect(float x, float y, float width, float height);
void strokeRect(float x, float y, float width, float height);
@@ -303,6 +308,9 @@
void strokeInternal(const Path&);
void clipInternal(const Path&, const String& winding);
+ bool isPointInPathInternal(const Path&, float x, float y, const String& winding);
+ bool isPointInStrokeInternal(const Path&, float x, float y);
+
void clearCanvas();
Path transformAreaToDevice(const Path&) const;
Path transformAreaToDevice(const FloatRect&) const;
Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl (165926 => 165927)
--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl 2014-03-19 22:21:51 UTC (rev 165926)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl 2014-03-19 22:39:41 UTC (rev 165927)
@@ -84,6 +84,11 @@
void stroke();
void clip(optional CanvasWindingRule winding);
+#if defined(ENABLE_CANVAS_PATH) && ENABLE_CANVAS_PATH
+ boolean isPointInPath(DOMPath path, float x, float y, optional CanvasWindingRule winding);
+ boolean isPointInStroke(DOMPath path, float x, float y);
+#endif
+
boolean isPointInPath(float x, float y, optional CanvasWindingRule winding);
boolean isPointInStroke(float x, float y);