While working on MathML support in WebKit in 2016, Igalia has regularly been in touch with Google engineers involved in Chromium layout developments. Following the technical discussions, there is now a general agreement on the way to proceed the implementation. The general technical agreement is based on two important premises.

The proposed implementation focuseson the MathML rendering described in this implementation note which extends MathML with some rules from the MATH table of the Open Font Format and from the TeXBook’s Appendix G. and which focuses on good integration in HTML5 technologies and in web engines.

As a consequence, it becomes much easier to write conformance tests that can be automatically executed in web engines. Tests for that implementation note have already been integrated into the official W3C’s web-platform-tests in order to ensure consistent rendering in Gecko, WebKit or any other web engines compatible with that test framework. This approach has been already successful for Gecko and WebKit developments.

The implementation will be done directly in Blink. We will rely on the existing C++ implementation of Houdini as well as other non-exposed features (e.g. HarfBuzz OpenType MATH support). Houdini is a set of specifications providing APIs to allow web authors to implement their own custom layout and rendering.

Additionally, we identified and discussed with Google the following basic features required to build a proper MathML implementation:

- Creating MathML element classes
- Custom layout of MathML boxes using LayoutNG
- Parsing of attributes
- Reading the MathML Operator Dictionary
- Painting of graphical elements
- Shaping large and stretchy operators
- Support mathvariant transforms of text

During the project we will consider introducing new APIs or CSS features to support these features and they could be used as a foundation for future higher-level implementation in Chromium. That way this will ensure long-term alignment with Google’s layout goals.

This initial plan would be covered by the primary sponsor NISO.

We will create basic classes for the following MathML elements as well as simple layout using LayoutNG. Right-to-left and vertical layout should be taken into account from the beginning.

- Simple grouping
`<math>`

(with its`display`

attribute),`<mrow>`

,`<mstyle>`

,`<merror>`

(with special CSS style),`<mpadded>`

,`<mphantom>`

(with`visibility: hidden`

),`<menclose>`

. - Simple text container:
`<mi>`

,`<mn>`

,`<mo>`

,`<mtext>`

and`<ms>`

. - Simple spacing:
`<mspace>`

element with`width`

,`depth`

,`height`

attributes. `dir`

,`mathcolor`

,`mathbackground`

and`mathsize`

attributes- Simplified
`semantics`

: just display the first child and hide annotations.

We will create partial implementation of some layout elements. Some, but not all OpenType MATH constants will be used. During this step, `displaystyle`

is assumed to be true while `scriptlevel`

is not incremented.

- Fraction (
`<mfrac>`

), with its`linethickness`

attribute. - Postscripts:
`<msub>`

,`<msup>`

,`<msubsup>`

- Under and over scripts:
`<munder>`

,`<mover>`

,`<munderover>`

- Multiple pre and post scripts:
`<mmultiscripts>`

- Basic HTML-like implementation of
`mtable`

. - Advanced Spacing:
`mpadded`

with simplified interpretation of`width`

,`depth`

,`height`

,`lspace`

and`voffset`

.

We will import the operator dictionary from WebKit and implement the following `<mo>`

attributes:

`form`

(for selecting an entry in the dictionary)`accent`

,`largeop`

and`movablelimits`

(to perform spacing in under and over scripts)`lspace`

and`rspace`

(to perform spacing in`<mrow>`

-like elements).

This is an important step during which the following tasks will be performed:

- Shaping large and stretchy operators using the
`MathVariants`

table. See this blog post for a shaping algorithm. - Drawing of
`largeop`

operators in under and over scripts (again, we assume`displaystyle`

to be true for now). - Stretch logic in
`<mrow>`

-like elements and under and over scripts. - Using
`stretchy`

and`symmetric`

attributes. - Simple embellished operators
- Roots (
`msqrt`

,`mroot`

): Some, but not all OpenType MATH constants will be used. During this step,`displaystyle`

is assumed to be true while`scriptlevel`

is not incremented.

The following attributes will be considered:

`mathvariant`

`displaystyle`

`scriptlevel`

Depending on the other sponsors and the funds raised the following tasks, in no particular order, might be covered as part of this project.

MathML standard has been stalled for a while, with the new implementation in Chromium it seems a right moment to revive the standardization work around it.

- Gather interest from standards bodies participants about the specification.
- Create some group of people willing to work on a new version of the MathML standard.
- Reduce the gap between MathML specification and the different implementations by integrating the MathML in HTML5 Implementation Note into it.
- Extract a core subset of MathML for browser implementers and provide polyfills of deprecated features for backward compatibility.
- Collaborate with the CSS WG and ARIA WG to define features needed for MathML layout and accessibility.

Igalia would contribute to the different browser engines that support MathML (Firefox and Safari/WebKit) to improve interoperability between the different implementations and provide a proper maintenance of the feature.

Different tasks will be part of this work:

- Create more shared tests in the official W3C’s web-platform-tests repository and synchronize it with existing Firefox/WebKit test suites.
- Submit patches to Firefox and WebKit to clean up existing implementations and improve interoperability.
- Fix any security issues and maintain current MathML implementations in browsers.
- Experiment long-term transition to higher-level Houdini-based implementation in Chromium with particular attention to preserve good test success rate and performance.

Additional features and bug fixes might be considered if time permits. For example:

`href`

: To do hyperlinks.`menclose`

: To draw special notations (important ones such as horizontal strike).`mtable`

: Extra attributes for spacing or alignments.- OpenType
`ssty`

feature to adjust the size of pre-scripted operators.

`mfenced`

, `mglyph`

, `maction`

or elementary math will not be considered in this project.