MathML Core

BlinkOn 11 - November, 2019
Sunnyvale, California
Γ(t)=0+xt1exdx=1tn=1(1+1n)t1+tn2πt(te)t{\Gamma(t)} = {\int_{0}^{+\infty} x^{t-1} e^{-x} dx} = {\frac{1}{t} \prod_{n=1}^\infty \frac{\left(1+\frac{1}{n}\right)^t}{1+\frac{t}{n}} } \sim {\sqrt{\frac{2\pi}{t}} \left(\frac{t}{e}\right)^t} Rob Buis (rbuis@)
Frédéric Wang (fwang@)
NISO logo Igalia Logo

Preface: Igalia

Book Cover: Sun Java Also Raises
A Parisian in good Spanish company

In a nutshell

View of the Tower of Hercules (A Coruña) and the surrounding area during sunrise. © Diego Delso, delso.photo, CC-BY-SA 4.0
world map of igalians
  • A Coruña, Galicia
  • Worker-owned company
  • ~90 people
  • Open Source/Standards
  • Browsers

Web Engines Hackfest

world map of igalians
Hacking
Talk
Breakout sessions
Restaurant
© Web Engines Hackfest, CC BY-SA 2.0

Chromium

  • ~30 active contributors (abhijeet, alexander, antonio, antía, caitlin, cathie, dape, fred, gyuyoung, henrique, ivan, jacobo, javi, jessica, joanie, joyee, julie, loren, maksim, mario, martin nick, oriol, rego, rob, sergio, shin, simon)
  • Main areas
    Chromium Logo
    • Accessibility
    • JavaScript/V8
    • Layout (CSS, MathML)
    • OnionSoup/s13n/CodeHealth
    • Ozone/Linux (Wayland, X11)
    • Scrolling

Web Standard
Committees

W3C logo
TC39 logo
  • ARIA WG (joanie)
  • CSS WG (brian, javi, oriol, rego)
  • MathML CG (brian, fred, rob)
  • TC39 (dan)

Chapter I: Project

Book cover: For whom the BEL tolls
Plans of a prodemocratic group in NW Spain

Fundraising

Implementation Roadmap

Screenshot of chromium-review issues with a mathml tag
  • Basic setup
  • Basic layout
  • Operator Dictionary
  • Stretchy operators:
  • Advanced style
  • HTML5 Compatibility
  • Upstreamed & shipped

Launching Features

Project Workflow

Diagram describing project workflow

Chapter II: Interop

Book Cover: A Farwel To ARM
Frederic's dramatic changes

MathML Core

Screenshot of mathml core spec
  • Fundamental subset
    • Ask CG members
    • Analyze tools & use statistics
  • Implementation details
    • TeX/OpenType layout
    • HTML5/CSS compatibility
  • Browser-driven
    • Gecko/WebKit/Blink
    • Web Platform Tests!
  • Extensible
    • MathMLElement IDL
    • CSS/Houdini
    • New MathML elements

Web Platform Tests

Implementation Report
  • ~2000 tests (1, 2, 3)
    • Math layout
    • Removed features
    • DOM/CSS interaction
  • Results (4)
    • Igalia's Blink: ~99%
    • Gecko: ~73%
    • WebKit: ~72%

Past implementations

Firefox/Gecko
2008
Firefox 3.6
Chrome/WebKit
2013
Chrome 23
Opera/Presto
2007
Chrome 76 with Presto's CSS rules

2019 implementations

Firefox/Gecko
July release
Firefox 68
Epiphany/WebKit
Build r249360
WebKitGTK dev build
Chromium/Blink
Igalia's Branch
Igalia's Chromium fork

Chapter III: Chromium

Book Cover: The old man and the C
Tumultuous story of a navigator

Changesets

Base Setup
  • Runtime flag
  • mathml.css
  • Element classes
  • New CSS
  • New DOM/IDL
Low-level API
  • Font parameters
  • Glyph stretching
  • Layout constraints
  • Ink metrics
MathML
  • Dictionary
  • Attributes
  • Painters
  • Layout utils
  • Layout classes

Base setup (1/2)

  • Runtime Enabled Feature
      name: "MathMLCore",
    status: "test",
  • Legacy support
    • virtual test suite
    • mathml-fallback.css
  • MathML Core tests and expectations
  • MathMLElement class
  • MathMLElement DOM/IDL
    • *EventHandlers
    • ElementCSSInlineStyle
    • HTMLOrForeignElement

Base setup (2/2)

  • CSS tweaks
    • mathml.css (e.g. default font-family)
    • StyleAdjuster (e.g. display: contents;)
  • mathvariant
    xt1ex, xt1ex, xt1ex, xt1ex
  • displaystyle and scriptlevel
    Γ(t)=1tn=1(1+1n)t1+tn{\Gamma(t)} = {\frac{1}{t} \prod_{n=1}^\infty \frac{\left(1+\frac{1}{n}\right)^t}{1+\frac{t}{n}} } , 1t 1n
  • display: math; (algo determined from tag name)

Low-level API (1/2)

  • Layout/Glyph constants: 2πt\sqrt{\frac{2\pi}{t}} 2πt\sqrt{\frac{2\pi}{t}} Subscript placement on a slanted integral
    FontPlatformData::GetHarfBuzzFace
  • Size variants and glyph stretching:
    ( ( (
    GraphicsContext::DrawText, passing a NGTextFragmentPaintInfo with a custom ShapeResultView/ShapeResult

Low-level API (2/2)

  • Layout constraints : ( te ) ( te )
    Parent, Stretchy, Non-Stretchy
    Target stretch sizes for NGConstraintSpace
  • Ink metrics: Fraction using block metrics VS ink metrics
    • Text box: (TextMetrics::actualBoundingBoxAscent/Descent)
    • All boxes: ink-over/ink-under baselines

MathML (1/4)

MathML Element classes
  • Group similar elements
  • Create/update layout objects
  • Parse/update attributes

MathML (2/4)

  • Map inherited style attributes
    • Existing ( dir, mathsize, mathcolor...)
    • Internal ( displaystyle, mathvariant, scriptlevel...)
  • Map length attributes
    • CSS length-%
    • 5 internal slots
  • Parse enumerated attributes (boolean attributes and operator's form attribute prefix/infix/postfix)
  • Dictionary for default operator attribute values
    • Key: (operator text, form)
    • Values: Lengths lspace, rspace and boolean flags
    • Optimization: Redundancy of values

MathML (3/4)

MathML layout and painter classes
  • Better classes with painting?
  • Rewrite operator stretching?
  • Use TableNG?
  • Derive from LayoutNGMixin<LayoutBlock>?

MathML (4/4)

MathML Algorithm classes
  • Use composition instead of inheritance
  • ComputeMinMaxSize()/Layout() as per the spec
  • Baselines, layout constraints, out-of-flow children, padding/border/margin...

Size Impact (2019-11-05)

Δsize
Linux Desktop chrome.stripped +284KB
deb archive +66KB
rpm archive +42KB
Android Native Code +82KB
Install +85KB
ΔLines
core/layout +4823
core/mathml +2876
core/css, core/style +1339
core/paint +298
platform/fonts, platform/graphics +268
core/dom, core/html, core/svg +56
Total +9660

Open Issues

  • MathML Refresh CG (MathML simplification, CSS clarifications, layout improvements, better test coverage)
  • LayoutNG
    • Tables
    • Legacy layout forced (SVG, print, multicol, editing)
  • Accessibility
    • ATK
    • NSAccessibility
    • MSAA / UI Automation?
  • Extensibility
    • Custom elements/layout
    • Expose more magic

Appendix: Demos

¿Questions?

crbug.com/6606

¡ 溜溜溜 !

Creative Commons License
Slide content is © Igalia S.L, CC-BY-SA 4.0 with the following exceptions:

The HTML slides are currently intended to be rendered with Igalia's Chromium build 2019/11/05, Latin Modern Math and STIX Two.