Bug 127932 - WebKit does not render namespaced MathML
Summary: WebKit does not render namespaced MathML
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: MathML (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2014-01-30 12:05 PST by James Craig
Modified: 2014-01-31 10:22 PST (History)
4 users (show)

See Also:


Attachments
test case (6.54 KB, text/html)
2014-01-30 12:05 PST, James Craig
no flags Details
screen shot (45.00 KB, image/png)
2014-01-30 12:22 PST, James Craig
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description James Craig 2014-01-30 12:05:26 PST
WebKit does not render namespaced MathML

Plain MathML in HTML, with no name-spacing (e.g. <math><mfrac>) is rendered correctly.
MathML with name-spacing (e.g. <m:math><m:mfrac>) is ignored.

Pearson is currently using the namespaced version exclusively, so this means MathML content is not viewable as such in any WebKit-based rendering context.
Comment 1 James Craig 2014-01-30 12:05:57 PST
Created attachment 222706 [details]
test case
Comment 2 James Craig 2014-01-30 12:10:25 PST
<rdar://problem/15949278>
Comment 4 James Craig 2014-01-30 12:22:15 PST
Created attachment 222711 [details]
screen shot
Comment 5 James Craig 2014-01-30 12:28:45 PST
In the meantime, Pearson could work around this pretty easily by converting their tagnames to ditch the namespaces.
Comment 6 Alexey Proskuryakov 2014-01-30 17:05:30 PST
Another workaround would be to serve an XML MIME type.

I don't think that this test case is valid - one must use namespaces in XML, but must not use them in HTML.
Comment 7 James Craig 2014-01-30 19:06:11 PST
(In reply to comment #6)
> Another workaround would be to serve an XML MIME type.

That works, but seems like an overly academic distinction. WebKit clearly knows that this is MathML and how to render this. We should just render it. Throw an error in the console or in a validator, but don't prevent the content from rendering.

> I don't think that this test case is valid - one must use namespaces in XML, but must not use them in HTML.

Possibly not, but that's a new distinction in HTML5. I can change the DOCTYPE of the test case to XHTML and make it valid.

Most of the Web is invalid tag soup and WebKit renders that fine. Namespaced MathML in HTML is a pretty clear case where we can improve the output even if the input isn't exactly what was anticipated.
Comment 8 James Craig 2014-01-30 19:10:25 PST
(In reply to comment #7)
> I can change the DOCTYPE of the test case to XHTML and make it valid.

Before someone calls me on this claim, it would take a few more changes to make *this* particular example valid XHTML, but I believe my general point stands.

WebKit knows that this is MathML and how to render this, so it should just render it. Throw an error in the console or in a validator, but don't prevent the content from rendering.
Comment 9 Alexey Proskuryakov 2014-01-30 21:00:38 PST
> Possibly not, but that's a new distinction in HTML5. 

This is not accurate, HTML5 codified existing behavior that all browsers had. There are some minor aspects that were new in HTML5, but certainly not anything that drastic.

> WebKit knows that this is MathML and how to render this, so it should just render it. Throw an error in the console or in a validator, but don't prevent the content from rendering.

This is not an argument that is likely to convince many people at this point. Browser engines were thinking like this for many years, and the amount of pain that caused is exactly why we need well defined parsing and error handling.

Adding knowledge of XML namespace syntax to HTML parser is certain to cause extreme pain, such as compatibility and security bugs unique to WebKit, and inability to implement future standard features.

Thinking about this more, this is not something we should even keep open as a bug. Please raise this as an issue with HTML5 if you'd like this changed.
Comment 10 James Craig 2014-01-31 10:06:06 PST
For what it's worth, I'm not suggesting we adopt all XML parsing rules in HTML. I'm just stating that certain XML languages (MathML and SVG in particular) are valid natively inside HTML, so it seems like an easy win to allow them to render in either their XML or HTML form.

I have too many issues with HTML5 to fight this one though, so I'll drop it.
Comment 11 Frédéric Wang (:fredw) 2014-01-31 10:22:13 PST
FYI, the testcase does not work in Gecko either. The reference of the MathML2 you give is for XML documents. I agree with Alexey that the point of HTML5 is to define clear behaviors and the spec says that in the HTML syntax, prefixes and namespace declarations do *not* have the same effect as in XML: http://www.w3.org/TR/html5/infrastructure.html#mathml-namespace. I don't think the authors are likely to change that, since one of the reason for integrating MathML/SVG in HTML5 was to eliminate the XML syntax...