Handle minsize on vertical stretching as well as horizontal. Also fix a vertical placement problem with stretched elements in tables in HTML-CSS, and improve performace for placeing the extension characters by making sure we have the bbox for them. Issue #210.

This commit is contained in:
Davide P. Cervone 2012-09-01 11:21:34 -04:00
parent 153297bdb9
commit 2f8a30a362
15 changed files with 64 additions and 42 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

File diff suppressed because one or more lines are too long

View File

@ -22,7 +22,7 @@
*/
MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
var VERSION = "2.0.1";
var VERSION = "2.0.2";
var MML = MathJax.ElementJax.mml,
HTMLCSS = MathJax.OutputJax["HTML-CSS"];
@ -39,7 +39,7 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
var scale = this.HTMLgetScale(), mu = this.HTMLgetMu(span), LABEL = -1;
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, HD,
LH = HTMLCSS.FONTDATA.lineH * scale, LD = HTMLCSS.FONTDATA.lineD * scale;
//
@ -64,17 +64,27 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
for (j = s, M = row.data.length + s; j < M; j++) {
cell = row.data[j-s];
if (cell.isMultiline) {A[i][j].style.width = "100%"}
if (cell.isEmbellished()) {
mo = cell.CoreMO();
var min = mo.Get("minsize",true);
if (min) {
var bbox = mo.HTMLspanElement().bbox;
if (mo.HTMLcanStretch("Vertical")) {
HD = bbox.h + bbox.d;
if (HD) {
min = HTMLCSS.length2em(min,mu,HD);
if (min*bbox.h/HD > H[j]) {H[j] = min*bbox.h/HD}
if (min*bbox.d/HD > D[j]) {D[j] = min*bbox.d/HD}
}
} else if (mo.HTMLcanStretch("Horizontal")) {
min = HTMLCSS.length2em(min,mu,bbox.w);
if (min > W[j]) {W[j] = min}
}
}
}
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.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")) {
min = HTMLCSS.length2em(min,mu,mo.HTMLspanElement().bbox.w);
if (min > W[j]) {W[j] = min}
}
}
}
}
if (H[0]+D[0]) {H[0] = Math.max(H[0],LH)}
@ -131,7 +141,7 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
//
// Determine array total height
//
var HD = H[0] + D[A.length-1];
HD = H[0] + D[A.length-1];
for (i = 0, m = A.length-1; i < m; i++) {HD += Math.max((H[i]+D[i] ? LHD : 0),D[i]+H[i+1]+RSPACE[i])}
//
// Determine frame and line sizes
@ -256,11 +266,11 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
s = (this.data[i].type === "mlabeledtr" ? LABEL : 0);
cell = this.data[i].data[j-s];
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]).bbox;
} else if (cell.HTMLcanStretch("Vertical")) {
mo = cell.CoreMO();
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; A[i][j].HH = null;
mo.symmetric = symmetric;
}
align = cell.rowalign||this.data[i].rowalign||RALIGN[i];
@ -268,7 +278,7 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
bottom: A[i][j].bbox.d - D[i],
center: ((H[i]-D[i]) - (A[i][j].bbox.h-A[i][j].bbox.d))/2,
baseline: 0, axis: 0})[align]; // FIXME: handle axis better?
align = (cell.columnalign||RCALIGN[i][j]||CALIGN[j])
align = (cell.columnalign||RCALIGN[i][j]||CALIGN[j]);
HTMLCSS.alignBox(A[i][j],align,y+dy);
}
if (i < A.length-1) {y -= Math.max((H[i]+D[i] ? LHD : 0),D[i]+H[i+1]+RSPACE[i])}

View File

@ -1122,6 +1122,7 @@
while (n-- > 0) {
if (!this.msieCloneNodeBug) {EXT = ext.cloneNode(true)}
else {EXT = this.Element("span"); this.createChar(EXT,delim.ext,scale,font)}
EXT.bbox = ext.bbox;
y -= eh; this.placeBox(this.addBox(stack,EXT),0,y,true);
}
y += dy - ext.bbox.d;
@ -1170,6 +1171,7 @@
while (n-- > 0) {
if (!this.msieCloneNodeBug) {REP = rep.cloneNode(true)}
else {REP = this.Element("span"); this.createChar(REP,delim.rep,scale,font)}
REP.bbox = rep.bbox;
this.placeBox(this.addBox(stack,REP),x,0,true); x += rw;
}
if (delim.mid && k) {this.placeBox(mid,x,0,true); x += mid.bbox.w - dx; n = N}
@ -1603,7 +1605,7 @@
if (SPAN) {
while (SPAN.firstChild) {SPAN.removeChild(SPAN.firstChild)}
SPAN.bbox = {w:0, h:0, d:0, lw:0, rw:0};
SPAN.scale = 1; SPAN.isMultChar = null;
SPAN.scale = 1; SPAN.isMultChar = SPAN.HH = null;
SPAN.style.cssText = "";
return SPAN;
}

View File

@ -22,7 +22,7 @@
*/
MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
var VERSION = "2.0.1";
var VERSION = "2.0.2";
var MML = MathJax.ElementJax.mml,
SVG = MathJax.OutputJax.SVG,
BBOX = SVG.BBOX;
@ -42,7 +42,7 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
var LABEL = -1;
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, HD,
LH = SVG.FONTDATA.lineH * scale, LD = SVG.FONTDATA.lineD * scale;
//
@ -60,17 +60,26 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
cell = row.data[j-s];
A[i][j] = cell.toSVG();
// 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].d > D[i]) {D[i] = A[i][j].d}
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")) {
min = SVG.length2em(min,mu,mo.SVGdata.w);
if (min > W[j]) {W[j] = min}
if (min) {
if (mo.SVGcanStretch("Vertical")) {
HD = mo.SVGdata.h + mo.SVGdata.d;
if (HD) {
min = SVG.length2em(min,mu,HD);
if (min*mo.SVGdata.h/HD > H[j]) {H[j] = min*mo.SVGdata.h/HD}
if (min*mo.SVGdata.d/HD > D[j]) {D[j] = min*mo.SVGdata.d/HD}
}
} else if (mo.SVGcanStretch("Horizontal")) {
min = SVG.length2em(min,mu,mo.SVGdata.w);
if (min > W[j]) {W[j] = min}
}
}
}
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].w > W[j]) {W[j] = A[i][j].w}
}
}
if (H[0]+D[0]) {H[0] = Math.max(H[0],LH)}
@ -127,7 +136,7 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
//
// Determine array total height
//
var HD = H[0] + D[A.length-1];
HD = H[0] + D[A.length-1];
for (i = 0, m = A.length-1; i < m; i++)
{HD += Math.max((H[i]+D[i] ? LHD : 0),D[i]+H[i+1]+RSPACE[i])}
//

View File

@ -985,6 +985,7 @@
SVGsaveData: function (svg) {
if (!this.SVGdata) {this.SVGdata = {}}
this.SVGdata.w = svg.w, this.SVGdata.x = svg.x;
this.SVGdata.h = svg.h, this.SVGdata.d = svg.d;
if (svg.X != null) {this.SVGdata.X = svg.X}
if (this["class"]) {svg.removeable = false; SVG.Element(svg.element,{"class":this["class"]})}
// FIXME: if an element is split by linebreaking, the ID will be the same on both parts