Bug 14421 - Possible error in canvas Philip test 2d.path.stroke.prune.arc
Possible error in canvas Philip test 2d.path.stroke.prune.arc
Status: RESOLVED FIXED
Product: HTML WG
Classification: Unclassified
Component: testsuite
unspecified
All All
: P2 normal
: ---
Assigned To: zqzhang
HTML WG Bugzilla archive list
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-10-11 05:52 UTC by Ben Wells
Modified: 2012-08-15 12:36 UTC (History)
11 users (show)

See Also:


Attachments
Fix on ctx.moveTo() (869 bytes, patch)
2012-08-14 15:37 UTC, zqzhang
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ben Wells 2011-10-11 05:52:25 UTC
This test is checking that no zero length segments are removed when using arcTo and arc. The code for checking arc is:

ctx.beginPath();
ctx.moveTo(50, 25);
ctx.arc(50, 25, 10, 0, 0, false);
ctx.stroke();

I think this should create a line from (50, 25) to the start of the arc, which in this case will be (60, 25): the center of the circle is (50, 25), the radius is 10 and the start angle is 0.

I believe arc call should be changed to:
ctx.arc(40, 25, 10, 0, 0, false);
Comment 1 Ben Wells 2011-10-11 05:54:16 UTC
Relevant section of the canvas spec: http://www.w3.org/TR/2dcontext/#dom-context-2d-arc
Comment 2 Ben Wells 2011-11-09 01:44:20 UTC
Any takers? Let me know if there is somewhere more appropriate I should log this.
Comment 3 Ian 'Hixie' Hickson 2012-01-27 18:26:21 UTC
The method is defined as only adding the straight line if the path already contains a subpath, which it doesn't in this case.
Comment 4 Ben Wells 2012-03-27 22:49:21 UTC
(In reply to comment #3)
> The method is defined as only adding the straight line if the path already
> contains a subpath, which it doesn't in this case.

The moveTo call before the arc will create a sub path: http://www.w3.org/TR/2dcontext/#dom-context-2d-moveto

"The moveTo(x, y) method must create a new subpath with the specified point as its first (and only) point."

More code from the test is below. The sections with arcTo and arc are, I believe, intended to be equivalent. However as the arguments are treated slightly differently they are not.

The first two arguments to arcTo describe a point on the arc. The first two arguments to arc describe the center of the arc.

ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);

ctx.strokeStyle = '#f00';
ctx.lineWidth = 100;
ctx.lineCap = 'round';
ctx.lineJoin = 'round';

ctx.beginPath();
ctx.moveTo(50, 25);
ctx.arcTo(50, 25, 150, 25, 10);
ctx.stroke();

ctx.beginPath();
ctx.moveTo(50, 25);
ctx.arc(50, 25, 10, 0, 0, false);
ctx.stroke();

_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");
Comment 6 Ian 'Hixie' Hickson 2012-08-14 23:46:47 UTC
Please disregard comment 3, I was indeed incorrect.
Comment 7 Mercator 2012-08-15 11:46:08 UTC
I can confirm that that patch is correct per spec.

(And Philip had already made that change in the unapproved version: http://dvcs.w3.org/hg/html/rev/f7e11f44274c)
Comment 8 Thiago Marcos P. Santos 2012-08-15 12:08:57 UTC
Is it ok to apply zqzhang's patch on the approved test? Any objection?
Comment 9 Ms2ger 2012-08-15 12:20:04 UTC
Yes, please do.
Comment 10 Thiago Marcos P. Santos 2012-08-15 12:36:20 UTC
Fixed at https://dvcs.w3.org/hg/html/rev/f64be2d08dcd