Restore the use of scanW that was removed in an earlier commit (it turns out to be needed after all, as info.scanW is changed in the recursive calls). Issue #255.

This commit is contained in:
Davide P. Cervone 2012-08-30 14:35:03 -04:00
parent dc9e4a760e
commit 5b698c20c2
4 changed files with 33 additions and 31 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -146,9 +146,9 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
// Get the current breakpoint position and other data // Get the current breakpoint position and other data
// //
var index = info.index.slice(0), i = info.index.shift(), var index = info.index.slice(0), i = info.index.shift(),
m = this.data.length, W, broken = (info.index.length > 0), better = false; m = this.data.length, W, w, scanW, broken = (info.index.length > 0), better = false;
if (i == null) {i = -1}; if (!broken) {i++; info.W += info.w; info.w = 0;} if (i == null) {i = -1}; if (!broken) {i++; info.W += info.w; info.w = 0}
info.scanW = info.W; info.nest++; scanW = info.scanW = info.W; info.nest++;
// //
// Look through the line for breakpoints, // Look through the line for breakpoints,
// (as long as we are not too far past the breaking width) // (as long as we are not too far past the breaking width)
@ -156,23 +156,24 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
while (i < m && info.scanW < 1.33*HTMLCSS.linebreakWidth) { while (i < m && info.scanW < 1.33*HTMLCSS.linebreakWidth) {
if (this.data[i]) { if (this.data[i]) {
if (this.data[i].HTMLbetterBreak(info,state)) { if (this.data[i].HTMLbetterBreak(info,state)) {
better = true; index = [i].concat(info.index); W = info.W; better = true; index = [i].concat(info.index); W = info.W; w = info.w;
if (info.penalty === PENALTY.newline) {info.index = index; info.nest--; return true} if (info.penalty === PENALTY.newline) {info.index = index; info.nest--; return true}
} }
if (!broken) {this.HTMLaddWidth(i,info)} if (!broken) {scanW = this.HTMLaddWidth(i,info,scanW)}
} }
info.index = []; i++; broken = false; info.index = []; i++; broken = false;
} }
info.nest--; info.index = index; info.nest--; info.index = index;
if (better) {info.W = W} if (better) {info.W = W; info.w = w}
return better; return better;
}, },
HTMLaddWidth: function (i,info) { HTMLaddWidth: function (i,info,scanW) {
var span = this.data[i].HTMLspanElement(); var span = this.data[i].HTMLspanElement();
info.scanW += span.bbox.w; scanW += span.bbox.w;
if (span.style.paddingLeft) {info.scanW += HTMLCSS.unEm(span.style.paddingLeft)} if (span.style.paddingLeft) {scanW += HTMLCSS.unEm(span.style.paddingLeft)}
if (span.style.paddingRight) {info.scanW += HTMLCSS.unEm(span.style.paddingRight)} if (span.style.paddingRight) {scanW += HTMLCSS.unEm(span.style.paddingRight)}
info.W = info.scanW; info.W = info.scanW = scanW; info.w = 0;
return scanW;
}, },
/****************************************************************/ /****************************************************************/
@ -375,9 +376,9 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
// Get the current breakpoint position and other data // Get the current breakpoint position and other data
// //
var index = info.index.slice(0), i = info.index.shift(), var index = info.index.slice(0), i = info.index.shift(),
m = this.data.length, W, broken = (info.index.length > 0), better = false; m = this.data.length, W, w, scanW, broken = (info.index.length > 0), better = false;
if (i == null) {i = -1}; if (!broken) {i++; info.W += info.w; info.w = 0;} if (i == null) {i = -1}; if (!broken) {i++; info.W += info.w; info.w = 0}
info.scanW = info.W; info.nest++; scanW = info.scanW = info.W; info.nest++;
// //
// Create indices that include the delimiters and separators // Create indices that include the delimiters and separators
// //
@ -400,15 +401,15 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
var k = this.dataI[i]; var k = this.dataI[i];
if (this.data[k]) { if (this.data[k]) {
if (this.data[k].HTMLbetterBreak(info,state)) { if (this.data[k].HTMLbetterBreak(info,state)) {
better = true; index = [i].concat(info.index); W = info.W; better = true; index = [i].concat(info.index); W = info.W; w = info.w;
if (info.penalty === PENALTY.newline) {info.index = index; info.nest--; return true} if (info.penalty === PENALTY.newline) {info.index = index; info.nest--; return true}
} }
if (!broken) {this.HTMLaddWidth(k,info)} if (!broken) {scanW = this.HTMLaddWidth(k,info,scanW)}
} }
info.index = []; i++; broken = false; info.index = []; i++; broken = false;
} }
info.nest--; info.index = index; info.nest--; info.index = index;
if (better) {info.W = W} if (better) {info.W = W; info.w = w}
return better; return better;
}, },

View File

@ -149,9 +149,9 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
// Get the current breakpoint position and other data // Get the current breakpoint position and other data
// //
var index = info.index.slice(0), i = info.index.shift(), var index = info.index.slice(0), i = info.index.shift(),
m = this.data.length, W, broken = (info.index.length > 0), better = false; m = this.data.length, W, w, scanW, broken = (info.index.length > 0), better = false;
if (i == null) {i = -1}; if (!broken) {i++; info.W += info.w; info.w = 0} if (i == null) {i = -1}; if (!broken) {i++; info.W += info.w; info.w = 0}
info.scanW = info.W; info.nest++; scanW = info.scanW = info.W; info.nest++;
// //
// Look through the line for breakpoints, // Look through the line for breakpoints,
// (as long as we are not too far past the breaking width) // (as long as we are not too far past the breaking width)
@ -159,10 +159,10 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
while (i < m && info.scanW < 1.33*SVG.linebreakWidth) { while (i < m && info.scanW < 1.33*SVG.linebreakWidth) {
if (this.data[i]) { if (this.data[i]) {
if (this.data[i].SVGbetterBreak(info,state)) { if (this.data[i].SVGbetterBreak(info,state)) {
better = true; index = [i].concat(info.index); W = info.W; better = true; index = [i].concat(info.index); W = info.W; w = info.w;
if (info.penalty === PENALTY.newline) {info.index = index; info.nest--; return true} if (info.penalty === PENALTY.newline) {info.index = index; info.nest--; return true}
} }
if (!broken) {this.SVGaddWidth(i,info)} if (!broken) {scanW = this.SVGaddWidth(i,info,scanW)}
} }
info.index = []; i++; broken = false; info.index = []; i++; broken = false;
} }
@ -170,10 +170,11 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
if (better) {info.W = W} if (better) {info.W = W}
return better; return better;
}, },
SVGaddWidth: function (i,info) { SVGaddWidth: function (i,info,scanW) {
var svg = this.data[i].SVGdata; var svg = this.data[i].SVGdata;
info.scanW += svg.w + svg.x; if (svg.X) {info.scanW += svg.X} scanW += svg.w + svg.x; if (svg.X) {scanW += svg.X}
info.W = info.scanW; info.W = info.scanW = scanW; info.w = 0;
return scanW;
}, },
/****************************************************************/ /****************************************************************/
@ -333,9 +334,9 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
// Get the current breakpoint position and other data // Get the current breakpoint position and other data
// //
var index = info.index.slice(0), i = info.index.shift(), var index = info.index.slice(0), i = info.index.shift(),
m = this.data.length, W, broken = (info.index.length > 0), better = false; m = this.data.length, W, w, scanW, broken = (info.index.length > 0), better = false;
if (i == null) {i = -1}; if (!broken) {i++; info.W += info.w; info.w = 0} if (i == null) {i = -1}; if (!broken) {i++; info.W += info.w; info.w = 0}
info.scanW = info.W; info.nest++; scanW = info.scanW = info.W; info.nest++;
// //
// Create indices that include the delimiters and separators // Create indices that include the delimiters and separators
// //
@ -358,15 +359,15 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
var k = this.dataI[i]; var k = this.dataI[i];
if (this.data[k]) { if (this.data[k]) {
if (this.data[k].SVGbetterBreak(info,state)) { if (this.data[k].SVGbetterBreak(info,state)) {
better = true; index = [i].concat(info.index); W = info.W; better = true; index = [i].concat(info.index); W = info.W; w = info.w;
if (info.penalty === PENALTY.newline) {info.index = index; info.nest--; return true} if (info.penalty === PENALTY.newline) {info.index = index; info.nest--; return true}
} }
if (!broken) {this.SVGaddWidth(k,info)} if (!broken) {scanW = this.SVGaddWidth(k,info,scanW)}
} }
info.index = []; i++; broken = false; info.index = []; i++; broken = false;
} }
info.nest--; info.index = index; info.nest--; info.index = index;
if (better) {info.W = W} if (better) {info.W = W; info.w = w}
return better; return better;
}, },