On 2013-10-11 1:08 PM, Ralph Giles wrote:
On 2013-10-10 12:28 PM, Steve Fink wrote:

It seems like the optimal efficiency vs surface exposure vs frequency
of use tradeoff would be to do everything but the top formats (JPG,
PNG, GIF?) in JS.

That's what we do today. We support those three image formats with
native code, and others can be supported by a js implementation, which
anyone can write.

*Can* anyone, though?  Concretely, one would like to be able to write

    <!doctype html>
    <script src="//cdn.provider.com/mysite/s/libtiff.js"></script>
    <img src="//cdn.provider.com/mysite/2002/02/20/giant-map.tiff">

Those are cross-domain references for both the script and the image, just to be clear. Potential problems include:

 - Getting the content of the image file
   - Not triggering repeated downloads of the same image
 - Informing layout of the dimensions of the image
 - Acquiring a drawing context
 - Integrating properly with repaint, such that we get all the nice
   decode-on-draw, cache-and-discard-pixels optimizations
 - Ensuring that we don't introduce cross-domain data leaks in
   the process of enabling the above

I am fairly sure that this is *not* possible right now in full generality; I think the best you can do from page script is issue an XHR for the image data (so it probably gets retrieved twice, and won't work cross-domain) and then manually replace the <img> with a <canvas> (and do your own caching and memory management).

zw
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to