RESOLVED FIXED Bug 37686
Canvas strokeRect strokes rectangle whose dimensions are 0 when lineWidth > 1
https://bugs.webkit.org/show_bug.cgi?id=37686
Summary Canvas strokeRect strokes rectangle whose dimensions are 0 when lineWidth > 1
Daniel Bates
Reported 2010-04-15 17:08:38 PDT
Currently, strokeRect will stroke a rectangle whose dimensions are 0 when lineWidth > 1. As per the definition of strokeRect in the HTML Canvas 2D Context spec. <http://www.w3.org/TR/2dcontext/#dom-context-2d-strokerect>, this method should have no effect when both the height and width of the rectangle are zero.
Attachments
Patch with test case (3.58 KB, patch)
2010-04-15 20:18 PDT, Daniel Bates
oliver: review-
Patch with test case (3.40 KB, patch)
2010-04-16 00:17 PDT, Daniel Bates
no flags
Patch with test cases (12.48 KB, patch)
2010-04-16 01:07 PDT, Daniel Bates
no flags
Example strokeRect of 0x0 rect with lineWidth > 1 and shadow (573 bytes, text/html)
2010-04-25 22:50 PDT, Daniel Bates
no flags
Patch with test cases (13.49 KB, patch)
2010-04-25 22:58 PDT, Daniel Bates
no flags
Daniel Bates
Comment 1 2010-04-15 20:18:03 PDT
Created attachment 53506 [details] Patch with test case
Oliver Hunt
Comment 2 2010-04-15 23:49:22 PDT
Comment on attachment 53506 [details] Patch with test case I think it would be better to make validateRectForCanvas do the check as that gets the validation in a single place that is used uniformly -- is there any place this might have a bad impact?
Daniel Bates
Comment 3 2010-04-16 00:16:52 PDT
(In reply to comment #2) > (From update of attachment 53506 [details]) > I think it would be better to make validateRectForCanvas do the check as that > gets the validation in a single place that is used uniformly -- is there any > place this might have a bad impact? I agree, it is better to place this check in validateRectForCanvas. There should not be any negative impact as this is an invalid state for clearRect, and fillRect as well.
Daniel Bates
Comment 4 2010-04-16 00:17:33 PDT
Created attachment 53520 [details] Patch with test case
Daniel Bates
Comment 5 2010-04-16 00:23:15 PDT
Comment on attachment 53520 [details] Patch with test case Will add some more test cases.
Daniel Bates
Comment 6 2010-04-16 01:07:57 PDT
Created attachment 53524 [details] Patch with test cases Added additional test cases for fillRect, clearRect, and rect.
Dirk Schulze
Comment 7 2010-04-23 13:04:34 PDT
I think the change and the tests are ok. What do you think Oliver?
Oliver Hunt
Comment 8 2010-04-23 13:18:27 PDT
Comment on attachment 53524 [details] Patch with test cases Daniel can you just verify behaviour if you have a shadow set? eg. should the shadow draw around a 0x0 rect (i know physically it shouldn't i just want to verify firefox compat) If the shadow behaviour is consistent the patch is good --Oliver
Daniel Bates
Comment 9 2010-04-25 22:50:30 PDT
Created attachment 54255 [details] Example strokeRect of 0x0 rect with lineWidth > 1 and shadow (In reply to comment #8) > (From update of attachment 53524 [details]) > Daniel can you just verify behaviour if you have a shadow set? eg. should the > shadow draw around a 0x0 rect (i know physically it shouldn't i just want to > verify firefox compat) Oliver, Firefox (3.6.3) does not draw a shadow around a 0x0 rect. I've attached one such test case. Dan > > If the shadow behaviour is consistent the patch is good > > --Oliver
Daniel Bates
Comment 10 2010-04-25 22:58:14 PDT
Created attachment 54256 [details] Patch with test cases Added a test case for strokeRect of 0x0 rect with lineWidth > 1 and shadow. Also, rebased results LayoutTests/fast/canvas/canvas-strokeRect-expected.txt.
Oliver Hunt
Comment 11 2010-04-25 23:41:04 PDT
Comment on attachment 54256 [details] Patch with test cases r=me
Daniel Bates
Comment 12 2010-04-27 22:42:58 PDT
Comment on attachment 54256 [details] Patch with test cases Clearing flags on attachment: 54256 Committed r58381: <http://trac.webkit.org/changeset/58381>
Daniel Bates
Comment 13 2010-04-27 22:43:05 PDT
All reviewed patches have been landed. Closing bug.
WebKit Review Bot
Comment 14 2010-04-27 23:12:42 PDT
http://trac.webkit.org/changeset/58381 might have broken Qt Linux Release
Eric Seidel (no email)
Comment 15 2010-04-27 23:18:04 PDT
Daniel Bates
Comment 16 2010-04-27 23:20:47 PDT
(In reply to comment #14) > http://trac.webkit.org/changeset/58381 might have broken Qt Linux Release The failing test, /fast/repaint/selection-gap-overflow-scroll-2.html, is unrelated to this change. Looking at the differences <http://build.webkit.org/results/Qt%20Linux%20Release/r58381%20(10853)/fast/repaint/selection-gap-overflow-scroll-2-pretty-diff.html> they seem to differ by 1-pixel. For completeness, the stdio from the Qt bot is at: <http://build.webkit.org/builders/Qt%20Linux%20Release/builds/10853/steps/layout-test/logs/stdio>
Csaba Osztrogonác
Comment 17 2010-04-28 00:21:45 PDT
(In reply to comment #16) I made a clean build, and nothing changed. This test needs only a rebaseline.
Daniel Bates
Comment 18 2010-04-28 00:48:40 PDT
(In reply to comment #17) > (In reply to comment #16) > I made a clean build, and nothing changed. This test needs only a rebaseline. Committed rebased result in change set 58388 <http://trac.webkit.org/changeset/58388>.
Note You need to log in before you can comment on or make changes to this bug.