blob: da343dd0bc35a79e0f309c38bbff34a69aa7df34 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Embellished operators</title>
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
<link rel="help" href="https://mathml-refresh.github.io/mathml-core/#embellished-operators">
<link rel="help" href="https://mathml-refresh.github.io/mathml-core/#definition-of-space-like-elements">
<link rel="help" href="https://mathml-refresh.github.io/mathml-core/#layout-of-mrow">
<meta name="assert" content="Verify definition of embellished operators">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/mathml/support/feature-detection.js"></script>
<style>
/* Default spacing of operator 'X' is 0.2777777777777778em so quite different
from the measured/specified 0em and 1em. */
math, math * {
font: 25px/1 Ahem;
}
mn {
color: black;
}
mtext.space-like {
color: lightblue !important;
}
.testedElement mo {
color: yellow !important;
}
.testedElement, .testedElement * {
color: blue !important;
background: blue !important;
}
</style>
<script>
function spaceBeforeElement(element) {
var mnBefore = element.previousElementSibling;
return element.getBoundingClientRect().left - mnBefore.getBoundingClientRect().right;
}
setup({ explicit_done: true });
window.addEventListener("load", runTests);
function runTests() {
var epsilon = 1;
var emToPx = 25;
["msub", "msup", "msubsup", "munder", "mover", "munderover",
"mmultiscripts", "mfrac", "maction", "semantics"].forEach(tag => {
test(function() {
assert_true(MathMLFeatureDetection.has_operator_spacing());
var element = document.getElementsByTagName(tag)[0];
assert_approx_equals(spaceBeforeElement(element), 2 * emToPx, epsilon);
}, `${tag} (embellished operator)`);
test(function() {
assert_true(MathMLFeatureDetection.has_operator_spacing());
var element = document.getElementsByTagName(tag)[1];
assert_approx_equals(spaceBeforeElement(element), 0, epsilon);
}, `${tag} (not embellished operator)`);
});
done();
}
</script>
</head>
<body>
<div id="log"></div>
<!-- <msub>, <msup>, <msubsup>, <munder>, <mover>, <munderover>,
<mmultiscripts>, <mfrac>, <semantics> or <maction> are embellished
operators if their first child exists and is an embellished operator -->
<p>
<math>
<mn>X</mn>
<msub class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
<mn>X</mn>
</msub>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<msup class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
<mn>X</mn>
</msup>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<msubsup class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
<mn>X</mn>
<mn>X</mn>
</msubsup>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<munder class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
<mn>X</mn>
</munder>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<mover class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
<mn>X</mn>
</mover>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<munderover class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
<mn>X</mn>
</munderover>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<mmultiscripts class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
<mn>X</mn>
<mn>X</mn>
<mn>X</mn>
<mn>X</mn>
</mmultiscripts>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<mfrac class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
<mn>X</mn>
</mfrac>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<maction class="testedElement" actiontype="statusline">
<mo lspace="2em" rspace="0em">X</mo>
<mn>STATUS MESSAGE</mn>
</maction>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<semantics class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
<annotation>TEXT ANNOTATION</annotation>
<mn>X</mn>
</semantics>
<mn>X</mn>
</math>
</p>
<!-- <msub>, <msup>, <msubsup>, <munder>, <mover>, <munderover>,
<mmultiscripts>, <mfrac>, <semantics> or <maction> are not embellished
operators if their first child is not an embellished operator -->
<p>
<math>
<mn>X</mn>
<msub class="testedElement">
<mn>X</mn>
<mo lspace="2em" rspace="0em">X</mo>
</msub>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<msup class="testedElement">
<mn>X</mn>
<mo lspace="2em" rspace="0em">X</mo>
</msup>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<msubsup class="testedElement">
<mn>X</mn>
<mo lspace="2em" rspace="0em">X</mo>
<mn>X</mn>
</msubsup>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<munder class="testedElement">
<mn>X</mn>
<mo lspace="2em" rspace="0em">X</mo>
</munder>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<mover class="testedElement">
<mn>X</mn>
<mo lspace="2em" rspace="0em">X</mo>
</mover>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<munderover class="testedElement">
<mn>X</mn>
<mo lspace="2em" rspace="0em">X</mo>
</munderover>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<mmultiscripts class="testedElement">
<mn>X</mn>
<mo lspace="2em" rspace="0em">X</mo>
<mn>X</mn>
<mn>X</mn>
<mn>X</mn>
</mmultiscripts>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<mfrac class="testedElement">
<mn>X</mn>
<mo lspace="2em" rspace="0em">X</mo>
</mfrac>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<maction class="testedElement" actiontype="statusline">
<mn>X</mn>
<mo lspace="2em" rspace="0em">STATUS MESSAGE</mo>
</maction>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<semantics class="testedElement">
<mrow>
<mn>X</mn>
<mo lspace="2em" rspace="0em">X</mo>
</mrow>
<annotation>TEXT ANNOTATION</annotation>
</semantics>
<mn>X</mn>
</math>
</p>
</body>
</html>