W3C home > Mailing lists > Public > www-style@w3.org > September 2010

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

From: Robert O'Callahan <robert@ocallahan.org>
Date: Wed, 1 Sep 2010 16:37:37 +1200
Message-ID: <AANLkTikq+qwDOxw_EVEvDaJc5y=0i6D621dhrVdR85PX@mail.gmail.com>
To: Simon Fraser <smfr@me.com>
Cc: Boris Zbarsky <bzbarsky@mit.edu>, "Tab Atkins Jr." <jackalmage@gmail.com>, www-style list <www-style@w3.org>
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.

"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

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:49:47 UTC