COMMIT_MESSAGE (13/19)

 1Bug 133567 - Use OpenType MATH constant AxisHeight
 2

LayoutTests/ChangeLog

 12016-03-18 Frederic Wang <fwang@igalia.com>
 2
 3 Use OpenType MATH constant AxisHeight.
 4 https://bugs.webkit.org/show_bug.cgi?id=133567
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 We add a simple reftest to verify that the AxisHeight parameter
 9 is used to align the middle of <mtable> elements.
 10
 11 * mathml/opentype/axisheight7000.woff: Added.
 12 * mathml/opentype/table-align-axis-expected.html: Added.
 13 * mathml/opentype/table-align-axis.html: Added.
 14
1152016-03-17 Frederic Wang <fwang@igalia.com>
216
317 Add support for mathvariants that cannot be emulated via CSS.

LayoutTests/mathml/opentype/axisheight7000.woff

Binary file, nothing to see here

LayoutTests/mathml/opentype/table-align-axis-expected.html

 1<!DOCTYPE html>
 2<html>
 3 <head>
 4 <title>table align axis</title>
 5 <meta charset="utf-8">
 6 <style type="text/css">
 7 /* For Latin Modern Math
 8 AxisHeight = 7000 * 5 / 1000 = 35px;
 9 */
 10 @font-face {
 11 font-family: axisheight;
 12 src: url("axisheight7000.woff");
 13 }
 14 math {
 15 font-family: axisheight;
 16 font-size: 5px;
 17 }
 18 </style>
 19 </head>
 20 <body>
 21
 22 <div style="position: absolute; left: 0px; top: -35px;">
 23 <math>
 24 <mspace height="100px" depth="100px" width="1px" mathbackground="black"/>
 25 <mspace width="100px" height="2px" depth="2px" mathbackground="green"/>
 26 </math>
 27 </div>
 28
 29 </body>
 30</html>

LayoutTests/mathml/opentype/table-align-axis.html

 1<!DOCTYPE html>
 2<html>
 3 <head>
 4 <title>table align axis</title>
 5 <meta charset="utf-8">
 6 <style type="text/css">
 7 /* For Latin Modern Math
 8 AxisHeight = 7000 * 5 / 1000 = 35px;
 9 */
 10 @font-face {
 11 font-family: axisheight;
 12 src: url("axisheight7000.woff");
 13 }
 14 math {
 15 font-family: axisheight;
 16 font-size: 5px;
 17 }
 18 </style>
 19 </head>
 20 <body>
 21
 22 <!-- This test passes if the red bar is hidden by the green bar -->
 23 <div style="position: absolute; left: 0px; top: 0px;">
 24 <math>
 25 <mspace height="100px" depth="100px" width="1px"/>
 26 <mtable>
 27 <mtr><mtd><mspace width="50px"/></mtd></mtr>
 28 <mtr><mtd><mspace mathbackground="red" width="50px" height="1px" depth="1px"/></mtd></mtr>
 29 <mtr><mtd><mspace width="50px"/></mtd></mtr>
 30 </mfrac>
 31 </math>
 32 </div>
 33
 34 <!-- This green bar is moved up by AxisHeight and is a bit thicker than the red bar to tolerate rounding errors. -->
 35 <div style="position: absolute; left: 0px; top: -35px;">
 36 <math>
 37 <mspace height="100px" depth="100px" width="1px" mathbackground="black"/>
 38 <mspace width="100px" height="2px" depth="2px" mathbackground="green"/>
 39 </math>
 40 </div>
 41
 42 </body>
 43</html>

Source/WebCore/ChangeLog

 12016-03-18 Frederic Wang <fwang@igalia.com>
 2
 3 Use OpenType MATH constant AxisHeight.
 4 https://bugs.webkit.org/show_bug.cgi?id=133567
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Test: mathml/opentype/table-align-axis.html
 9
 10 We make RenderMathMLTable use the OpenType MATH constant AxisHeight.
 11 This is the only remaining case to handle since RenderMathMLFraction
 12 and RenderMathMLOperator already use that constant.
 13
 14 * rendering/mathml/RenderMathMLBlock.cpp: Make RenderMathMLTable use the math axis
 15 for its vertical alignment and update a bit the comments.
 16 (WebCore::axisHeight): Move the code in a static function that can be called by
 17 RenderMathMLBlock and RenderMathMLTable.
 18 (WebCore::RenderMathMLBlock::mathAxisHeight): Use axisHeight.
 19 (WebCore::RenderMathMLTable::firstLineBaseline): Ditto.
 20
1212016-03-17 Frederic Wang <fwang@igalia.com>
222
323 Add support for mathvariants that cannot be emulated via CSS.

Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp

@@bool RenderMathMLBlock::isChildAllowed(const RenderObject& child, const RenderSt
6767 return is<Element>(child.node());
6868}
6969
70 LayoutUnit RenderMathMLBlock::mathAxisHeight() const
 70static LayoutUnit axisHeight(const RenderStyle& style)
7171{
72  const auto& primaryFont = style().fontCascade().primaryFont();
 72 // If we have a MATH table we just return the AxisHeight constant.
 73 const auto& primaryFont = style.fontCascade().primaryFont();
7374 if (auto* mathData = primaryFont.mathData())
7475 return mathData->getMathConstant(primaryFont, OpenTypeMathData::AxisHeight);
7576
76  return style().fontMetrics().xHeight() / 2;
 77 // Otherwise, the idea is to try and use the middle of operators as the math axis which we thus approximate by "half of the x-height".
 78 // Note that Gecko has a slower but more accurate version that measures half of the height of U+2212 MINUS SIGN.
 79 return style.fontMetrics().xHeight() / 2;
 80}
 81
 82LayoutUnit RenderMathMLBlock::mathAxisHeight() const
 83{
 84 return axisHeight(style());
7785}
7886
7987LayoutUnit RenderMathMLBlock::mirrorIfNeeded(LayoutUnit horizontalOffset, LayoutUnit boxWidth) const

@@bool parseMathMLNamedSpace(const String& string, LayoutUnit& lengthValue, const
304312
305313Optional<int> RenderMathMLTable::firstLineBaseline() const
306314{
307  // In legal MathML, we'll have a MathML parent. That RenderFlexibleBox parent will use our firstLineBaseline() for baseline alignment, per
308  // http://dev.w3.org/csswg/css3-flexbox/#flex-baselines. We want to vertically center an <mtable>, such as a matrix. Essentially the whole <mtable> element fits on a
309  // single line, whose baseline gives this centering. This is different than RenderTable::firstLineBoxBaseline, which returns the baseline of the first row of a <table>.
310  return (logicalHeight() + style().fontMetrics().xHeight()) / 2;
 315 // By default the vertical center of <mtable> is aligned on the math axis.
 316 // This is different than RenderTable::firstLineBoxBaseline, which returns the baseline of the first row of a <table>.
 317 return Optional<int>(logicalHeight() / 2 + axisHeight(style()));
311318}
312319
313320void RenderMathMLBlock::layoutItems(bool relayoutChildren)