[whatwg] Canvas Zero/NaN/Infinity issues

Ian Hickson ian at hixie.ch
Tue May 15 18:36:38 PDT 2007


On Sat, 20 May 2006, Anne van Kesteren wrote:
>
> I think http://whatwg.org/specs/web-apps/current-work/#strokerect must 
> have no effect when it has a zero height or width (or both). Currently 
> Safari, Firefox and Opera act that way when they are both zero and 
> Safari acts that way for all cases. Firefox and Opera draw a small line 
> when either is larger than zero but that can easily be changed. It also 
> makes the method more consistent with the other two.
> 
> For those "If either height or width are zero, this method has no 
> effect." should probably be changed to "If either height or width are 
> zero, this method must have no effect."

Fixed, but not that way. Let me know if it's ok.


On Mon, 26 Mar 2007, Philip Taylor wrote:
> 
> 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.

Specifically for transform(), setTransform(), scale(), and translate(), 
I've made Infinity cause the canvas to stop drawing instead of raising an 
exception. Everything else, exceptions.


On Wed, 4 Apr 2007, Philip Taylor wrote:
> 
> What if offset is NaN? That is neither less than 0 nor greater than 1.

Fixed.


On Sat, 12 May 2007, Darin Adler wrote:
> > 
> > Changed to unsigned.
> 
> If it's unsigned, it's ambiguous what behavior should be when an attempt 
> is made to set the value to a signed value via JavaScript. Should an 
> INDEX_SIZE_ERR exception be raised? Should the value be ignored?
> 
> I think I ran into this problem with HTMLOptionsCollection length 
> property.

Fixed by adding a general rule to the conformance section.


On Sat, 5 May 2007, Darin Adler wrote:
>
> A while back I did some work on WebKit's canvas implementation and I 
> noticed a few things in the canvas section of Web Apps that I'd like to 
> see specified so they don't end up different between implementations:
> 
> a) NAN arguments
> 
> For the graphics context functions that take floating point values, I 
> think the specification should say what the expected behavior is for:
> 
>     1) NANs
>     2) non-floating point values
>     3) missing parameters
> b) excess arguments

1, 3, and b now raise exceptions except if otherwise specified. I haven't 
yet defined 2. I'm not sure what it should say.

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



More information about the whatwg mailing list