Reputation: 60988
Short version: Do I have to add graphical DOM nodes to the DOM tree in order to use them in some graphics pipeline?
There are many ways how a HTML5 webapp can use graphical DOM elements for purposes other than by visibly including them in the DOM tree:
<video>
element could be used to capture a webcam stream and load the current frame into a WebGL texture attached to some <canvas>
.<canvas>
element can be used to prepare an off-screen image (using 2d graphics or WebGL), which can then be composed into some other <canvas>
with a global alpha applied to the content as a whole.<img>
can be drawn to a <canvas>
to gain access to its individual pixels, or to convert it to PNG from whatever it happened to be originally.On the whole, I'd say CanvasImageSource and TexImageSource consistently name <img>
, <video>
and <canvas>
as the image sources relevant to my question, and the 2d and WebGL contexts of <canvas>
as the destinations.
Is there any requirement, in specification or in practice, to have the source element, destination element or both attached to the DOM tree of the current document for such processing steps to work?
So far I haven't yet encountered a compatibility problem due to working with unattached elements. But I tend to develop on modern browsers, I don't have a huge machine park to do tests, and so far I've been conservative and added nodes to the tree (with css visibility hidden
) in order to be on the safe side. It would be great to have some reliable guideline on this, preferably from some authoritative specification, but some reasonably comprehensive tests would be great as well. Do you know of any such guidelines?
(Bonus question: is there any specification ruling whether or not one can combine graphical elements created for different documents using the techniques described above?)
Upvotes: 1
Views: 155
Reputation: 60988
Up till now I have not encountered any such requirement, in documentation or in practice. So I'd tentatively answer my own question with a NO. On the other hand I'm ready to change that verdict if anyone has evidence to the contrary, so please report any cases where this was not true.
Upvotes: 1