mathml.css (11205B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 /**************************************************************************/ 6 /* namespace for MathML elements */ 7 /**************************************************************************/ 8 9 @namespace url(http://www.w3.org/1998/Math/MathML); 10 11 * { 12 writing-mode: horizontal-tb !important; 13 font-size: math; 14 } 15 16 /**************************************************************************/ 17 /* <math> - outermost math element */ 18 /**************************************************************************/ 19 20 math { 21 direction: ltr; 22 unicode-bidi: embed; 23 display: inline; 24 font-size: inherit; 25 font-style: normal; 26 font-weight: normal; 27 text-indent: 0; 28 font-family: serif; 29 line-height: normal; 30 word-spacing: normal; 31 letter-spacing: normal; 32 text-rendering: optimizeLegibility; 33 -moz-float-edge: margin-box; 34 math-shift: normal; 35 math-style: compact; 36 math-depth: 0; 37 /* stylelint-disable-next-line media-query-no-invalid */ 38 @media -moz-pref("mathml.font_family_math.enabled") { 39 font-family: math; 40 } 41 } 42 math[display="block" i] { 43 display: block; 44 text-align: -moz-center; 45 math-style: normal; 46 } 47 math[display="inline" i] { 48 display: inline; 49 math-style: compact; 50 } 51 52 /**************************************************************************/ 53 /* Links */ 54 /**************************************************************************/ 55 :any-link { 56 text-decoration: none !important; 57 } 58 59 /**************************************************************************/ 60 /* attributes common to all tags */ 61 /**************************************************************************/ 62 63 /* These attributes are mapped to style in MathMLElement.cpp: 64 65 - background -> background (deprecated) 66 - color -> color (deprecated) 67 - fontfamily -> font-family (deprecated) 68 - fontsize -> font-size (deprecated) 69 - fontstyle -> font-style (deprecated) 70 - fontweight -> font-weight (deprecated) 71 - mathvariant -> -moz-math-variant 72 - scriptlevel -> math-depth 73 - mathsize -> font-size 74 - mathcolor -> color 75 - mathbackground -> background 76 77 */ 78 79 /* Fractions */ 80 mfrac { 81 padding-inline: 1px; 82 } 83 84 /**************************************************************************/ 85 /* merror */ 86 /**************************************************************************/ 87 88 merror { 89 border: 1px solid red; 90 background-color: lightyellow; 91 } 92 93 /**************************************************************************/ 94 /* mtable and its related tags */ 95 /**************************************************************************/ 96 97 mtable { 98 display: inline-table; 99 border-collapse: separate; 100 border-spacing: 0; 101 text-indent: 0; 102 } 103 mtable[frame="none"] { 104 border: none; 105 } 106 mtable[frame="solid"] { 107 border: solid thin; 108 } 109 mtable[frame="dashed"] { 110 border: dashed thin; 111 } 112 113 mtr, 114 mlabeledtr { 115 display: table-row; 116 vertical-align: baseline; 117 } 118 119 mtd { 120 display: table-cell; 121 vertical-align: inherit; 122 text-align: -moz-center; 123 white-space: nowrap; 124 } 125 126 /* Don't support m(labeled)tr without mtable, nor mtd without m(labeled)tr */ 127 :not(mtable) > mtr, 128 :not(mtable) > mlabeledtr, 129 :not(mtr, mlabeledtr) > mtd { 130 display: none !important; 131 } 132 133 /* Hide the label because mlabeledtr is not supported yet (bug 356870). This 134 rule can be overriden by users. */ 135 mlabeledtr > mtd:first-child { 136 display: none; 137 } 138 139 /**********************************************************************/ 140 /* rules to achieve the default spacing between cells. When rowspacing, 141 columnspacing and framespacing aren't set on mtable. The back-end code 142 will set the internal attributes depending on the cell's position. 143 When they are set, the spacing behaviour is handled outside of CSS */ 144 mtd { 145 padding-right: 0.4em; /* half of columnspacing[colindex] */ 146 padding-left: 0.4em; /* half of columnspacing[colindex-1] */ 147 padding-bottom: 0.5ex; /* half of rowspacing[rowindex] */ 148 padding-top: 0.5ex; /* half of rowspacing[rowindex-1] */ 149 } 150 /* turn off the spacing at the periphery of boundary cells */ 151 mtr:first-child > mtd { 152 padding-top: 0; 153 } 154 mtr:last-child > mtd { 155 padding-bottom: 0; 156 } 157 mtd:first-child { 158 padding-inline-start: 0; 159 } 160 mtd:last-child { 161 padding-inline-end: 0; 162 } 163 /* re-instate the spacing if the table has a surrounding frame */ 164 mtable[frame="solid"] > mtr:first-child > mtd, 165 mtable[frame="dashed"] > mtr:first-child > mtd { 166 padding-top: 0.5ex; /* framespacing.top */ 167 } 168 mtable[frame="solid"] > mtr:last-child > mtd, 169 mtable[frame="dashed"] > mtr:last-child > mtd { 170 padding-bottom: 0.5ex; /* framespacing.bottom */ 171 } 172 mtable[frame="solid"] > mtr > mtd:first-child, 173 mtable[frame="dashed"] > mtr > mtd:first-child { 174 padding-inline-start: 0.4em; /* framespacing.left (or right in rtl)*/ 175 } 176 mtable[frame="solid"] > mtr > mtd:last-child, 177 mtable[frame="dashed"] > mtr > mtd:last-child { 178 padding-inline-end: 0.4em; /* framespacing.right (or left in rtl)*/ 179 } 180 181 mtable[rowspacing] > mtr > mtd, 182 mtable[columnspacing] > mtr > mtd, 183 mtable[framespacing] > mtr > mtd { 184 /* Spacing handled outside of CSS */ 185 padding: 0; 186 } 187 188 /**********************************************************************/ 189 /* This is used when wrapping non-MathML inline elements inside math. */ 190 *|*::-moz-mathml-anonymous-block { 191 display: inline-block !important; 192 position: static !important; 193 text-indent: 0; 194 } 195 196 /**************************************************************************/ 197 /* Controlling Displaystyle and Scriptlevel */ 198 /**************************************************************************/ 199 200 /* 201 http://www.w3.org/Math/draft-spec/chapter3.html#presm.scriptlevel 202 203 The determination of math-style for <math> involves the displaystyle 204 and display attributes. See the <math> section above. 205 */ 206 207 /* munder, mover and munderover change the scriptlevels of their children 208 using -moz-math-increment-script-level because regular CSS rules are 209 insufficient to control when the scriptlevel should be incremented. All other 210 cases can be described using regular CSS, so we do it this way because it's 211 more efficient and less code. */ 212 :-moz-math-increment-script-level { 213 math-depth: add(1); 214 } 215 216 /* 217 The mfrac element sets displaystyle to "false", or if it was already false 218 increments scriptlevel by 1, within numerator and denominator. 219 */ 220 mfrac > * { 221 math-depth: auto-add; 222 math-style: compact; 223 } 224 225 /* 226 The mroot element increments scriptlevel by 2, and sets displaystyle to 227 "false", within index, but leaves both attributes unchanged within base. 228 The msqrt element leaves both attributes unchanged within its argument. 229 */ 230 mroot > :not(:first-child) { 231 math-depth: add(2); 232 math-style: compact; 233 } 234 235 /* 236 The msub element [...] increments scriptlevel by 1, and sets displaystyle to 237 "false", within subscript, but leaves both attributes unchanged within base. 238 239 The msup element [...] increments scriptlevel by 1, and sets displaystyle to 240 "false", within superscript, but leaves both attributes unchanged within 241 base. 242 243 The msubsup element [...] increments scriptlevel by 1, and sets displaystyle 244 to "false", within subscript and superscript, but leaves both attributes 245 unchanged within base. 246 247 The mmultiscripts element increments scriptlevel by 1, and sets displaystyle 248 to "false", within each of its arguments except base, but leaves both 249 attributes unchanged within base. 250 */ 251 msub > :not(:first-child), 252 msup > :not(:first-child), 253 msubsup > :not(:first-child), 254 mmultiscripts > :not(:first-child) { 255 math-depth: add(1); 256 math-style: compact; 257 } 258 259 /* 260 The munder element [...] always sets displaystyle to "false" within the 261 underscript, but increments scriptlevel by 1 only when accentunder is 262 "false". Within base, it always leaves both attributes unchanged. 263 264 The mover element [...] always sets displaystyle to "false" within 265 overscript, but increments scriptlevel by 1 only when accent is "false". 266 Within base, it always leaves both attributes unchanged. 267 268 The munderover [..] always sets displaystyle to "false" within underscript 269 and overscript, but increments scriptlevel by 1 only when accentunder or 270 accent, respectively, are "false". Within base, it always leaves both 271 attributes unchanged. 272 */ 273 munder > :not(:first-child), 274 mover > :not(:first-child), 275 munderover > :not(:first-child) { 276 math-style: compact; 277 } 278 279 /* 280 https://w3c.github.io/mathml-core/#user-agent-stylesheet 281 282 A `math-shift: compact` value is applied to secondary elements like 283 denominators, roots, subscripts and specific multi-script parts to render 284 them at a reduced, "cramped" size. 285 286 For certain sub-elements within `mmultiscripts`, `math-shift: inherit` is 287 used to ensure they adopt the scaling of their parent. 288 */ 289 mfrac > :nth-child(2) { 290 math-shift: compact; 291 } 292 293 mroot, 294 msqrt { 295 math-shift: compact; 296 } 297 298 msub > :nth-child(2), 299 msubsup > :nth-child(2), 300 mmultiscripts > :nth-child(even), 301 mmultiscripts > mprescripts ~ :nth-child(odd), 302 mover[accent="true" i] > :first-child, 303 munderover[accent="true" i] > :first-child { 304 math-shift: compact; 305 } 306 307 mmultiscripts > mprescripts ~ :nth-child(even) { 308 math-shift: inherit; 309 } 310 311 /* 312 The displaystyle attribute is allowed on the mtable element to set the 313 inherited value of the attribute. If the attribute is not present, the 314 mtable element sets displaystyle to "false" within the table elements. 315 */ 316 mtable { 317 math-style: compact; 318 } 319 320 /* 321 The mscarries element sets displaystyle to "false", and increments 322 scriptlevel by 1, so the children are typically displayed in a smaller font. 323 XXXfredw: This element is not implemented yet. See bug 534967. 324 mscarries { 325 math-depth: add(1); 326 math-style: compact; 327 } 328 */ 329 330 /* "The mphantom element renders invisibly, but with the same size and other 331 dimensions, including baseline position, that its contents would have if 332 they were rendered normally.". 333 Also, we do not expose the <mphantom> element to the accessible tree 334 (see bug 1108378). */ 335 mphantom { 336 visibility: hidden; 337 } 338 339 /* Implement MathML Core's semantics/maction support 340 https://w3c.github.io/mathml-core/#dfn-semantics 341 https://w3c.github.io/mathml-core/#dfn-maction */ 342 maction > :not(:first-child), 343 semantics > :not(:first-child) { 344 display: none; 345 } 346 347 /* stylelint-disable-next-line media-query-no-invalid */ 348 @media -moz-pref("mathml.legacy_mathvariant_attribute.disabled") { 349 /* Implement MathML Core's automatic italic on mi. 350 https://w3c.github.io/mathml-core/#the-mathvariant-attribute */ 351 mi { 352 text-transform: math-auto; 353 } 354 }