[whatwg] Canvas patterns, and miscellaneous other things

On Sat, 2 Feb 2008, Philip Taylor wrote:
>
> On 31/01/2008, Ian Hickson <ian at hixie.ch> wrote:
> > I've made toDataURL() return "data:," if it's faced with a 0-pixel image.
> > It's arbitrary, but I guess it represents the image, at least!
> 
> That makes the "Note: When trying to use types other than image/png, 
> authors can check if the image was really returned in the requested 
> format by checking to see if the returned string starts with one the 
> exact strings "data:image/png," or "data:image/png;"." now incorrect. 
> The non-image/png format might be unsupported, but someone might be 
> drawing a 0-pixel image and they'll get back something that doesn't 
> start with data:image/png[,;].
> 
> It does seem pretty weird to return text/plain content when asked for an 
> image. But I guess it's safer than e.g. returning an empty string, since 
> it won't get misinterpreted as a relative address when people do 
> img.src=canvas.toDataURL(), and I can't think of a better idea.

I agree that it's not ideal. I'm not sure what would be better. I've made 
the note you quote above mention this edge case, just in case.


> > User agents may impose implementation-specific limits on otherwise 
> > unconstrained inputs, e.g. to prevent denial of service attacks, to 
> > guard against running out of memory, or to work around 
> > platform-specific limitations. (See ...#hardwareLimitations.)
> 
> Does anything say that those limitations should be imposed by throwing 
> an exception, and not by e.g. returning null or aborting the entire 
> script?

No. It's hard to legislate what should happen here. For instance, raising 
an exception might require allocating memory, which can't happen if the 
hardware limitation in question is running out of memory.

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

Received on Sunday, 10 February 2008 01:05:59 UTC