From 94f2f20448535e329dc9dbe6f21385a7fac8d160 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Mon, 20 Jun 2016 18:23:18 -0400 Subject: [PATCH] Fix problem with Safari inserting linebreaks for in-line math due to new width-detection scheme (linebreakSpan). #1478. --- unpacked/jax/output/CommonHTML/jax.js | 9 +++++---- unpacked/jax/output/HTML-CSS/jax.js | 9 ++++++--- unpacked/jax/output/SVG/jax.js | 9 +++++---- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/unpacked/jax/output/CommonHTML/jax.js b/unpacked/jax/output/CommonHTML/jax.js index b0fd4eacd..4c8ca67d5 100644 --- a/unpacked/jax/output/CommonHTML/jax.js +++ b/unpacked/jax/output/CommonHTML/jax.js @@ -174,7 +174,8 @@ position: "absolute", width:"1px", height:"60ex" }, - ".mjx-line-box-test": { + ".mjx-line-box-test": {display: "table!important"}, + ".mjx-line-box-test span": { display: "table-cell!important", width: "10000em!important", "min-width":0, "max-width":"none", @@ -245,7 +246,7 @@ // // Used in preTranslate to get linebreak width // - this.linebreakSpan = HTML.Element("span",{className:"mjx-line-box-test"}); + this.linebreakSpan = HTML.Element("span",{className:"mjx-line-box-test"},[["span"]]); // // Set up styles and preload web fonts @@ -278,7 +279,7 @@ document.body.appendChild(this.linebreakSpan); this.defaultEm = this.getFontSize(this.TestSpan); this.defaultEx = this.TestSpan.firstChild.offsetHeight/60; - this.defaultWidth = this.linebreakSpan.offsetWidth; + this.defaultWidth = this.linebreakSpan.firstChild.offsetWidth; document.body.removeChild(this.linebreakSpan); document.body.removeChild(this.TestSpan); }, @@ -452,7 +453,7 @@ jax = script.MathJax.elementJax; if (!jax) continue; em = CHTML.getFontSize(test); ex = test.firstChild.offsetHeight/60; - cwidth = Math.max(0,test.previousSibling.offsetWidth-2); + cwidth = Math.max(0,test.previousSibling.firstChild.offsetWidth-2); if (ex === 0 || ex === "NaN") { ex = this.defaultEx; cwidth = this.defaultWidth; diff --git a/unpacked/jax/output/HTML-CSS/jax.js b/unpacked/jax/output/HTML-CSS/jax.js index 366d75bdb..706e8782f 100644 --- a/unpacked/jax/output/HTML-CSS/jax.js +++ b/unpacked/jax/output/HTML-CSS/jax.js @@ -339,6 +339,9 @@ "min-height": 0, "max-height":"none" }, ".MathJax_LineBox": { + display: (oldIE ? "block" : "table") + "!important" + }, + ".MathJax_LineBox span": { display: (oldIE ? "block" : "table-cell") + "!important", width: (oldIE ? "100%" : "10000em") + "!important", "min-width":0, "max-width":"none", @@ -495,7 +498,7 @@ ); // Used in preTranslate to get linebreak width - this.linebreakSpan = MathJax.HTML.Element("span",{className:"MathJax_LineBox"}); + this.linebreakSpan = MathJax.HTML.Element("span",{className:"MathJax_LineBox"},[["span"]]); // Set up styles and preload web fonts return AJAX.Styles(this.config.styles,["InitializeHTML",this]); @@ -551,7 +554,7 @@ document.body.appendChild(this.linebreakSpan); this.defaultEx = this.EmExSpan.firstChild.offsetHeight/60; this.defaultEm = this.EmExSpan.lastChild.firstChild.offsetHeight/60; - this.defaultWidth = this.linebreakSpan.offsetWidth; + this.defaultWidth = this.linebreakSpan.firstChild.offsetWidth; document.body.removeChild(this.linebreakSpan); document.body.removeChild(this.EmExSpan); }, @@ -621,7 +624,7 @@ jax = script.MathJax.elementJax; if (!jax) continue; ex = test.firstChild.offsetHeight/60; em = test.lastChild.firstChild.offsetHeight/60; - cwidth = Math.max(0,div.previousSibling.offsetWidth - 2); + cwidth = Math.max(0,div.previousSibling.firstChild.offsetWidth - 2); if (relwidth) {maxwidth = cwidth} if (ex === 0 || ex === "NaN") { // can't read width, so move to hidden div for processing diff --git a/unpacked/jax/output/SVG/jax.js b/unpacked/jax/output/SVG/jax.js index ef7a4732f..a6a49c70a 100644 --- a/unpacked/jax/output/SVG/jax.js +++ b/unpacked/jax/output/SVG/jax.js @@ -100,7 +100,8 @@ "min-height": 0, "max-height":"none", padding:0, border: 0, margin: 0 }, - ".MathJax_SVG_LineBox": { + ".MathJax_SVG_LineBox": {display: "table!important"}, + ".MathJax_SVG_LineBox span": { display: "table-cell!important", width: "10000em!important", "min-width":0, "max-width":"none", @@ -179,7 +180,7 @@ ); // Used in preTranslate to get linebreak width - this.linebreakSpan = HTML.Element("span",{className:"MathJax_SVG_LineBox"}); + this.linebreakSpan = HTML.Element("span",{className:"MathJax_SVG_LineBox"},[["span"]]); // Set up styles return AJAX.Styles(this.config.styles,["InitializeSVG",this]); @@ -195,7 +196,7 @@ document.body.appendChild(this.ExSpan); document.body.appendChild(this.linebreakSpan); this.defaultEx = this.ExSpan.firstChild.offsetHeight/60; - this.defaultWidth = this.linebreakSpan.offsetWidth; + this.defaultWidth = this.linebreakSpan.firstChild.offsetWidth; document.body.removeChild(this.linebreakSpan); document.body.removeChild(this.ExSpan); }, @@ -261,7 +262,7 @@ test = script.previousSibling; div = test.previousSibling; jax = script.MathJax.elementJax; if (!jax) continue; ex = test.firstChild.offsetHeight/60; - cwidth = Math.max(0,(div.previousSibling.offsetWidth-2) / this.config.scale * 100); + cwidth = Math.max(0,(div.previousSibling.firstChild.offsetWidth-2) / this.config.scale * 100); if (ex === 0 || ex === "NaN") { // can't read width, so move to hidden div for processing // (this will cause a reflow for each math element that is hidden)