[whatwg] CSS canvas() function

Robert O'Callahan robert at ocallahan.org
Tue Nov 23 16:59:49 PST 2010


On Wed, Nov 24, 2010 at 1:13 PM, Tab Atkins Jr. <jackalmage at gmail.com>wrote:

> Webkit has for some time now supported using the -webkit-canvas()
> function in CSS anywhere you could use an image
> (<http://webkit.org/blog/176/css-canvas-drawing/>, published in April
> 2008).  The function takes an ident, which can then be used in the
> window.getCSSCanvasContext() function in javascript to grab a context
> keyed to that ident.  Drawing on that context is then reflected
> everywhere on the page that references that canvas.
>
> In essence, this is defining a scriptable paint server, which seems
> useful enough that we'd really like it in the platform.
>

Out of interest, what use-cases do you have for this? Mozilla people
couldn't think of many that aren't already addressed by other means.

I'm willing to define a canvas() function in the CSS Image Values
> specification, but since this relies explicitly on an HTML feature, it
> feels like the full definition should exist in the HTML spec.
>

One of our goals for element() was to subsume canvas(). Is there a reason to
have an independent canvas() feature if we have element()?

Note that the setImageElement() API lets you render elements that are not in
a document, so you can get the effect of window.getCSSCanvasContext(type,
id, width, height) with
  var c = document.createElement("canvas");
  c.width = width; c.height = height;
  window.setImageElement(id, c);
  return c.getContext(type);

http://hacks.mozilla.org/2010/08/mozelement/

Rob
-- 
"Now the Bereans were of more noble character than the Thessalonians, for
they received the message with great eagerness and examined the Scriptures
every day to see if what Paul said was true." [Acts 17:11]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20101124/ecff0f35/attachment-0002.htm>


More information about the whatwg mailing list