[webkit-dev] HTML5 Parsing & MathML

Adam Barth abarth at webkit.org
Fri Oct 1 12:52:01 PDT 2010


Our parser follows the spec (modulo late-breaking spec changes that we
haven't picked up yet).  The different namespaces can only be nested
in certain ways, unlike in XML where arbitrary nesting is possible.

Adam


On Fri, Oct 1, 2010 at 12:46 PM, Alex Milowski <alex at milowski.org> wrote:
> I'm curious as to what the current HTML5 parser does when MathML
> and SVG are mixed.  In a recent review of MathML 3 I made the comment
> that this kind of markup, in XHTML, works just fine:
>
>  <math xmlns="ttp://www.w3.org/1998/Math/MathML">
>      <mfrac>
>          <svg .. >happy smilely..</svg>
>          <mrow>
>               <svg .. >happy smilely..</svg>
>               <mo>+</mo>
>               <svg .. >unhappy smilely..</svg>
>          </mrow>
>      </mfrac>
>   </math>
>
> Yet, it does not seem to be blessed by MathML3 as valid or allowed.  I'm
> still debating that restriction with others.  Note that the svg elements would
> need to have the SVG namespace declared and used somehow.
>
> In HTML5, the namespace declarations and use for MathML or
> SVG wouldn't be required (or really allowed).
>
> <div>
> <math>
>      <mfrac>
>          <svg .. >happy smilely..</svg>
>          <mrow>
>               <svg .. >happy smilely..</svg>
>               <mo>+</mo>
>               <svg .. >unhappy smilely..</svg>
>          </mrow>
>      </mfrac>
>   </math>
> </div>
>
> So, my question is:  What does webkit do?
>
> >From reading the section on "in foreign content' [1], it would seem that it
> should assign the 'svg' elements to the MathML namespace when they
> are embedded as above.  That means cutting and pasting the same
> content fragment gives two very different interpretations--which is more
> of a problem for the HTML5 spec than webkit.
>
> I've looked at HTMLTreeBuilder.cpp and it looks like it will assign
> all child elements to the MathML namespace.  That's not 100%
> correct as the 'annotation-xml' has a special case for SVG
> annotations.
>
> >From a browser perspective, when you are using the XHTML syntax,
> you can compose elements from different namespaces--embedding
> them as above--and it does work.  In fact, the above kind of embedding
> of SVG as direct actors in rendering a fraction works right now in
> WebKit.  That is, of course, an unsanctioned behavior.
>
> [1] http://dev.w3.org/html5/spec/Overview.html#parsing-main-inforeign
>
> --
> --Alex Milowski
> "The excellence of grammar as a guide is proportional to the paucity of the
> inflexions, i.e. to the degree of analysis effected by the language
> considered."
>
> Bertrand Russell in a footnote of Principles of Mathematics
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
>


More information about the webkit-dev mailing list