[whatwg] Canvas spec issues

A couple of points that are unclear and are causing differences
between current implementations (which is presumably a bad thing):


"interface HTMLCanvasElement" says "attribute long width;". #reflect
says "If a reflecting DOM attribute is a signed integer type (long)
then the content attribute must be parsed according to the rules for
parsing signed integers first", which seems to apply in this case.
But the canvas section says of width/height, "The rules for parsing
non-negative integers must be used to obtain their numeric values".
Hence, conflict.

Also, "canvas.width = -1" is acceptable for a signed long, but doesn't
make sense here. (After setting that, Firefox gives canvas.width==0,
Opera gives 300, Safari gives -1.)


What should happen when Infinity or -Infinity or NaN are passed as
float arguments? I assume there shouldn't be a type exception since
they're perfectly valid floats (under the usual models of floating
point arithmetic), though I don't know where/if that's defined. In
some cases there is a logical behaviour (e.g. when translating a
finite-sized object by infinity, or scaling an object like
rect(-10,-10,20,20) by infinity then clipping it to the viewable
area), but in most cases there isn't (e.g. rotating by infinity, or
doing anything with NaN, when the output depends on those values).

My experience with some 3d canvas code is that infinities come up in
naturally harmless places, e.g. having a function that scales by x
then translates by 1/x and wanting it to work when x=0 (which ought to
draw nothing, since anything it draws is zero pixels wide), and it's a
bit annoying to track down and fix those issues, so I'd probably like
it if they were harmless in canvas methods. Opera appears to silently
not draw anything if the transformation matrix is not finite, but
Firefox throws exceptions when passing in non-finite arguments.


And some minor issues with the text:

"DOMString toDataURL();" has the link stretching across the brackets.

In "interface CanvasRenderingContext2D", it looks like
"HTMLCanvasElement canvas;" should be "readonly attribute
HTMLCanvasElement canvas;" (because everything else has "attribute",
and the comment says it's readonly).

"When the context is created, the transformation matrix must initially
be the identity transform. It may then be adjusted using the three
transformation methods" - but there are now five (not three)
transformation methods (scale, rotate, translate, transform,
setTransform).

In Compositing, "darker" says "destination images" while all the
others say "destination image".

-- 
Philip Taylor
excors at gmail.com

Received on Sunday, 25 March 2007 18:50:48 UTC