[whatwg] CanvasRenderingContext2D.lineTo compatibility problem

On Sat, 11 Jul 2009, Oliver Hunt wrote:
>
> While investigating a compatibility issue with 
> http://www.blahbleh.com/clock.php I found that the spec behaviour on 
> CanvasRenderingContext2D.lineTo conflicts with what Gecko implements.
> 
> The current spec language is
> "The lineTo(x, y) method must do nothing if the context has no subpaths.
> Otherwise, it must connect the last point in the subpath to the given point
> (x, y) using a straight line, and must then add the given point (x, y) to the
> subpath."
> 
> Gecko appears to treat the empty path case as moveTo(x,y).  I'm going to do a
> bit more investigation into the behaviour of this and the other path
> manipulation functions to see whether lineTo is "special" or this logic
> effects every function (of course any Gecko devs may be able to answer more
> quickly than i can manually verify).  On the *assumption* that my initial
> analysis is correct i propose that the language be updated to something akin
> to:
> The lineTo(x, y) method is equivalent to moveTo(x, y) if the context has no
> subpaths. Otherwise, it must connect the last point in the subpath to the
> given point (x, y) using a straight line, and must then add the given point
> (x, y) to the subpath.

On Sat, 11 Jul 2009, Oliver Hunt wrote:
>
> Okay the behaviour for lineTo, quadraticCurveTo and bezierCurveTo without an
> existing subpath (unsure about arcTo any "sane" response to arcTo with an
> empty path results in one of those edge cases where webkit, gecko, and presto
> all disagree) should probably be changed to (worded better of course :D ):
> 
> * lineTo(x, y) is equivalent to moveTo(x, y) if the context has no subpaths.
> * The quadraticCurveTo(cpx, cpy, x, y) method is equivalent to "moveTo(cpx,
> cpy); quadraticCurveTo(cpx, cpy, x, y);"  if the context has no subpaths
> * The bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y) method is equivalent to
> "moveTo(cp1x, cp1y); bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);"  if the
> context has no subpaths
> 
> My rationale for this change is that it is a relaxation of existing API 
> -- in the specified API these cases would become no-ops that feed into 
> subsequent calls, eg. lineTo(..);lineTo(..);lineTo(..) will draw nothing 
> as the path never becomes non-empty so none of the calls can ever have 
> an effect, whereas this re-specification would result in subsequent 
> operations drawing something.

Fixed the spec as proposed (and also for arcTo(), though as you say, the 
behaviour there isn't very interoperable).

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Monday, 27 July 2009 16:48:54 UTC