Bug 13666
Summary: | Canvas: fill() blows away the current path | ||
---|---|---|---|
Product: | WebKit | Reporter: | Ian 'Hixie' Hickson <ian> |
Component: | Layout and Rendering | Assignee: | Nobody <webkit-unassigned> |
Status: | RESOLVED INVALID | ||
Severity: | Normal | CC: | drj, mrowe |
Priority: | P2 | ||
Version: | 523.x (Safari 3) | ||
Hardware: | PC | ||
OS: | OS X 10.4 | ||
URL: | http://www.hixie.ch/tests/adhoc/html/canvas/020.html |
Ian 'Hixie' Hickson
STEPS TO REPRODUCE
1. Create a path.
2. Call fillRect().
3. Stroke the path.
ACTUAL RESULTS
The stroke doesn't work.
EXPECTED RESULTS
Until you call beginPath() or you change the size of the canvas, the path
shouldn't be touched.
TESTCASE:
http://www.hixie.ch/tests/adhoc/html/canvas/020.html
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Mark Rowe (bdash)
Ian, the test case does not appear to match the description of the bug. Did you link to the right test case?
Ian 'Hixie' Hickson
Looks like it's fill(), not fillRect(), that blows away the path.
David Jones
Well, Hixie's test still fails, but the bug is mis-diagnosed. fill() does not blow away the path, as it is still available for later stroking. As <a href="data:text/html;base64,PCFET0NUWVBFIEhUTUw+CjxodG1sPgogPGhlYWQ+CiAgPHRpdGxlPkZpbGxpbmcgYW5kIFN0cm9raW5nPC90aXRsZT4KIDwvaGVhZD4KIDxib2R5PgogIDxwPlRoZXJlIHNob3VsZCBiZSBhIHJlZCBzcXVhcmUgd2l0aCBhIHRoaWNrIG9yYW5nZSBib3JkZXIuPC9wPgogIDxkaXY+PGNhbnZhcyB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCIKY2xhc3M9ImJlZm9yZSI+RkFJTDwvY2FudmFzPjwvZGl2PgogIDxzY3JpcHQ+CiAgIHZhciBjYW52YXMgPSBkb2N1bWVudC5nZXRFbGVtZW50c0J5VGFnTmFtZSgnY2FudmFzJylbMF07CiAgIHZhciBjb250ZXh0ID0gY2FudmFzLmdldENvbnRleHQoJzJkJyk7CiAgIGNvbnRleHQuZmlsbFN0eWxlID0gJ3JlZCc7CiAgIGNvbnRleHQuc3Ryb2tlU3R5bGUgPSAnb3JhbmdlJwogICBjb250ZXh0LmxpbmVXaWR0aCA9ICcxMCcKICAgY29udGV4dC5yZWN0KDUwLCA1MCwgMTAwLCAxMDApOwogICBjb250ZXh0LmZpbGwoKTsKICAgY29udGV4dC5zdHJva2UoKTsKICA8L3NjcmlwdD4KIDwvYm9keT4KPC9odG1sPgo=">this test</a> shows.
David Jones
The testcase Hixie gives, http://www.hixie.ch/tests/adhoc/html/canvas/020.html , is bogus. It is creating a path using rect() and then fill()ing it 4 times, changing the CTM by using translate() before each fill. Apparently the intention is that the rectangle is filled in four different positions. But this is not how the CTM and the path interact, the CTM operates on the rectangle co-ordinates when they are specified by rect(), not later on when the path is filled (see HTML5 4.7.11.1.8 http://www.whatwg.org/specs/web-apps/current-work/#complex ). Thus, at least in this regard, WebKit is behaving as per the "spec".
David Jones
Moreover, fillRect() does not appear to disturbed the path:
<!DOCTYPE HTML>
<html>
<head>
<title>Filling and Stroking</title>
</head>
<body>
<p>There should be a red cross.</p>
<div><canvas width="200" height="200"
class="before">FAIL</canvas></div>
<script>
var canvas = document.getElementsByTagName('canvas')[0];
var context = canvas.getContext('2d');
context.fillStyle = 'red';
context.rect(75, 25, 50, 150);
context.fillRect(25,75,150,50)
context.fill();
</script>
</body>
</html>
Ian 'Hixie' Hickson
Yeah this is bogus, the spec changed since I wrote those tests. Sorry.
David Jones
Yes, i did wonder if the spec had changed.
It occurred to me this morning that your test, 020.html , could be used as a test that changing the CTM does _not_ affect the path. In other words simply change the text to "there should be a green square displayed in the upper left corner of a red square".