Making it possible to use an <svg> root in text/html

Some notes about the implications of making it possible to use <svg>  
as the root element in text/html.

  * The 'before html' insertion mode would get a new entry:
    A start tag whose tag name is "svg"

     Adjust SVG attributes</span> for the token.

     Create an element for the token in the SVG namespace. Append it  
to the Document object. Put this element in the stack of open elements.

     (XXX: should SVG gain all the cache manifest stuff?)

     Let the secondary insertion mode be "after body", and then switch  
the insertion mode to "in foreign content".

  * Change 'in foreign content' as follows:
A start tag whose tag name is "meta"

     Adjust foreign attributes for the token.

     Insert a foreign element for the token, in the same namespace as  
the current node. Immediately pop the current node off the stack of  
open elements.

     If the token's self-closing flag is not set, this is a parse error.

     Acknowledge the token's self-closing flag, if it is set.

     If the element has a charset attribute, and its value is a  
supported encoding, and the confidence is currently tentative, then  
change the encoding to the encoding given by the value of the charset  
attribute.

     Otherwise, if the element has a content attribute, and applying  
the algorithm for extracting an encoding from a Content-Type to its  
value returns a supported encoding encoding, and the confidence is  
currently tentative, then change the encoding to the encoding encoding.

A start tag whose tag name is one of:  "b", "big", "blockquote",  
"body", "br", "center", "code", "dd", "div", "dl", "dt", "em",  
"embed", "h1", "h2", "h3", "h4", "h5", "h6", "head", "hr", "i", "img",  
"li", "listing", "menu", "nobr", "ol", "p", "pre", "ruby", "s",   
"small", "span", "strong", "strike",  "sub", "sup", "table", "tt",  
"u", "ul", "var"
A start tag whose tag name is "font", if the token has any attributes  
named "color", "face", or "size"
An end-of-file token

     (note that "meta" has been zapped from the list)

     Parse error.

     If the first element on the stack of open elements is in the HTML  
namespace, pop elements from the stack of open elements until the  
current node is in the HTML namespace, switch the insertion mode to  
the secondary insertion mode, and reprocess the token.

     Otherwise, let the 'old root' be the first element on the stack  
of open elements. Pop all the elements on the stack of open elements.  
Detach 'old root' from its parent (the document node). Create an  
'html' element in the HTML namespace. Append it to the Document  
object. Put this element in the stack of open elements. Insert an HTML  
element 'head'. Immediately pop the current node off the stack of open  
elements. Insert an HTML element 'body'. Append 'old root' to this  
element. Switch the insertion mode to 'in body', and reprocess the  
token.

  * Make an element with the local name 'meta' in the SVG namespace  
and with an attribute charset in no namespace conforming as a child of  
a root <svg> element in text/html.

  * The above formulation doesn't make it possible to declare text/ 
html character encoding with the XML syntax, because text/html  
encoding sniffing is crazy enough as is and letting the XML syntax  
change the encoding for existing XHTML-served-as-text/html pages could  
very well break stuff.

  * The above formulation requires <!DOCTYPE html> for <svg> root  
element, which *would be well-formed* but *not valid* in XML due to  
the html vs. svg name mismatch. Making an initial <svg> token imply  
the standards mode poses the problem of having to either stick to the  
standards mode with bogus content or changing the mode later in the  
parse back to quirks, which probably is something that shouldn't be  
done, since the mode will have affected CSS parsing by that time.

-- 
Henri Sivonen
hsivonen@iki.fi
http://hsivonen.iki.fi/

Received on Wednesday, 4 March 2009 11:58:57 UTC