COMMIT_MESSAGE (02/20)

 1Bug 153917 - Refactor RenderMathMLFraction layout to avoid using flexbox
 2

LayoutTests/ChangeLog

112016-03-03 Frederic Wang <fwang@igalia.com>
22
 3 Refactor RenderMathMLFraction layout to avoid using flexbox
 4 https://bugs.webkit.org/show_bug.cgi?id=153917
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * TestExpectations: No longer skip mathml/presentation/fractions-positions.html
 9 * mathml/opentype/fraction-line-expected.html: Added. New test to verify AxisHeight and
 10 FractionRuleThickness parameters.
 11 * mathml/opentype/fraction-line.html: Added. New test to verify axis height and rule
 12 thickness parameters.
 13 * mathml/presentation/fractions-linethickness-expected.html: Adjust the test to be sure that
 14 the default rule thickness is 1px.
 15 * mathml/presentation/fractions-linethickness.html: Adjust the test to be sure that the
 16 default rule thickness is 1px.
 17 * platform/gtk/mathml/presentation/roots-expected.txt: Update reference to take into account
 18 changes in the render tree.
 19 * platform/mac/TestExpectations: Mark fraction-line-expected and fractions-linethickness as
 20 possibly failing since these tests require Latin Modern Math to work reliably.
 21
 222016-03-03 Frederic Wang <fwang@igalia.com>
 23
324 Refactor RenderMathMLUnderOver layout functions to avoid using flexbox
425 https://bugs.webkit.org/show_bug.cgi?id=153742
526

LayoutTests/TestExpectations

@@webkit.org/b/127860 [ Debug ] js/function-apply-aliased.html [ Skip ]
112112# This test verifies dynamic manipulation of the mroot and msqrt elements.
113113mathml/roots-removeChild.html [ ImageOnlyFailure ]
114114
115 # There is a small 1px size difference but this will be fixed when we refactor completely RenderMathMLFraction.
116 mathml/presentation/fractions-positions.html [ Skip ]
117 
118115# For now we ignore margin/padding/border properties of MathML renderers.
119116mathml/presentation/bug97990.html [ Skip ]
120117

LayoutTests/mathml/opentype/fraction-line-expected.html

 1<!DOCTYPE html>
 2<html>
 3 <head>
 4 <title>Fraction line (axis height and rule thickness)</title>
 5 <meta charset="utf-8">
 6 <style type="text/css">
 7 math {
 8 font-family: "Latin Modern Math";
 9 font-size: 100px;
 10 }
 11 </style>
 12 </head>
 13 <body>
 14
 15 <div style="position: absolute; left: 0px; top: -25px;">
 16 <math>
 17 <mspace height="50px" depth="50px"/>
 18 <mspace width="100px" height="2px" depth="2px" mathbackground="green"/>
 19 </math>
 20 </div>
 21
 22 </body>
 23</html>

LayoutTests/mathml/opentype/fraction-line.html

 1<!DOCTYPE html>
 2<html>
 3 <head>
 4 <title>Fraction line (axis height and rule thickness)</title>
 5 <meta charset="utf-8">
 6 <style type="text/css">
 7 /* For Latin Modern Math
 8 AxisHeight = 250 * 100 / 1000 = 25px;
 9 FractionRuleThickness = 40 * 100 / 1000 = 4px;
 10 */
 11 math {
 12 font-family: "Latin Modern Math";
 13 font-size: 100px;
 14 }
 15 </style>
 16 </head>
 17 <body>
 18
 19 <!-- This test passes if the (red) fraction bar is hidden by the green bar -->
 20 <div style="position: absolute; left: 0px; top: 0px;">
 21 <math>
 22 <mspace height="50px" depth="50px"/>
 23 <mfrac mathcolor="red">
 24 <mspace width="50px"/>
 25 <mspace width="50px"/>
 26 </mfrac>
 27 </math>
 28 </div>
 29
 30 <!-- This green bar is moved up by AxisHeight and has thickness height + depth = FractionRuleThickness. -->
 31 <div style="position: absolute; left: 0px; top: -25px;">
 32 <math>
 33 <mspace height="50px" depth="50px"/>
 34 <mspace width="100px" height="2px" depth="2px" mathbackground="green"/>
 35 </math>
 36 </div>
 37
 38 </body>
 39</html>

LayoutTests/mathml/presentation/fractions-linethickness-expected.html

33 <head>
44 <title>fractions linethickness</title>
55 <meta charset="utf-8"/>
 6 <style type="text/css">
 7 /* For Latin Modern Math
 8 FractionRuleThickness = 40 * 25 / 1000 = 1px;
 9 */
 10 math {
 11 font-family: "Latin Modern Math";
 12 font-size: 25px;
 13 }
 14 </style>
615 </head>
716 <body>
817

2029 gLineThick = 3.f;
2130 -->
2231
23  <math mathsize="32px">
 32 <math>
2433 <mfrac linethickness="0.33px"><mn>1</mn><mn>2</mn></mfrac>
2534 <mfrac linethickness="1px"><mn>1</mn><mn>2</mn></mfrac>
2635 <mfrac linethickness="3px"><mn>1</mn><mn>2</mn></mfrac>

LayoutTests/mathml/presentation/fractions-linethickness.html

33 <head>
44 <title>fractions linethickness</title>
55 <meta charset="utf-8"/>
 6 <style type="text/css">
 7 /* For Latin Modern Math
 8 FractionRuleThickness = 40 * 25 / 1000 = 1px;
 9 */
 10 math {
 11 font-family: "Latin Modern Math";
 12 font-size: 25px;
 13 }
 14 </style>
615 </head>
716 <body>
817
918 <!-- This should draw fraction bars of increasing thickness -->
10  <math mathsize="32px">
 19 <math>
1120 <mfrac linethickness="thin"><mn>1</mn><mn>2</mn></mfrac>
1221 <mfrac linethickness="medium"><mn>1</mn><mn>2</mn></mfrac>
1322 <mfrac linethickness="thick"><mn>1</mn><mn>2</mn></mfrac>

LayoutTests/platform/gtk/mathml/presentation/roots-expected.txt

11layer at (0,0) size 800x600
22 RenderView at (0,0) size 800x600
3 layer at (0,0) size 800x492
4  RenderBlock {html} at (0,0) size 800x492
5  RenderBody {body} at (8,16) size 784x460
 3layer at (0,0) size 800x491
 4 RenderBlock {html} at (0,0) size 800x491
 5 RenderBody {body} at (8,16) size 784x459
66 RenderBlock {p} at (0,0) size 784x18
77 RenderText {#text} at (0,0) size 177x17
88 text run at (0,0) width 177: "square root (should be red): "

@@layer at (0,0) size 800x492
8686 RenderBlock {p} at (0,103) size 784x40
8787 RenderText {#text} at (0,8) size 113x17
8888 text run at (0,8) width 113: "root of a fraction: "
89  RenderMathMLMath {math} at (113,0) size 58x41 [padding: 0 1 0 1]
90  RenderMathMLSquareRoot {msqrt} at (1,0) size 56x41
 89 RenderMathMLMath {math} at (113,0) size 56x41 [padding: 0 1 0 1]
 90 RenderMathMLSquareRoot {msqrt} at (1,0) size 54x41
9191 RenderMathMLBlock (anonymous, flex) at (0,0) size 17x41
9292 RenderMathMLRadicalOperator (anonymous) at (0,0) size 17x41
9393 RenderMathMLBlock (anonymous, flex) at (0,0) size 13x40
9494 RenderBlock (anonymous) at (0,0) size 13x40
9595 RenderText at (0,-56) size 13x106
9696 text run at (0,-56) width 13: "\x{221A}"
97  RenderMathMLRootWrapper at (17,2) size 39x39
98  RenderMathMLFraction {mfrac} at (1,0) size 37x34
99  RenderMathMLBlock (anonymous, flex) at (0,0) size 37x17
100  RenderMathMLRow {mrow} at (0,0) size 37x13
101  RenderMathMLToken {mi} at (0,4) size 10x8 [padding: 0 2 0 0]
102  RenderMathMLBlock (anonymous, flex) at (0,0) size 8x8
103  RenderBlock (anonymous) at (0,0) size 8x8
104  RenderText {#text} at (0,-50) size 8x106
105  text run at (0,-50) width 8: "x"
106  RenderMathMLOperator {mo} at (9,1) size 20x12
107  RenderMathMLBlock (anonymous, flex) at (3,0) size 13x12
108  RenderBlock (anonymous) at (0,0) size 12x12
109  RenderText at (0,-47) size 12x106
110  text run at (0,-47) width 12: "+"
111  RenderMathMLToken {mn} at (28,0) size 9x12
112  RenderMathMLBlock (anonymous, flex) at (0,0) size 8x12
113  RenderBlock (anonymous) at (0,0) size 8x12
114  RenderText {#text} at (0,-46) size 8x106
115  text run at (0,-46) width 8: "1"
116  RenderMathMLBlock (anonymous, flex) at (0,16) size 37x18 [padding: 1 0 0 0]
117  RenderMathMLRow {mrow} at (0,4) size 37x14
118  RenderMathMLToken {mi} at (0,4) size 10x8 [padding: 0 2 0 0]
119  RenderMathMLBlock (anonymous, flex) at (0,0) size 8x8
120  RenderBlock (anonymous) at (0,0) size 8x8
121  RenderText {#text} at (0,-50) size 8x106
122  text run at (0,-50) width 8: "x"
123  RenderMathMLOperator {mo} at (9,1) size 20x12
124  RenderMathMLBlock (anonymous, flex) at (3,0) size 13x12
125  RenderBlock (anonymous) at (0,0) size 12x12
126  RenderText at (0,-47) size 12x106
127  text run at (0,-47) width 12: "+"
128  RenderMathMLToken {mn} at (28,0) size 9x12
129  RenderMathMLBlock (anonymous, flex) at (0,0) size 8x12
130  RenderBlock (anonymous) at (0,0) size 8x12
131  RenderText {#text} at (0,-46) size 8x106
132  text run at (0,-46) width 8: "2"
 97 RenderMathMLRootWrapper at (17,2) size 37x39
 98 RenderMathMLFraction {mfrac} at (0,0) size 37x34
 99 RenderMathMLRow {mrow} at (0,0) size 37x13
 100 RenderMathMLToken {mi} at (0,4) size 10x8 [padding: 0 2 0 0]
 101 RenderMathMLBlock (anonymous, flex) at (0,0) size 8x8
 102 RenderBlock (anonymous) at (0,0) size 8x8
 103 RenderText {#text} at (0,-50) size 8x106
 104 text run at (0,-50) width 8: "x"
 105 RenderMathMLOperator {mo} at (9,1) size 20x12
 106 RenderMathMLBlock (anonymous, flex) at (3,0) size 13x12
 107 RenderBlock (anonymous) at (0,0) size 12x12
 108 RenderText at (0,-47) size 12x106
 109 text run at (0,-47) width 12: "+"
 110 RenderMathMLToken {mn} at (28,0) size 9x12
 111 RenderMathMLBlock (anonymous, flex) at (0,0) size 8x12
 112 RenderBlock (anonymous) at (0,0) size 8x12
 113 RenderText {#text} at (0,-46) size 8x106
 114 text run at (0,-46) width 8: "1"
 115 RenderMathMLRow {mrow} at (0,20) size 37x14
 116 RenderMathMLToken {mi} at (0,4) size 10x8 [padding: 0 2 0 0]
 117 RenderMathMLBlock (anonymous, flex) at (0,0) size 8x8
 118 RenderBlock (anonymous) at (0,0) size 8x8
 119 RenderText {#text} at (0,-50) size 8x106
 120 text run at (0,-50) width 8: "x"
 121 RenderMathMLOperator {mo} at (9,1) size 20x12
 122 RenderMathMLBlock (anonymous, flex) at (3,0) size 13x12
 123 RenderBlock (anonymous) at (0,0) size 12x12
 124 RenderText at (0,-47) size 12x106
 125 text run at (0,-47) width 12: "+"
 126 RenderMathMLToken {mn} at (28,0) size 9x12
 127 RenderMathMLBlock (anonymous, flex) at (0,0) size 8x12
 128 RenderBlock (anonymous) at (0,0) size 8x12
 129 RenderText {#text} at (0,-46) size 8x106
 130 text run at (0,-46) width 8: "2"
133131 RenderBlock {p} at (0,159) size 784x18
134132 RenderText {#text} at (0,0) size 173x17
135133 text run at (0,0) width 173: "cube root (should be blue): "

@@layer at (0,0) size 800x492
200198 RenderBlock {p} at (0,227) size 784x40
201199 RenderText {#text} at (0,8) size 185x17
202200 text run at (0,8) width 185: "long index w/ complex base: "
203  RenderMathMLMath {math} at (185,0) size 92x41 [padding: 0 1 0 1]
204  RenderMathMLRoot {mroot} at (1,0) size 90x41
 201 RenderMathMLMath {math} at (185,0) size 90x41 [padding: 0 1 0 1]
 202 RenderMathMLRoot {mroot} at (1,0) size 88x41
205203 RenderMathMLRootWrapper at (4,8) size 40x33
206204 RenderMathMLRow {mrow} at (0,0) size 39x8
207205 RenderMathMLToken {mi} at (0,2) size 6x5 [padding: 0 1 0 0]

@@layer at (0,0) size 800x492
235233 RenderBlock (anonymous) at (0,0) size 13x40
236234 RenderText at (0,-56) size 13x106
237235 text run at (0,-56) width 13: "\x{221A}"
238  RenderMathMLRootWrapper at (51,2) size 39x39
239  RenderMathMLFraction {mfrac} at (1,0) size 37x34
240  RenderMathMLBlock (anonymous, flex) at (0,0) size 37x17
241  RenderMathMLRow {mrow} at (0,0) size 37x13
242  RenderMathMLToken {mi} at (0,4) size 10x8 [padding: 0 2 0 0]
243  RenderMathMLBlock (anonymous, flex) at (0,0) size 8x8
244  RenderBlock (anonymous) at (0,0) size 8x8
245  RenderText {#text} at (0,-50) size 8x106
246  text run at (0,-50) width 8: "x"
247  RenderMathMLOperator {mo} at (9,1) size 20x12
248  RenderMathMLBlock (anonymous, flex) at (3,0) size 13x12
249  RenderBlock (anonymous) at (0,0) size 12x12
250  RenderText at (0,-47) size 12x106
251  text run at (0,-47) width 12: "+"
252  RenderMathMLToken {mn} at (28,0) size 9x12
253  RenderMathMLBlock (anonymous, flex) at (0,0) size 8x12
254  RenderBlock (anonymous) at (0,0) size 8x12
255  RenderText {#text} at (0,-46) size 8x106
256  text run at (0,-46) width 8: "1"
257  RenderMathMLBlock (anonymous, flex) at (0,16) size 37x18 [padding: 1 0 0 0]
258  RenderMathMLRow {mrow} at (0,4) size 37x14
259  RenderMathMLToken {mi} at (0,4) size 10x8 [padding: 0 2 0 0]
260  RenderMathMLBlock (anonymous, flex) at (0,0) size 8x8
261  RenderBlock (anonymous) at (0,0) size 8x8
262  RenderText {#text} at (0,-50) size 8x106
263  text run at (0,-50) width 8: "x"
264  RenderMathMLOperator {mo} at (9,1) size 20x12
265  RenderMathMLBlock (anonymous, flex) at (3,0) size 13x12
266  RenderBlock (anonymous) at (0,0) size 12x12
267  RenderText at (0,-47) size 12x106
268  text run at (0,-47) width 12: "+"
269  RenderMathMLToken {mn} at (28,0) size 9x12
270  RenderMathMLBlock (anonymous, flex) at (0,0) size 8x12
271  RenderBlock (anonymous) at (0,0) size 8x12
272  RenderText {#text} at (0,-46) size 8x106
273  text run at (0,-46) width 8: "2"
274  RenderBlock {p} at (0,283) size 784x35
275  RenderText {#text} at (0,17) size 75x17
276  text run at (0,17) width 75: "high index: "
277  RenderMathMLMath {math} at (75,0) size 33x36 [padding: 0 1 0 1]
278  RenderMathMLRoot {mroot} at (1,0) size 31x36
279  RenderMathMLRootWrapper at (4,0) size 11x36
280  RenderMathMLFraction {mfrac} at (1,0) size 8x26
281  RenderMathMLBlock (anonymous, flex) at (0,0) size 8x18
282  RenderMathMLFraction {mfrac} at (1,0) size 6x16
283  RenderMathMLBlock (anonymous, flex) at (0,0) size 6x7
284  RenderMathMLToken {mi} at (0,0) size 6x5 [padding: 0 1 0 0]
285  RenderMathMLBlock (anonymous, flex) at (0,0) size 5x5
286  RenderBlock (anonymous) at (0,0) size 5x5
287  RenderText {#text} at (0,-29) size 5x61
288  text run at (0,-29) width 5: "x"
289  RenderMathMLBlock (anonymous, flex) at (0,6) size 6x10 [padding: 1 0 0 0]
290  RenderMathMLToken {mi} at (0,2) size 6x7 [padding: 0 1 0 0]
291  RenderMathMLBlock (anonymous, flex) at (0,0) size 5x6
292  RenderBlock (anonymous) at (0,0) size 5x6
293  RenderText {#text} at (0,-29) size 5x61
294  text run at (0,-29) width 5: "y"
295  RenderMathMLBlock (anonymous, flex) at (0,17) size 8x9 [padding: 1 0 0 0]
296  RenderMathMLToken {mi} at (1,2) size 6x6 [padding: 0 1 0 0]
297  RenderMathMLBlock (anonymous, flex) at (0,0) size 4x5
298  RenderBlock (anonymous) at (0,0) size 4x5
299  RenderText {#text} at (0,-29) size 4x61
300  text run at (0,-29) width 4: "z"
301  RenderMathMLBlock (anonymous, flex) at (5,0) size 18x36
302  RenderMathMLRadicalOperator (anonymous) at (0,18) size 17x18
 236 RenderMathMLRootWrapper at (51,2) size 37x39
 237 RenderMathMLFraction {mfrac} at (0,0) size 37x34
 238 RenderMathMLRow {mrow} at (0,0) size 37x13
 239 RenderMathMLToken {mi} at (0,4) size 10x8 [padding: 0 2 0 0]
 240 RenderMathMLBlock (anonymous, flex) at (0,0) size 8x8
 241 RenderBlock (anonymous) at (0,0) size 8x8
 242 RenderText {#text} at (0,-50) size 8x106
 243 text run at (0,-50) width 8: "x"
 244 RenderMathMLOperator {mo} at (9,1) size 20x12
 245 RenderMathMLBlock (anonymous, flex) at (3,0) size 13x12
 246 RenderBlock (anonymous) at (0,0) size 12x12
 247 RenderText at (0,-47) size 12x106
 248 text run at (0,-47) width 12: "+"
 249 RenderMathMLToken {mn} at (28,0) size 9x12
 250 RenderMathMLBlock (anonymous, flex) at (0,0) size 8x12
 251 RenderBlock (anonymous) at (0,0) size 8x12
 252 RenderText {#text} at (0,-46) size 8x106
 253 text run at (0,-46) width 8: "1"
 254 RenderMathMLRow {mrow} at (0,20) size 37x14
 255 RenderMathMLToken {mi} at (0,4) size 10x8 [padding: 0 2 0 0]
 256 RenderMathMLBlock (anonymous, flex) at (0,0) size 8x8
 257 RenderBlock (anonymous) at (0,0) size 8x8
 258 RenderText {#text} at (0,-50) size 8x106
 259 text run at (0,-50) width 8: "x"
 260 RenderMathMLOperator {mo} at (9,1) size 20x12
 261 RenderMathMLBlock (anonymous, flex) at (3,0) size 13x12
 262 RenderBlock (anonymous) at (0,0) size 12x12
 263 RenderText at (0,-47) size 12x106
 264 text run at (0,-47) width 12: "+"
 265 RenderMathMLToken {mn} at (28,0) size 9x12
 266 RenderMathMLBlock (anonymous, flex) at (0,0) size 8x12
 267 RenderBlock (anonymous) at (0,0) size 8x12
 268 RenderText {#text} at (0,-46) size 8x106
 269 text run at (0,-46) width 8: "2"
 270 RenderBlock {p} at (0,283) size 784x34
 271 RenderText {#text} at (0,16) size 75x17
 272 text run at (0,16) width 75: "high index: "
 273 RenderMathMLMath {math} at (75,0) size 29x35 [padding: 0 1 0 1]
 274 RenderMathMLRoot {mroot} at (1,0) size 27x35
 275 RenderMathMLRootWrapper at (4,0) size 7x35
 276 RenderMathMLFraction {mfrac} at (0,0) size 6x24
 277 RenderMathMLFraction {mfrac} at (0,0) size 6x15
 278 RenderMathMLToken {mi} at (0,0) size 6x5 [padding: 0 1 0 0]
 279 RenderMathMLBlock (anonymous, flex) at (0,0) size 5x5
 280 RenderBlock (anonymous) at (0,0) size 5x5
 281 RenderText {#text} at (0,-29) size 5x61
 282 text run at (0,-29) width 5: "x"
 283 RenderMathMLToken {mi} at (0,8) size 6x7 [padding: 0 1 0 0]
 284 RenderMathMLBlock (anonymous, flex) at (0,0) size 5x6
 285 RenderBlock (anonymous) at (0,0) size 5x6
 286 RenderText {#text} at (0,-29) size 5x61
 287 text run at (0,-29) width 5: "y"
 288 RenderMathMLToken {mi} at (0,18) size 6x6 [padding: 0 1 0 0]
 289 RenderMathMLBlock (anonymous, flex) at (0,0) size 4x5
 290 RenderBlock (anonymous) at (0,0) size 4x5
 291 RenderText {#text} at (0,-29) size 4x61
 292 text run at (0,-29) width 4: "z"
 293 RenderMathMLBlock (anonymous, flex) at (1,0) size 18x35
 294 RenderMathMLRadicalOperator (anonymous) at (0,17) size 17x18
303295 RenderMathMLBlock (anonymous, flex) at (0,0) size 13x17
304296 RenderBlock (anonymous) at (0,0) size 13x17
305297 RenderText at (0,-56) size 13x106
306298 text run at (0,-56) width 13: "\x{221A}"
307  RenderMathMLRootWrapper at (22,20) size 9x16
 299 RenderMathMLRootWrapper at (18,18) size 9x17
308300 RenderMathMLToken {mn} at (0,0) size 8x12
309301 RenderMathMLBlock (anonymous, flex) at (0,0) size 8x12
310302 RenderBlock (anonymous) at (0,0) size 8x12
311303 RenderText {#text} at (0,-46) size 8x106
312304 text run at (0,-46) width 8: "2"
313  RenderBlock {p} at (0,334) size 784x54
 305 RenderBlock {p} at (0,333) size 784x54
314306 RenderText {#text} at (0,14) size 155x17
315307 text run at (0,14) width 155: "Imbricated square roots: "
316308 RenderMathMLMath {math} at (155,0) size 342x55 [padding: 0 1 0 1]

@@layer at (0,0) size 800x492
460452 RenderText {#text} at (0,-45) size 12x106
461453 text run at (0,-45) width 12: "A"
462454 RenderText {#text} at (0,0) size 0x0
463  RenderBlock {p} at (0,404) size 784x56
464  RenderText {#text} at (0,25) size 110x17
465  text run at (0,25) width 110: "Imbricated roots: "
466  RenderMathMLMath {math} at (110,0) size 366x57 [padding: 0 1 0 1]
467  RenderMathMLRoot {mroot} at (1,0) size 364x57
 455 RenderBlock {p} at (0,403) size 784x56
 456 RenderText {#text} at (0,24) size 110x17
 457 text run at (0,24) width 110: "Imbricated roots: "
 458 RenderMathMLMath {math} at (110,0) size 364x57 [padding: 0 1 0 1]
 459 RenderMathMLRoot {mroot} at (1,0) size 362x57
468460 RenderMathMLRootWrapper at (4,15) size 6x42
469461 RenderMathMLToken {mn} at (0,0) size 5x7
470462 RenderMathMLBlock (anonymous, flex) at (0,0) size 5x7

@@layer at (0,0) size 800x492
477469 RenderBlock (anonymous) at (0,0) size 13x57
478470 RenderText at (0,-56) size 13x106
479471 text run at (0,-56) width 13: "\x{221A}"
480  RenderMathMLRootWrapper at (17,2) size 347x55
481  RenderMathMLRow {mrow} at (0,0) size 346x55
482  RenderMathMLToken {mn} at (0,26) size 8x12
 472 RenderMathMLRootWrapper at (17,2) size 345x55
 473 RenderMathMLRow {mrow} at (0,0) size 344x55
 474 RenderMathMLToken {mn} at (0,25) size 8x12
483475 RenderMathMLBlock (anonymous, flex) at (0,0) size 8x12
484476 RenderBlock (anonymous) at (0,0) size 8x12
485477 RenderText {#text} at (0,-46) size 8x106
486478 text run at (0,-46) width 8: "1"
487  RenderMathMLOperator {mo} at (8,27) size 20x12
 479 RenderMathMLOperator {mo} at (8,26) size 20x12
488480 RenderMathMLBlock (anonymous, flex) at (3,0) size 13x12
489481 RenderBlock (anonymous) at (0,0) size 12x12
490482 RenderText at (0,-47) size 12x106
491483 text run at (0,-47) width 12: "+"
492  RenderMathMLRoot {mroot} at (27,0) size 319x55
 484 RenderMathMLRoot {mroot} at (27,0) size 317x55
493485 RenderMathMLRootWrapper at (4,14) size 6x41
494486 RenderMathMLToken {mn} at (0,0) size 5x8
495487 RenderMathMLBlock (anonymous, flex) at (0,0) size 5x8

@@layer at (0,0) size 800x492
502494 RenderBlock (anonymous) at (0,0) size 13x55
503495 RenderText at (0,-56) size 13x106
504496 text run at (0,-56) width 13: "\x{221A}"
505  RenderMathMLRootWrapper at (17,2) size 302x53
506  RenderMathMLRow {mrow} at (0,0) size 302x53
507  RenderMathMLToken {mn} at (0,24) size 8x12
 497 RenderMathMLRootWrapper at (17,2) size 300x53
 498 RenderMathMLRow {mrow} at (0,0) size 300x53
 499 RenderMathMLToken {mn} at (0,23) size 8x12
508500 RenderMathMLBlock (anonymous, flex) at (0,0) size 8x12
509501 RenderBlock (anonymous) at (0,0) size 8x12
510502 RenderText {#text} at (0,-46) size 8x106
511503 text run at (0,-46) width 8: "2"
512  RenderMathMLOperator {mo} at (8,25) size 20x12
 504 RenderMathMLOperator {mo} at (8,24) size 20x12
513505 RenderMathMLBlock (anonymous, flex) at (3,0) size 13x12
514506 RenderBlock (anonymous) at (0,0) size 12x12
515507 RenderText at (0,-47) size 12x106
516508 text run at (0,-47) width 12: "+"
517  RenderMathMLRoot {mroot} at (27,0) size 275x53
 509 RenderMathMLRoot {mroot} at (27,0) size 273x53
518510 RenderMathMLRootWrapper at (4,14) size 6x39
519511 RenderMathMLToken {mn} at (0,0) size 5x7
520512 RenderMathMLBlock (anonymous, flex) at (0,0) size 5x7

@@layer at (0,0) size 800x492
527519 RenderBlock (anonymous) at (0,0) size 13x53
528520 RenderText at (0,-56) size 13x106
529521 text run at (0,-56) width 13: "\x{221A}"
530  RenderMathMLRootWrapper at (17,2) size 258x51
531  RenderMathMLRow {mrow} at (0,0) size 257x51
532  RenderMathMLToken {mn} at (0,22) size 8x12
 522 RenderMathMLRootWrapper at (17,2) size 256x51
 523 RenderMathMLRow {mrow} at (0,0) size 255x51
 524 RenderMathMLToken {mn} at (0,21) size 8x12
533525 RenderMathMLBlock (anonymous, flex) at (0,0) size 8x12
534526 RenderBlock (anonymous) at (0,0) size 8x12
535527 RenderText {#text} at (0,-46) size 8x106
536528 text run at (0,-46) width 8: "3"
537  RenderMathMLOperator {mo} at (8,23) size 20x12
 529 RenderMathMLOperator {mo} at (8,22) size 20x12
538530 RenderMathMLBlock (anonymous, flex) at (3,0) size 13x12
539531 RenderBlock (anonymous) at (0,0) size 12x12
540532 RenderText at (0,-47) size 12x106
541533 text run at (0,-47) width 12: "+"
542  RenderMathMLRoot {mroot} at (27,0) size 230x51
 534 RenderMathMLRoot {mroot} at (27,0) size 228x51
543535 RenderMathMLRootWrapper at (4,13) size 6x38
544536 RenderMathMLToken {mn} at (0,0) size 5x7
545537 RenderMathMLBlock (anonymous, flex) at (0,0) size 5x7

@@layer at (0,0) size 800x492
552544 RenderBlock (anonymous) at (0,0) size 13x51
553545 RenderText at (0,-56) size 13x106
554546 text run at (0,-56) width 13: "\x{221A}"
555  RenderMathMLRootWrapper at (17,2) size 213x49
556  RenderMathMLRow {mrow} at (0,0) size 212x49
557  RenderMathMLToken {mn} at (0,20) size 8x12
 547 RenderMathMLRootWrapper at (17,2) size 211x49
 548 RenderMathMLRow {mrow} at (0,0) size 210x49
 549 RenderMathMLToken {mn} at (0,19) size 8x12
558550 RenderMathMLBlock (anonymous, flex) at (0,0) size 8x12
559551 RenderBlock (anonymous) at (0,0) size 8x12
560552 RenderText {#text} at (0,-46) size 8x106
561553 text run at (0,-46) width 8: "4"
562  RenderMathMLOperator {mo} at (8,21) size 20x12
 554 RenderMathMLOperator {mo} at (8,20) size 20x12
563555 RenderMathMLBlock (anonymous, flex) at (3,0) size 13x12
564556 RenderBlock (anonymous) at (0,0) size 12x12
565557 RenderText at (0,-47) size 12x106
566558 text run at (0,-47) width 12: "+"
567  RenderMathMLRoot {mroot} at (27,0) size 185x49
 559 RenderMathMLRoot {mroot} at (27,0) size 183x49
568560 RenderMathMLRootWrapper at (4,11) size 6x38
569561 RenderMathMLToken {mn} at (0,0) size 5x8
570562 RenderMathMLBlock (anonymous, flex) at (0,0) size 5x8

@@layer at (0,0) size 800x492
577569 RenderBlock (anonymous) at (0,0) size 13x48
578570 RenderText at (0,-56) size 13x106
579571 text run at (0,-56) width 13: "\x{221A}"
580  RenderMathMLRootWrapper at (17,2) size 168x47
581  RenderMathMLRow {mrow} at (0,0) size 168x41
582  RenderMathMLToken {mn} at (0,18) size 8x12
 572 RenderMathMLRootWrapper at (17,2) size 166x47
 573 RenderMathMLRow {mrow} at (0,0) size 166x41
 574 RenderMathMLToken {mn} at (0,17) size 8x12
583575 RenderMathMLBlock (anonymous, flex) at (0,0) size 8x12
584576 RenderBlock (anonymous) at (0,0) size 8x12
585577 RenderText {#text} at (0,-46) size 8x106
586578 text run at (0,-46) width 8: "5"
587  RenderMathMLOperator {mo} at (8,19) size 20x12
 579 RenderMathMLOperator {mo} at (8,18) size 20x12
588580 RenderMathMLBlock (anonymous, flex) at (3,0) size 13x12
589581 RenderBlock (anonymous) at (0,0) size 12x12
590582 RenderText at (0,-47) size 12x106
591583 text run at (0,-47) width 12: "+"
592  RenderMathMLRoot {mroot} at (27,0) size 141x41
 584 RenderMathMLRoot {mroot} at (27,0) size 139x41
593585 RenderMathMLRootWrapper at (4,9) size 6x32
594586 RenderMathMLToken {mn} at (0,0) size 5x7
595587 RenderMathMLBlock (anonymous, flex) at (0,0) size 5x7

@@layer at (0,0) size 800x492
602594 RenderBlock (anonymous) at (0,0) size 13x40
603595 RenderText at (0,-56) size 13x106
604596 text run at (0,-56) width 13: "\x{221A}"
605  RenderMathMLRootWrapper at (17,2) size 124x39
606  RenderMathMLRow {mrow} at (0,0) size 123x31
607  RenderMathMLToken {mn} at (0,16) size 8x12
 597 RenderMathMLRootWrapper at (17,2) size 122x39
 598 RenderMathMLRow {mrow} at (0,0) size 121x31
 599 RenderMathMLToken {mn} at (0,15) size 8x12
608600 RenderMathMLBlock (anonymous, flex) at (0,0) size 8x12
609601 RenderBlock (anonymous) at (0,0) size 8x12
610602 RenderText {#text} at (0,-46) size 8x106
611603 text run at (0,-46) width 8: "6"
612  RenderMathMLOperator {mo} at (8,17) size 20x12
 604 RenderMathMLOperator {mo} at (8,16) size 20x12
613605 RenderMathMLBlock (anonymous, flex) at (3,0) size 13x12
614606 RenderBlock (anonymous) at (0,0) size 12x12
615607 RenderText at (0,-47) size 12x106
616608 text run at (0,-47) width 12: "+"
617  RenderMathMLRoot {mroot} at (27,0) size 96x31
 609 RenderMathMLRoot {mroot} at (27,0) size 94x31
618610 RenderMathMLRootWrapper at (4,5) size 6x26
619611 RenderMathMLToken {mn} at (0,0) size 5x7
620612 RenderMathMLBlock (anonymous, flex) at (0,0) size 5x7

@@layer at (0,0) size 800x492
627619 RenderBlock (anonymous) at (0,0) size 13x30
628620 RenderText at (0,-56) size 13x106
629621 text run at (0,-56) width 13: "\x{221A}"
630  RenderMathMLRootWrapper at (17,2) size 79x29
631  RenderMathMLRow {mrow} at (0,0) size 79x29
632  RenderMathMLToken {mn} at (0,14) size 8x12
 622 RenderMathMLRootWrapper at (17,2) size 77x29
 623 RenderMathMLRow {mrow} at (0,0) size 77x28
 624 RenderMathMLToken {mn} at (0,13) size 8x12
633625 RenderMathMLBlock (anonymous, flex) at (0,0) size 8x12
634626 RenderBlock (anonymous) at (0,0) size 8x12
635627 RenderText {#text} at (0,-46) size 8x106
636628 text run at (0,-46) width 8: "7"
637  RenderMathMLOperator {mo} at (8,15) size 20x12
 629 RenderMathMLOperator {mo} at (8,14) size 20x12
638630 RenderMathMLBlock (anonymous, flex) at (3,0) size 13x12
639631 RenderBlock (anonymous) at (0,0) size 12x12
640632 RenderText at (0,-47) size 12x106
641633 text run at (0,-47) width 12: "+"
642  RenderMathMLRoot {mroot} at (27,0) size 52x29
643  RenderMathMLRootWrapper at (4,0) size 26x29
644  RenderMathMLFraction {mfrac} at (1,0) size 23x18
645  RenderMathMLBlock (anonymous, flex) at (0,0) size 23x10
646  RenderMathMLRow {mrow} at (0,0) size 23x8
647  RenderMathMLToken {mi} at (0,2) size 6x5 [padding: 0 1 0 0]
648  RenderMathMLBlock (anonymous, flex) at (0,0) size 5x5
649  RenderBlock (anonymous) at (0,0) size 5x5
650  RenderText {#text} at (0,-29) size 5x61
651  text run at (0,-29) width 5: "x"
652  RenderMathMLOperator {mo} at (5,0) size 12x7
653  RenderMathMLBlock (anonymous, flex) at (2,0) size 7x7
654  RenderBlock (anonymous) at (0,0) size 7x7
655  RenderText at (0,-27) size 7x61
656  text run at (0,-27) width 7: "+"
657  RenderMathMLToken {mi} at (16,2) size 7x6 [padding: 0 1 0 0]
658  RenderMathMLBlock (anonymous, flex) at (0,0) size 5x6
659  RenderBlock (anonymous) at (0,0) size 5x6
660  RenderText {#text} at (0,-29) size 5x61
661  text run at (0,-29) width 5: "y"
662  RenderMathMLBlock (anonymous, flex) at (0,9) size 23x9 [padding: 1 0 0 0]
663  RenderMathMLToken {mi} at (8,2) size 6x6 [padding: 0 1 0 0]
664  RenderMathMLBlock (anonymous, flex) at (0,0) size 4x5
665  RenderBlock (anonymous) at (0,0) size 4x5
666  RenderText {#text} at (0,-29) size 4x61
667  text run at (0,-29) width 4: "z"
668  RenderMathMLBlock (anonymous, flex) at (20,0) size 18x29
669  RenderMathMLRadicalOperator (anonymous) at (0,11) size 17x18
 634 RenderMathMLRoot {mroot} at (27,0) size 50x28
 635 RenderMathMLRootWrapper at (4,0) size 24x28
 636 RenderMathMLFraction {mfrac} at (0,0) size 23x17
 637 RenderMathMLRow {mrow} at (0,0) size 23x8
 638 RenderMathMLToken {mi} at (0,2) size 6x5 [padding: 0 1 0 0]
 639 RenderMathMLBlock (anonymous, flex) at (0,0) size 5x5
 640 RenderBlock (anonymous) at (0,0) size 5x5
 641 RenderText {#text} at (0,-29) size 5x61
 642 text run at (0,-29) width 5: "x"
 643 RenderMathMLOperator {mo} at (5,0) size 12x7
 644 RenderMathMLBlock (anonymous, flex) at (2,0) size 7x7
 645 RenderBlock (anonymous) at (0,0) size 7x7
 646 RenderText at (0,-27) size 7x61
 647 text run at (0,-27) width 7: "+"
 648 RenderMathMLToken {mi} at (16,2) size 7x6 [padding: 0 1 0 0]
 649 RenderMathMLBlock (anonymous, flex) at (0,0) size 5x6
 650 RenderBlock (anonymous) at (0,0) size 5x6
 651 RenderText {#text} at (0,-29) size 5x61
 652 text run at (0,-29) width 5: "y"
 653 RenderMathMLToken {mi} at (8,11) size 6x6 [padding: 0 1 0 0]
 654 RenderMathMLBlock (anonymous, flex) at (0,0) size 4x5
 655 RenderBlock (anonymous) at (0,0) size 4x5
 656 RenderText {#text} at (0,-29) size 4x61
 657 text run at (0,-29) width 4: "z"
 658 RenderMathMLBlock (anonymous, flex) at (18,0) size 18x28
 659 RenderMathMLRadicalOperator (anonymous) at (0,10) size 17x18
670660 RenderMathMLBlock (anonymous, flex) at (0,0) size 13x17
671661 RenderBlock (anonymous) at (0,0) size 13x17
672662 RenderText at (0,-56) size 13x106
673663 text run at (0,-56) width 13: "\x{221A}"
674  RenderMathMLRootWrapper at (37,12) size 14x17
 664 RenderMathMLRootWrapper at (35,11) size 14x17
675665 RenderMathMLToken {mi} at (0,0) size 14x13 [padding: 0 2 0 0]
676666 RenderMathMLBlock (anonymous, flex) at (0,0) size 12x13
677667 RenderBlock (anonymous) at (0,0) size 12x13

LayoutTests/platform/mac/TestExpectations

@@webkit.org/b/130693 mathml/presentation/tokenElements-background-color.html [ Im
791791webkit.org/b/72828 mathml/opentype/horizontal.html [ Failure ]
792792webkit.org/b/72828 mathml/opentype/horizontal-munderover.html [ Failure ]
793793
 794# These tests require the Latin Modern Math font.
 795mathml/opentype/fraction-line.html [ Pass ImageOnlyFailure ]
 796mathml/presentation/fractions-linethickness.html [ Pass ImageOnlyFailure ]
 797
794798# Missing references
795799webkit.org/b/119038 mathml/presentation/mo-stretch.html [ Failure ]
796800webkit.org/b/119038 mathml/presentation/roots.xhtml [ Failure ]

Source/WebCore/ChangeLog

112016-03-03 Frederic Wang <fwang@igalia.com>
22
 3 Refactor RenderMathMLFraction layout to avoid using flexbox
 4 https://bugs.webkit.org/show_bug.cgi?id=153917
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Implement the layoutBlock method to handle the layout calculations
 9 directly in the class. This also fixes parsing of absolute values for
 10 linethickness attribute (e.g. 10px) and adds support for the AxisHeight
 11 and FractionRuleThickness MATH parameters.
 12
 13 Test: mathml/opentype/fraction-line.html
 14
 15 * accessibility/AccessibilityRenderObject.cpp:
 16 (WebCore::AccessibilityRenderObject::mathLineThickness): Use the thickness relative to the
 17 default line thickness since that's really what is expected by mathml-line-fraction.html
 18 * css/mathml.css: Remove flexbox properties for mfrac.
 19 (mfrac): Deleted.
 20 (mfrac > *): Deleted.
 21 (mfrac[numalign="left"] > :first-child): Deleted.
 22 (mfrac[numalign="right"] > :first-child): Deleted.
 23 (mfrac[denomalign="left"] > :last-child): Deleted.
 24 (mfrac[denomalign="right"] > :last-child): Deleted.
 25 (mfrac > :first-child): Deleted.
 26 (mfrac > :last-child): Deleted.
 27 (mfrac): Deleted.
 28 * rendering/mathml/RenderMathMLBlock.cpp: Introduce a helper function to retrieve the math
 29 axis height.
 30 (WebCore::RenderMathMLBlock::getMathAxisHeight):
 31 * rendering/mathml/RenderMathMLBlock.h: Declare getMathAxisHeight.
 32 * rendering/mathml/RenderMathMLFraction.cpp:
 33 (WebCore::RenderMathMLFraction::RenderMathMLFraction):
 34 (WebCore::RenderMathMLFraction::parseAlignmentAttribute): Helper function to parse the align
 35 attribute.
 36 (WebCore::RenderMathMLFraction::isValid): Helper function to verify whether the child list
 37 is valid with respect to the MathML specificitation.
 38 (WebCore::RenderMathMLFraction::getNumerator): Helper function to retrieve the numerator.
 39 (WebCore::RenderMathMLFraction::getDenominator): Helper function to retrieve the denominator.
 40 (WebCore::RenderMathMLFraction::updateFromElement): Use the FractionRuleThickness parameter
 41 when avaiable to calculate the default linethickness.
 42 Fix computation of linethickness for absolute values (e.g. 10px), the default linethickness
 43 must not be involved for such values.
 44 We no longer need to manage style of anonymous wrappers.
 45 (WebCore::RenderMathMLFraction::unembellishedOperator): Use the helper function and we no
 46 longer care about anonymous wrappers.
 47 (WebCore::RenderMathMLFraction::computePreferredLogicalWidths): Implement this function
 48 without using flexbox.
 49 (WebCore::RenderMathMLFraction::getHorizontalOffset): Helper function to get the horizontal
 50 offsets of children depending of the alignment.
 51 (WebCore::RenderMathMLFraction::layoutBlock): Implement this function without using flexbox.
 52 (WebCore::RenderMathMLFraction::paint): Do not paint if the fraction is invalid. Use helper
 53 function. Use the width of the renderer (instead of the one of the denominator) as the
 54 length of the fraction bar.
 55 (WebCore::RenderMathMLFraction::firstLineBaseline): Use the helper functions to get children
 56 and axis height.
 57 (WebCore::RenderMathMLFraction::paintChildren): Temporary function to remove in a
 58 follow-up patch.
 59 (WebCore::RenderMathMLFraction::fixChildStyle): Deleted. We no longer need to manage style
 60 of anonymous wrappers.
 61 (WebCore::RenderMathMLFraction::addChild): Deleted. We no longer need to manage
 62 anonymous wrappers.
 63 (WebCore::RenderMathMLFraction::styleDidChange): We no longer need to manage style of
 64 anonymous wrappers.
 65 (WebCore::RenderMathMLFraction::layout): Deleted.
 66 * rendering/mathml/RenderMathMLFraction.h: Replace lineThickness with relativeLineThickness,
 67 as needed by the accessibility code. Update function and members declarations.
 68
 692016-03-03 Frederic Wang <fwang@igalia.com>
 70
371 Refactor RenderMathMLUnderOver layout functions to avoid using flexbox
472 https://bugs.webkit.org/show_bug.cgi?id=153742
573

Source/WebCore/accessibility/AccessibilityRenderObject.cpp

@@int AccessibilityRenderObject::mathLineThickness() const
39793979 if (!is<RenderMathMLFraction>(m_renderer))
39803980 return -1;
39813981
3982  return downcast<RenderMathMLFraction>(*m_renderer).lineThickness();
 3982 return downcast<RenderMathMLFraction>(*m_renderer).relativeLineThickness();
39833983}
39843984
39853985#endif

Source/WebCore/css/mathml.css

@@ms, mtext, mi, mn, mo, annotation, mtd {
4444 white-space: nowrap !important;
4545}
4646
47 mo, mfrac {
 47mo {
4848 flex-direction: column;
4949}
5050
51 mfrac > * {
52  align-self: center;
53 }
54 mfrac[numalign="left"] > :first-child {
55  align-self: flex-start;
56 }
57 mfrac[numalign="right"] > :first-child {
58  align-self: flex-end;
59 }
60 mfrac[denomalign="left"] > :last-child {
61  align-self: flex-start;
62 }
63 mfrac[denomalign="right"] > :last-child {
64  align-self: flex-end;
65 }
66 mfrac > :first-child {
67  -webkit-margin-after: 0.2em;
68 }
69 mfrac > :last-child {
70  -webkit-margin-before: 0.2em;
71 }
72 mfrac {
73  -webkit-margin-start: 1px;
74  -webkit-margin-end: 1px;
75 }
76 
7751msub > * + *, msup > * + *, msubsup > * + *, mmultiscripts > * + *, munder > * + *, mover > * + *, munderover > * + * {
7852 font-size: 0.75em; /* FIXME: MathML standard is 0.71em */
7953}

Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp

@@RenderPtr<RenderMathMLBlock> RenderMathMLBlock::createAnonymousMathMLBlock()
6565 return newBlock;
6666}
6767
 68LayoutUnit RenderMathMLBlock::getMathAxisHeight() const
 69{
 70 const auto& primaryFont = style().fontCascade().primaryFont();
 71 if (auto* mathData = primaryFont.mathData())
 72 return mathData->getMathConstant(primaryFont, OpenTypeMathData::AxisHeight);
 73
 74 return style().fontMetrics().xHeight() / 2;
 75}
 76
6877int RenderMathMLBlock::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const
6978{
7079 // mathml.css sets math { -webkit-line-box-contain: glyphs replaced; line-height: 0; }, so when linePositionMode == PositionOfInteriorLineBoxes we want to

Source/WebCore/rendering/mathml/RenderMathMLBlock.h

@@public:
6363
6464 // Create a new RenderMathMLBlock, with a new style inheriting from this->style().
6565 RenderPtr<RenderMathMLBlock> createAnonymousMathMLBlock();
 66
 67 LayoutUnit getMathAxisHeight() const;
6668
6769protected:
6870 static LayoutUnit ascentForChild(const RenderBox& child)

Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp

11/*
22 * Copyright (C) 2009 Alex Milowski (alex@milowski.com). All rights reserved.
33 * Copyright (C) 2010 François Sausset (sausset@gmail.com). All rights reserved.
 4 * Copyright (C) 2016 Igalia S.L.
45 *
56 * Redistribution and use in source and binary forms, with or without
67 * modification, are permitted provided that the following conditions

@@namespace WebCore {
3839
3940using namespace MathMLNames;
4041
 42// FIXME: The "MathML in HTML5" implementation note suggests the values 50% for "thin" and 200% for "thick".
4143static const float gLineThin = 0.33f;
4244static const float gLineMedium = 1.f;
4345static const float gLineThick = 3.f;
4446static const float gFractionBarWidth = 0.05f;
4547
 48// FIXME: We should read the gaps and shifts from the MATH table (https://bugs.webkit.org/show_bug.cgi?id=122297).
 49static const float gNumeratorGap = 0.2f;
 50static const float gDenominatorGap = 0.2f;
 51
4652RenderMathMLFraction::RenderMathMLFraction(MathMLInlineContainerElement& element, Ref<RenderStyle>&& style)
4753 : RenderMathMLBlock(element, WTFMove(style))
48  , m_lineThickness(gLineMedium)
 54 , m_defaultLineThickness(1)
 55 , m_lineThickness(0)
 56 , m_numeratorAlign(kCenter)
 57 , m_denominatorAlign(kCenter)
 58{
 59}
 60
 61RenderMathMLFraction::FractionAlignment RenderMathMLFraction::parseAlignmentAttribute(const String& value)
 62{
 63 if (equalIgnoringASCIICase(value, "left"))
 64 return kLeft;
 65 if (equalIgnoringASCIICase(value, "right"))
 66 return kRight;
 67 return kCenter;
 68}
 69
 70bool RenderMathMLFraction::isValid() const
4971{
 72 // Verify whether the list of children is valid:
 73 // <mfrac> numerator denominator </mfrac>
 74 RenderBox* child = firstChildBox();
 75 if (!child)
 76 return false;
 77 child = child->nextSiblingBox();
 78 return child && !child->nextSiblingBox();
5079}
5180
52 void RenderMathMLFraction::fixChildStyle(RenderObject* child)
 81RenderBox& RenderMathMLFraction::numerator() const
5382{
54  ASSERT(child->isAnonymous() && child->style().refCount() == 1);
55  child->style().setFlexDirection(FlowColumn);
 83 ASSERT(isValid());
 84 return *firstChildBox();
 85}
 86
 87RenderBox& RenderMathMLFraction::denominator() const
 88{
 89 ASSERT(isValid());
 90 return *firstChildBox()->nextSiblingBox();
5691}
5792
58 // FIXME: It's cleaner to only call updateFromElement when an attribute has changed. Move parts
59 // of this to fixChildStyle or other methods, and call them when needed.
6093void RenderMathMLFraction::updateFromElement()
6194{
62  // FIXME: mfrac where bevelled=true will need to reorganize the descendants
63  if (isEmpty())
 95 if (isEmpty())
6496 return;
6597
66  RenderObject* numeratorWrapper = firstChild();
67  RenderObject* denominatorWrapper = numeratorWrapper->nextSibling();
68  if (!denominatorWrapper)
69  return;
 98 // We first determine the default line thickness.
 99 const auto& primaryFont = style().fontCascade().primaryFont();
 100 if (auto* mathData = style().fontCascade().primaryFont().mathData())
 101 m_defaultLineThickness = mathData->getMathConstant(primaryFont, OpenTypeMathData::FractionRuleThickness);
 102 else
 103 m_defaultLineThickness = gFractionBarWidth * style().fontSize();
70104
 105 // Next, we parse the linethickness attribute.
71106 String thickness = element().getAttribute(MathMLNames::linethicknessAttr);
72  m_lineThickness = gLineMedium;
73107 if (equalLettersIgnoringASCIICase(thickness, "thin"))
74  m_lineThickness = gLineThin;
 108 m_lineThickness = m_defaultLineThickness * gLineThin;
75109 else if (equalLettersIgnoringASCIICase(thickness, "medium"))
76  m_lineThickness = gLineMedium;
 110 m_lineThickness = m_defaultLineThickness * gLineMedium;
77111 else if (equalLettersIgnoringASCIICase(thickness, "thick"))
78  m_lineThickness = gLineThick;
 112 m_lineThickness = m_defaultLineThickness * gLineThick;
79113 else {
80  // This function parses the thickness attribute using gLineMedium as
81  // the default value. If the parsing fails, m_lineThickness will not be
82  // modified i.e. the default value will be used.
 114 // Parse the thickness using m_defaultLineThickness as the default value.
 115 m_lineThickness = m_defaultLineThickness;
83116 parseMathMLLength(thickness, m_lineThickness, &style(), false);
84117 }
85118
86  // Update the style for the padding of the denominator for the line thickness
87  lastChild()->style().setPaddingTop(Length(static_cast<int>(m_lineThickness), Fixed));
88 }
89 
90 void RenderMathMLFraction::addChild(RenderObject* child, RenderObject* /* beforeChild */)
91 {
92  if (isEmpty()) {
93  RenderPtr<RenderMathMLBlock> numeratorWrapper = createAnonymousMathMLBlock();
94  fixChildStyle(numeratorWrapper.get());
95  RenderMathMLBlock::addChild(numeratorWrapper.leakPtr());
96 
97  RenderPtr<RenderMathMLBlock> denominatorWrapper = createAnonymousMathMLBlock();
98  fixChildStyle(denominatorWrapper.get());
99  RenderMathMLBlock::addChild(denominatorWrapper.leakPtr());
100  }
101 
102  if (firstChild()->isEmpty())
103  downcast<RenderElement>(*firstChild()).addChild(child);
104  else
105  downcast<RenderElement>(*lastChild()).addChild(child);
106 
107  updateFromElement();
 119 m_numeratorAlign = parseAlignmentAttribute(element().getAttribute(MathMLNames::numalignAttr));
 120 m_denominatorAlign = parseAlignmentAttribute(element().getAttribute(MathMLNames::denomalignAttr));
108121}
109122
110123void RenderMathMLFraction::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
111124{
112125 RenderMathMLBlock::styleDidChange(diff, oldStyle);
113126
114  for (RenderObject* child = firstChild(); child; child = child->nextSibling())
115  fixChildStyle(child);
116127 updateFromElement();
117128}
118129
119130RenderMathMLOperator* RenderMathMLFraction::unembellishedOperator()
120131{
121  RenderObject* numeratorWrapper = firstChild();
122  if (!numeratorWrapper)
123  return nullptr;
124  RenderObject* numerator = numeratorWrapper->firstChildSlow();
125  if (!is<RenderMathMLBlock>(numerator))
 132 if (!isValid() || !is<RenderMathMLBlock>(numerator()))
126133 return nullptr;
127  return downcast<RenderMathMLBlock>(*numerator).unembellishedOperator();
 134
 135 return downcast<RenderMathMLBlock>(numerator()).unembellishedOperator();
 136}
 137
 138void RenderMathMLFraction::computePreferredLogicalWidths()
 139{
 140 ASSERT(preferredLogicalWidthsDirty());
 141
 142 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = 0;
 143
 144 if (isValid()) {
 145 LayoutUnit numeratorWidth = numerator().maxPreferredLogicalWidth();
 146 LayoutUnit denominatorWidth = denominator().maxPreferredLogicalWidth();
 147 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = std::max(numeratorWidth, denominatorWidth);
 148 }
 149
 150 setPreferredLogicalWidthsDirty(false);
 151}
 152
 153LayoutUnit RenderMathMLFraction::horizontalOffset(RenderBox& child, FractionAlignment align)
 154{
 155 switch (align) {
 156 case kRight:
 157 return LayoutUnit(logicalWidth() - child.logicalWidth());
 158 case kCenter:
 159 return LayoutUnit((logicalWidth() - child.logicalWidth()) / 2);
 160 case kLeft:
 161 return LayoutUnit(0);
 162 }
 163
 164 ASSERT_NOT_REACHED();
 165
 166 return LayoutUnit(0);
128167}
129168
130 void RenderMathMLFraction::layout()
 169void RenderMathMLFraction::layoutBlock(bool relayoutChildren, LayoutUnit)
131170{
 171 ASSERT(needsLayout());
 172
 173 // FIXME: We should be able to remove this.
132174 updateFromElement();
133175
134  // Adjust the fraction line thickness for the zoom
135  if (lastChild() && lastChild()->isRenderBlock())
136  m_lineThickness *= ceilf(gFractionBarWidth * style().fontSize());
 176 if (!relayoutChildren && simplifiedLayout())
 177 return;
 178
 179 if (!isValid()) {
 180 setLogicalWidth(0);
 181 setLogicalHeight(0);
 182 clearNeedsLayout();
 183 return;
 184 }
 185
 186 LayoutUnit verticalOffset = 0;
137187
138  RenderMathMLBlock::layout();
 188 numerator().layoutIfNeeded();
 189 denominator().layoutIfNeeded();
 190
 191 setLogicalWidth(std::max<LayoutUnit>(numerator().logicalWidth(), denominator().logicalWidth()));
 192
 193 LayoutPoint numeratorLocation(horizontalOffset(numerator(), m_numeratorAlign), verticalOffset);
 194 numerator().setLocation(numeratorLocation);
 195
 196 verticalOffset += numerator().logicalHeight() + gNumeratorGap * style().fontSize() + m_lineThickness + gDenominatorGap * style().fontSize();
 197
 198 LayoutPoint denominatorLocation(horizontalOffset(denominator(), m_denominatorAlign), verticalOffset);
 199 denominator().setLocation(denominatorLocation);
 200
 201 setLogicalHeight(verticalOffset + denominator().logicalHeight());
 202
 203 clearNeedsLayout();
139204}
140205
141206void RenderMathMLFraction::paint(PaintInfo& info, const LayoutPoint& paintOffset)
142207{
143208 RenderMathMLBlock::paint(info, paintOffset);
144  if (info.context().paintingDisabled() || info.phase != PaintPhaseForeground || style().visibility() != VISIBLE)
145  return;
146 
147  RenderBox* denominatorWrapper = lastChildBox();
148  if (!denominatorWrapper || !m_lineThickness)
 209 if (info.context().paintingDisabled() || info.phase != PaintPhaseForeground || style().visibility() != VISIBLE || !isValid())
149210 return;
150211
151  IntPoint adjustedPaintOffset = roundedIntPoint(paintOffset + location() + denominatorWrapper->location() + LayoutPoint(0, m_lineThickness / 2));
 212 IntPoint adjustedPaintOffset = roundedIntPoint(paintOffset + location() + LayoutPoint(0, numerator().logicalHeight() + gNumeratorGap * style().fontSize() + m_lineThickness / 2));
152213
153214 GraphicsContextStateSaver stateSaver(info.context());
154215
155216 info.context().setStrokeThickness(m_lineThickness);
156217 info.context().setStrokeStyle(SolidStroke);
157218 info.context().setStrokeColor(style().visitedDependentColor(CSSPropertyColor));
158  info.context().drawLine(adjustedPaintOffset, roundedIntPoint(LayoutPoint(adjustedPaintOffset.x() + denominatorWrapper->offsetWidth(), adjustedPaintOffset.y())));
 219 info.context().drawLine(adjustedPaintOffset, roundedIntPoint(LayoutPoint(adjustedPaintOffset.x() + logicalWidth(), adjustedPaintOffset.y())));
159220}
160221
161222Optional<int> RenderMathMLFraction::firstLineBaseline() const
162223{
163  if (RenderBox* denominatorWrapper = lastChildBox())
164  return Optional<int>(denominatorWrapper->logicalTop() + static_cast<int>(lroundf((m_lineThickness + style().fontMetrics().xHeight()) / 2)));
 224 if (isValid()) {
 225 LayoutUnit axisHeight = getMathAxisHeight();
 226 return Optional<int>(numerator().logicalHeight() + gNumeratorGap * style().fontSize() + static_cast<int>(lroundf(m_lineThickness / 2 + axisHeight)));
 227 }
165228 return RenderMathMLBlock::firstLineBaseline();
166229}
167230
 231void RenderMathMLFraction::paintChildren(PaintInfo& paintInfo, const LayoutPoint& paintOffset, PaintInfo& paintInfoForChild, bool usePrintRect)
 232{
 233 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox()) {
 234 if (!paintChild(*child, paintInfo, paintOffset, paintInfoForChild, usePrintRect, PaintAsInlineBlock))
 235 return;
 236 }
 237}
 238
168239}
169240
170241#endif // ENABLE(MATHML)

Source/WebCore/rendering/mathml/RenderMathMLFraction.h

11/*
22 * Copyright (C) 2009 Alex Milowski (alex@milowski.com). All rights reserved.
33 * Copyright (C) 2010 François Sausset (sausset@gmail.com). All rights reserved.
 4 * Copyright (C) 2016 Igalia S.L.
45 *
56 * Redistribution and use in source and binary forms, with or without
67 * modification, are permitted provided that the following conditions

@@public:
3940 RenderMathMLFraction(MathMLInlineContainerElement&, Ref<RenderStyle>&&);
4041
4142 MathMLInlineContainerElement& element() { return static_cast<MathMLInlineContainerElement&>(nodeForNonAnonymous()); }
42  float lineThickness() const { return m_lineThickness; }
 43 float relativeLineThickness() const { return m_defaultLineThickness ? m_lineThickness / m_defaultLineThickness : LayoutUnit(0); }
4344
44 private:
45  bool isRenderMathMLFraction() const override { return true; }
46  const char* renderName() const override { return "RenderMathMLFraction"; }
 45 void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight = 0) final;
 46 void paintChildren(PaintInfo& forSelf, const LayoutPoint&, PaintInfo& forChild, bool usePrintRect) final;
 47
 48protected:
 49 void computePreferredLogicalWidths() final;
4750
48  void addChild(RenderObject* child, RenderObject* beforeChild) override;
49  void updateFromElement() override;
50  Optional<int> firstLineBaseline() const override;
51  void paint(PaintInfo&, const LayoutPoint&) override;
52  RenderMathMLOperator* unembellishedOperator() override;
53  void layout() override;
54  void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override;
 51private:
 52 bool isRenderMathMLFraction() const final { return true; }
 53 const char* renderName() const final { return "RenderMathMLFraction"; }
5554
56  void fixChildStyle(RenderObject*);
 55 void updateFromElement() final;
 56 Optional<int> firstLineBaseline() const final;
 57 void paint(PaintInfo&, const LayoutPoint&) final;
 58 RenderMathMLOperator* unembellishedOperator() final;
 59 void styleDidChange(StyleDifference, const RenderStyle* oldStyle) final;
5760
 61 bool isValid() const;
 62 RenderBox& numerator() const;
 63 RenderBox& denominator() const;
 64 enum FractionAlignment {
 65 kCenter,
 66 kLeft,
 67 kRight
 68 };
 69 FractionAlignment parseAlignmentAttribute(const String& value);
 70 LayoutUnit horizontalOffset(RenderBox&, FractionAlignment);
 71
 72 LayoutUnit m_defaultLineThickness;
5873 LayoutUnit m_lineThickness;
 74 FractionAlignment m_numeratorAlign;
 75 FractionAlignment m_denominatorAlign;
5976};
6077
6178} // namespace WebCore