Skip to content

Commit 7dc7a40

Browse files
authored
1 parent a981267 commit 7dc7a40

1 file changed

Lines changed: 85 additions & 0 deletions

File tree

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Operator dictionary (combining char, default category)</title>
6+
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
7+
<link rel="help" href="https://w3c.github.io/mathml-core/#operator-fence-separator-or-accent-mo">
8+
<link rel="help" href="https://w3c.github.io/mathml-core/#dictionary-based-attributes">
9+
<link rel="help" href="https://w3c.github.io/mathml-core/#operator-dictionary">
10+
<link rel="help" href="https://w3c.github.io/mathml-core/#layout-of-mrow">
11+
<link rel="stylesheet" href="./support/operator-dictionary-tests.css"/>
12+
<meta name="assert" content="Operators with unsupported combining characters or three or more characters fall back to Default category (lspace=rspace=0.2777777777777778em)">
13+
<script src="/resources/testharness.js"></script>
14+
<script src="/resources/testharnessreport.js"></script>
15+
<script src="/mathml/support/feature-detection.js"></script>
16+
<style>
17+
mo {
18+
color: blue;
19+
}
20+
mn {
21+
background: black;
22+
}
23+
</style>
24+
<script>
25+
function spaceBetween(element, i, j) {
26+
return element.children[j].getBoundingClientRect().left -
27+
element.children[i].getBoundingClientRect().right;
28+
}
29+
window.addEventListener("load", () => {
30+
var epsilon = 1;
31+
// Default category spacing per https://w3c.github.io/mathml-core/#operator-dictionary-categories-values
32+
var defaultSpaceEm = 0.2777777777777778;
33+
34+
Array.from(document.getElementsByClassName("test-group")).forEach(group => {
35+
var ref = group.getElementsByClassName("reference")[0];
36+
var def = group.getElementsByClassName("default")[0];
37+
test(function() {
38+
assert_true(MathMLFeatureDetection.has_operator_spacing());
39+
var fontSize = parseFloat(getComputedStyle(def).fontSize);
40+
var expected = 2 * defaultSpaceEm * fontSize;
41+
var actual = spaceBetween(def, 0, 2) - spaceBetween(ref, 0, 2);
42+
assert_approx_equals(actual, expected, epsilon, "lspace + rspace");
43+
}, `Default spacing for ${group.dataset.description}`);
44+
});
45+
});
46+
</script>
47+
</head>
48+
<body>
49+
<div id="log"></div>
50+
<!-- U+0303 COMBINING TILDE is not a recognized combining overlay -->
51+
<div class="test-group" data-description="= + unsupported combining char U+0303">
52+
<p>
53+
<math class="reference">
54+
<mn>&nbsp;</mn>
55+
<mo lspace="0" rspace="0">=&#x303;</mo>
56+
<mn>&nbsp;</mn>
57+
</math>
58+
</p>
59+
<p>
60+
<math class="default">
61+
<mn>&nbsp;</mn>
62+
<mo>=&#x303;</mo>
63+
<mn>&nbsp;</mn>
64+
</math>
65+
</p>
66+
</div>
67+
<!-- Three characters: base + two combining overlays -->
68+
<div class="test-group" data-description="= + U+0338 + U+20D2 (too many characters)">
69+
<p>
70+
<math class="reference">
71+
<mn>&nbsp;</mn>
72+
<mo lspace="0" rspace="0">=&#x338;&#x20D2;</mo>
73+
<mn>&nbsp;</mn>
74+
</math>
75+
</p>
76+
<p>
77+
<math class="default">
78+
<mn>&nbsp;</mn>
79+
<mo>=&#x338;&#x20D2;</mo>
80+
<mn>&nbsp;</mn>
81+
</math>
82+
</p>
83+
</div>
84+
</body>
85+
</html>

0 commit comments

Comments
 (0)