Bug 37686

Summary: Canvas strokeRect strokes rectangle whose dimensions are 0 when lineWidth > 1
Product: WebKit Reporter: Daniel Bates <dbates>
Component: Layout and RenderingAssignee: Daniel Bates <dbates>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, eric, krit, oliver, ossy, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Patch with test case
oliver: review-
Patch with test case
none
Patch with test cases
none
Example strokeRect of 0x0 rect with lineWidth > 1 and shadow
none
Patch with test cases none

Description Daniel Bates 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.
Comment 1 Daniel Bates 2010-04-15 20:18:03 PDT
Created attachment 53506 [details]
Patch with test case
Comment 2 Oliver Hunt 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?
Comment 3 Daniel Bates 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.
Comment 4 Daniel Bates 2010-04-16 00:17:33 PDT
Created attachment 53520 [details]
Patch with test case
Comment 5 Daniel Bates 2010-04-16 00:23:15 PDT
Comment on attachment 53520 [details]
Patch with test case

Will add some more test cases.
Comment 6 Daniel Bates 2010-04-16 01:07:57 PDT
Created attachment 53524 [details]
Patch with test cases

Added additional test cases for fillRect, clearRect, and rect.
Comment 7 Dirk Schulze 2010-04-23 13:04:34 PDT
I think the change and the tests are ok. What do you think Oliver?
Comment 8 Oliver Hunt 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
Comment 9 Daniel Bates 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
Comment 10 Daniel Bates 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.
Comment 11 Oliver Hunt 2010-04-25 23:41:04 PDT
Comment on attachment 54256 [details]
Patch with test cases

r=me
Comment 12 Daniel Bates 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>
Comment 13 Daniel Bates 2010-04-27 22:43:05 PDT
All reviewed patches have been landed.  Closing bug.
Comment 14 WebKit Review Bot 2010-04-27 23:12:42 PDT
http://trac.webkit.org/changeset/58381 might have broken Qt Linux Release
Comment 15 Eric Seidel (no email) 2010-04-27 23:18:04 PDT
The failure looks real:
http://build.webkit.org/results/Qt%20Linux%20Release/r58381%20(10853)/fast/repaint/selection-gap-overflow-scroll-2-diffs.txt

Not sure if it's related to this bug or not.
Comment 16 Daniel Bates 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>
Comment 17 Csaba Osztrogonác 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.
Comment 18 Daniel Bates 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>.