Bug 48105 - mathml in html sometimes incorrectly parsed
Summary: mathml in html sometimes incorrectly parsed
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL: http://mathjax.org
Keywords: HTML5
Depends on:
Blocks:
 
Reported: 2010-10-21 18:30 PDT by Sean Hogan
Modified: 2010-11-02 20:57 PDT (History)
6 users (show)

See Also:


Attachments
html5 test file with badly parsed mathml (2.39 KB, text/html)
2010-11-01 16:57 PDT, David Carlisle
no flags Details
file showing problem descibed in comment #2 (342 bytes, text/html)
2010-11-02 13:23 PDT, David Carlisle
no flags Details
Patch (2.72 KB, patch)
2010-11-02 14:03 PDT, James Simonsen
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sean Hogan 2010-10-21 18:30:11 PDT
1. visit https://eyeasme.com/Joe/MathML/HTML5_MathML_browser_test.html - there are several rendering errors
2. Look at Webkit's rendering of the Quadratic Formula - the denominator of the fraction is inline with the equation.
3. right-click on Webkit's rendering and then Inspect Element
4. the DOM for the Quadratic Formula (the output of Webkit's mathml parser) doesn't match the markup in the page
(though it does seem to match what gets rendered).

I've observed this in Webkit nightlies and the latest Chrome release (Vista and OS-X).
This effects MathJax which can over-ride the mathml rendering, but relies on the parser being correct.
Comment 1 David Carlisle 2010-11-01 16:57:37 PDT
Created attachment 72600 [details]
html5 test file with badly parsed mathml
Comment 2 David Carlisle 2010-11-01 16:58:35 PDT
I also see this in webkit nightlies (affecting native mathml rendering) and chrome 7 affecting generated DOM, thus further processing.

I attach a smaller test case, nested mrows apparently being the main culprit.

The first div in the attached file has

<math>
<mrow>
<mrow><mn>1</mn></mrow>
<mi>a</mi>
</mrow>
</math>

but the innerHTML of that div, as inserted into the second, is


<math> <mrow> <mrow><mn>1</mn></mrow></mrow> <mi>a</mi> </math>

and the <mi>a</mi> has moved out of its correct location in the tree.
Comment 3 Eric Seidel (no email) 2010-11-02 12:20:03 PDT
I don't see a single <mrow> in the attached example.  Can you be more clear as to what is wrong with the DOM in webkit in the attached example?
Comment 4 David Carlisle 2010-11-02 13:17:44 PDT
(In reply to comment #3)
> I don't see a single <mrow> in the attached example.  Can you be more clear as to what is wrong with the DOM in webkit in the attached example?

??? the full mathml expression (and the incorrect parse tree produced) is shown in comment #2. the attached example just wraps that in a complete html5 document for ease of testing.

there are two mrows one inside the other but the parser apparently terminates both mrows when the inner one ends, this is not related to  the mrow element, it appears that you get the same effect with any nested elements in foreign content (ie within math or svg)



David
Comment 5 David Carlisle 2010-11-02 13:23:00 PDT
Created attachment 72726 [details]
file showing problem descibed in comment #2

sorry! wrong file attached previously this s file intended in comment #2 and #4
Comment 6 James Simonsen 2010-11-02 14:03:44 PDT
Created attachment 72732 [details]
Patch
Comment 7 Adam Barth 2010-11-02 14:35:17 PDT
Comment on attachment 72732 [details]
Patch

Thanks.
Comment 8 David Carlisle 2010-11-02 14:58:46 PDT
(In reply to comment #7)
> (From update of attachment 72732 [details])
> Thanks.


thanks
Comment 9 WebKit Commit Bot 2010-11-02 20:57:05 PDT
Comment on attachment 72732 [details]
Patch

Clearing flags on attachment: 72732

Committed r71209: <http://trac.webkit.org/changeset/71209>
Comment 10 WebKit Commit Bot 2010-11-02 20:57:11 PDT
All reviewed patches have been landed.  Closing bug.