haikuwebkit/LayoutTests/mathml/mrow-preferred-width-with-o...

22 lines
485 B
HTML
Raw Permalink Normal View History

Split layout of RenderMathMLRow into smaller steps https://bugs.webkit.org/show_bug.cgi?id=180348 Patch by Frederic Wang <fwang@igalia.com> on 2017-12-20 Reviewed by Manuel Rego Casasnovas. Source/WebCore: Currently, RenderMathMLRow mixes too many steps in the same layout functions: layout children, calculate stretch size, stretch vertical operators, calculate final ascent/descent, handle out-of-flow positioned children, set logical height, set logical width for non-display <math> tag, center display <math> tag etc This situation is inherited from the old flexbox implementation but it makes difficult to read the code and to re-use layout & metrics calculation for follow-up work on <mrow>-like elements (<menclose>, <mapdded>, <msqrt> or <math>). See for example bug 160547 for <math> or bug 161126 for <menclose>. This patch rewrites RenderMathMLRow into smaller steps: - stretchVerticalOperatorsAndLayoutChildren() which calls layoutIfNeeded() or insertPositionedObject() on children and stretch vertical operators. - getContentBoundingBox() to determine the metrics of the mrow-like element without calling layout on children or positioning them, so that we can improve mrow-like element in the future. - layoutRowItems() which sets the position of children. Setting the logical width/height or centering children is now moved into layoutBlock() since derived class overriding layoutBlock() will do their own adjustment for width, height and positions. Test: mathml/mrow-preferred-width-with-out-of-flow-child.html The rest of the behavior is unchanged and already covered by existing tests. * rendering/mathml/RenderMathMLMenclose.cpp: (WebCore::RenderMathMLMenclose::layoutBlock): Use the new function and get contentWidth directly from getContentBoundingBox(). * rendering/mathml/RenderMathMLPadded.cpp: (WebCore::RenderMathMLPadded::layoutBlock): Ditto. * rendering/mathml/RenderMathMLRoot.cpp: (WebCore::RenderMathMLRoot::layoutBlock): Ditto, also remove useless statement baseAscent = baseDescent. * rendering/mathml/RenderMathMLRow.cpp: (WebCore::toVerticalStretchyOperator): New helper function to cast to a vertical stretchy operator. (WebCore::RenderMathMLRow::stretchVerticalOperatorsAndLayoutChildren): New helper function to ensure layoutIfNeeded()/insertPositionedObject() is called on children and that the vertical operators are stretched. (WebCore::RenderMathMLRow::getContentBoundingBox const): New helper function to determine the width/ascent/descent to use for the mrow content. (WebCore::RenderMathMLRow::computePreferredLogicalWidths): Skip out-of-flow children in the preferred width calculation. This is verified by the new test. (WebCore::RenderMathMLRow::layoutRowItems): Only keep the positioning of children with the specified width and ascent. (WebCore::RenderMathMLRow::layoutBlock): Center children for <math display="block"> tag and set the logical width in other cases. Also set the logical height here. (WebCore::RenderMathMLRow::computeLineVerticalStretch): Deleted. This work is included in stretchVerticalOperatorsAndLayoutChildren() now. * rendering/mathml/RenderMathMLRow.h: Update declaration of functions. LayoutTests: New test to verify that out-of-flow positioned children are not taken into account in the calculation of the preferred width of the mrow element. * mathml/mrow-preferred-width-with-out-of-flow-child-expected.html: Added. * mathml/mrow-preferred-width-with-out-of-flow-child.html: Added. Canonical link: https://commits.webkit.org/196905@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226180 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-12-20 16:34:43 +00:00
<!DOCTYPE html>
<html>
<head>
<title>mrow preferred width with out-of-flow child</title>
</head>
<body>
<p>This test passes if the absolute positioned child is not taken in account in the preferred width computation. You'll see a blue rectangle of about 100px width.</p>
<table>
<tr>
<td style="background: blue">
<math>
<mspace width="100px"></mspace>
</math>
</td>
</tr>
</table>
</body>
</html>