Bug 66832 - LayoutTests/canvas/philip/tests/2d.path.stroke.prune.arc.html misinterprets pruning requirement
Summary: LayoutTests/canvas/philip/tests/2d.path.stroke.prune.arc.html misinterprets p...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Tom Zakrajsek
URL:
Keywords:
Depends on:
Blocks: 55696
  Show dependency treegraph
 
Reported: 2011-08-23 18:06 PDT by Tom Zakrajsek
Modified: 2011-08-29 11:20 PDT (History)
1 user (show)

See Also:


Attachments
Demo of path pruning when arc length = 0 (416 bytes, text/html)
2011-08-23 18:06 PDT, Tom Zakrajsek
no flags Details
Demo of path pruning compared to path when arc is not pruned (610 bytes, text/html)
2011-08-24 12:28 PDT, Tom Zakrajsek
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Zakrajsek 2011-08-23 18:06:01 PDT
Created attachment 104950 [details]
Demo of path pruning when arc length = 0

WebKit incorrectly prunes the path when it contains a 0 length arc, and the 2d.path.stroke.prune.arc test is expecting/enforcing that behavior.  In addition to removing the 0 length arc, we are also removing the connecting line.  From the spec, at http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#complex-shapes-%28paths%29

<quote>
context.arc(x,y,radius,startAngle,endAngle[,anticlockwise]) adds points to the subpath such that the arc described by the arguments .../snip/... is added to the path, connected to the previous point by a straight line.
: : :
The arc(x, y, radius, startAngle, endAngle, anticlockwise) method draws an arc. If the context has any subpaths, then the method must add a straight line from the last point in the subpath to the start point of the arc. In any case, it must draw the arc between the start point of the arc and the end point of the arc, and add the start and end points of the arc to the subpath. The arc and its start and end points are defined as follows:
: : :
If the two points are the same, or if the radius is zero, then the arc is defined as being of zero length in both directions.
: : :
And then under general path stuff... "Zero-length line segments must be pruned before stroking a path. Empty subpaths must be ignored."
</quote>

Now consider the case of several arc calls.  If you follow all of the steps and construct paths you construct a series of arcs with connecting lines.  If we set one arc length to 0, the current interpretation (enforced by this test) has us removing the non-zero length connecting line also.  That goes beyond what the spec says, and differs from the interpretation of all other tested browsers, including: IE, Firefox, and Opera.  See the attached example.

Problems with the current interpretation include:
  * Divergence from *all* other browser engines,
  * Divergence from how svg handles analogous paths
  * Divergence from WebKit's own handling of 0 length line segments created by lineTo.
  * Violates principle of least surprise.  Behavior at arcLen == 0 differs (discontinuously) from behavior as arcLen approaches 0. 

We can fix the WebKit behavior under https://bugs.webkit.org/show_bug.cgi?id=55696, but this test will start failing.
Comment 1 Tom Zakrajsek 2011-08-24 12:28:16 PDT
Created attachment 105042 [details]
Demo of path pruning compared to path when arc is not pruned
Comment 2 Tom Zakrajsek 2011-08-29 11:20:53 PDT
Fixed by patch for https://bugs.webkit.org/show_bug.cgi?id=55696.