summaryrefslogtreecommitdiffstats
path: root/layout/mathml/mathml.css
blob: 597aedabb7787dd058757b75fe6ebaa32d497981 (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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
/* 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/. */


/**************************************************************************/
/* namespace for MathML elements                                          */
/**************************************************************************/

@namespace url(http://www.w3.org/1998/Math/MathML);

* {
  writing-mode: horizontal-tb !important;
}

/**************************************************************************/
/* <math> - outermost math element                                        */
/**************************************************************************/

math {
  direction: ltr;
  unicode-bidi: embed;
  display: inline;
  font-size: inherit;
  font-style: normal;
  font-weight: normal;
  text-indent: 0;
  font-family: serif;
  line-height: normal;
  word-spacing: normal;
  letter-spacing: normal;
  text-rendering: optimizeLegibility;
  -moz-float-edge: margin-box;
  math-style: compact;
}
math[display="block" i] {
  display: block;
  text-align: -moz-center;
  math-style: normal;
}
math[display="inline" i] {
  display: inline;
  math-style: compact;
}

/**************************************************************************/
/* Token elements                                                         */
/**************************************************************************/

@media not (-moz-mathml-core-ms) {
  ms {
    display: inline;
  }
  ms:before, ms:after {
    content: "\0022"
  }
  ms[lquote]:before {
    content: attr(lquote)
  }
  ms[rquote]:after {
    content: attr(rquote)
  }
}

/**************************************************************************/
/* Links                                                                  */
/**************************************************************************/
:any-link {
  text-decoration: none !important;
}

/**************************************************************************/
/* attributes common to all tags                                          */
/**************************************************************************/

/* These attributes are mapped to style in MathMLElement.cpp:

   - background -> background                             (deprecated)
   - color -> color                                       (deprecated)
   - fontfamily -> font-family                            (deprecated)
   - fontsize -> font-size                                (deprecated)
   - fontstyle -> font-style                              (deprecated)
   - fontweight -> font-weight                            (deprecated)
   - mathvariant -> -moz-math-variant
   - scriptsizemultiplier -> -moz-script-size-multiplier
   - scriptminsize -> -moz-script-min-size
   - scriptlevel -> math-depth
   - mathsize -> font-size
   - mathcolor -> color
   - mathbackground -> background

*/


/**************************************************************************/
/* merror                                                                 */
/**************************************************************************/

merror {
  display: block;
  font-family: sans-serif;
  font-weight: bold;
  white-space: pre;
  margin: 1em;
  padding: 1em;
  border-width: thin;
  border-style: inset;
  border-color: red;
  font-size: 14pt;
  background-color: lightyellow;
}

/**************************************************************************/
/* mtable and its related tags                                            */
/**************************************************************************/

mtable {
  display: inline-table;
  border-collapse: separate;
  border-spacing: 0;
  text-indent: 0;
}
mtable[frame="none"] {
  border: none;
}
mtable[frame="solid"] {
  border: solid thin;
}
mtable[frame="dashed"] {
  border: dashed thin;
}

mtr, mlabeledtr {
  display: table-row;
  vertical-align: baseline;
}

mtd {
  display: table-cell;
  vertical-align: inherit;
  text-align: -moz-center;
  white-space: nowrap;
}

/* Don't support m(labeled)tr without mtable, nor mtd without m(labeled)tr */
:not(mtable) > mtr,
:not(mtable) > mlabeledtr,
:not(mtr, mlabeledtr) > mtd {
  display: none !important;
}

/* Hide the label because mlabeledtr is not supported yet (bug 356870). This
   rule can be overriden by users. */
mlabeledtr > mtd:first-child {
    display: none;
}

/**********************************************************************/
/* rules to achieve the default spacing between cells. When rowspacing,
   columnspacing and framespacing aren't set on mtable.  The back-end code
   will set the internal attributes depending on the cell's position.
   When they are set, the spacing behaviour is handled outside of CSS */
mtd {
  padding-right: 0.4em;  /* half of columnspacing[colindex] */
  padding-left: 0.4em;   /* half of columnspacing[colindex-1] */
  padding-bottom: 0.5ex; /* half of rowspacing[rowindex] */
  padding-top: 0.5ex;    /* half of rowspacing[rowindex-1] */
}
/* turn off the spacing at the periphery of boundary cells */
mtr:first-child > mtd {
  padding-top: 0ex;
}
mtr:last-child > mtd {
  padding-bottom: 0ex;
}
mtd:first-child {
  padding-inline-start: 0em;
}
mtd:last-child {
  padding-inline-end: 0em;
}
/* re-instate the spacing if the table has a surrounding frame */
mtable[frame="solid"] > mtr:first-child > mtd,
mtable[frame="dashed"] > mtr:first-child > mtd {
  padding-top: 0.5ex; /* framespacing.top */
}
mtable[frame="solid"] > mtr:last-child > mtd,
mtable[frame="dashed"] > mtr:last-child > mtd {
  padding-bottom: 0.5ex; /* framespacing.bottom */
}
mtable[frame="solid"] > mtr > mtd:first-child,
mtable[frame="dashed"] > mtr > mtd:first-child {
  padding-inline-start: 0.4em; /* framespacing.left (or right in rtl)*/
}
mtable[frame="solid"] > mtr > mtd:last-child,
mtable[frame="dashed"] > mtr > mtd:last-child {
  padding-inline-end: 0.4em; /* framespacing.right (or left in rtl)*/
}

mtable[rowspacing] > mtr > mtd,
mtable[columnspacing] > mtr > mtd,
mtable[framespacing] > mtr > mtd {
  /* Spacing handled outside of CSS */
  padding: 0px;
}

/**********************************************************************/
/* This is used when wrapping non-MathML inline elements inside math. */
*|*::-moz-mathml-anonymous-block {
  display: inline-block !important;
  position: static !important;
  text-indent: 0;
}

/**************************************************************************/
/* Controlling Displaystyle and Scriptlevel                               */
/**************************************************************************/

/*
  http://www.w3.org/Math/draft-spec/chapter3.html#presm.scriptlevel

  The determination of math-style for <math> involves the displaystyle
  and display attributes. See the <math> section above.
*/

/*  munder, mover and munderover change the scriptlevels of their children
   using -moz-math-increment-script-level because regular CSS rules are
   insufficient to control when the scriptlevel should be incremented. All other
   cases can be described using regular CSS, so we do it this way because it's
   more efficient and less code. */
:-moz-math-increment-script-level { math-depth: add(1); }

/*
   The mfrac element sets displaystyle to "false", or if it was already false
   increments scriptlevel by 1, within numerator and denominator.
*/
mfrac > * {
    math-depth: auto-add;
    math-style: compact;
}

/*
   The mroot element increments scriptlevel by 2, and sets displaystyle to
   "false", within index, but leaves both attributes unchanged within base.
   The msqrt element leaves both attributes unchanged within its argument.
*/
mroot > :not(:first-child) {
    math-depth: add(2);
    math-style: compact;
}

/*
   The msub element [...] increments scriptlevel by 1, and sets displaystyle to
   "false", within subscript, but leaves both attributes unchanged within base.

   The msup element [...] increments scriptlevel by 1, and sets displaystyle to
   "false", within superscript, but leaves both attributes unchanged within
   base.

   The msubsup element [...] increments scriptlevel by 1, and sets displaystyle
   to "false", within subscript and superscript, but leaves both attributes
   unchanged within base.

   The mmultiscripts element increments scriptlevel by 1, and sets displaystyle
   to "false", within each of its arguments except base, but leaves both
   attributes unchanged within base.
 */
msub > :not(:first-child),
msup > :not(:first-child),
msubsup > :not(:first-child),
mmultiscripts > :not(:first-child) {
    math-depth: add(1);
    math-style: compact;
}

/*
   The munder element [...] always sets displaystyle to "false" within the
   underscript, but increments scriptlevel by 1 only when accentunder is
   "false". Within base, it always leaves both attributes unchanged.

   The mover element [...] always sets displaystyle to "false" within
   overscript, but increments scriptlevel by 1 only when accent is "false".
   Within base, it always leaves both attributes unchanged.

   The munderover [..] always sets displaystyle to "false" within underscript
   and overscript, but increments scriptlevel by 1 only when accentunder or
   accent, respectively, are "false". Within base, it always leaves both
   attributes unchanged.
*/
munder > :not(:first-child),
mover > :not(:first-child),
munderover > :not(:first-child) {
    math-style: compact;
}

/*
   The displaystyle attribute is allowed on the mtable element to set the
   inherited value of the attribute. If the attribute is not present, the
   mtable element sets displaystyle to "false" within the table elements.
*/
mtable { math-style: compact; }

/*
   The mscarries element sets displaystyle to "false", and increments
   scriptlevel by 1, so the children are typically displayed in a smaller font.
   XXXfredw: This element is not implemented yet. See bug 534967.
mscarries {
  math-depth: add(1);
  math-style: compact;
}
*/

/* "The mphantom element renders invisibly, but with the same size and other
   dimensions, including baseline position, that its contents would have if
   they were rendered normally.".
   Also, we do not expose the <mphantom> element to the accessible tree
   (see bug 1108378). */
mphantom {
    visibility: hidden;
}

@media (-moz-mathml-core-maction-and-semantics) {
  /* Implement MathML Core's semantics/maction support
     https://w3c.github.io/mathml-core/#dfn-semantics
     https://w3c.github.io/mathml-core/#dfn-maction */
  maction > :not(:first-child),
  semantics > :not(:first-child) {
    display: none;
  }
}