<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[165927] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/165927">165927</a></dd>
<dt>Author</dt> <dd>krit@webkit.org</dd>
<dt>Date</dt> <dd>2014-03-19 15:39:41 -0700 (Wed, 19 Mar 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Implement isPointInPath and isPointInStroke with Path2D argument
https://bugs.webkit.org/show_bug.cgi?id=130473

Reviewed by Dean Jackson.

Source/WebCore:

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:

LayoutTests:

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.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorehtmlcanvasCanvasRenderingContext2Dcpp">trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlcanvasCanvasRenderingContext2Dh">trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h</a></li>
<li><a href="#trunkSourceWebCorehtmlcanvasCanvasRenderingContext2Didl">trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastcanvascanvaspathisPointInPathexpectedtxt">trunk/LayoutTests/fast/canvas/canvas-path-isPointInPath-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastcanvascanvaspathisPointInPathhtml">trunk/LayoutTests/fast/canvas/canvas-path-isPointInPath.html</a></li>
<li><a href="#trunkLayoutTestsfastcanvascanvaspathisPointInStrokeexpectedtxt">trunk/LayoutTests/fast/canvas/canvas-path-isPointInStroke-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastcanvascanvaspathisPointInStrokehtml">trunk/LayoutTests/fast/canvas/canvas-path-isPointInStroke.html</a></li>
<li><a href="#trunkLayoutTestsfastcanvasscripttestscanvaspathisPointInPathjs">trunk/LayoutTests/fast/canvas/script-tests/canvas-path-isPointInPath.js</a></li>
<li><a href="#trunkLayoutTestsfastcanvasscripttestscanvaspathisPointInStrokejs">trunk/LayoutTests/fast/canvas/script-tests/canvas-path-isPointInStroke.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (165926 => 165927)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-03-19 22:21:51 UTC (rev 165926)
+++ trunk/LayoutTests/ChangeLog        2014-03-19 22:39:41 UTC (rev 165927)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2014-03-19  Dirk Schulze  &lt;krit@webkit.org&gt;
+
+        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.
+
</ins><span class="cx"> 2014-03-19  Antti Koivisto  &lt;antti@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Crash with long selector list
</span></span></pre></div>
<a id="trunkLayoutTestsfastcanvascanvaspathisPointInPathexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/canvas/canvas-path-isPointInPath-expected.txt (0 => 165927)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,30 @@
</span><ins>+Series of tests to ensure correct results of isPointInPath with Path2D argument.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+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: &quot;nonzero&quot;, &quot;evenodd&quot;.
+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: &quot;nonzero&quot;, &quot;evenodd&quot;.
+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: &quot;nonzero&quot;, &quot;evenodd&quot;.
+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

</ins></span></pre></div>
<a id="trunkLayoutTestsfastcanvascanvaspathisPointInPathhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/canvas/canvas-path-isPointInPath.html (0 => 165927)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+&lt;!DOCTYPE HTML PUBLIC &quot;-//IETF//DTD HTML//EN&quot;&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;canvas id=&quot;canvas&quot; width=&quot;200&quot; height=&quot;200&quot;&gt;&lt;/canvas&gt;
+&lt;script src=&quot;script-tests/canvas-path-isPointInPath.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcanvascanvaspathisPointInStrokeexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/canvas/canvas-path-isPointInStroke-expected.txt (0 => 165927)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,62 @@
</span><ins>+Series of tests to ensure correct results of isPointInStroke with Path2D argument.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+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: &quot;nonzero&quot;, &quot;evenodd&quot;.
+PASS ctx.isPointInPath(undefined, 50, 50) threw exception TypeError: Argument 3 ('winding') to CanvasRenderingContext2D.isPointInPath must be one of: &quot;nonzero&quot;, &quot;evenodd&quot;.
+PASS ctx.isPointInPath(Number.MAX_VALUE, 50, 50) threw exception TypeError: Argument 3 ('winding') to CanvasRenderingContext2D.isPointInPath must be one of: &quot;nonzero&quot;, &quot;evenodd&quot;.
+PASS ctx.isPointInPath(function() {}, 50, 50) threw exception TypeError: Argument 3 ('winding') to CanvasRenderingContext2D.isPointInPath must be one of: &quot;nonzero&quot;, &quot;evenodd&quot;.
+PASS ctx.isPointInPath(false, 50, 50) threw exception TypeError: Argument 3 ('winding') to CanvasRenderingContext2D.isPointInPath must be one of: &quot;nonzero&quot;, &quot;evenodd&quot;.
+PASS ctx.isPointInPath(new Date(), 50, 50) threw exception TypeError: Argument 3 ('winding') to CanvasRenderingContext2D.isPointInPath must be one of: &quot;nonzero&quot;, &quot;evenodd&quot;.
+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

</ins></span></pre></div>
<a id="trunkLayoutTestsfastcanvascanvaspathisPointInStrokehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/canvas/canvas-path-isPointInStroke.html (0 => 165927)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+&lt;!DOCTYPE HTML PUBLIC &quot;-//IETF//DTD HTML//EN&quot;&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;canvas id=&quot;canvas&quot; width=&quot;200&quot; height=&quot;200&quot;&gt;&lt;/canvas&gt;
+&lt;script src=&quot;script-tests/canvas-path-isPointInStroke.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcanvasscripttestscanvaspathisPointInPathjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/canvas/script-tests/canvas-path-isPointInPath.js (0 => 165927)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,40 @@
</span><ins>+description(&quot;Series of tests to ensure correct results of isPointInPath with Path2D argument.&quot;);
+
+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(&quot;ctx.isPointInPath(path, 50, 50)&quot;);
+shouldBeFalse(&quot;ctx.isPointInPath(path, NaN, 50)&quot;);
+shouldBeFalse(&quot;ctx.isPointInPath(path, 50, NaN)&quot;);
+
+path = new Path2D();
+path.rect(0, 0, 100, 100);
+path.rect(25, 25, 50, 50);
+shouldBeTrue(&quot;ctx.isPointInPath(path, 50, 50, 'nonzero')&quot;);
+
+path = new Path2D();
+path.rect(0, 0, 100, 100);
+path.rect(25, 25, 50, 50);
+shouldBeFalse(&quot;ctx.isPointInPath(path, 50, 50, 'evenodd')&quot;);
+
+ctx.translate(100,100);
+shouldBeFalse(&quot;ctx.isPointInPath(path, 50, 50, 'nonzero')&quot;);
+
+shouldThrow(&quot;ctx.isPointInPath(null, 50, 50)&quot;);
+shouldThrow(&quot;ctx.isPointInPath(null, 50, 50, 'nonzero')&quot;);
+shouldThrow(&quot;ctx.isPointInPath(null, 50, 50, 'evenodd')&quot;);
+shouldThrow(&quot;ctx.isPointInPath([], 50, 50)&quot;);
+shouldThrow(&quot;ctx.isPointInPath([], 50, 50, 'nonzero')&quot;);
+shouldThrow(&quot;ctx.isPointInPath([], 50, 50, 'evenodd')&quot;);
+shouldThrow(&quot;ctx.isPointInPath({}, 50, 50)&quot;);
+shouldThrow(&quot;ctx.isPointInPath({}, 50, 50, 'nonzero')&quot;);
+shouldThrow(&quot;ctx.isPointInPath({}, 50, 50, 'evenodd')&quot;);
+shouldThrow(&quot;ctx.isPointInPath('path2d', 50, 50, 'evenodd')&quot;);
+shouldThrow(&quot;ctx.isPointInPath(undefined, 50, 50, 'evenodd')&quot;);
+shouldThrow(&quot;ctx.isPointInPath(Number.MAX_VALUE, 50, 50, 'evenodd')&quot;);
+shouldThrow(&quot;ctx.isPointInPath(function() {}, 50, 50, 'evenodd')&quot;);
+shouldThrow(&quot;ctx.isPointInPath(false, 50, 50, 'evenodd')&quot;);
+shouldThrow(&quot;ctx.isPointInPath(new Date(), 50, 50, 'evenodd')&quot;);
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestsfastcanvasscripttestscanvaspathisPointInStrokejs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/canvas/script-tests/canvas-path-isPointInStroke.js (0 => 165927)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,91 @@
</span><ins>+description(&quot;Series of tests to ensure correct results of isPointInStroke with Path2D argument.&quot;);
+
+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(&quot;ctx.isPointInStroke(path,20,20)&quot;);
+shouldBeTrue(&quot;ctx.isPointInStroke(path,120,20)&quot;);
+shouldBeTrue(&quot;ctx.isPointInStroke(path,20,120)&quot;);
+shouldBeTrue(&quot;ctx.isPointInStroke(path,120,120)&quot;);
+shouldBeTrue(&quot;ctx.isPointInStroke(path,70,20)&quot;);
+shouldBeTrue(&quot;ctx.isPointInStroke(path,20,70)&quot;);
+shouldBeTrue(&quot;ctx.isPointInStroke(path,120,70)&quot;);
+shouldBeTrue(&quot;ctx.isPointInStroke(path,70,120)&quot;);
+shouldBeFalse(&quot;ctx.isPointInStroke(path,22,22)&quot;);
+shouldBeFalse(&quot;ctx.isPointInStroke(path,118,22)&quot;);
+shouldBeFalse(&quot;ctx.isPointInStroke(path,22,118)&quot;);
+shouldBeFalse(&quot;ctx.isPointInStroke(path,118,118)&quot;);
+shouldBeFalse(&quot;ctx.isPointInStroke(path,70,18)&quot;);
+shouldBeFalse(&quot;ctx.isPointInStroke(path,122,70)&quot;);
+shouldBeFalse(&quot;ctx.isPointInStroke(path,70,122)&quot;);
+shouldBeFalse(&quot;ctx.isPointInStroke(path,18,70)&quot;);
+shouldBeFalse(&quot;ctx.isPointInStroke(path,NaN,122)&quot;);
+shouldBeFalse(&quot;ctx.isPointInStroke(path,18,NaN)&quot;);
+
+shouldThrow(&quot;ctx.isPointInStroke(null,70,20)&quot;);
+shouldThrow(&quot;ctx.isPointInStroke([],20,70)&quot;);
+shouldThrow(&quot;ctx.isPointInStroke({},120,70)&quot;);
+shouldThrow(&quot;ctx.isPointInPath('path2d', 50, 50)&quot;);
+shouldThrow(&quot;ctx.isPointInPath(undefined, 50, 50)&quot;);
+shouldThrow(&quot;ctx.isPointInPath(Number.MAX_VALUE, 50, 50)&quot;);
+shouldThrow(&quot;ctx.isPointInPath(function() {}, 50, 50)&quot;);
+shouldThrow(&quot;ctx.isPointInPath(false, 50, 50)&quot;);
+shouldThrow(&quot;ctx.isPointInPath(new Date(), 50, 50)&quot;);
+
+ctx.lineWidth = 10;
+shouldBeTrue(&quot;ctx.isPointInStroke(path,22,22)&quot;);
+shouldBeTrue(&quot;ctx.isPointInStroke(path,118,22)&quot;);
+shouldBeTrue(&quot;ctx.isPointInStroke(path,22,118)&quot;);
+shouldBeTrue(&quot;ctx.isPointInStroke(path,118,118)&quot;);
+shouldBeTrue(&quot;ctx.isPointInStroke(path,70,18)&quot;);
+shouldBeTrue(&quot;ctx.isPointInStroke(path,122,70)&quot;);
+shouldBeTrue(&quot;ctx.isPointInStroke(path,70,122)&quot;);
+shouldBeTrue(&quot;ctx.isPointInStroke(path,18,70)&quot;);
+shouldBeFalse(&quot;ctx.isPointInStroke(path,26,70)&quot;);
+shouldBeFalse(&quot;ctx.isPointInStroke(path,70,26)&quot;);
+shouldBeFalse(&quot;ctx.isPointInStroke(path,70,114)&quot;);
+shouldBeFalse(&quot;ctx.isPointInStroke(path,114,70)&quot;);
+
+path = new Path2D();
+path.moveTo(10,10);
+path.lineTo(110,20);
+path.lineTo(10,30);
+ctx.lineJoin = &quot;bevel&quot;;
+shouldBeFalse(&quot;ctx.isPointInStroke(path,113,20)&quot;);
+
+ctx.miterLimit = 40.0;
+ctx.lineJoin = &quot;miter&quot;;
+shouldBeTrue(&quot;ctx.isPointInStroke(path,113,20)&quot;);
+
+ctx.miterLimit = 2.0;
+shouldBeFalse(&quot;ctx.isPointInStroke(path,113,20)&quot;);
+
+path = new Path2D();
+path.moveTo(10,10);
+path.lineTo(110,10);
+ctx.lineCap = &quot;butt&quot;;
+shouldBeFalse(&quot;ctx.isPointInStroke(path,112,10)&quot;);
+
+ctx.lineCap = &quot;round&quot;;
+shouldBeTrue(&quot;ctx.isPointInStroke(path,112,10)&quot;);
+shouldBeFalse(&quot;ctx.isPointInStroke(path,117,10)&quot;);
+
+ctx.lineCap = &quot;square&quot;;
+shouldBeTrue(&quot;ctx.isPointInStroke(path,112,10)&quot;);
+shouldBeFalse(&quot;ctx.isPointInStroke(path,117,10)&quot;);
+
+ctx.lineCap = &quot;butt&quot;;
+ctx.setLineDash([10,10]);
+shouldBeTrue(&quot;ctx.isPointInStroke(path,15,10)&quot;);
+shouldBeFalse(&quot;ctx.isPointInStroke(path,25,10)&quot;);
+shouldBeTrue(&quot;ctx.isPointInStroke(path,35,10)&quot;);
+
+ctx.lineDashOffset = 10;
+shouldBeFalse(&quot;ctx.isPointInStroke(path,15,10)&quot;);
+shouldBeTrue(&quot;ctx.isPointInStroke(path,25,10)&quot;);
+shouldBeFalse(&quot;ctx.isPointInStroke(path,35,10)&quot;);
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (165926 => 165927)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2014-03-19  Dirk Schulze  &lt;krit@webkit.org&gt;
+
+        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:
+
</ins><span class="cx"> 2014-03-13  Mark Hahnenberg  &lt;mhahnenberg@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         GC timer should intelligently choose between EdenCollections and FullCollections
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlcanvasCanvasRenderingContext2Dcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp (165926 => 165927)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -996,6 +996,28 @@
</span><span class="cx"> 
</span><span class="cx"> bool CanvasRenderingContext2D::isPointInPath(const float x, const float y, const String&amp; windingRuleString)
</span><span class="cx"> {
</span><ins>+    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&amp; windingRuleString)
+{
+    return isPointInPathInternal(path-&gt;path(), x, y, windingRuleString);
+}
+
+bool CanvasRenderingContext2D::isPointInStroke(DOMPath* path, const float x, const float y)
+{
+    return isPointInStrokeInternal(path-&gt;path(), x, y);
+}
+#endif
+
+bool CanvasRenderingContext2D::isPointInPathInternal(const Path&amp; path, float x, float y, const String&amp; windingRuleString)
+{
</ins><span class="cx">     GraphicsContext* c = drawingContext();
</span><span class="cx">     if (!c)
</span><span class="cx">         return false;
</span><span class="lines">@@ -1012,11 +1034,10 @@
</span><span class="cx">     if (!parseWinding(windingRuleString, windRule))
</span><span class="cx">         return false;
</span><span class="cx">     
</span><del>-    return m_path.contains(transformedPoint, windRule);
</del><ins>+    return path.contains(transformedPoint, windRule);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-
-bool CanvasRenderingContext2D::isPointInStroke(const float x, const float y)
</del><ins>+bool CanvasRenderingContext2D::isPointInStrokeInternal(const Path&amp; path, float x, float y)
</ins><span class="cx"> {
</span><span class="cx">     GraphicsContext* c = drawingContext();
</span><span class="cx">     if (!c)
</span><span class="lines">@@ -1031,7 +1052,7 @@
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     CanvasStrokeStyleApplier applier(this);
</span><del>-    return m_path.strokeContains(&amp;applier, transformedPoint);
</del><ins>+    return path.strokeContains(&amp;applier, transformedPoint);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CanvasRenderingContext2D::clearRect(float x, float y, float width, float height)
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlcanvasCanvasRenderingContext2Dh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h (165926 => 165927)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -144,6 +144,11 @@
</span><span class="cx">     bool isPointInPath(const float x, const float y, const String&amp; winding = &quot;nonzero&quot;);
</span><span class="cx">     bool isPointInStroke(const float x, const float y);
</span><span class="cx"> 
</span><ins>+#if ENABLE(CANVAS_PATH)
+    bool isPointInPath(DOMPath*, const float x, const float y, const String&amp; winding = &quot;nonzero&quot;);
+    bool isPointInStroke(DOMPath*, const float x, const float y);
+#endif
+
</ins><span class="cx">     void clearRect(float x, float y, float width, float height);
</span><span class="cx">     void fillRect(float x, float y, float width, float height);
</span><span class="cx">     void strokeRect(float x, float y, float width, float height);
</span><span class="lines">@@ -303,6 +308,9 @@
</span><span class="cx">     void strokeInternal(const Path&amp;);
</span><span class="cx">     void clipInternal(const Path&amp;, const String&amp; winding);
</span><span class="cx"> 
</span><ins>+    bool isPointInPathInternal(const Path&amp;, float x, float y, const String&amp; winding);
+    bool isPointInStrokeInternal(const Path&amp;, float x, float y);
+
</ins><span class="cx">     void clearCanvas();
</span><span class="cx">     Path transformAreaToDevice(const Path&amp;) const;
</span><span class="cx">     Path transformAreaToDevice(const FloatRect&amp;) const;
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlcanvasCanvasRenderingContext2Didl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl (165926 => 165927)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -84,6 +84,11 @@
</span><span class="cx">     void stroke();
</span><span class="cx">     void clip(optional CanvasWindingRule winding);
</span><span class="cx"> 
</span><ins>+#if defined(ENABLE_CANVAS_PATH) &amp;&amp; ENABLE_CANVAS_PATH
+    boolean isPointInPath(DOMPath path, float x, float y, optional CanvasWindingRule winding);
+    boolean isPointInStroke(DOMPath path, float x, float y);
+#endif
+
</ins><span class="cx">     boolean isPointInPath(float x, float y, optional CanvasWindingRule winding);
</span><span class="cx">     boolean isPointInStroke(float x, float y);
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>