Bug 40271 - The HTML5 canvas 2d.drawImage.zerocanvas test does not pass
Summary: The HTML5 canvas 2d.drawImage.zerocanvas test does not pass
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P3 Normal
Assignee: Jan Erik Hanssen
URL: http://philip.html5.org/tests/canvas/...
Keywords: HTML5
Depends on:
Blocks:
 
Reported: 2010-06-07 16:56 PDT by Jan Erik Hanssen
Modified: 2010-07-01 11:49 PDT (History)
8 users (show)

See Also:


Attachments
Proposed patch (4.34 KB, patch)
2010-06-24 19:58 PDT, Andreas Kling
no flags Details | Formatted Diff | Diff
Proposed patch v2 (4.23 KB, patch)
2010-06-24 21:10 PDT, Andreas Kling
no flags Details | Formatted Diff | Diff
Proposed patch v3 (4.78 KB, patch)
2010-07-01 08:03 PDT, Andreas Kling
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Erik Hanssen 2010-06-07 16:56:02 PDT
The HTML5 canvas 2d.drawImage.zerocanvas test does not pass, the INVALID_STATE_ERR DOM exception should be set when no image data is present.

http://philip.html5.org/tests/canvas/suite/tests/2d.drawImage.zerocanvas.html
Comment 1 Andreas Kling 2010-06-24 19:58:10 PDT
Created attachment 59721 [details]
Proposed patch
Comment 2 Andreas Kling 2010-06-24 20:44:52 PDT
Comment on attachment 59721 [details]
Proposed patch

Not quite there.
Comment 3 Andreas Kling 2010-06-24 21:10:18 PDT
Created attachment 59726 [details]
Proposed patch v2

Proper patch.

See HTML5 spec at http://www.whatwg.org/specs/web-apps/current-work/#dom-context-2d-drawimage

"If the image argument is an HTMLCanvasElement object with either a horizontal dimension or a vertical dimension equal to zero, then the implementation must raise an INVALID_STATE_ERR exception."
Comment 4 Andreas Kling 2010-07-01 08:03:12 PDT
Created attachment 60249 [details]
Proposed patch v3

Ok, a patch for *this* bug now :-)
Comment 5 Darin Adler 2010-07-01 11:29:09 PDT
Comment on attachment 60249 [details]
Proposed patch v3

> +    if (!srcCanvasRect.width() || !srcCanvasRect.height()) {

Could you use srcCanvasRect.isEmpty() instead? If so, I think it would read nicer.
Comment 6 WebKit Commit Bot 2010-07-01 11:43:05 PDT
Comment on attachment 60249 [details]
Proposed patch v3

Clearing flags on attachment: 60249

Committed r62277: <http://trac.webkit.org/changeset/62277>
Comment 7 WebKit Commit Bot 2010-07-01 11:43:09 PDT
All reviewed patches have been landed.  Closing bug.
Comment 8 Andreas Kling 2010-07-01 11:49:33 PDT
(In reply to comment #5)
> (From update of attachment 60249 [details])
> > +    if (!srcCanvasRect.width() || !srcCanvasRect.height()) {
> 
> Could you use srcCanvasRect.isEmpty() instead? If so, I think it would read nicer.

I could, but FloatRect::isEmpty() checks (width <= 0 && height <= 0) which would open some incorrect code paths until bug 39149 is fixed.