Re: [css3-values][css3-images] element() function

On Wed, Sep 1, 2010 at 5:57 AM, Simon Fraser <smfr@me.com> wrote:

> Agreed, I think -webkit-canvas is a different beast to element().
> -webkit-canvas simply creates a canvas context with the specified height and
> width; there is no associated canvas element, and there's nothing in the
> document.
>

You can get very close to -webkit-canvas using element() with the
setImageElement API. In particular, a referenced canvas need not be in the
document. E.g.

var e = document.createElement("canvas");
var ctx = e.getContext("2d"); drawInto(ctx);
window.setImageElement("anon-canvas", e);

.canvas-background { background:element(#anon-canvas); }

One useful use case I see missing with element() is the ability to reference
> an element in a display: none subtree, so you can, for example, have some
> nodes in the <head> that you use to draw HTML content into a <canvas> or CSS
> background or WebGL.
>

Arbitrary display:none HTML content doesn't have CSS boxes so I'm not sure
how you would want it to be rendered.

element() is able to render <canvas>, <video> and <img> elements that are
display:none or not in the document. That list could be extended to any
other type of element that has its own "natural" non-CSS rendering. Perhaps
<svg> could be added to that list.

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]

Received on Wednesday, 1 September 2010 04:38:04 UTC