Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/mathml/presentation-markup/fractions/frac-1.html

Issue 2425083003: Import wpt@4114c724042b41e257caab98f3eb23c143b50de4 (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <title>Fraction</title>
6 <link rel="help" href="http://www.mathml-association.org/MathMLinHTML5/S3.html#S S3.SSS2">
7 <meta name="assert" content="Verify fraction metrics for different sizes of nume rator and denominator.">
8 <script src="/resources/testharness.js"></script>
9 <script src="/resources/testharnessreport.js"></script>
10 <style>
11 math, mspace {
12 font-size: 10px;
13 }
14 </style>
15 <script>
16 /* This test does not use any specific fonts and so the exact rules are not
17 specified precisely. We assume reasonable values for numerator/denominator
18 shifts and spacing. */
19
20 function getBox(aId) {
21 var box = document.getElementById(aId).getBoundingClientRect();
22 box.middle = (box.bottom + box.top) / 2;
23 box.center = (box.left + box.right) / 2;
24 return box;
25 }
26
27 function getFractionAxis(aId) {
28 return (getBox(aId).top * den.height + getBox(aId).bottom * num.height) / (n um.height + den.height);
29 }
30
31 setup({ explicit_done: true });
32 window.addEventListener("load", runTests);
33
34 function runTests() {
35 test(function() {
36 var e = 3;
37 var mathAxis = getBox("axis").middle;
38 // For stacks, nothing in the OpenType MATH specification seems to ensure
39 // that the gap is split symmetrically around the math axis so we only
40 // do the following verification for standard fractions.
41 for (var i = 0; i <= 4; i++) {
42 var frac = getBox("frac" + i);
43 var num = getBox("frac" + i + "num");
44 var den = getBox("frac" + i + "den");
45 // To estimate the fraction axis, we calculate barycenter between the
46 // top and bottom of the fraction, using the heights of numerator and
47 // denominator as weights.
48 var fracAxis = (frac.top * den.height + frac.bottom * num.height) / (num .height + den.height);
49 assert_approx_equals(fracAxis, mathAxis, e, "frac" + i + " fraction bar" );
50 }
51 }, "Fraction axis is aligned on the math axis");
52
53 test(function() {
54 for (var i = 0; i < 10; i++) {
55 assert_less_than(getBox("frac" + i + "num").bottom, getBox("frac" + i + "den").top, "numerator is above denominator");
56 assert_less_than(getBox("frac" + i + "den").top - getBox("frac" + i + "n um").bottom, 5, "The gap between numerator and denominator is not too large");
57 }
58 }, "Vertical positions of numerator and denominator");
59
60 test(function() {
61 var e = 3;
62 for (var i = 0; i < 10; i++)
63 assert_approx_equals(getBox("frac" + i + "num").center, getBox("frac" + i + "den").center, e, "numerator and denominator are horizontally centered");
64 }, "Horizontal alignments of numerator and denominator");
65
66 test(function() {
67 var e = 5;
68 for (var i = 0; i < 10; i++) {
69 var frac = getBox("frac" + i);
70 var num = getBox("frac" + i + "num");
71 var den = getBox("frac" + i + "den");
72 assert_approx_equals(frac.height, den.bottom - num.top, e, "height of fr ac " + i + " is determined by the bottom/top sides of the denominator/numerator" );
73 assert_approx_equals(frac.width, Math.max(num.right, den.right) - Math.m in(num.left, den.left), e, "width of frac " + i + " is determined by the left/ri ght sides of the denominator/numerator (plus some spacing)");
74 }
75 }, "Dimension of mfrac elements");
76
77 done();
78 }
79 </script>
80 </head>
81 <body>
82 <p>
83 <math>
84 <mo id="axis">−</mo>
85 <mfrac id="frac0">
86 <mspace id="frac0num" width="15px" height="15px" mathbackground="blue"/>
87 <mspace id="frac0den" width="15px" height="15px" mathbackground="green"/ >
88 </mfrac>
89 <mfrac id="frac1">
90 <mspace id="frac1num" width="30px" height="15px" mathbackground="blue"/>
91 <mspace id="frac1den" width="15px" height="15px" mathbackground="green"/ >
92 </mfrac>
93 <mfrac id="frac2">
94 <mspace id="frac2num" width="15px" height="15px" mathbackground="blue"/>
95 <mspace id="frac2den" width="30px" height="15px" mathbackground="green"/ >
96 </mfrac>
97 <mfrac id="frac3">
98 <mspace id="frac3num" width="15px" height="30px" mathbackground="blue"/>
99 <mspace id="frac3den" width="15px" height="15px" mathbackground="green"/ >
100 </mfrac>
101 <mfrac id="frac4">
102 <mspace id="frac4num" width="15px" height="15px" mathbackground="blue"/>
103 <mspace id="frac4den" width="15px" height="30px" mathbackground="green"/ >
104 </mfrac>
105 <mfrac id="frac5" linethickness="0px">
106 <mspace id="frac5num" width="15px" height="15px" mathbackground="blue"/>
107 <mspace id="frac5den" width="15px" height="15px" mathbackground="green"/ >
108 </mfrac>
109 <mfrac id="frac6" linethickness="0px">
110 <mspace id="frac6num" width="30px" height="15px" mathbackground="blue"/>
111 <mspace id="frac6den" width="15px" height="15px" mathbackground="green"/ >
112 </mfrac>
113 <mfrac id="frac7" linethickness="0px">
114 <mspace id="frac7num" width="15px" height="15px" mathbackground="blue"/>
115 <mspace id="frac7den" width="30px" height="15px" mathbackground="green"/ >
116 </mfrac>
117 <mfrac id="frac8" linethickness="0px">
118 <mspace id="frac8num" width="15px" height="30px" mathbackground="blue"/>
119 <mspace id="frac8den" width="15px" height="15px" mathbackground="green"/ >
120 </mfrac>
121 <mfrac id="frac9" linethickness="0px">
122 <mspace id="frac9num" width="15px" height="15px" mathbackground="blue"/>
123 <mspace id="frac9den" width="15px" height="30px" mathbackground="green"/ >
124 </mfrac>
125 </math>
126 </p>
127 <hr/>
128 </body>
129 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698