Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
Showing
with
701 additions
and 471 deletions.
- +23 −0 LayoutTests/ChangeLog
- +0 −3 LayoutTests/TestExpectations
- +23 −0 LayoutTests/mathml/opentype/fraction-line-expected.html
- +39 −0 LayoutTests/mathml/opentype/fraction-line.html
- +10 −1 LayoutTests/mathml/presentation/fractions-linethickness-expected.html
- +10 −1 LayoutTests/mathml/presentation/fractions-linethickness.html
- +168 −178 LayoutTests/platform/gtk/mathml/presentation/roots-expected.txt
- +4 −0 LayoutTests/platform/ios-simulator/TestExpectations
- +175 −185 LayoutTests/platform/ios-simulator/mathml/presentation/roots-expected.txt
- +4 −0 LayoutTests/platform/mac/TestExpectations
- +70 −0 Source/WebCore/ChangeLog
- +1 −1 Source/WebCore/accessibility/AccessibilityRenderObject.cpp
- +1 −27 Source/WebCore/css/mathml.css
- +9 −0 Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp
- +2 −0 Source/WebCore/rendering/mathml/RenderMathMLBlock.h
- +133 −63 Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp
- +29 −12 Source/WebCore/rendering/mathml/RenderMathMLFraction.h
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.