Make column widths take minsize into account. Resolved issue #210.

This commit is contained in:
Davide P. Cervone 2012-03-15 15:45:47 -04:00
parent 6ca2bcba94
commit 6ede07ba29
13 changed files with 44 additions and 23 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -38,7 +38,7 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
var stack = HTMLCSS.createStack(span); var stack = HTMLCSS.createStack(span);
var scale = this.HTMLgetScale(), mu = this.HTMLgetMu(span), LABEL = -1; var scale = this.HTMLgetScale(), mu = this.HTMLgetMu(span), LABEL = -1;
var H = [], D = [], W = [], A = [], C = [], i, j, J = -1, m, M, s, row, entries = []; var H = [], D = [], W = [], A = [], C = [], i, j, J = -1, m, M, s, row, cell, mo, entries = [];
var LHD = HTMLCSS.FONTDATA.baselineskip * scale * values.useHeight, var LHD = HTMLCSS.FONTDATA.baselineskip * scale * values.useHeight,
LH = HTMLCSS.FONTDATA.lineH * scale, LD = HTMLCSS.FONTDATA.lineD * scale; LH = HTMLCSS.FONTDATA.lineH * scale, LD = HTMLCSS.FONTDATA.lineD * scale;
@ -62,10 +62,21 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
for (i = 0, m = this.data.length; i < m; i++) { for (i = 0, m = this.data.length; i < m; i++) {
row = this.data[i]; s = (row.type === "mlabeledtr" ? LABEL : 0); row = this.data[i]; s = (row.type === "mlabeledtr" ? LABEL : 0);
for (j = s, M = row.data.length + s; j < M; j++) { for (j = s, M = row.data.length + s; j < M; j++) {
if (row.data[j-s].isMultiline) {A[i][j].style.width = "100%"} cell = row.data[j-s];
if (cell.isMultiline) {A[i][j].style.width = "100%"}
if (A[i][j].bbox.h > H[i]) {H[i] = A[i][j].bbox.h} if (A[i][j].bbox.h > H[i]) {H[i] = A[i][j].bbox.h}
if (A[i][j].bbox.d > D[i]) {D[i] = A[i][j].bbox.d} if (A[i][j].bbox.d > D[i]) {D[i] = A[i][j].bbox.d}
if (A[i][j].bbox.w > W[j]) {W[j] = A[i][j].bbox.w} if (A[i][j].bbox.w > W[j]) {W[j] = A[i][j].bbox.w}
if (cell.isEmbellished()) {
mo = cell.CoreMO()
var min = mo.Get("minsize",true);
if (min && mo.HTMLcanStretch("Horizontal")) {
var mw = mo.HTMLspanElement().bbox.w
A[i][j].dw = HTMLCSS.length2em(min,mu,mw) - mw;
min = A[i][j].bbox.w + A[i][j].dw;
if (min > W[j]) {W[j] = min}
}
}
} }
} }
if (H[0]+D[0]) {H[0] = Math.max(H[0],LH)} if (H[0]+D[0]) {H[0] = Math.max(H[0],LH)}
@ -245,11 +256,11 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
for (i = 0, m = A.length; i < m; i++) { for (i = 0, m = A.length; i < m; i++) {
if (A[i][j]) { if (A[i][j]) {
s = (this.data[i].type === "mlabeledtr" ? LABEL : 0); s = (this.data[i].type === "mlabeledtr" ? LABEL : 0);
var cell = this.data[i].data[j-s]; cell = this.data[i].data[j-s];
if (cell.HTMLcanStretch("Horizontal")) { if (cell.HTMLcanStretch("Horizontal")) {
A[i][j].bbox = cell.HTMLstretchH(C[j],W[j]).bbox A[i][j].bbox = cell.HTMLstretchH(C[j],W[j]-(A[i][j].dw||0)).bbox
} else if (cell.HTMLcanStretch("Vertical")) { } else if (cell.HTMLcanStretch("Vertical")) {
var mo = cell.CoreMO(); mo = cell.CoreMO();
var symmetric = mo.symmetric; mo.symmetric = false; var symmetric = mo.symmetric; mo.symmetric = false;
A[i][j].bbox = cell.HTMLstretchV(C[j],H[i],D[i]).bbox; A[i][j].bbox = cell.HTMLstretchV(C[j],H[i],D[i]).bbox;
mo.symmetric = symmetric; mo.symmetric = symmetric;

View File

@ -41,7 +41,7 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
var scale = this.SVGgetScale(), mu = this.SVGgetMu(svg); var scale = this.SVGgetScale(), mu = this.SVGgetMu(svg);
var LABEL = -1; var LABEL = -1;
var H = [], D = [], W = [], A = [], C = [], i, j, J = -1, m, M, s, row; var H = [], D = [], W = [], A = [], C = [], i, j, J = -1, m, M, s, row, cell, mo;
var LHD = SVG.FONTDATA.baselineskip * scale * values.useHeight, var LHD = SVG.FONTDATA.baselineskip * scale * values.useHeight,
LH = SVG.FONTDATA.lineH * scale, LD = SVG.FONTDATA.lineD * scale; LH = SVG.FONTDATA.lineH * scale, LD = SVG.FONTDATA.lineD * scale;
@ -57,11 +57,21 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
C[j] = BBOX.G(); C[j] = BBOX.G();
W[j] = -SVG.BIGDIMEN; W[j] = -SVG.BIGDIMEN;
} }
A[i][j] = row.data[j-s].toSVG(); cell = row.data[j-s];
A[i][j] = cell.toSVG();
// if (row.data[j-s].isMultiline) {A[i][j].style.width = "100%"} // if (row.data[j-s].isMultiline) {A[i][j].style.width = "100%"}
if (A[i][j].h > H[i]) {H[i] = A[i][j].h} if (A[i][j].h > H[i]) {H[i] = A[i][j].h}
if (A[i][j].d > D[i]) {D[i] = A[i][j].d} if (A[i][j].d > D[i]) {D[i] = A[i][j].d}
if (A[i][j].w > W[j]) {W[j] = A[i][j].w} if (A[i][j].w > W[j]) {W[j] = A[i][j].w}
if (cell.isEmbellished()) {
mo = cell.CoreMO();
var min = mo.Get("minsize",true);
if (min && mo.SVGcanStretch("Horizontal")) {
A[i][j].dw = SVG.length2em(min,mu,mo.SVGdata.w) - mo.SVGdata.w;
min = A[i][j].w + A[i][j].dw;
if (min > W[j]) {W[j] = min}
}
}
} }
} }
if (H[0]+D[0]) {H[0] = Math.max(H[0],LH)} if (H[0]+D[0]) {H[0] = Math.max(H[0],LH)}
@ -229,11 +239,11 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
for (i = 0, m = A.length; i < m; i++) { for (i = 0, m = A.length; i < m; i++) {
if (A[i][j]) { if (A[i][j]) {
s = (this.data[i].type === "mlabeledtr" ? LABEL : 0); s = (this.data[i].type === "mlabeledtr" ? LABEL : 0);
var cell = this.data[i].data[j-s]; cell = this.data[i].data[j-s];
if (cell.SVGcanStretch("Horizontal")) { if (cell.SVGcanStretch("Horizontal")) {
A[i][j] = cell.SVGstretchH(W[j]); A[i][j] = cell.SVGstretchH(W[j]-(A[i][j].dw||0));
} else if (cell.SVGcanStretch("Vertical")) { } else if (cell.SVGcanStretch("Vertical")) {
var mo = cell.CoreMO(); mo = cell.CoreMO();
var symmetric = mo.symmetric; mo.symmetric = false; var symmetric = mo.symmetric; mo.symmetric = false;
A[i][j] = cell.SVGstretchV(H[i],D[i]); A[i][j] = cell.SVGstretchV(H[i],D[i]);
mo.symmetric = symmetric; mo.symmetric = symmetric;

View File

@ -1349,7 +1349,7 @@
svg.y = H - svg.h; svg.y = H - svg.h;
this.SVGhandleSpace(svg); this.SVGhandleSpace(svg);
this.SVGhandleColor(svg); this.SVGhandleColor(svg);
delete this.svg; delete this.svg.element;
this.SVGsaveData(svg); this.SVGsaveData(svg);
return svg; return svg;
}, },
@ -1365,7 +1365,7 @@
svg = SVG.createDelimiter(this.data.join("").charCodeAt(0),w,svg.scale,values.mathvariant); svg = SVG.createDelimiter(this.data.join("").charCodeAt(0),w,svg.scale,values.mathvariant);
this.SVGhandleSpace(svg); this.SVGhandleSpace(svg);
this.SVGhandleColor(svg); this.SVGhandleColor(svg);
delete this.svg; delete this.svg.element;
this.SVGsaveData(svg); this.SVGsaveData(svg);
return svg; return svg;
} }