Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should we say that application/mathml+xml is a MIME type supported by browsers? #204

Open
fred-wang opened this issue Jul 31, 2023 · 7 comments

Comments

@fred-wang
Copy link
Contributor

fred-wang commented Jul 31, 2023

While checking Firefox reftests, I found the following one which is not passing in Chrome or WebKit:

mathml-type-supported.xhtml

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>Test mime type application/mathml+xml</title>
</head>
<body>
  <object type="application/mathml+xml" data="mathml-type-supported-ref.xml"
          style="position: absolute; top: 0; left: 0; background: red;
                 width: 100px; height: 100px;"/>
</body>
</html>
mathml-type-supported-ref.xml

<math xmlns="http://www.w3.org/1998/Math/MathML">
  <mspace style="position: absolute; top: 0; left: 0; background: green;"
          width="100px" height="100px" depth="0"/>
</math>

https://html.spec.whatwg.org/multipage/iframe-embed-object.html#attr-object-type says

If the type attribute is present and its value is not a type that the user agent supports, then the user agent may jump to the step below labeled fallback without fetching the content to examine its real type.

but there does not seem to be an official list of supported MIME type. Should we explicitly state that application/mathml+xml is supported? Not sure if this is still relevant now that we have MathML in HTML5.

The original Mozilla bug where this was requested is https://bugzilla.mozilla.org/show_bug.cgi?id=124709 ; this is more general than just support for the <object> attribute.

Searching in the source code:
It is in https://searchfox.org/mozilla-central/source/uriloader/exthandler/nsExternalHelperAppService.cpp#540
It's not in https://source.chromium.org/chromium/chromium/src/+/refs/heads/main:net/base/mime_util.cc
and not in https://searchfox.org/wubkat/source/Source/WebCore/platform/MIMETypeRegistry.cpp (webkit seems to have platform-dependent implementation)

@davidcarlisle
Copy link
Collaborator

That is the mime type registered for mathml so it would be good if it was supported whatever that means here

IANA registration
https://www.iana.org/assignments/media-types/application/mathml+xml

and media type definition

https://w3c.github.io/mathml-docs/mathml-media-types/#media-types-mathml

@bkardell
Copy link
Collaborator

Discussed in the meeting today and we believe the title of the issue is more general than the actual issue. It is a valid mime type, but is that the question or is this specifically WRT object?

@fred-wang
Copy link
Contributor Author

Yes, so more explanation:

There are many MIME types registered at IANA but not all are known by browsers. Unknown MIME types would typically make the browser trigger a "download file" or "open with..." menu. But files with known MIME types like application/xhtml+xml or image/svg+xml will be handled by the browser.

If an XML document is served with MIME type application/mathml+xml to the browser, should it be rendered it as a MathML formula instead of treating it as an unknown file?

And when opening a file with the "mml", should the browser map this file extension to application/mathml+xml and then render the document as MathML?

Currently, it seems support for application/mathml+xml was only implemented in Firefox (in https://bugzilla.mozilla.org/show_bug.cgi?id=124709). WebKit-based and Chromium-based browsers don't know about it. application/mathml-presentation+xml is not supported by any browser.

A reftest was added in Firefox to check this support and relying on <object> is just how the test is written.

@dginev
Copy link

dginev commented Jul 31, 2023

It would be useful to have clear guidelines how (if at all?) one should embed MathML Core in HTML5 - both in terms of getting an embedded formula to render, as well as for allowing it to be "interactive" via scripting.

I thought there was more clarity around SVG, but apparently one can in practice use all three of <iframe>, <object> and <embed> for embedding an SVG (with a CSS animation). Stranger still, for the <embed> and <object> variations that demonstration works well in both Chrome and Firefox having set type="". I suspect the browser is taking advantage of the request to the SVG URL clearly returning a resource with Content-Type: image/svg+xml. Not sure what conclusions (if any) one can draw from that...

@NSoiffer
Copy link
Contributor

NSoiffer commented Aug 1, 2023

In general, we've had a rule of thumb that MathML and SVG live in parallel worlds. So if something works for SVG (and isn't considered a bug), then it should work for MathML.

With that in mind, unless what @dginev wrote is considered incorrect behavior, then <iframe>, <object>, and <embed> should work for MathML.

@fred-wang fred-wang changed the title Should we say that application/mathml+xml is a valid MIME type? Should we say that application/mathml+xml is a MIME type supported by browsers? Aug 4, 2023
@fred-wang
Copy link
Contributor Author

Not sure if this is still relevant now that we have MathML in HTML5.

To be clear, I meant in the past it was only possible to use MathML in XML document so probably the options were:

  1. Write your whole page as XHTML so you can put MathML inside.
  2. Write your page as HTML but embed some XML markup with the MathML content.

Now that MathML is in HTML5 I suppose (2) has become obsolete and moreover it was not helping with our "math is text" goal (cf issues we've long been discussed when using images for mathematical formulas). I believe that's also a situation where SVG is quite different from MathML, as editing a standalone SVG image and inserting it as an <img> is a much more standard and accepted practice.

Incidentally, if for some reason one really wants to insert MathML via <iframe>, <object>, and <embed> etc then they can just do it via a HTML5 document with a single <math> tag, my question here is really about the MIME type.

https://w3c.github.io/mathml-docs/mathml-media-types defines three MIME types and I guess it's fine for XML equation editors, generators etc But the question is whether we really need this MIME type to be recognized by browsers these days?

My comment as an implemeter:

  1. If there isn't a strong motivation, I foresee difficulty to get patches accepted in WebKit/Chrome, even if they can be small.
  2. If there is still some reason to keep them, it might be difficult to unship that from Firefox.
  3. I see an interop issue here, so I'd like to have this clarified in the spec and a test added to WPT.

@dginev
Copy link

dginev commented Feb 2, 2024

@fred-wang the main discussion during the MathML 4 charter involving MathML MIME types has been about enabling a math-aware clipboard. That was summarized in a new note document and video for TPAC 2022. I recall I tried to open a discussion on whether there may be a possibility to use the text/html MIME type for <math> copy/paste, and - if I remember correctly - the sentiment was that we are currently closer to SVG in what browsers might implement.

Since we don't have browser vendors on the calls, I think we may not have the freshest sentiments available.

(Edit: retracting some details that I am not fully informed on.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants