Properly determine container width for shrink-wrapped elements in CommonHTML. Issue #1478.
This commit is contained in:
parent
22c1cf4cb9
commit
97ab12ea52
|
@ -71,6 +71,10 @@
|
||||||
".mjx-chtml[tabindex]:focus, body :focus .mjx-chtml[tabindex]": {
|
".mjx-chtml[tabindex]:focus, body :focus .mjx-chtml[tabindex]": {
|
||||||
display: "inline-table" // see issues #1282 and #1338
|
display: "inline-table" // see issues #1282 and #1338
|
||||||
},
|
},
|
||||||
|
".mjx-full-width": {
|
||||||
|
display: "table-cell",
|
||||||
|
width: "10000em"
|
||||||
|
},
|
||||||
|
|
||||||
".mjx-math": {
|
".mjx-math": {
|
||||||
"display": "inline-block",
|
"display": "inline-block",
|
||||||
|
@ -170,6 +174,12 @@
|
||||||
position: "absolute",
|
position: "absolute",
|
||||||
width:"1px", height:"60ex"
|
width:"1px", height:"60ex"
|
||||||
},
|
},
|
||||||
|
".mjx-line-box-test": {
|
||||||
|
display: "table-cell!important",
|
||||||
|
width: "10000em!important",
|
||||||
|
"min-width":0, "max-width":"none",
|
||||||
|
padding:0, border:0, margin:0
|
||||||
|
},
|
||||||
|
|
||||||
"#MathJax_CHTML_Tooltip": {
|
"#MathJax_CHTML_Tooltip": {
|
||||||
"background-color": "InfoBackground", color: "InfoText",
|
"background-color": "InfoBackground", color: "InfoText",
|
||||||
|
@ -232,6 +242,11 @@
|
||||||
//
|
//
|
||||||
this.TestSpan = CHTML.Element("mjx-test",{style:{left:"1em"}},[["mjx-ex-box-test"]]);
|
this.TestSpan = CHTML.Element("mjx-test",{style:{left:"1em"}},[["mjx-ex-box-test"]]);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Used in preTranslate to get linebreak width
|
||||||
|
//
|
||||||
|
this.linebreakSpan = HTML.Element("span",{className:"mjx-line-box-test"});
|
||||||
|
|
||||||
//
|
//
|
||||||
// Set up styles and preload web fonts
|
// Set up styles and preload web fonts
|
||||||
//
|
//
|
||||||
|
@ -260,9 +275,11 @@
|
||||||
// Get the default sizes (need styles in place to do this)
|
// Get the default sizes (need styles in place to do this)
|
||||||
//
|
//
|
||||||
document.body.appendChild(this.TestSpan);
|
document.body.appendChild(this.TestSpan);
|
||||||
|
document.body.appendChild(this.linebreakSpan);
|
||||||
this.defaultEm = this.getFontSize(this.TestSpan);
|
this.defaultEm = this.getFontSize(this.TestSpan);
|
||||||
this.defaultEx = this.TestSpan.firstChild.offsetHeight/60;
|
this.defaultEx = this.TestSpan.firstChild.offsetHeight/60;
|
||||||
this.defaultWidth = this.TestSpan.offsetWidth;
|
this.defaultWidth = this.linebreakSpan.offsetWidth;
|
||||||
|
document.body.removeChild(this.linebreakSpan);
|
||||||
document.body.removeChild(this.TestSpan);
|
document.body.removeChild(this.TestSpan);
|
||||||
},
|
},
|
||||||
getFontSize: (window.getComputedStyle ?
|
getFontSize: (window.getComputedStyle ?
|
||||||
|
@ -422,6 +439,7 @@
|
||||||
//
|
//
|
||||||
// Add test nodes for determineing scales and linebreak widths
|
// Add test nodes for determineing scales and linebreak widths
|
||||||
//
|
//
|
||||||
|
script.parentNode.insertBefore(this.linebreakSpan.cloneNode(true),script);
|
||||||
script.parentNode.insertBefore(this.TestSpan.cloneNode(true),script);
|
script.parentNode.insertBefore(this.TestSpan.cloneNode(true),script);
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
@ -434,12 +452,10 @@
|
||||||
jax = script.MathJax.elementJax; if (!jax) continue;
|
jax = script.MathJax.elementJax; if (!jax) continue;
|
||||||
em = CHTML.getFontSize(test);
|
em = CHTML.getFontSize(test);
|
||||||
ex = test.firstChild.offsetHeight/60;
|
ex = test.firstChild.offsetHeight/60;
|
||||||
if (ex === 0 || ex === "NaN") ex = this.defaultEx
|
cwidth = Math.max(0,test.previousSibling.offsetWidth-2);
|
||||||
node = test;
|
if (ex === 0 || ex === "NaN") {
|
||||||
while (node) {
|
ex = this.defaultEx;
|
||||||
cwidth = node.offsetWidth; if (cwidth) break;
|
cwidth = this.defaultWidth;
|
||||||
cwidth = CHTML.getMaxWidth(node); if (cwidth) break;
|
|
||||||
node = node.parentNode;
|
|
||||||
}
|
}
|
||||||
if (relwidth) maxwidth = cwidth;
|
if (relwidth) maxwidth = cwidth;
|
||||||
scale = (this.config.matchFontHeight ? ex/this.TEX.x_height/em : 1);
|
scale = (this.config.matchFontHeight ? ex/this.TEX.x_height/em : 1);
|
||||||
|
@ -455,7 +471,9 @@
|
||||||
for (i = 0; i < m; i++) {
|
for (i = 0; i < m; i++) {
|
||||||
script = scripts[i]; if (!script.parentNode) continue;
|
script = scripts[i]; if (!script.parentNode) continue;
|
||||||
test = scripts[i].previousSibling;
|
test = scripts[i].previousSibling;
|
||||||
|
span = test.previousSibling;
|
||||||
jax = scripts[i].MathJax.elementJax; if (!jax) continue;
|
jax = scripts[i].MathJax.elementJax; if (!jax) continue;
|
||||||
|
span.parentNode.removeChild(span);
|
||||||
test.parentNode.removeChild(test);
|
test.parentNode.removeChild(test);
|
||||||
}
|
}
|
||||||
state.CHTMLeqn = state.CHTMLlast = 0; state.CHTMLi = -1;
|
state.CHTMLeqn = state.CHTMLlast = 0; state.CHTMLi = -1;
|
||||||
|
@ -1723,8 +1741,8 @@
|
||||||
var alttext = this.Get("alttext");
|
var alttext = this.Get("alttext");
|
||||||
if (alttext && !node.getAttribute("aria-label")) node.setAttribute("aria-label",alttext);
|
if (alttext && !node.getAttribute("aria-label")) node.setAttribute("aria-label",alttext);
|
||||||
if (this.CHTML.pwidth) {
|
if (this.CHTML.pwidth) {
|
||||||
node.parentNode.style.width = this.CHTML.pwidth;
|
|
||||||
node.parentNode.style.minWidth = this.CHTML.mwidth||CHTML.Em(this.CHTML.w);
|
node.parentNode.style.minWidth = this.CHTML.mwidth||CHTML.Em(this.CHTML.w);
|
||||||
|
node.parentNode.className += " mjx-full-width";
|
||||||
} else if (!this.isMultiline && this.Get("display") === "block") {
|
} else if (!this.isMultiline && this.Get("display") === "block") {
|
||||||
var values = this.getValues("indentalignfirst","indentshiftfirst","indentalign","indentshift");
|
var values = this.getValues("indentalignfirst","indentshiftfirst","indentalign","indentshift");
|
||||||
if (values.indentalignfirst !== MML.INDENTALIGN.INDENTALIGN) values.indentalign = values.indentalignfirst;
|
if (values.indentalignfirst !== MML.INDENTALIGN.INDENTALIGN) values.indentalign = values.indentalignfirst;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user