1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
|
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Edge cases for minsize and maxsize</title>
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
<link rel="help" href="https://w3c.github.io/mathml-core/#dictionary-based-attributes">
<meta name="assert" content="Verify edge cases for minsize and maxsize .">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/mathml/support/fonts.js"></script>
<style>
math {
font: 25px/1 Ahem;
}
@font-face {
font-family: operators;
src: url("/fonts/math/operators.woff"); /* AxisHeight == 0 */
}
mo {
font-family: operators;
}
</style>
<script>
setup({ explicit_done: true });
window.addEventListener("load", () => { loadAllFonts().then(runTests); });
function runTests() {
var epsilon = 1;
var emToPx = 25;
test(function() {
assert_approx_equals(document.getElementById("negative_minsize").getBoundingClientRect().height, 5 * emToPx, epsilon);
}, `minsize < 0 is treated as 0`);
test(function() {
assert_approx_equals(document.getElementById("maxsize_less_than_minsize").getBoundingClientRect().height, 7 * emToPx, epsilon);
}, `maxsize < minsize is treated as maxsize = minsize`);
test(function() {
assert_less_than(document.getElementById("minsize_less_than_negative_maxsize").getBoundingClientRect().height, 2 * emToPx);
}, `minsize < maxsize < 0 is treated as maxsize = minsize = 0`);
test(function() {
assert_approx_equals(document.getElementById("zero_target_size_with_minsize").getBoundingClientRect().height, 2 * emToPx, epsilon);
assert_approx_equals(document.getElementById("zero_target_size_with_minsize").getBoundingClientRect().bottom - document.getElementById("zero_target_size_with_minsize_math_axis").getBoundingClientRect().bottom, emToPx, epsilon);
}, `target size = 0 is treated as Tascent = Tdescent = minsize/2`);
test(function() {
assert_approx_equals(document.getElementById("percent_minsize").getBoundingClientRect().height, 12 * emToPx, epsilon, "percent minsize");
assert_approx_equals(document.getElementById("percent_maxsize").getBoundingClientRect().height, 3 * emToPx, epsilon, "percent maxsize");
}, `minsize/maxsize percentages are relative to the target size`);
test(function() {
// These tests are not really strong:
// - The smallest glyph for this stretchy operator is a 1em square so
// it can't go under a minsize of 1em anyway.
// - The maxsize is theorically infinite, this only tests that a large
// value of 300em is clamped.
assert_approx_equals(document.getElementById("default_minsize").getBoundingClientRect().height, 1 * emToPx, epsilon, "default minsize is 1em");
assert_approx_equals(document.getElementById("default_maxsize").getBoundingClientRect().height, 300 * emToPx, epsilon, "default maxsize is infinity");
}, `default minsize/maxsize percentages`);
done();
}
</script>
</head>
<body>
<div id="log"></div>
<p>
<math>
<mrow>
<mspace width="1em" height="5em" style="background: blue"/>
<mo id="negative_minsize" minsize="-10em" stretchy="true" symmetric="false">⥯</mo>
<mn><!-- not space like --></mn>
</mrow>
</math>
</p>
<p>
<math>
<mrow>
<mspace width="1em" height="5em" style="background: blue"/>
<mo id="maxsize_less_than_minsize" minsize="7em" maxsize="2em" stretchy="true" symmetric="false">⥯</mo>
<mn><!-- not space like --></mn>
</mrow>
</math>
</p>
<p>
<math>
<mrow>
<mspace width="1em" height="5em" style="background: blue"/>
<mo id="minsize_less_than_negative_maxsize" minsize="-2em" maxsize="-1em" stretchy="true" symmetric="false">⥯</mo>
<mn><!-- not space like --></mn>
</mrow>
</math>
</p>
<p>
<math>
<mrow>
<mspace id="zero_target_size_with_minsize_math_axis" width="1em" height="0em" style="background: blue"/>
<mo id="zero_target_size_with_minsize" minsize="2em" stretchy="true" symmetric="true">⥯</mo>
<mn><!-- not space like --></mn>
</mrow>
</math>
</p>
<p>
<math>
<mrow>
<mspace width="1em" height="6em" style="background: blue"/>
<mo id="percent_minsize" minsize="200%" stretchy="true" symmetric="false">⥯</mo>
<mn><!-- not space like --></mn>
</mrow>
</math>
</p>
<p>
<math>
<mrow>
<mspace width="1em" height="6em" style="background: blue"/>
<mo id="percent_maxsize" maxsize="50%" stretchy="true" symmetric="false">⥯</mo>
<mn><!-- not space like --></mn>
</mrow>
</math>
</p>
<p>
<math>
<mrow>
<mspace width="1em" height=".5em" style="background: blue"/>
<mo id="default_minsize" stretchy="true" symmetric="false">⥯</mo>
<mn><!-- not space like --></mn>
</mrow>
</math>
</p>
<p>
<math>
<mrow>
<mspace width="1em" height="300em" style="background: blue"/>
<mo id="default_maxsize" stretchy="true" symmetric="false">⥯</mo>
<mn><!-- not space like --></mn>
</mrow>
</math>
</p>
</body>
</html>
|