Bug 151592

Summary: Find a replacement for -webkit-line-box-contain in mathml.css
Product: WebKit Reporter: Frédéric Wang (:fredw) <fred.wang>
Component: MathMLAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: ahmad.saleem792, alex, bfulgham, cfleizach, darin, jfernandez, mrobinson
Priority: P2    
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
Bug Depends on: 43819, 131839, 153991, 155433    
Bug Blocks:    

Description Frédéric Wang (:fredw) 2015-11-24 13:27:05 PST
In http://trac.webkit.org/changeset/124512, David Barton added the following CSS properties to avoid excessive line spacing in MathML expressions:

math { 
  -webkit-line-box-contain: glyphs replaced; 
  line-height: 0; 
} 
mtext { 
  line-height: 1.0; 
}

(the "line-height: 0;" has been removed since then, but the one for mtext preserved)

I suspect this is no longer necessary with OpenType math fonts setting the USE_TYPO_METRICS flag now that it is supported by WebKit (bug 131839). However, it's probably good to reset some CSS spacing properties, for example an issue was reported in Wikipedia for Gecko, see https://bugzilla.mozilla.org/show_bug.cgi?id=1187673.

So I'd suggest to replace the above rules with just:

math {
  line-height: normal;
  word-spacing: normal;
  letter-spacing: normal;
}

Related to that is the list of math fonts in the font-family rule. Apple engineer will still have to upgrade the pre-installed STIX fonts to version 2.0 when it is released before we can update the default font-family. As a comparison, the latest Gecko release use the following list of math fonts: "Latin Modern Math, XITS Math, Cambria Math, TeX Gyre Bonum Math, TeX Gyre Pagella Math, TeX Gyre Schola, TeX Gyre Termes Math, STIX Math, Asana Math, STIXGeneral, DejaVu Serif, DejaVu Sans, serif"
Comment 1 Frédéric Wang (:fredw) 2015-11-24 13:32:27 PST
(I forgot to mention that the -webkit-line-box-contain property was removed from Blink, so it's probably good to avoid relying on it anyway: https://code.google.com/p/chromium/issues/detail?id=522215)
Comment 2 Frédéric Wang (:fredw) 2016-02-05 00:59:49 PST
@Alex: I've done the proposed adjustment on your MathML branch, except that I kept "-webkit-line-box-contain: glyphs replaced;". Indeed, removing that one causes excessive ascent/descent and breaks tests. Upgrading the math test font to a version that has the USE_TYPO_METRICS flag gives a better result (see https://github.com/mrobinson/webkitgtk-test-fonts/issues/6) ; but using logical metrics still gives slightly taller ascent/descent than ink metrics [1]. So I suspect we will have to keep it for now and consider that again when the MathML layout code can really distinguish between logical/ink metrics. We will probably have to do something similar to Gecko (which does not support -webkit-line-box-contain) if we want to port the MathML code to Blink.

[1] http://www.mathml-association.org/MathMLinHTML5/S3.html#SS1.SSS1
Comment 3 Frédéric Wang (:fredw) 2016-03-14 06:06:11 PDT
I moved the safe changes into bug 155433 and bug 155018. Let's keep this bug for the -webkit-line-box-contain rule only.