summaryrefslogtreecommitdiffstats
path: root/layout/mathml/tests/stretchy-and-large-operators.html
blob: 13fe14aa7145b778b6a2cfdbc4943eb6d33441df (plain)
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
<!-- -*- mode: HTML; tab-width: 2; indent-tabs-mode: nil; -*- -->
<!-- vim: set tabstop=2 expandtab shiftwidth=2 textwidth=80:  -->
<!DOCTYPE html>
<html>
  <head>
    <title>Test Stretchy and Large Operators</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
   - License, v. 2.0. If a copy of the MPL was not distributed with this
   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
    <script type="text/javascript"
            src="stretchy-and-large-operators.js"></script>
    <script type="text/javascript">

      var mathml = "http://www.w3.org/1998/Math/MathML";

      function createMo(aOperator, aForm)
      {
        var mo = document.createElementNS(mathml, "mo");
        mo.appendChild(document.createTextNode(aOperator));
        mo.setAttribute("form", aForm);
        return mo;
      }

      function createTest(aEntry)
      {
        var opname = aEntry[0];
        var operator = aEntry[1];
        var type = aEntry[2];
        var form = aEntry[3];

        var div = document.createElement("div");
        div.appendChild(document.createTextNode(opname));

        var math = document.createElementNS(mathml, "math");

        switch (type)
        {
          case "l": // largeop
            math.appendChild(createMo(operator, form));
            var mstyle = document.createElementNS(mathml, "mstyle");
            mstyle.setAttribute("displaystyle", "true");
            mstyle.appendChild(createMo(operator, form));
            math.appendChild(mstyle);
          break;

          case "v": // vertical
            for (var i = 1; i < 10; i+=2) {
              var mo = createMo(operator, form);
              mo.setAttribute("minsize", (.5 * i) + "em");
              math.appendChild(mo);
            }
          break;

          case "h": // horizontal
            for (var i = 1; i < 10; i+=2) {
              var mo = createMo(operator, form);
              var mspace = document.createElementNS(mathml, "mspace");
              mspace.setAttribute("width", (.5 * i) + "em");
              var mover = document.createElementNS(mathml, "mover");
              mover.setAttribute("accent", "false");
              mover.appendChild(mspace);
              mover.appendChild(mo);
              math.appendChild(mover);
            }
          break;

          default:
          break;
        }

        div.appendChild(math);
        document.body.appendChild(div);
      }

      function init()
      {
        for (var i in stretchy_and_large_operators) {
          createTest(stretchy_and_large_operators[i]);
        }
      }
    </script>
  </head>

  <body onload="init()">

 </body>
</html>