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 implemenation 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

Here is a proposed roadmap with estimated full-time resource. On the one hand, testing and review might require additional work or waiting period. On the other hand, some tasks may be performed in parallel. Initial plan may be adjusted as we make progress or depending of the funds raised.

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:
`<msub>`

,`<msup>`

,`<msubsup>`

- 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`

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.