Re: HTMLImageElement -- use of SVG within <canvas>

On 4/28/11 7:53 PM, Dailey, David P. wrote:
> "Images can thus be static bitmaps (e.g. PNGs, GIFs, JPEGs), single-page vector documents (single-page PDFs, XML files with an SVG root element), animated bitmaps (APNGs, animated GIFs), animated vector graphics (XML files with an SVG root element that use declarative SMIL animation), and so forth. However, this also precludes SVG files with script, multipage PDF files, interactive MNG files, HTML documents, plain text documents, and so forth."
>
> I assume there are good reasons for excluding SVG files with script; at least I am certain that careful thought went into that stipulation, and will assume the thinking was cogent.
>
> However, it would be nicer, I think, to allow one to reference an SVG file that happens to have script, and to render the image, but simply not to require the script to be run.

That's what Gecko does, yes.

> See for example:
>
> http://srufaculty.sru.edu/david.dailey/svg/recent/htmlsvgcanvas7b.htm
>
> It runs "properly" in no extant browser, that I'm aware of.

In Gecko, this testcase fails because the <svg> has no intrinsic size 
specified, so we have no idea how to actually go about drawing it into 
the canvas.

What the spec says about this case for drawImage is:

   If the sx, sy, sw, and sh arguments are omitted, they must default
   to 0, 0, the image's intrinsic width in image pixels, and the image's
   intrinsic height in image pixels, respectively.

But this image has no intrinsic size, so this step can't really be 
performed, and we throw instead.

For the particular case of unspecified source rectangle, it seems like 
this could be made to work for images with no intrinsic size in the spec.

None of this has to do with the fact that the SVG contains a <script>.

> On the other hand, the above file, when referencing a JPEG rather than an SVG runs "properly" in all modern browsers I've tested. (IE9, Chrome, FF4, Opera, and Safari): http://srufaculty.sru.edu/david.dailey/svg/recent/htmlsvgcanvas7a.htm

Yeah, hard to produce a JPEG that doesn't know its own size.  ;)

-Boris

Received on Friday, 29 April 2011 01:19:12 UTC