mathml.css 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  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. /* namespace for MathML elements */
  6. /**************************************************************************/
  7. @namespace url(http://www.w3.org/1998/Math/MathML);
  8. /**************************************************************************/
  9. /* <math> - outermost math element */
  10. /**************************************************************************/
  11. math {
  12. writing-mode: horizontal-tb !important;
  13. direction: ltr;
  14. unicode-bidi: embed;
  15. display: inline;
  16. font-size: inherit;
  17. font-style: normal;
  18. font-family: serif;
  19. line-height: normal;
  20. word-spacing: normal;
  21. letter-spacing: normal;
  22. text-rendering: optimizeLegibility;
  23. -moz-float-edge: margin-box;
  24. -moz-math-display: inline;
  25. }
  26. math[mode="display"], math[display="block"] {
  27. display: block;
  28. text-align: -moz-center;
  29. -moz-math-display: block;
  30. }
  31. math[display="inline"] {
  32. display: inline;
  33. -moz-math-display: inline;
  34. }
  35. math[displaystyle="false"] {
  36. -moz-math-display: inline;
  37. }
  38. math[displaystyle="true"] {
  39. -moz-math-display: block;
  40. }
  41. /**************************************************************************/
  42. /* Token elements */
  43. /**************************************************************************/
  44. ms {
  45. display: inline;
  46. }
  47. ms:before, ms:after {
  48. content: "\0022"
  49. }
  50. ms[lquote]:before {
  51. content: attr(lquote)
  52. }
  53. ms[rquote]:after {
  54. content: attr(rquote)
  55. }
  56. /**************************************************************************/
  57. /* Links */
  58. /**************************************************************************/
  59. :any-link {
  60. text-decoration: none !important;
  61. }
  62. /**************************************************************************/
  63. /* attributes common to all tags */
  64. /**************************************************************************/
  65. /* These attributes are mapped to style in nsMathMLElement.cpp:
  66. - background -> background (deprecated)
  67. - color -> color (deprecated)
  68. - fontfamily -> font-family (deprecated)
  69. - fontsize -> font-size (deprecated)
  70. - fontstyle -> font-style (deprecated)
  71. - fontweight -> font-weight (deprecated)
  72. - mathvariant -> -moz-math-variant
  73. - scriptsizemultiplier -> -moz-script-size-multiplier
  74. - scriptminsize -> -moz-script-min-size
  75. - scriptlevel -> -moz-script-level
  76. - mathsize -> font-size
  77. - mathcolor -> color
  78. - mathbackground -> background
  79. */
  80. /**************************************************************************/
  81. /* merror */
  82. /**************************************************************************/
  83. merror {
  84. display: block;
  85. font-family: sans-serif;
  86. font-weight: bold;
  87. white-space: pre;
  88. margin: 1em;
  89. padding: 1em;
  90. border-width: thin;
  91. border-style: inset;
  92. border-color: red;
  93. font-size: 14pt;
  94. background-color: lightyellow;
  95. }
  96. /**************************************************************************/
  97. /* mtable and its related tags */
  98. /**************************************************************************/
  99. mtable {
  100. display: inline-table;
  101. border-collapse: separate;
  102. border-spacing: 0;
  103. text-indent: 0;
  104. }
  105. mtable[frame="none"] {
  106. border: none;
  107. }
  108. mtable[frame="solid"] {
  109. border: solid thin;
  110. }
  111. mtable[frame="dashed"] {
  112. border: dashed thin;
  113. }
  114. mtr, mlabeledtr {
  115. display: table-row;
  116. vertical-align: baseline;
  117. }
  118. mtd {
  119. display: table-cell;
  120. vertical-align: inherit;
  121. text-align: -moz-center;
  122. white-space: nowrap;
  123. }
  124. /* Don't support m(labeled)tr without mtable, nor mtd without m(labeled)tr */
  125. :not(mtable) > mtr,
  126. :not(mtable) > mlabeledtr,
  127. :not(mtr):not(mlabeledtr) > mtd {
  128. display: none !important;
  129. }
  130. /* Hide the label because mlabeledtr is not supported yet (bug 356870). This
  131. rule can be overriden by users. */
  132. mlabeledtr > mtd:first-child {
  133. display: none;
  134. }
  135. /**********************************************************************/
  136. /* rules to achieve the default spacing between cells. When rowspacing,
  137. columnspacing and framespacing aren't set on mtable. The back-end code
  138. will set the internal attributes depending on the cell's position.
  139. When they are set, the spacing behaviour is handled outside of CSS */
  140. mtd {
  141. padding-right: 0.4em; /* half of columnspacing[colindex] */
  142. padding-left: 0.4em; /* half of columnspacing[colindex-1] */
  143. padding-bottom: 0.5ex; /* half of rowspacing[rowindex] */
  144. padding-top: 0.5ex; /* half of rowspacing[rowindex-1] */
  145. }
  146. /* turn off the spacing at the periphery of boundary cells */
  147. mtr:first-child > mtd {
  148. padding-top: 0ex;
  149. }
  150. mtr:last-child > mtd {
  151. padding-bottom: 0ex;
  152. }
  153. mtd:first-child {
  154. padding-inline-start: 0em;
  155. }
  156. mtd:last-child {
  157. padding-inline-end: 0em;
  158. }
  159. /* re-instate the spacing if the table has a surrounding frame */
  160. mtable[frame="solid"] > mtr:first-child > mtd,
  161. mtable[frame="dashed"] > mtr:first-child > mtd {
  162. padding-top: 0.5ex; /* framespacing.top */
  163. }
  164. mtable[frame="solid"] > mtr:last-child > mtd,
  165. mtable[frame="dashed"] > mtr:last-child > mtd {
  166. padding-bottom: 0.5ex; /* framespacing.bottom */
  167. }
  168. mtable[frame="solid"] > mtr > mtd:first-child,
  169. mtable[frame="dashed"] > mtr > mtd:first-child {
  170. padding-inline-start: 0.4em; /* framespacing.left (or right in rtl)*/
  171. }
  172. mtable[frame="solid"] > mtr > mtd:last-child,
  173. mtable[frame="dashed"] > mtr > mtd:last-child {
  174. padding-inline-end: 0.4em; /* framespacing.right (or left in rtl)*/
  175. }
  176. mtable[rowspacing] > mtr > mtd,
  177. mtable[columnspacing] > mtr > mtd,
  178. mtable[framespacing] > mtr > mtd {
  179. /* Spacing handled outside of CSS */
  180. padding: 0px;
  181. }
  182. /**************************************************************************/
  183. /* This rule is used to give a style context suitable for nsMathMLChars.
  184. We don't actually style -moz-math-anonymous by default. */
  185. /*
  186. ::-moz-math-anonymous {
  187. }
  188. */
  189. /**********************************************************************/
  190. /* This is used when wrapping non-MathML inline elements inside math. */
  191. *|*::-moz-mathml-anonymous-block {
  192. display: inline-block !important;
  193. position: static !important;
  194. text-indent: 0;
  195. }
  196. /**************************************************************************/
  197. /* Controlling Displaystyle and Scriptlevel */
  198. /**************************************************************************/
  199. /*
  200. http://www.w3.org/Math/draft-spec/chapter3.html#presm.scriptlevel
  201. The determination of -moz-math-display for <math> involves the displaystyle
  202. and display attributes. See the <math> section above.
  203. */
  204. /*
  205. Map mstyle@displaystyle to -moz-math-display.
  206. */
  207. mstyle[displaystyle="false"] {
  208. -moz-math-display: inline;
  209. }
  210. mstyle[displaystyle="true"] {
  211. -moz-math-display: block;
  212. }
  213. /* munder, mover and munderover change the scriptlevels of their children
  214. using -moz-math-increment-script-level because regular CSS rules are
  215. insufficient to control when the scriptlevel should be incremented. All other
  216. cases can be described using regular CSS, so we do it this way because it's
  217. more efficient and less code. */
  218. :-moz-math-increment-script-level { -moz-script-level: +1; }
  219. /*
  220. The mfrac element sets displaystyle to "false", or if it was already false
  221. increments scriptlevel by 1, within numerator and denominator.
  222. */
  223. mfrac > * {
  224. -moz-script-level: auto;
  225. -moz-math-display: inline;
  226. }
  227. /*
  228. The mroot element increments scriptlevel by 2, and sets displaystyle to
  229. "false", within index, but leaves both attributes unchanged within base.
  230. The msqrt element leaves both attributes unchanged within its argument.
  231. */
  232. mroot > :not(:first-child) {
  233. -moz-script-level: +2;
  234. -moz-math-display: inline;
  235. }
  236. /*
  237. The msub element [...] increments scriptlevel by 1, and sets displaystyle to
  238. "false", within subscript, but leaves both attributes unchanged within base.
  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. The msubsup element [...] increments scriptlevel by 1, and sets displaystyle
  243. to "false", within subscript and superscript, but leaves both attributes
  244. unchanged within base.
  245. The mmultiscripts element increments scriptlevel by 1, and sets displaystyle
  246. to "false", within each of its arguments except base, but leaves both
  247. attributes unchanged within base.
  248. */
  249. msub > :not(:first-child),
  250. msup > :not(:first-child),
  251. msubsup > :not(:first-child),
  252. mmultiscripts > :not(:first-child) {
  253. -moz-script-level: +1;
  254. -moz-math-display: inline;
  255. }
  256. /*
  257. The munder element [...] always sets displaystyle to "false" within the
  258. underscript, but increments scriptlevel by 1 only when accentunder is
  259. "false". Within base, it always leaves both attributes unchanged.
  260. The mover element [...] always sets displaystyle to "false" within
  261. overscript, but increments scriptlevel by 1 only when accent is "false".
  262. Within base, it always leaves both attributes unchanged.
  263. The munderover [..] always sets displaystyle to "false" within underscript
  264. and overscript, but increments scriptlevel by 1 only when accentunder or
  265. accent, respectively, are "false". Within base, it always leaves both
  266. attributes unchanged.
  267. */
  268. munder > :not(:first-child),
  269. mover > :not(:first-child),
  270. munderover > :not(:first-child) {
  271. -moz-math-display: inline;
  272. }
  273. /*
  274. The displaystyle attribute is allowed on the mtable element to set the
  275. inherited value of the attribute. If the attribute is not present, the
  276. mtable element sets displaystyle to "false" within the table elements.
  277. */
  278. mtable { -moz-math-display: inline; }
  279. mtable[displaystyle="true"] { -moz-math-display: block; }
  280. /*
  281. The mscarries element sets displaystyle to "false", and increments
  282. scriptlevel by 1, so the children are typically displayed in a smaller font.
  283. XXXfredw: This element is not implemented yet. See bug 534967.
  284. mscarries {
  285. -moz-script-level: +1;
  286. -moz-math-display: inline;
  287. }
  288. */
  289. /* "The mphantom element renders invisibly, but with the same size and other
  290. dimensions, including baseline position, that its contents would have if
  291. they were rendered normally.".
  292. Also, we do not expose the <mphantom> element to the accessible tree
  293. (see bug 1108378). */
  294. mphantom {
  295. visibility: hidden;
  296. }