Bug 42211 - Canvas: rect(x,y,w,h) should move to (x,y) even if w=0 and h=0
Summary: Canvas: rect(x,y,w,h) should move to (x,y) even if w=0 and h=0
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords: HTML5
Depends on:
Blocks:
 
Reported: 2010-07-13 16:37 PDT by Andreas Kling
Modified: 2010-07-13 17:45 PDT (History)
0 users

See Also:


Attachments
Proposed patch (3.47 KB, patch)
2010-07-13 16:40 PDT, Andreas Kling
darin: review+
kling: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Kling 2010-07-13 16:37:42 PDT
Quoth HTML5:

The rect(x, y, w, h) method must create a new subpath containing just the four points (x, y), (x+w, y), (x+w, y+h), (x, y+h), with those four points connected by straight lines, and must then mark the subpath as closed. It must then create a new subpath with the point (x, y) as the only point in the subpath.

This would fix one in-tree layout test:
- canvas/philip/tests/2d.path.rect.zero.4.html

Spec link:
http://www.whatwg.org/specs/web-apps/current-work/#dom-context-2d-rect
Comment 1 Andreas Kling 2010-07-13 16:40:45 PDT
Created attachment 61433 [details]
Proposed patch
Comment 2 Darin Adler 2010-07-13 17:18:57 PDT
Comment on attachment 61433 [details]
Proposed patch

Do we still need the validateRectForCanvas function? Can we refactor it so we can still use it?

> +    if (!isfinite(x) | !isfinite(y) | !isfinite(width) | !isfinite(height))
> +        return;

Why "|" instead of "||"?

> +    if (width < 0) {
> +        width = -width;
> +        x -= width;
> +    }
> +
> +    if (height < 0) {
> +        height = -height;
> +        y -= height;
> +    }

It’s inelegant to modify the arguments like this.

r=me
Comment 3 Andreas Kling 2010-07-13 17:45:43 PDT
Committed r63270: <http://trac.webkit.org/changeset/63270>