You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a MathML-input-conformant application receives input containing one or more elements with an illegal number or type of attributes or child schemata, it should nonetheless attempt to render all the input in an intelligible way, i.e., to render normally those parts of the input that were valid, and to render error messages (rendered as if enclosed in an merror element) in place of invalid expressions.
Gecko renders (not very useful) "invalid-markup" message
WebKit just layout a 0x0 box for the invalid subtree
I think the latter is more efficient and less code so I'd prefer it. Probably if we want to log errors, it should be in the console instead.
I certainly would not want error reporting to be placing any constraints on browsers here, so I'd agree to any wording here that tells authors not to produce bad markup, but basically authorises browsers to do whatever they find convenient if there is bad markup. If making a zero sized subtree works (could be made to work) for all the current implementations, specifying that to get interoperable behaviour would also be Ok I think.
Just for the record, there is a third option which is probably a bit more complicate to implement/describe but more aligned with to what people expect with CSS / HTML5: Add anonymous <mrow> elements (e.g. one for numerator and one for denominator for mfrac) to ensure that MathML elements have the right number of arguments.
The above example indicates that the implementations are trying to do something funny with various inputs which an implementation thinks is invalid.
I suggest removing these, and instead making sure that all the MathML algorithms can deal with the edge cases which developers might feed them.
(an alternative would be to strictly define, with algorithms, what type of DOM input is required, and the validation steps, however this would be prone to bugs, and compatibility issues).
This the a bit of a meta issue, however would need lots of tests with the "edge" cases for all of the different layout algorithms within MathML.
I'm not sure there is a canonical way to "fix" invalid markup (Ignore extra children? Add empty anonymous? Wrap a subset of children into anonymous containers?). My preference would be to align on WebKit's behavior as it's the easiest to specify/test/implement. This is already how we (at Igalia) implement it our Chromium branch and we would only have to fix Firefox. Basically, my proposal would be:
Add a section about invalid markup in MathML Core (maybe import from MathML 4 full), define the invalid constructions (essentially elements that don't have the expected number of children). There is probably an exception do make for mtable, until we clarify what the table layout is.
Say that invalid markup has intrinsize size of 0, the layout results as an empty 0x0 box and no painting.
Write testharness tests with all markup of the form <span style="display: inline-block"><math>INVALID MARKUP</math></span> as defined in (1) and ensure that the span has size 0 (intrinsic size) and that the "INVALID MARKUP" subtree has size 0x0. Write reftests checking that they don't paint anything (e.g. for fractions, roots...). Probably more tests involving valid and invalid subtrees. I believe we already have tests for invalid markup in Gecko and WebKit that we could "import". However, they would need to be tweaked a bit probably.
WebKits implementation causes issues in other areas of the browser. For example the "invalid" is still accessible from VoiceOver, etc.
This type of "easy" fixup produces technical debt in the codebase, and complexity later on which I'd be strongly opposed to adding in chromium.
Having said that one guiding principle that CSS usually follows is that it should attempt to display all content. This is probably a good principle for MathML to also follow.
I think that for display types which can only accept up to "N" children, inserting any additional children in an anonymous mrow type would be acceptable.
Add a section about invalid markup in MathML Core defining the invalid constructions. Essentially elements they have n children while they expect N != n children. If n < N, they append N - n anonymous empty mrow's. If n > N, they wrap the last N - n + 1 children into an anonymous mrow. An alternative is to always generate N anonymous children but that would lead to bigger render/layout trees and complexity for such elements (even when they are valid) and so is less optimal. Again, there is an exception to make for mtable, were the fixup is instead using anonymous mtr and mtd like in HTML.
In each section where we define elements, mention the expected number of children if appropriate (import from MathML 4 full) and link to the general section about how to fix it.
Write static reftests checking that invalid markup render the same as their "fixed" version. Also write dynamic versions where n varies between 0 and (at least) N + 2.
Implement the behavior for WebKit, Gecko and Chromium.
My main concern (in addition to adding more work) is how dynamic changes will be handled. In the past, WebKit generated some anonymous elements (sometimes two levels of nested anonymous e.g. for scripted elements) in the Renderer/Layout classes and set/remove anonymous style on them: That caused at best inconsistencies after dynamic changes and at worst asserts/crashes. Hopefully, this proposal is a bit safer and we could maybe even handle the Render/Layout tree fixup & reorganization from the DOM classes.
However, I agree that the proposed behavior would be more aligned with HTML5 / CSS (adding the label now btw) and more natural for users, so it's probably worth the added complexity/work.
I don't really like the alternative of "making sure that all the MathML algorithms can deal with the edge cases" as that makes the algorithm more complex and harder to read. For example, the advantage of WebKit's current implementation is that once we know an element is valid we can just call the children and associated variable numerator/denominator/base/superscript etc and that makes the algorithm (which is already relatively complex when we follow all TeX / Open Type MATH metrics) much easier to read and understand.
An alternative is to always generate N anonymous children but that would lead to bigger render/layout trees and complexity for such elements (even when they are valid) and so is less optimal.
Since VoiceOver was mentioned above, I however have to say that adding such anonymous children could help accessibility ( w3c/mathml#9 ). Typically,
mfrac
|_mfrac
|_mfrac
would become
mfrac
|_mrow
|__frac
|_mrow
|__frac
and then we can add roles numerator/denominator on the anonymous mrow's while still keeping roles fraction on the mfrac. Otherwise, this fixup would have to be done in the a11y tree.
I'm not sure what is left, but @bkardell pointed out this can't be closed until there is agreement from the other implementations that rendering as an mrow is ok with them -- they do something different now as pointed out in the initial comment.
Activity
davidcarlisle commentedon Feb 19, 2019
I certainly would not want error reporting to be placing any constraints on browsers here, so I'd agree to any wording here that tells authors not to produce bad markup, but basically authorises browsers to do whatever they find convenient if there is bad markup. If making a zero sized subtree works (could be made to work) for all the current implementations, specifying that to get interoperable behaviour would also be Ok I think.
[-]Handling of invalid markup interoperability[/-][+]Interoperable handling of invalid markup [/+]fred-wang commentedon Feb 22, 2019
Adding mathml4 label too, as we might want to adjust the behavior.
fred-wang commentedon Feb 25, 2019
cc @rwlbuis
fred-wang commentedon Feb 25, 2019
Just for the record, there is a third option which is probably a bit more complicate to implement/describe but more aligned with to what people expect with CSS / HTML5: Add anonymous
<mrow>elements (e.g. one for numerator and one for denominator formfrac) to ensure that MathML elements have the right number of arguments.fred-wang commentedon Feb 28, 2019
Quoting @bfgeek
fred-wang commentedon Feb 28, 2019
I'm not sure there is a canonical way to "fix" invalid markup (Ignore extra children? Add empty anonymous? Wrap a subset of children into anonymous containers?). My preference would be to align on WebKit's behavior as it's the easiest to specify/test/implement. This is already how we (at Igalia) implement it our Chromium branch and we would only have to fix Firefox. Basically, my proposal would be:
<span style="display: inline-block"><math>INVALID MARKUP</math></span>as defined in (1) and ensure that the span has size 0 (intrinsic size) and that the "INVALID MARKUP" subtree has size 0x0. Write reftests checking that they don't paint anything (e.g. for fractions, roots...). Probably more tests involving valid and invalid subtrees. I believe we already have tests for invalid markup in Gecko and WebKit that we could "import". However, they would need to be tweaked a bit probably.Putting this on the agenda of next meeting.
bfgeek commentedon Feb 28, 2019
WebKits implementation causes issues in other areas of the browser. For example the "invalid" is still accessible from VoiceOver, etc.
This type of "easy" fixup produces technical debt in the codebase, and complexity later on which I'd be strongly opposed to adding in chromium.
Having said that one guiding principle that CSS usually follows is that it should attempt to display all content. This is probably a good principle for MathML to also follow.
I think that for display types which can only accept up to "N" children, inserting any additional children in an anonymous mrow type would be acceptable.
E.g.
would render as:
@emilio @heycam
bfgeek commentedon Feb 28, 2019
@tabatkins also might have some good thoughts.
fred-wang commentedon Mar 1, 2019
So the alternative proposal would be:
My main concern (in addition to adding more work) is how dynamic changes will be handled. In the past, WebKit generated some anonymous elements (sometimes two levels of nested anonymous e.g. for scripted elements) in the Renderer/Layout classes and set/remove anonymous style on them: That caused at best inconsistencies after dynamic changes and at worst asserts/crashes. Hopefully, this proposal is a bit safer and we could maybe even handle the Render/Layout tree fixup & reorganization from the DOM classes.
However, I agree that the proposed behavior would be more aligned with HTML5 / CSS (adding the label now btw) and more natural for users, so it's probably worth the added complexity/work.
I don't really like the alternative of "making sure that all the MathML algorithms can deal with the edge cases" as that makes the algorithm more complex and harder to read. For example, the advantage of WebKit's current implementation is that once we know an element is valid we can just call the children and associated variable numerator/denominator/base/superscript etc and that makes the algorithm (which is already relatively complex when we follow all TeX / Open Type MATH metrics) much easier to read and understand.
fred-wang commentedon Mar 1, 2019
Since VoiceOver was mentioned above, I however have to say that adding such anonymous children could help accessibility ( w3c/mathml#9 ). Typically,
would become
and then we can add roles numerator/denominator on the anonymous mrow's while still keeping roles fraction on the mfrac. Otherwise, this fixup would have to be done in the a11y tree.
25 remaining items
NSoiffer commentedon Aug 3, 2020
w3c/mathml#175 was resolved with 'render as an mrow'.
I'm not sure what is left, but @bkardell pointed out this can't be closed until there is agreement from the other implementations that rendering as an mrow is ok with them -- they do something different now as pointed out in the initial comment.
NSoiffer commentedon Aug 17, 2020
@fred-wang: I don't think this can be closed unless you heard from other implementers as per @bkardell comment.
fred-wang commentedon Aug 21, 2020
Checking the discussions, it seems Mozilla and Apple are happy with the "render as mrow" approach, but let's see what @bkardell says.
NSoiffer commentedon Aug 21, 2020
For my benefit and the benefit of others that are interested in what was said by Mozilla and Apple, can you provide a link to the discussions?
fred-wang commentedon Aug 22, 2020
This was discussed in an Apple/Igalia private chat, but Brian will be able to explain.
About Mozilla, I don't have a link either but I'm pretty sure @emilio had mentioned several times in the past that having this error message layout was complicating things (I'll ping him again). I actually had written a WIP patch one year ago https://bugzilla.mozilla.org/show_bug.cgi?id=1583037
fred-wang commentedon Dec 8, 2022
Closing this bug:
There is also a WebKit bug to align with the spec: https://bugs.webkit.org/show_bug.cgi?id=123348