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
|
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>writing mode</title>
<link rel="help" href="https://w3c.github.io/mathml-core/#layout-algorithms">
<meta name="assert" content="Verify CSS writing mode (writing-mode and direction properties) for mrow.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/mathml/support/feature-detection.js"></script>
<script src="/mathml/support/layout-comparison.js"></script>
<script src="/mathml/support/mathml-fragments.js"></script>
<script>
var epsilon = 1;
setup({ explicit_done: true });
window.addEventListener("load", runTests);
function runTests() {
for (tag in MathMLFragments) {
if (tag == "annotation" || tag == "annotation-xml")
continue; // These tags have display: none.
["horizontal-tb_rtl"].forEach(id => {
var writingMode = id.split("_");
var writingModeString = `writing-mode: ${writingMode[0]}; direction: ${writingMode[1]};`;
document.body.insertAdjacentHTML("beforeend", `<div>\
<math>${MathMLFragments[tag]}</math>\
<math>${MathMLFragments[tag]}</math>\
</div>`);
var div = document.body.lastElementChild;
var styleMath = div.firstElementChild;
styleMath.setAttribute("style", writingModeString);
var styleElement = FragmentHelper.element(styleMath);
var referenceMath = div.lastElementChild;
var referenceElement = FragmentHelper.element(referenceMath);
[styleMath, referenceMath].forEach(math => {
Array.from(math.getElementsByClassName("mathml-container")).forEach(container => {
container.insertAdjacentHTML("beforeend", "\
<mspace style='background: blue'\
width='20px' height='30px' depth='40px'></mspace>\
<mspace style='background: black'\
width='50px' depth='60px'></mspace>\
<mspace style='background: yellow'\
width='70px' height='80px'></mspace>");
});
Array.from(math.getElementsByClassName("foreign-container")).forEach(container => {
container.insertAdjacentHTML("beforeend", "\
<span style='display: inline-block; background: lightblue;\
inline-size: 20px; block-size: 30px;\
vertical-align: bottom;'></span>\
<span style='display: inline-block; background: pink;\
inline-size: 40px; block-size: 50px;\
vertical-align: bottom;'></span>");
});
});
test(function() {
assert_true(MathMLFeatureDetection.has_mspace());
var style = window.getComputedStyle(styleElement);
assert_equals(style.getPropertyValue("writing-mode"),
writingMode[0], "writing-mode");
assert_equals(style.getPropertyValue("direction"),
writingMode[1], "direction");
compareLayout(styleElement, referenceElement, epsilon);
}, `Layout of ${tag} (${writingModeString})`);
div.style = "display: none;"; // Hide the div after testing.
});
}
done();
}
</script>
</head>
<body>
<div id="log"></div>
</body>
</html>
|