Skip to content
Permalink
Browse files
Refactor RenderMathMLFraction layout to avoid using flexbox
https://bugs.webkit.org/show_bug.cgi?id=153917

Patch by Frederic Wang <fwang@igalia.com> on 2016-04-11
Reviewed by Sergio Villar Senin.

Source/WebCore:

Based on a patch by Alejandro G. Castro <alex@igalia.com>

Implement the layoutBlock method to handle the layout calculations
directly in the class. This also fixes parsing of absolute values for
linethickness attribute (e.g. 10px) and adds support for the AxisHeight
and FractionRuleThickness MATH parameters.

Test: mathml/opentype/fraction-line.html

* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::mathLineThickness): Use the thickness relative to the
default line thickness since that's really what is expected by mathml-line-fraction.html
* css/mathml.css: Remove flexbox properties for mfrac.
(mfrac): Deleted.
(mfrac > *): Deleted.
(mfrac[numalign="left"] > :first-child): Deleted.
(mfrac[numalign="right"] > :first-child): Deleted.
(mfrac[denomalign="left"] > :last-child): Deleted.
(mfrac[denomalign="right"] > :last-child): Deleted.
(mfrac > :first-child): Deleted.
(mfrac > :last-child): Deleted.
(mfrac): Deleted.
* rendering/mathml/RenderMathMLBlock.cpp: Introduce a helper function to retrieve the math
axis height.
(WebCore::RenderMathMLBlock::mathAxisHeight):
* rendering/mathml/RenderMathMLBlock.h: Declare mathAxisHeight.
* rendering/mathml/RenderMathMLFraction.cpp:
(WebCore::RenderMathMLFraction::RenderMathMLFraction):
(WebCore::RenderMathMLFraction::parseAlignmentAttribute): Helper function to parse the align
attribute.
(WebCore::RenderMathMLFraction::isValid): Helper function to verify whether the child list
is valid with respect to the MathML specificitation.
(WebCore::RenderMathMLFraction::numerator): Helper function to retrieve the numerator.
(WebCore::RenderMathMLFraction::denominator): Helper function to retrieve the denominator.
(WebCore::RenderMathMLFraction::updateFromElement): Use the FractionRuleThickness parameter
when avaiable to calculate the default linethickness.
Fix computation of linethickness for absolute values (e.g. 10px), the default linethickness
must not be involved for such values.
We no longer need to manage style of anonymous wrappers.
(WebCore::RenderMathMLFraction::unembellishedOperator): Use the helper function and we no
longer care about anonymous wrappers.
(WebCore::RenderMathMLFraction::computePreferredLogicalWidths): Implement this function
without using flexbox.
(WebCore::RenderMathMLFraction::horizontalOffset): Helper function to get the horizontal
offsets of children depending of the alignment.
(WebCore::RenderMathMLFraction::layoutBlock): Implement this function without using flexbox.
(WebCore::RenderMathMLFraction::paint): Do not paint if the fraction is invalid. Use helper
function. Use the width of the renderer (instead of the one of the denominator) as the
length of the fraction bar.
(WebCore::RenderMathMLFraction::firstLineBaseline): Use the helper functions to get children
and axis height.
(WebCore::RenderMathMLFraction::paintChildren): Temporary function to remove in a
follow-up patch.
(WebCore::RenderMathMLFraction::fixChildStyle): Deleted. We no longer need to manage style
of anonymous wrappers.
(WebCore::RenderMathMLFraction::addChild): Deleted. We no longer need to manage
anonymous wrappers.
(WebCore::RenderMathMLFraction::styleDidChange): We no longer need to manage style of
anonymous wrappers.
(WebCore::RenderMathMLFraction::layout): Deleted.
* rendering/mathml/RenderMathMLFraction.h: Replace lineThickness with relativeLineThickness,
as needed by the accessibility code. Update function and members declarations.

LayoutTests:

* TestExpectations: No longer skip mathml/presentation/fractions-positions.html
* mathml/opentype/fraction-line-expected.html: Added. New test to verify AxisHeight and
FractionRuleThickness parameters.
* mathml/opentype/fraction-line.html: Added. New test to verify axis height and rule
thickness parameters.
* mathml/presentation/fractions-linethickness-expected.html: Adjust the test to be sure that
the default rule thickness is 1px.
* mathml/presentation/fractions-linethickness.html: Adjust the test to be sure that the
default rule thickness is 1px.
* platform/gtk/mathml/presentation/roots-expected.txt: Update reference to take into account
changes in the render tree.
* platform/ios-simulator/mathml/presentation/roots-expected.txt: Ditto
* platform/mac/TestExpectations: Mark fraction-line and fractions-linethickness as
possibly failing since these tests require Latin Modern Math to work reliably.
* platform/ios-simulator/TestExpectations: Ditto

Canonical link: https://commits.webkit.org/174555@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@199295 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
fred-wang committed Apr 11, 2016
1 parent ac4ba3c commit 116a2471db1603bc6b4c993fd579d3a41ddca293
@@ -1,3 +1,26 @@
2016-04-11 Frederic Wang <fwang@igalia.com>

Refactor RenderMathMLFraction layout to avoid using flexbox
https://bugs.webkit.org/show_bug.cgi?id=153917

Reviewed by Sergio Villar Senin.

* TestExpectations: No longer skip mathml/presentation/fractions-positions.html
* mathml/opentype/fraction-line-expected.html: Added. New test to verify AxisHeight and
FractionRuleThickness parameters.
* mathml/opentype/fraction-line.html: Added. New test to verify axis height and rule
thickness parameters.
* mathml/presentation/fractions-linethickness-expected.html: Adjust the test to be sure that
the default rule thickness is 1px.
* mathml/presentation/fractions-linethickness.html: Adjust the test to be sure that the
default rule thickness is 1px.
* platform/gtk/mathml/presentation/roots-expected.txt: Update reference to take into account
changes in the render tree.
* platform/ios-simulator/mathml/presentation/roots-expected.txt: Ditto
* platform/mac/TestExpectations: Mark fraction-line and fractions-linethickness as
possibly failing since these tests require Latin Modern Math to work reliably.
* platform/ios-simulator/TestExpectations: Ditto

2016-04-11 Commit Queue <commit-queue@webkit.org>

Unreviewed, rolling out r199290.
@@ -112,9 +112,6 @@ webkit.org/b/127860 [ Debug ] js/function-apply-aliased.html [ Skip ]
# This test verifies dynamic manipulation of the mroot and msqrt elements.
mathml/roots-removeChild.html [ ImageOnlyFailure ]

# There is a small 1px size difference but this will be fixed when we refactor completely RenderMathMLFraction.
mathml/presentation/fractions-positions.html [ Skip ]

# For now we ignore margin/padding/border properties of MathML renderers.
mathml/presentation/bug97990.html [ Skip ]

@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html>
<head>
<title>Fraction line (axis height and rule thickness)</title>
<meta charset="utf-8">
<style type="text/css">
math {
font-family: "Latin Modern Math";
font-size: 100px;
}
</style>
</head>
<body>

<div style="position: absolute; left: 0px; top: -25px;">
<math>
<mspace height="50px" depth="50px"/>
<mspace width="100px" height="2px" depth="2px" mathbackground="green"/>
</math>
</div>

</body>
</html>
@@ -0,0 +1,39 @@
<!DOCTYPE html>
<html>
<head>
<title>Fraction line (axis height and rule thickness)</title>
<meta charset="utf-8">
<style type="text/css">
/* For Latin Modern Math
AxisHeight = 250 * 100 / 1000 = 25px;
FractionRuleThickness = 40 * 100 / 1000 = 4px;
*/
math {
font-family: "Latin Modern Math";
font-size: 100px;
}
</style>
</head>
<body>

<!-- This test passes if the (red) fraction bar is hidden by the green bar -->
<div style="position: absolute; left: 0px; top: 0px;">
<math>
<mspace height="50px" depth="50px"/>
<mfrac mathcolor="red">
<mspace width="50px"/>
<mspace width="50px"/>
</mfrac>
</math>
</div>

<!-- This green bar is moved up by AxisHeight and has thickness height + depth = FractionRuleThickness. -->
<div style="position: absolute; left: 0px; top: -25px;">
<math>
<mspace height="50px" depth="50px"/>
<mspace width="100px" height="2px" depth="2px" mathbackground="green"/>
</math>
</div>

</body>
</html>
@@ -3,6 +3,15 @@
<head>
<title>fractions linethickness</title>
<meta charset="utf-8"/>
<style type="text/css">
/* For Latin Modern Math
FractionRuleThickness = 40 * 25 / 1000 = 1px;
*/
math {
font-family: "Latin Modern Math";
font-size: 25px;
}
</style>
</head>
<body>

@@ -20,7 +29,7 @@
gLineThick = 3.f;
-->

<math mathsize="32px">
<math>
<mfrac linethickness="0.33px"><mn>1</mn><mn>2</mn></mfrac>
<mfrac linethickness="1px"><mn>1</mn><mn>2</mn></mfrac>
<mfrac linethickness="3px"><mn>1</mn><mn>2</mn></mfrac>
@@ -3,11 +3,20 @@
<head>
<title>fractions linethickness</title>
<meta charset="utf-8"/>
<style type="text/css">
/* For Latin Modern Math
FractionRuleThickness = 40 * 25 / 1000 = 1px;
*/
math {
font-family: "Latin Modern Math";
font-size: 25px;
}
</style>
</head>
<body>

<!-- This should draw fraction bars of increasing thickness -->
<math mathsize="32px">
<math>
<mfrac linethickness="thin"><mn>1</mn><mn>2</mn></mfrac>
<mfrac linethickness="medium"><mn>1</mn><mn>2</mn></mfrac>
<mfrac linethickness="thick"><mn>1</mn><mn>2</mn></mfrac>

0 comments on commit 116a247

Please sign in to comment.