Bug 123348

Summary: [MathML] Layout invalid markup as an <mrow>
Product: WebKit Reporter: Brent Fulgham <bfulgham>
Component: MathMLAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: ahmad.saleem792, alex, fred.wang, mrobinson, webkit-bug-importer
Priority: P2 Keywords: InRadar, WPTImpact
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
See Also: https://bugs.webkit.org/show_bug.cgi?id=254093
Bug Depends on: 153991    
Bug Blocks: 195797    
Attachments:
Description Flags
testcase none

Description Brent Fulgham 2013-10-25 11:04:59 PDT
Currently, certain invalid MathML documents (such as a MathML document containing arbitrary HTML markup) is rendered improperly.  According to the MathML specification, we should be providing better error information.

From http://www.w3.org/TR/MathML3/chapter6.html), Section 6.4 Combining MathML and Other Formats:

"In the standard schema, elements from other namespaces are not allowed, but attributes from other namespaces are permitted. MathML processors that encounter unknown XML markup should behave as follows:

An attribute from a non-MathML namespace should be silently ignored.
An element from a non-MathML namespace should be treated as an error, except in an annotation-xml element. If the element is a child of a presentation element, it should be handled as described in Section 3.3.5 Error Message <merror>. If the element is a child of a content element, it should be handled as described in Section 4.2.9 Error Markup <cerror>.

For example, if the second child of an mfrac element is an unknown element, the fraction should be rendered with a denominator that indicates the error."
Comment 1 Martin Robinson 2013-10-25 13:55:49 PDT
I looked at the torture tests in WebKitGTK+ and they seem fine.
Comment 2 Brent Fulgham 2013-10-25 16:32:06 PDT
See also http://www.whatwg.org/specs/web-apps/current-work/multipage/the-map-element.html#mathml:

"User agents must act as if any MathML element whose contents does not match the element's content model was replaced, for the purposes of MathML layout and rendering, by an merror element in the MathML namespace containing some appropriate error message."
Comment 3 Frédéric Wang (:fredw) 2013-10-27 05:25:03 PDT
Created attachment 215269 [details]
testcase
Comment 4 Brent Fulgham 2013-10-28 09:34:34 PDT
(In reply to comment #1)
> I looked at the torture tests in WebKitGTK+ and they seem fine.

I think this comment was intended for Bug 121728. :-)
Comment 5 Frédéric Wang (:fredw) 2016-03-14 03:58:56 PDT
At the moment, the choice in the in-progress MathML refactoring is just to not display anything for invalid markup. However, we may do something as in Gecko and the refactoring will make that much easier. So I'm making this depends on bug 153991.

(That said, I suspect we want to spend more time on supporting valid markup than on deciding a fallback rendering for invalid markup...)
Comment 6 Frédéric Wang (:fredw) 2022-08-30 02:54:56 PDT
Renaming the bug. MathML Core says to render invalid markup as an mrow, for example:

"If the <mfrac> element has less or more than two in-flow children, its layout algorithm is the same as the <mrow> element. Otherwise, the first in-flow child is called numerator, the second in-flow child is called denominator and the layout algorithm is explained below."

Chromium does that, and there is a plan for Firefox to align with that behavior.
Comment 7 Radar WebKit Bug Importer 2022-08-30 09:51:35 PDT
<rdar://problem/99335890>
Comment 8 Frédéric Wang (:fredw) 2022-12-08 05:34:25 PST
Firefox 106 and Chrome 109 implements the "mrow fallback" behavior described in the MathML Core specification and there is a WPT test for that: https://wpt.fyi/results/mathml/presentation-markup/mrow/mrow-fallback.html