Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Embellished operators</title>
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
<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>
<script src="/mathml/support/box-navigation.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;
}
.testedElement mo {
color: yellow !important;
}
.testedElement, .testedElement * {
color: blue !important;
background: blue !important;
}
.oof1 {
position: absolute;
}
.oof2 {
position: fixed;
}
.nobox {
display: none;
}
</style>
<script>
function spaceBeforeElement(id) {
var element = document.getElementById(id);
var mnBefore = previousInFlowSibling(element);
return element.getBoundingClientRect().left - mnBefore.getBoundingClientRect().right;
}
function spaceBeforeCoreOperator(id) {
var element = document.getElementById(id);
var coreMo = element.getElementsByTagName("mo")[0];
return coreMo.getBoundingClientRect().left - element.getBoundingClientRect().left;
}
setup({ explicit_done: true });
window.addEventListener("load", runTests);
function runTests() {
var epsilon = 1;
var emToPx = 25;
["mrow", "mstyle", "mphantom", "mpadded", "merror", "mprescripts", "none", "unknown"].forEach(tag => {
test(function() {
assert_true(MathMLFeatureDetection.has_operator_spacing());
assert_approx_equals(spaceBeforeElement(`${tag}-op-1`), 2 * emToPx, epsilon);
assert_approx_equals(spaceBeforeCoreOperator(`${tag}-op-1`), 0, epsilon);
}, `${tag} (embellished operator)`);
test(function() {
assert_true(MathMLFeatureDetection.has_operator_spacing());
assert_approx_equals(spaceBeforeElement(`${tag}-op-2`), 2 * emToPx, epsilon);
assert_approx_equals(spaceBeforeCoreOperator(`${tag}-op-2`), 0, epsilon);
}, `${tag} (embellished operator, from in-flow children)`);
test(function() {
assert_true(MathMLFeatureDetection.has_operator_spacing());
assert_approx_equals(spaceBeforeElement(`${tag}-nonop-1`), 0, epsilon);
assert_approx_equals(spaceBeforeCoreOperator(`${tag}-nonop-1`), 2 * emToPx, epsilon);
}, `${tag} (not embellished operator)`);
test(function() {
assert_true(MathMLFeatureDetection.has_operator_spacing());
assert_approx_equals(spaceBeforeElement(`${tag}-nonop-2`), 0, epsilon);
assert_approx_equals(spaceBeforeCoreOperator(`${tag}-nonop-2`), 2 * emToPx, epsilon);
}, `${tag} (not embellished operator, from in-flow children)`);
});
done();
}
</script>
</head>
<body>
<div id="log"></div>
<!-- mrow is an embellished operator if its in-flow children consist
of one embellished operator and zero or more space-like elements. -->
<p>
<math>
<mn>X</mn>
<mrow id="mrow-op-1" class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
<mtext class="space-like">X</mtext>
</mrow>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<mrow id="mrow-nonop-1" class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
<mn>X</mn> <!-- "mn" is not space-like -->
</mrow>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mn>X</mn>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mrow id="mrow-op-2" class="testedElement">
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mo lspace="2em" rspace="0em">X</mo>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mtext class="space-like">X</mtext>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
</mrow>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mn>X</mn>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
</math>
</p>
<p>
<math>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mn>X</mn>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mrow id="mrow-nonop-2" class="testedElement">
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mo lspace="2em" rspace="0em">X</mo>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mn>X</mn> <!-- "mn" is not space-like -->
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
</mrow>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mn>X</mn>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
</math>
</p>
<!-- mstyle is an embellished operator if its in-flow children consist
of one embellished operator and zero or more space-like elements. -->
<p>
<math>
<mn>X</mn>
<mstyle id="mstyle-op-1" class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
</mstyle>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<mstyle id="mstyle-nonop-1" class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
<mn>X</mn> <!-- "mn" is not space-like -->
</mstyle>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mn>X</mn>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mstyle id="mstyle-op-2" class="testedElement">
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mo lspace="2em" rspace="0em">X</mo>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
</mstyle>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mn>X</mn>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
</math>
</p>
<p>
<math>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mn>X</mn>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mstyle id="mstyle-nonop-2" class="testedElement">
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mo lspace="2em" rspace="0em">X</mo>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mn>X</mn> <!-- "mn" is not space-like -->
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
</mstyle>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mn>X</mn>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
</math>
</p>
<!-- mphantom is an embellished operator if its in-flow children consist
of one embellished operator and zero or more space-like elements. -->
<p>
<math>
<mn>X</mn>
<mphantom id="mphantom-op-1" class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
</mphantom>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<mphantom id="mphantom-nonop-1" class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
<mn>X</mn> <!-- "mn" is not space-like -->
</mphantom>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mn>X</mn>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mphantom id="mphantom-op-2" class="testedElement">
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mo lspace="2em" rspace="0em">X</mo>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
</mphantom>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mn>X</mn>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
</math>
</p>
<p>
<math>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mn>X</mn>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mphantom id="mphantom-nonop-2" class="testedElement">
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mo lspace="2em" rspace="0em">X</mo>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mn>X</mn> <!-- "mn" is not space-like -->
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
</mphantom>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mn>X</mn>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
</math>
</p>
<!-- mpadded is an embellished operator if its in-flow children consist
of one embellished operator and zero or more space-like elements. -->
<p>
<math>
<mn>X</mn>
<mpadded id="mpadded-op-1" class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
</mpadded>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<mpadded id="mpadded-nonop-1" class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
<mn>X</mn> <!-- "mn" is not space-like -->
</mpadded>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mn>X</mn>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mpadded id="mpadded-op-2" class="testedElement">
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mo lspace="2em" rspace="0em">X</mo>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
</mpadded>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mn>X</mn>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
</math>
</p>
<p>
<math>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mn>X</mn>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mpadded id="mpadded-nonop-2" class="testedElement">
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mo lspace="2em" rspace="0em">X</mo>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mn>X</mn> <!-- "mn" is not space-like -->
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
</mpadded>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mn>X</mn>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
</math>
</p>
<!-- merror is an embellished operator if its in-flow children consist
of one embellished operator and zero or more space-like elements. -->
<p>
<math>
<mn>X</mn>
<merror id="merror-op-1" class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
</merror>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<merror id="merror-nonop-1" class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
<mn>X</mn> <!-- "mn" is not space-like -->
</merror>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mn>X</mn>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<merror id="merror-op-2" class="testedElement">
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mo lspace="2em" rspace="0em">X</mo>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
</merror>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mn>X</mn>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
</math>
</p>
<p>
<math>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mn>X</mn>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<merror id="merror-nonop-2" class="testedElement">
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mo lspace="2em" rspace="0em">X</mo>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mn>X</mn> <!-- "mn" is not space-like -->
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
</merror>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mn>X</mn>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
</math>
</p>
<!-- mprescripts is an embellished operator if its in-flow children consist
of one embellished operator and zero or more space-like elements. -->
<p>
<math>
<mn>X</mn>
<mprescripts id="mprescripts-op-1" class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
</mprescripts>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<mprescripts id="mprescripts-nonop-1" class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
<mn>X</mn> <!-- "mn" is not space-like -->
</mprescripts>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mn>X</mn>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mprescripts id="mprescripts-op-2" class="testedElement">
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mo lspace="2em" rspace="0em">X</mo>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
</mprescripts>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mn>X</mn>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
</math>
</p>
<p>
<math>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mn>X</mn>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mprescripts id="mprescripts-nonop-2" class="testedElement">
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mo lspace="2em" rspace="0em">X</mo>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mn>X</mn> <!-- "mn" is not space-like -->
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
</mprescripts>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mn>X</mn>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
</math>
</p>
<!-- none is an embellished operator if its in-flow children consist
of one embellished operator and zero or more space-like elements. -->
<p>
<math>
<mn>X</mn>
<none id="none-op-1" class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
</none>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<none id="none-nonop-1" class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
<mn>X</mn> <!-- "mn" is not space-like -->
</none>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mn>X</mn>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<none id="none-op-2" class="testedElement">
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mo lspace="2em" rspace="0em">X</mo>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
</none>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mn>X</mn>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
</math>
</p>
<p>
<math>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mn>X</mn>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<none id="none-nonop-2" class="testedElement">
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mo lspace="2em" rspace="0em">X</mo>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mn>X</mn> <!-- "mn" is not space-like -->
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
</none>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mn>X</mn>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
</math>
</p>
<!-- unknown is an embellished operator if its in-flow children consist
of one embellished operator and zero or more space-like elements. -->
<p>
<math>
<mn>X</mn>
<unknown id="unknown-op-1" class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
</unknown>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn>X</mn>
<unknown id="unknown-nonop-1" class="testedElement">
<mo lspace="2em" rspace="0em">X</mo>
<mn>X</mn> <!-- "mn" is not space-like -->
</unknown>
<mn>X</mn>
</math>
</p>
<p>
<math>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mn>X</mn>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<unknown id="unknown-op-2" class="testedElement">
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mo lspace="2em" rspace="0em">X</mo>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
</unknown>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mn>X</mn>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
</math>
</p>
<p>
<math>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mn>X</mn>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<unknown id="unknown-nonop-2" class="testedElement">
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mo lspace="2em" rspace="0em">X</mo>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mn>X</mn> <!-- "mn" is not space-like -->
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
</unknown>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
<mn>X</mn>
<mn class="oof1">0</mn><mn class="oof2">1</mn><mn class="nobox">2</mn>
</math>
</p>
</body>
</html>