The concept seems interesting. It certainly allows for improved
flexibility of how views are rendered beyond HTML. By any chance,
would you happen to have any diagrams that depict the proposed
architecture?
Regarding SVG, yes, it works like DOM where each SVG element is part
of the DOM structure and therefore acts like DOM elements. However,
there's a difference with pre-HTML5 SVG and the new HTML5 SVG.
For pre-HTML5 SVG, there are a few ways to render. One method is to
use the embed or object HTML tags to include an SVG image. That
approach isn't great for when you want to dynamically create SVG
images on the fly, like I'm sure most people would like to do in
SproutCore :-). Another approach is to have SVG directly part of the
document by representing it as a string of (X)HTML syntax that can be
interpreted by the browser's rendered. But for (X)HTML approach to
work you need to have the document's content type to be "application/
xhtml+xml" and that must come from the HTTP response or else the
browser won't recognize the SVG syntax. Commonly, web pages served up
by a server are "text/html", as is the case with sc-server. In
addition, you also have to have special meta doc headers to indicate
the use of XHTML. It's a headache. A final approach is to instead use
JavaScript to call the document object's createElementNS method to
dynamically generate SVG elements. The benefit of this is that you
don't have to do anything special to the HTTP response or document
itself since createElementNS is W3C DOM compliant. The downside is
that you can't represent the SVG and text and use innerHTML to render
the SVG. And as we all know, touching the DOM is sloooow.
In HTML5, the SVG syntax is part of the normal HTML document structure
and is implicitly recognized by the browser's rendered. So no funny
XML/XHTML things to do. And because the SVG syntax is build into the
browser's lexicon, you can use innerHTML and get the speed
performance. This is where Microsoft has an advantage with VML in that
the VML syntax was directly recognized by the IE browser, so you could
use innerHTML.
What would this all mean for the proposed SC2.0 rendering API? Well,
for newer HTML5 compliant browsers, not much I guess since the
DOMRenderContext would fit the bill. But for pre-HTML5 browsers,
that's an open question at the moment. Something that may be of
interest is to incorporate the SproutCore Sai framework that handles
the rendering of SVG and VML and update it to work with the new SC2.0
rendering API. As of now, Sai hooks into the view's didCreateLayer and
didUpdateLayer methods in order to trigger when to create and update a
special Sai canvas that renders either SVG or VML. Sai will be updated
to work with HTML5 SVG, that way innerHTML would be used to create the
SVG elements instead of using createElementNS as is being done right
now. Perhaps if DOMRenderContext were updated to have pre- and post-
rendering hooks, it would make it easy to make the necessary updates.
In any case, that was just a quick idea that was currently on the top
of my head :-).
Mike