|
71 | 71 | ".mjx-chtml[tabindex]:focus, body :focus .mjx-chtml[tabindex]": {
|
72 | 72 | display: "inline-table" // see issues #1282 and #1338
|
73 | 73 | },
|
| 74 | + ".mjx-full-width": { |
| 75 | + display: "table-cell", |
| 76 | + width: "10000em" |
| 77 | + }, |
74 | 78 |
|
75 | 79 | ".mjx-math": {
|
76 | 80 | "display": "inline-block",
|
|
170 | 174 | position: "absolute",
|
171 | 175 | width:"1px", height:"60ex"
|
172 | 176 | },
|
| 177 | + ".mjx-line-box-test": { |
| 178 | + display: "table-cell!important", |
| 179 | + width: "10000em!important", |
| 180 | + "min-width":0, "max-width":"none", |
| 181 | + padding:0, border:0, margin:0 |
| 182 | + }, |
173 | 183 |
|
174 | 184 | "#MathJax_CHTML_Tooltip": {
|
175 | 185 | "background-color": "InfoBackground", color: "InfoText",
|
|
232 | 242 | //
|
233 | 243 | this.TestSpan = CHTML.Element("mjx-test",{style:{left:"1em"}},[["mjx-ex-box-test"]]);
|
234 | 244 |
|
| 245 | + // |
| 246 | + // Used in preTranslate to get linebreak width |
| 247 | + // |
| 248 | + this.linebreakSpan = HTML.Element("span",{className:"mjx-line-box-test"}); |
| 249 | + |
235 | 250 | //
|
236 | 251 | // Set up styles and preload web fonts
|
237 | 252 | //
|
|
260 | 275 | // Get the default sizes (need styles in place to do this)
|
261 | 276 | //
|
262 | 277 | document.body.appendChild(this.TestSpan);
|
| 278 | + document.body.appendChild(this.linebreakSpan); |
263 | 279 | this.defaultEm = this.getFontSize(this.TestSpan);
|
264 | 280 | this.defaultEx = this.TestSpan.firstChild.offsetHeight/60;
|
265 |
| - this.defaultWidth = this.TestSpan.offsetWidth; |
| 281 | + this.defaultWidth = this.linebreakSpan.offsetWidth; |
| 282 | + document.body.removeChild(this.linebreakSpan); |
266 | 283 | document.body.removeChild(this.TestSpan);
|
267 | 284 | },
|
268 | 285 | getFontSize: (window.getComputedStyle ?
|
|
422 | 439 | //
|
423 | 440 | // Add test nodes for determineing scales and linebreak widths
|
424 | 441 | //
|
| 442 | + script.parentNode.insertBefore(this.linebreakSpan.cloneNode(true),script); |
425 | 443 | script.parentNode.insertBefore(this.TestSpan.cloneNode(true),script);
|
426 | 444 | }
|
427 | 445 | //
|
|
434 | 452 | jax = script.MathJax.elementJax; if (!jax) continue;
|
435 | 453 | em = CHTML.getFontSize(test);
|
436 | 454 | ex = test.firstChild.offsetHeight/60;
|
437 |
| - if (ex === 0 || ex === "NaN") ex = this.defaultEx |
438 |
| - node = test; |
439 |
| - while (node) { |
440 |
| - cwidth = node.offsetWidth; if (cwidth) break; |
441 |
| - cwidth = CHTML.getMaxWidth(node); if (cwidth) break; |
442 |
| - node = node.parentNode; |
| 455 | + cwidth = Math.max(0,test.previousSibling.offsetWidth-2); |
| 456 | + if (ex === 0 || ex === "NaN") { |
| 457 | + ex = this.defaultEx; |
| 458 | + cwidth = this.defaultWidth; |
443 | 459 | }
|
444 | 460 | if (relwidth) maxwidth = cwidth;
|
445 | 461 | scale = (this.config.matchFontHeight ? ex/this.TEX.x_height/em : 1);
|
|
455 | 471 | for (i = 0; i < m; i++) {
|
456 | 472 | script = scripts[i]; if (!script.parentNode) continue;
|
457 | 473 | test = scripts[i].previousSibling;
|
| 474 | + span = test.previousSibling; |
458 | 475 | jax = scripts[i].MathJax.elementJax; if (!jax) continue;
|
| 476 | + span.parentNode.removeChild(span); |
459 | 477 | test.parentNode.removeChild(test);
|
460 | 478 | }
|
461 | 479 | state.CHTMLeqn = state.CHTMLlast = 0; state.CHTMLi = -1;
|
|
1723 | 1741 | var alttext = this.Get("alttext");
|
1724 | 1742 | if (alttext && !node.getAttribute("aria-label")) node.setAttribute("aria-label",alttext);
|
1725 | 1743 | if (this.CHTML.pwidth) {
|
1726 |
| - node.parentNode.style.width = this.CHTML.pwidth; |
1727 | 1744 | node.parentNode.style.minWidth = this.CHTML.mwidth||CHTML.Em(this.CHTML.w);
|
| 1745 | + node.parentNode.className += " mjx-full-width"; |
1728 | 1746 | } else if (!this.isMultiline && this.Get("display") === "block") {
|
1729 | 1747 | var values = this.getValues("indentalignfirst","indentshiftfirst","indentalign","indentshift");
|
1730 | 1748 | if (values.indentalignfirst !== MML.INDENTALIGN.INDENTALIGN) values.indentalign = values.indentalignfirst;
|
|
0 commit comments