Handle interleaved Typeset() calls better.

This commit is contained in:
Davide P. Cervone 2016-08-17 16:20:59 -04:00
parent d3eec1386a
commit 624572a654
3 changed files with 22 additions and 13 deletions

View File

@ -415,7 +415,10 @@
// Add the node for the math and mark it as being processed
//
jax = script.MathJax.elementJax; if (!jax) continue;
jax.CHTML = {display: (jax.root.Get("display") === "block")}
jax.CHTML = {
display: (jax.root.Get("display") === "block"),
preview: (jax.CHTML||{}).preview // in case typeset calls are interleaved
};
node = CHTML.Element("mjx-chtml",{
id:jax.inputID+"-Frame", className:"MathJax_CHTML", isMathJax:true, jaxID:this.id,
oncontextmenu:EVENT.Menu, onmousedown: EVENT.Mousedown,

View File

@ -683,7 +683,7 @@
// Get the data about the math
//
var jax = script.MathJax.elementJax, math = jax.root,
span = document.getElementById(jax.inputID+"-Frame"),
span = script.previousSibling;
div = (jax.HTMLCSS.display ? (span||{}).parentNode : span);
if (!div) return;
//
@ -775,7 +775,8 @@
script = scripts[i];
if (script && script.parentNode && script.MathJax.elementJax) {
jax = script.MathJax.elementJax; this.getMetrics(jax);
jax.root.toHTML(jax.HTMLCSS.span,jax.HTMLCSS.div,this.PHASE.II);
if (jax.HTMLCSS.span && jax.HTMLCSS.div)
jax.root.toHTML(jax.HTMLCSS.span,jax.HTMLCSS.div,this.PHASE.II);
}
}
//
@ -788,14 +789,16 @@
// Finish the math with its measured size (toHTML phase III)
//
jax = script.MathJax.elementJax; this.getMetrics(jax);
jax.root.toHTML(jax.HTMLCSS.span,jax.HTMLCSS.div,this.PHASE.III);
if (jax.HTMLCSS.isHidden) script.parentNode.insertBefore(jax.HTMLCSS.div,script);
delete jax.HTMLCSS.span; delete jax.HTMLCSS.div;
//
// The math is now fully processed
//
script.MathJax.state = jax.STATE.PROCESSED;
HUB.signal.Post(["New Math",script.MathJax.elementJax.inputID]); // FIXME: wait for this? (i.e., restart if returns uncalled callback)
if (jax.HTMLCSS.span && jax.HTMLCSS.div) {
jax.root.toHTML(jax.HTMLCSS.span,jax.HTMLCSS.div,this.PHASE.III);
if (jax.HTMLCSS.isHidden) script.parentNode.insertBefore(jax.HTMLCSS.div,script);
delete jax.HTMLCSS.span; delete jax.HTMLCSS.div;
//
// The math is now fully processed
//
script.MathJax.state = jax.STATE.PROCESSED;
HUB.signal.Post(["New Math",script.MathJax.elementJax.inputID]); // FIXME: wait for this? (i.e., restart if returns uncalled callback)
}
}
}
if (this.forceReflow) {

View File

@ -228,7 +228,10 @@
// then set the role and mark it as being processed
//
jax = script.MathJax.elementJax; if (!jax) continue;
jax.SVG = {display: (jax.root.Get("display") === "block")}
jax.SVG = {
display: (jax.root.Get("display") === "block"),
preview: (jax.SVG||{}).preview // in case typeset calls are interleaved
};
span = div = HTML.Element("span",{
style: {"font-size": this.config.scale+"%", display:"inline-block"},
className:"MathJax_SVG", id:jax.inputID+"-Frame", isMathJax:true, jaxID:this.id,
@ -312,7 +315,7 @@
// Get the data about the math
//
var jax = script.MathJax.elementJax, math = jax.root,
span = document.getElementById(jax.inputID+"-Frame"),
span = script.previousSibling;
div = (jax.SVG.display ? (span||{}).parentNode : span),
localCache = (SVG.config.useFontCache && !SVG.config.useGlobalCache);
if (!div) return;