[whatwg] Canvas methods and exceptions

Hi all,

In a recent foray into the world of canvas compatibility I've noticed  
that a number of canvas methods are defined as throwing exceptions on  
"invalid" input which aren't really insane, for example
  * clear/fill/drawRect with negative width/height
  * drawImage with negative sx/sw
  * putImageData with pixel data outside of the 0-255 range

There may be other similar examples that i missed.

Anyway, there are many cases in which people people compute value for  
these (and similar) api's in which their are edge cases which can  
result in values that would be required to trigger an exception  
according this specification.  This type of all or nothing approach  
leads to the potential for otherwise working code to just fail  
mysteriously in some cases.

Following the idea of doing the least surprising action, i think we  
should go through the Canvas spec and remove "surprising"  
exceptions.  For instance a negative width for a rectangle should not  
terminate execution (although whether it should fail silently, or  
just draw the rect as though it
were positioned differently is a question that would need to be  
answered), ditto for the other cases that i mentioned.

I would argue that in these (and maybe other) cases failing silently  
is less harmful than throwing an exception, and from my testing this  
is the behaviour firefox already follows, and i know from experience  
that throwing an exception in these cases breaks sites.

Do other people have thoughts on this matter?

--Oliver

Received on Monday, 14 January 2008 18:26:16 UTC