forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 2
/
mathml.css
469 lines (419 loc) · 14.9 KB
/
mathml.css
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
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla MathML Project.
*
* The Initial Developer of the Original Code is
* The University Of Queensland.
* Portions created by the Initial Developer are Copyright (C) 1999
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Roger B. Sidje <rbs@maths.uq.edu.au>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**************************************************************************/
/* namespace for MathML elements */
/**************************************************************************/
@namespace url(http://www.w3.org/1998/Math/MathML);
/**************************************************************************/
/* <math> - outermost math element */
/* Put Cambria before Cambria Math as Cambria Math has neither bold nor */
/* italic. */
/**************************************************************************/
math {
direction: ltr;
unicode-bidi: embed;
display: inline;
font-size: inherit;
font-style: normal;
font-family: STIXGeneral, DejaVu Serif, DejaVu Sans, Cambria, Cambria Math, Times, Lucida Sans Unicode, OpenSymbol, Standard Symbols L, serif;
text-rendering: optimizeLegibility;
-moz-float-edge: margin-box;
}
math[mode="display"], math[display="block"] {
display: block;
text-align: -moz-center;
}
math[display="inline"] {
display: inline;
}
/**************************************************************************/
/* Style switching during frame construction depending on the context of <mi>:
These rules are not used when mathvariant or fontstyle is specified
explicitly.
/**************************************************************************/
/* If the textual content of an <mi> consists of a single character
with a corresponding mathematical italic alphanumeric character,
then try to emulate that character */
[_moz-math-font-style="italic"] {
font-style: italic;
font-weight: normal;
}
/* If the textual content consists of multiple characters, then the default is
mathvariant=normal. It seems that mathvariant=normal should be interpreted
to mean non-slanted:
http://www.w3.org/TR/2003/REC-MathML2-20031021/chapter3.html#presm.commatt
"In particular, inheritance of the mathvariant attribute does not follow
the CSS model. The default value for this attribute is "normal"
(non-slanted) for all tokens except mi. ... (The deprecated fontslant
attribute also behaves this way.)"
*/
[_moz-math-font-style="normal"] {
font-style: normal;
}
/* A style-invariant character preserves its own style */
[_moz-math-font-style="invariant"] {
font-style: normal;
font-weight: normal;
}
/**************************************************************************/
/* Links */
/**************************************************************************/
:-moz-any-link {
text-decoration: none !important;
}
/**************************************************************************/
/* attributes common to all tags */
/**************************************************************************/
/* deprecated attributes from MathML 1.0 */
/* fontstyle */
[fontstyle="normal"] {
font-style: normal;
}
[fontstyle="italic"] {
font-style: italic;
}
/* fontweight */
[fontweight="normal"] {
font-weight: normal;
}
[fontweight="bold"] {
font-weight: bold;
}
/* attributes from MathML 2.0 */
/* These ones are handled in the back-end:
mathcolor (replaces 'color'):
#rgb | #rrggbb | html-color-name
mathbackground (replaces 'background'):
#rgb | #rrggbb | html-color-name
*/
/* mathvariant (replaces 'fontstyle' & 'fontweight' & 'fontslant'):
normal | bold | italic | bold-italic | double-struck | bold-fraktur | script |
bold-script | fraktur | sans-serif | bold-sans-serif | sans-serif-italic |
sans-serif-bold-italic | monospace
Note1: Back-end code for these is not yet written (bug 114365):
double-struck, script, fraktur, bold-fraktur, bold-script
Note2: Don't use the 'font' shorthand because it resets the font-size and this
breaks the propagation of the scriptlevel size.
XXX bugs 46622 & 114365: need -moz-math-serif, etc, to only lookup math fonts
The meaning of mathvariant=normal is unclear as there is no interpretation
that "corresponds to SMP Math Alphanumeric Symbol characters"
(http://www.w3.org/TR/2003/REC-MathML2-20031021/chapter3.html#presm.commatt),
but let's assume an explicit mathvariant=normal is an attempt to reset all
style.
*/
[mathvariant] { /* shared and same as [mathvariant="normal"] */
/* reset all font properties except those that affect the size */
font-style: normal;
font-variant: normal;
font-weight: normal;
}
[mathvariant="bold-fraktur"],
[mathvariant="bold-script"] {
font-weight: bold;
}
[mathvariant="bold"] {
font-weight: bold;
}
[mathvariant="italic"] {
font-style: italic;
}
[mathvariant="bold-italic"] {
font-weight: bold;
font-style: italic;
}
[mathvariant="sans-serif"] {
font-family: sans-serif;
}
[mathvariant="bold-sans-serif"] {
font-weight: bold;
font-family: sans-serif;
}
[mathvariant="sans-serif-italic"] {
font-family: sans-serif;
font-style: italic;
}
[mathvariant="sans-serif-bold-italic"] {
font-family: sans-serif;
font-weight: bold;
font-style: italic;
}
[mathvariant="monospace"] {
font-family: monospace;
}
/**************************************************************************/
/* tags with generated content */
/**************************************************************************/
ms {
display: inline;
}
ms:before {
content: open-quote;
}
ms:after {
content: close-quote;
}
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):not(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;
}
/***********************/
/* -- mtd: columnalign */
mtd[_moz-math-columnalign="left"],
mtd[columnalign="left"] {
text-align: left;
}
mtd[_moz-math-columnalign="right"],
mtd[columnalign="right"] {
text-align: right;
}
mtd[_moz-math-columnalign="center"],
mtd[columnalign="center"] {
text-align: -moz-center;
}
/*************************/
/* -- mtr, mtd: rowalign */
mtr[_moz-math-rowalign="top"],
mtr[rowalign="top"],
mtd[rowalign="top"] {
vertical-align: top;
}
mtr[_moz-math-rowalign="bottom"],
mtr[rowalign="bottom"],
mtd[rowalign="bottom"] {
vertical-align: bottom;
}
mtr[_moz-math-rowalign="center"],
mtr[rowalign="center"],
mtd[rowalign="center"] {
vertical-align: middle;
}
mtr[_moz-math-rowalign="baseline"],
mtr[rowalign="baseline"],
mtd[rowalign="baseline"] {
vertical-align: baseline;
}
/* -- not yet supported --
mtr[_moz-math-rowalign="axis"],
mtr[rowalign="axis"],
mtd[rowalign="axis"] {
vertical-align: mathline;
}
*/
/**********************************************************************/
/* rules to achieve the default spacing between cells. The back-end code
will set the internal attributes depending on the cell's position.
These rules are hard-coded, the comments indicate what would be
desirable if the style data could be changed on the fly to pick
the values that users may set with the attributes of <mtable> */
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-left: 0em;
}
mtd:last-child {
padding-right: 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-left: 0.4em; /* framespacing.left */
}
mtable[frame="solid"] > mtr > mtd:last-child,
mtable[frame="dashed"] > mtr > mtd:last-child {
padding-right: 0.4em; /* framespacing.right */
}
/**********************************************************************/
/* internal settings to support 'rowlines' and 'columnlines'. To
achieve the recommended behavior, the back-end code will avoid setting
unsuitable rules on the cells on the first row and the first column.
In general, however, authors can use the 'border' property of CSS to
achieve varying effects down to the level of the table cell. */
mtr[_moz-math-rowline="none"] > mtd {
border-top: none;
}
mtr[_moz-math-rowline="solid"] > mtd {
border-top: solid thin;
}
mtr[_moz-math-rowline="dashed"] > mtd {
border-top: dashed thin;
}
mtd[_moz-math-columnline="none"] {
border-left: none;
}
mtd[_moz-math-columnline="solid"] {
border-left: solid thin;
}
mtd[_moz-math-columnline="dashed"] {
border-left: dashed thin;
}
/**************************************************************************/
/* Style used for stretchy symbols *must* be normal to avoid misaligments */
/* By leaving the font-family empty, the MathML engine will use the value
provided by the mathfont-family property in the mathfont.properties file
or the value of the user's pref("font.mathfont-family", "...").
Authors can make elements on a document to be stretched with different
fonts, e.g.,
To request the use of STIX fonts, you can add a <style>...</style> with:
<mo myfonts="stix">...</mo> with the associated CSS declaration
mo[myfonts="stix"]::-moz-math-stretchy {
font-family: STIXNonUnicode, STIXSizeOneSym, STIXSize1, STIXGeneral;
}
To request the use of Asana fonts, you can add a <style>...</style> with:
<mo myfonts="asana">...</mo> with the associated CSS declaration
mo[myfonts="asana"]::-moz-math-stretchy {
font-family: Asana Math;
}
Of course, if you just want all of the stretchy characters in your
document to be stretched with your preferred list, you can just do:
::-moz-math-stretchy {
font-family: [your-particular-list]
}
Note that like other fonts in the document, users can override this by
clicking the pref to override document fonts.
/**************************************************************************/
::-moz-math-stretchy {
font-style: normal;
font-family: serif; /* an empty family is ignored as an error and behaves like inherit */
/* background-color: #3C6; */
}
/* Don't actually style -moz-math-anonymous by default */
/*
::-moz-math-anonymous {
}
*/
/**********************************************************************/
/* Hide embedded semantic MathML content (as opposed to presentational
content, which we render). Ideally, here is the behavior that we want:
if there is an annotation-xml[encoding="MathML-Presentation"]
render that annotation, and ignore the first child of the
<semantics> element and all other annotations,
else
render the first child of <semantics> and ignore all annotations
But this cannot be expressed with CSS. As a stop-gap, just render
the first child to cater for most of the common cases - bug 154931.
*/
semantics > :not(:first-child) {
display: none;
}
/**********************************************************************/
/* 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 scriptlevel */
/*****************************************/
/* mfrac, 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 */
:-moz-math-increment-script-level { -moz-script-level:+1; }
/* all other cases can be described using regular CSS, so we do it this way because it's
more efficient and less code */
mroot > :not(:first-child) { -moz-script-level:+2; }
msub > :not(:first-child),
msup > :not(:first-child),
msubsup > :not(:first-child),
mmultiscripts > :not(:first-child) { -moz-script-level:+1; }