File: subsup-1.html

package info (click to toggle)
thunderbird 1%3A68.10.0-1~deb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,754,812 kB
  • sloc: cpp: 5,411,679; javascript: 4,161,772; ansic: 2,639,702; python: 763,064; java: 346,606; xml: 266,623; asm: 265,884; sh: 117,270; lisp: 41,340; makefile: 23,560; perl: 18,042; objc: 5,277; yacc: 1,778; ada: 1,681; pascal: 1,673; lex: 1,417; cs: 879; exp: 527; awk: 495; php: 436; ruby: 221; sed: 69; csh: 27
file content (104 lines) | stat: -rw-r--r-- 6,156 bytes parent folder | download | duplicates (2)
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Subscripts and Superscripts metrics</title>
<link rel="help" href="https://mathml-refresh.github.io/mathml-core/#msubmsup">
<meta name="assert" content="Basic metrics for elements msub, msup and msubsup.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
  math, mspace {
    font-size: 10px;
  }
</style>
<script>
  /* This test does not use any specific fonts and so the exact rules are not
  specified precisely. We assume reasonable values for script shifts and
  spacing. */

  function getBox(aId) {
    var box = document.getElementById(aId).getBoundingClientRect();
    box.middle = (box.bottom + box.top) / 2;
    return box;
  }

  setup({ explicit_done: true });
  window.addEventListener("load", runTests);

  function runTests() {
    test(function() {
      var e = 1;
      assert_less_than_equal(getBox("msubBase").right, getBox("msubSub").left, e, "msub: subscript is after base");
      assert_less_than_equal(getBox("msupBase").right, getBox("msupSup").left, e, "msup: superscript is after base");
      assert_less_than_equal(getBox("msubsupBase").right, getBox("msubsupSub").left, e, "msubsup: subscript is after base");
      assert_less_than_equal(getBox("msubsupBase").right, getBox("msubsupSup").left, e, "msubsup: superscript is after base");

      e = 3;
      assert_approx_equals(getBox("msubBase").right, getBox("msubSub").left, e, "msub: space between base and subscript is small");
      assert_approx_equals(getBox("msubBase").right, getBox("msubSub").left, e, "msub: subscript is after base");
      assert_approx_equals(getBox("msupBase").right, getBox("msupSup").left, e, "msup: superscript is after base");
      assert_approx_equals(getBox("msubsupBase").right, getBox("msubsupSub").left, e, "msubsup: subscript is after base");
      assert_approx_equals(getBox("msubsupBase").right, getBox("msubsupSup").left, e, "msubsup: superscript is after base");
    }, "Respective horizontal positions");

    test(function() {
      var e = 1;
      assert_approx_equals(getBox("msubBase").middle, getBox("baseline").bottom, e, "msub: base is placed on the baseline");
      assert_approx_equals(getBox("msupBase").middle, getBox("baseline").bottom, e, "msup: base is placed on the baseline");
      assert_approx_equals(getBox("msubsupBase").middle, getBox("baseline").bottom, e, "msubsup: base is placed on the baseline");
    }, "Alignment of the base on the baseline");

    test(function() {
      var e = 3;
      assert_approx_equals(getBox("msubSub").middle, getBox("msubBase").bottom, e, "msub: script is placed at the bottom of the base");
      assert_approx_equals(getBox("msupSup").middle, getBox("msupBase").top, e, "msup: script is placed at the top of the base");
      assert_approx_equals(getBox("msubsupSub").middle, getBox("msubsupBase").bottom, e, "msubsup: script is placed at the bottom of the base");
      assert_approx_equals(getBox("msubsupSup").middle, getBox("msubsupBase").top, e, "msubsup: script is placed at the top of the base");
    }, "Vertical position of scripts");

    test(function() {
      var e = 3;
      assert_approx_equals(getBox("msub").width, getBox("msubSub").right - getBox("msubBase").left, e, "msub: width is determined by the left/right sides of base/script (+ some space after script)");
      assert_approx_equals(getBox("msup").width, getBox("msupSup").right - getBox("msupBase").left, e, "msup: width is determined by the left/right sides of base/script (+ some space after script)");
      assert_approx_equals(getBox("msubsup").width, Math.max(getBox("msubsupSub").right, getBox("msubsupSup").right) - getBox("msubsupBase").left, e, "msubsup: width is determined by the left/right sides of base/scripts (+ some space after script)");
    }, "Width of scripted elements");

    test(function() {
      var e = 1;
      assert_greater_than_equal(getBox("msub").height, getBox("msubBase").height, e, "msub: height is at least the one of the base");
      assert_greater_than_equal(getBox("msup").height, getBox("msupBase").height, e, "msup: height is at least the one of the base");
      assert_greater_than_equal(getBox("msubsup").height, getBox("msubsupBase").height, e, "msubsup: height is at least the one of the base");

      e = 3;
      assert_approx_equals(getBox("msub").height, Math.max(getBox("msubSub").bottom, getBox("msubBase").bottom) - getBox("msubBase").top, e, "msub: height is determined by the top/bottom sides of base/scripts");
      assert_approx_equals(getBox("msup").height, getBox("msupBase").bottom - Math.min(getBox("msupSup").top, getBox("msupBase").top), e, "msup: height is determined by the top/bottom sides of base/scripts");
      assert_approx_equals(getBox("msubsup").height, Math.max(getBox("msubSub").bottom, getBox("msubBase").bottom) - Math.min(getBox("msupSup").top, getBox("msupBase").top), e, "msubsup: height is determined by the top/bottom sides of base/scripts");
    }, "Height of scripted elements");

    done();
  }
</script>
</head>
<body>
  <div id="log"></div>
  <p>
    <math>
      <mspace id="baseline" width="30px" height="2px" depth="0px" style="background: blue"/>
      <msub id="msub" style="background: green">
        <mspace id="msubBase" width="30px" height="15px" depth="15px" style="background: black"/>
        <mspace id="msubSub" width="10px" height="5px" depth="5px" style="background: black"/>
      </msub>
      <msup id="msup" style="background: blue">
        <mspace id="msupBase" width="30px" height="15px" depth="15px" style="background: black"/>
        <mspace id="msupSup" width="10px" height="5px" depth="5px" style="background: black"/>
      </msup>
      <msubsup id="msubsup" style="background: green">
        <mspace id="msubsupBase" width="30px" height="15px" depth="15px" style="background: black"/>
        <mspace id="msubsupSub" width="10px" height="5px" depth="5px" style="background: black"/>
        <mspace id="msubsupSup" width="10px" height="5px" depth="5px" style="background: black"/>
      </msubsup>
    </math>
  </p>
</body>
</html>