[webkit-dev] HTML5 Parsing & MathML

Alex Milowski alex at milowski.org
Wed Nov 3 03:37:18 PDT 2010


On Tue, Nov 2, 2010 at 7:55 AM, David Carlisle <d.p.carlisle at gmail.com> wrote:
>
> Personally I agree with you that this desire to make html elements forcibly
> close the surrounding math elements is entirely bogus, and it causes all sorts
> of problems in annotation-xml (where you really want nested html) but we failed
> to convince the html WG (or the html editor) of that and so ended up with a
> special case workaround for annotation-xml
>
> http://www.w3.org/Bugs/Public/show_bug.cgi?id=9887#c16
>
> sometimes you have to take what you can get:-)

I will take a look.

>
> However I don't agree that using the token elements as extension points is only
> necessary because of html parser strangeness, I think it leads to a cleaner
> design, and better fallback behaviour for systems that do not understand the
> foreign elements, in any case.
>

Uncle!  This will take some work to get working correctly with the
implementation in WebKit.  Right now, in XHTML documents with MathML,
we get non-token XHTML for free.  Within MathML token elements, this
won't necessarily be the case.  For example, the 'mo' element renderer
as currently implemented won't preserve child rendering objects.
We'll need to detect these situations and decide what to do.

It would have been nice if MathML 3 had a "foreign token" element or
indication via attribute typing so that we'd know that there is some
kind of non-MathML content children that should be rendering according
to the host language.  We'll now have to have some kind of de-facto
default set of rules that say that mixed content within a MathML is
identified and handled slightly differently (especially if it contains
things like SVG).

That is, we'll need to detect things like:

<math><mo> random text <svg> ... </svg>  more random text</mo></math>

While this example is rather pathological, it is still possible and
should render as a stack of line boxes wrapped in the inline-block for
the 'mo'.

Also, this:

<math><mtext> <div> ...</div> </mtext></math>

should be equivalent to the XHTML chunk:

<math xmlns='http://www.w3.org/1998/Math/MathML/'><div
xmlns='http://www.w3.org/1999/xhtml'>...</div></math>

Both of the above examples should work today but once we implement the
renderers for mtext/mi/mn etc. we'll need to take this "foreign
element" rendering into account.

-- 
--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


More information about the webkit-dev mailing list