OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <meta charset="utf-8"> |
| 5 <title>Underscripts and Overscripts parameters</title> |
| 6 <link rel="help" href="http://www.mathml-association.org/MathMLinHTML5/S3.html#S
S4"> |
| 7 <meta name="assert" content="Elements munder, mover, munderover correctly ."> |
| 8 <script src="/resources/testharness.js"></script> |
| 9 <script src="/resources/testharnessreport.js"></script> |
| 10 <style> |
| 11 math, mspace, mo { |
| 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 script shifts and |
| 18 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 setup({ explicit_done: true }); |
| 28 window.addEventListener("load", runTests); |
| 29 |
| 30 function runTests() { |
| 31 test(function() { |
| 32 var e = 1; |
| 33 for (var i = 0; i <= 3; i++) { |
| 34 assert_approx_equals(getBox("under" + i + "base").middle, getBox("baseli
ne").bottom, e, "munder " + i + ": base is placed on the baseline"); |
| 35 assert_approx_equals(getBox("over" + i + "base").middle, getBox("baselin
e").bottom, e, "mover " + i + ": base is placed on the baseline"); |
| 36 } |
| 37 for (var i = 0; i <= 5; i++) { |
| 38 assert_approx_equals(getBox("underover" + i + "base").middle, getBox("ba
seline").bottom, e, "munderover " + i + ": base is placed on the baseline"); |
| 39 } |
| 40 }, "Alignment of the base on the baseline"); |
| 41 |
| 42 test(function() { |
| 43 var e = 1; |
| 44 for (var i = 0; i <= 3; i++) { |
| 45 assert_approx_equals(getBox("under" + i + "under").center, getBox("under
" + i + "base").center, e, "munder " + i + ": base and script are horizontally c
entered"); |
| 46 assert_approx_equals(getBox("over" + i + "over").center, getBox("over" +
i + "base").center, e, "mover " + i + ": base and script are horizontally cente
red"); |
| 47 } |
| 48 for (var i = 0; i <= 5; i++) { |
| 49 assert_approx_equals(getBox("underover" + i + "under").center, getBox("u
nderover" + i + "base").center, e, "munderover " + i + ": base and underscript a
re horizontally centered"); |
| 50 assert_approx_equals(getBox("underover" + i + "over").center, getBox("un
derover" + i + "base").center, e, "munderover " + i + ": base and overscript are
horizontally centered"); |
| 51 } |
| 52 }, "Horizontal alignments of base and scripts"); |
| 53 |
| 54 test(function() { |
| 55 for (var i = 0; i <= 3; i++) { |
| 56 assert_greater_than_equal(getBox("under" + i + "under").top, getBox("und
er" + i + "base").bottom, "munder " + i + ": script is under base"); |
| 57 assert_less_than_equal(getBox("over" + i + "over").bottom, getBox("over"
+ i + "base").top, "mover " + i + ": script is over base"); |
| 58 } |
| 59 for (var i = 0; i <= 5; i++) { |
| 60 assert_greater_than_equal(getBox("underover" + i + "under").top, getBox(
"underover" + i + "base").bottom, "munderover " + i + ": underscript is under ba
se"); |
| 61 assert_less_than_equal(getBox("underover" + i + "over").bottom, getBox("
underover" + i + "base").top, "munderover " + i + ": overscript is over base"); |
| 62 } |
| 63 }, "Relative vertical positions of base and scripts"); |
| 64 |
| 65 test(function() { |
| 66 var e = 1; |
| 67 for (var i = 0; i <= 3; i++) { |
| 68 assert_approx_equals(getBox("under" + i).width, Math.max(getBox("under"
+ i + "base").width, getBox("under" + i + "under").width), e, "munder " + i + ":
width is determined by the maximum of width of base and script"); |
| 69 assert_approx_equals(getBox("over" + i).width, Math.max(getBox("over" +
i + "base").width, getBox("over" + i + "over").width), e, "mover " + i + ": widt
h is determined by the maximum of width of base and script"); |
| 70 } |
| 71 for (var i = 0; i <= 5; i++) { |
| 72 assert_approx_equals(getBox("underover" + i).width, Math.max(getBox("und
erover" + i + "base").width, getBox("underover" + i + "under").width, getBox("un
derover" + i + "over").width), e, "munderover " + i + ": width is determined by
the maximum of width of base and scripts"); |
| 73 } |
| 74 }, "Width of scripted elements"); |
| 75 |
| 76 test(function() { |
| 77 var e = 3; |
| 78 for (var i = 0; i <= 3; i++) { |
| 79 assert_approx_equals(getBox("under" + i).height, getBox("under" + i + "b
ase").height + getBox("under" + i + "under").height + e, e, "munder " + i + ": h
eight is determined by the sum of heights of base and script plus some spacing."
); |
| 80 assert_approx_equals(getBox("over" + i).height, getBox("over" + i + "bas
e").height + getBox("over" + i + "over").height + e, e, "mover " + i + ": height
is determined by the sum of heights of base and script plus some spacing."); |
| 81 } |
| 82 for (var i = 0; i <= 5; i++) { |
| 83 assert_approx_equals(getBox("underover" + i).height, getBox("underover"
+ i + "base").height + getBox("underover" + i + "under").height + getBox("undero
ver" + i + "over").height + e, e, "munderover " + i + ": height is determined by
the sum heights of base and scripts"); |
| 84 } |
| 85 }, "Height of scripted elements"); |
| 86 |
| 87 done(); |
| 88 } |
| 89 </script> |
| 90 </head> |
| 91 <body> |
| 92 <p> |
| 93 <math> |
| 94 <mspace id="baseline" width="30px" height="2px" depth="0px" mathbackground
="blue"/> |
| 95 <munder id="under0"> |
| 96 <mspace id="under0base" width="30px" height="5px" depth="5px" mathbackgr
ound="black"/> |
| 97 <mspace id="under0under" width="10px" height="5px" depth="5px" mathbackg
round="black"/> |
| 98 </munder> |
| 99 <munder id="under1"> |
| 100 <mspace id="under1base" width="10px" height="5px" depth="5px" mathbackgr
ound="black"/> |
| 101 <mspace id="under1under" width="30px" height="5px" depth="5px" mathbackg
round="black"/> |
| 102 </munder> |
| 103 <munder id="under2"> |
| 104 <mspace id="under2base" width="10px" height="15px" depth="15px" mathback
ground="black"/> |
| 105 <mspace id="under2under" width="10px" height="5px" depth="5px" mathbackg
round="black"/> |
| 106 </munder> |
| 107 <munder id="under3"> |
| 108 <mspace id="under3base" width="10px" height="5px" depth="5px" mathbackgr
ound="black"/> |
| 109 <mspace id="under3under" width="10px" height="15px" depth="15px" mathbac
kground="black"/> |
| 110 </munder> |
| 111 <mover id="over0"> |
| 112 <mspace id="over0base" width="30px" height="5px" depth="5px" mathbackgro
und="black"/> |
| 113 <mspace id="over0over" width="10px" height="5px" depth="5px" mathbackgro
und="black"/> |
| 114 </mover> |
| 115 <mover id="over1"> |
| 116 <mspace id="over1base" width="10px" height="5px" depth="5px" mathbackgro
und="black"/> |
| 117 <mspace id="over1over" width="30px" height="5px" depth="5px" mathbackgro
und="black"/> |
| 118 </mover> |
| 119 <mover id="over2"> |
| 120 <mspace id="over2base" width="10px" height="15px" depth="15px" mathbackg
round="black"/> |
| 121 <mspace id="over2over" width="10px" height="5px" depth="5px" mathbackgro
und="black"/> |
| 122 </mover> |
| 123 <mover id="over3"> |
| 124 <mspace id="over3base" width="10px" height="5px" depth="5px" mathbackgro
und="black"/> |
| 125 <mspace id="over3over" width="10px" height="15px" depth="15px" mathbackg
round="black"/> |
| 126 </mover> |
| 127 <munderover id="underover0"> |
| 128 <mspace id="underover0base" width="30px" height="5px" depth="5px" mathba
ckground="black"/> |
| 129 <mspace id="underover0under" width="10px" height="5px" depth="5px" mathb
ackground="black"/> |
| 130 <mspace id="underover0over" width="10px" height="5px" depth="5px" mathba
ckground="black"/> |
| 131 </munderover> |
| 132 <munderover id="underover1"> |
| 133 <mspace id="underover1base" width="10px" height="5px" depth="5px" mathba
ckground="black"/> |
| 134 <mspace id="underover1under" width="30px" height="5px" depth="5px" mathb
ackground="black"/> |
| 135 <mspace id="underover1over" width="10px" height="5px" depth="5px" mathba
ckground="black"/> |
| 136 </munderover> |
| 137 <munderover id="underover2"> |
| 138 <mspace id="underover2base" width="10px" height="5px" depth="5px" mathba
ckground="black"/> |
| 139 <mspace id="underover2under" width="10px" height="5px" depth="5px" mathb
ackground="black"/> |
| 140 <mspace id="underover2over" width="30px" height="5px" depth="5px" mathba
ckground="black"/> |
| 141 </munderover> |
| 142 <munderover id="underover3"> |
| 143 <mspace id="underover3base" width="10px" height="15px" depth="15px" math
background="black"/> |
| 144 <mspace id="underover3under" width="10px" height="5px" depth="5px" mathb
ackground="black"/> |
| 145 <mspace id="underover3over" width="10px" height="5px" depth="5px" mathba
ckground="black"/> |
| 146 </munderover> |
| 147 <munderover id="underover4"> |
| 148 <mspace id="underover4base" width="10px" height="5px" depth="5px" mathba
ckground="black"/> |
| 149 <mspace id="underover4under" width="10px" height="15px" depth="15px" mat
hbackground="black"/> |
| 150 <mspace id="underover4over" width="10px" height="5px" depth="5px" mathba
ckground="black"/> |
| 151 </munderover> |
| 152 <munderover id="underover5"> |
| 153 <mspace id="underover5base" width="10px" height="5px" depth="5px" mathba
ckground="black"/> |
| 154 <mspace id="underover5under" width="10px" height="5px" depth="5px" mathb
ackground="black"/> |
| 155 <mspace id="underover5over" width="10px" height="15px" depth="15px" math
background="black"/> |
| 156 </munderover> |
| 157 </math> |
| 158 </p> |
| 159 <hr/> |
| 160 </body> |
| 161 </html> |
OLD | NEW |