Measure mtable entries all at once (to reduce reflows)

This commit is contained in:
Davide P. Cervone 2011-09-06 12:51:34 -04:00
parent b719fb481b
commit 3717fcfb57
8 changed files with 28 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

View File

@ -22,7 +22,7 @@
*/
MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
var VERSION = "1.1";
var VERSION = "1.1.1";
var MML = MathJax.ElementJax.mml,
HTMLCSS = MathJax.OutputJax["HTML-CSS"];
@ -38,7 +38,7 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
var stack = HTMLCSS.createStack(span);
var scale = this.HTMLgetScale(); 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, entries = [];
var LHD = HTMLCSS.FONTDATA.baselineskip * scale * values.useHeight,
LH = HTMLCSS.FONTDATA.lineH * scale, LD = HTMLCSS.FONTDATA.lineD * scale;
@ -55,7 +55,13 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
W[j] = -HTMLCSS.BIGDIMEN;
}
A[i][j] = HTMLCSS.createBox(C[j]);
HTMLCSS.Measured(row.data[j-s].toHTML(A[i][j]),A[i][j]);
entries.push(row.data[j-s].toHTML(A[i][j]));
}
}
HTMLCSS.MeasureSpans(entries);
for (i = 0, m = this.data.length; i < m; i++) {
row = this.data[i]; s = (row.type === "mlabeledtr" ? LABEL : 0);
for (j = s, M = row.data.length + s; j < M; j++) {
if (row.data[j-s].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.d > D[i]) {D[i] = A[i][j].bbox.d}
@ -419,9 +425,8 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
span = this.HTMLcreateSpan(span);
if (this.data[0]) {
var box = this.data[0].toHTML(span);
if (D != null) {HTMLCSS.Remeasured(this.data[0].HTMLstretchV(span,HW,D),span)}
else if (HW != null) {HTMLCSS.Remeasured(this.data[0].HTMLstretchH(span,HW),span)}
else {HTMLCSS.Measured(box,span)}
if (D != null) {box = this.data[0].HTMLstretchV(span,HW,D)}
else if (HW != null) {box = this.data[0].HTMLstretchH(span,HW)}
span.bbox = box.bbox;
}
this.HTMLhandleSpace(span);

View File

@ -663,13 +663,13 @@
Remeasured: function (span,parent) {
parent.bbox = this.Measured(span,parent).bbox;
},
MeasureSpans: function () {
MeasureSpans: function (SPANS) {
var spans = [], span, i, m, bbox, start, end, W;
//
// Insert the needed markers
//
for (i = 0, m = arguments.length; i < m; i++) {
span = arguments[i]; if (!span) continue;
for (i = 0, m = SPANS.length; i < m; i++) {
span = SPANS[i]; if (!span) continue;
bbox = span.bbox;
if (bbox.exactW || bbox.width || bbox.w === 0 || bbox.isMultiline) {
if (!span.parentNode.bbox) {span.parentNode.bbox = bbox}
@ -1889,7 +1889,7 @@
span = this.HTMLcreateSpan(span);
var frac = HTMLCSS.createStack(span);
var num = HTMLCSS.createBox(frac), den = HTMLCSS.createBox(frac);
HTMLCSS.MeasureSpans(this.HTMLboxChild(0,num),this.HTMLboxChild(1,den));
HTMLCSS.MeasureSpans([this.HTMLboxChild(0,num),this.HTMLboxChild(1,den)]);
var values = this.getValues("displaystyle","linethickness","numalign","denomalign","bevelled");
var scale = this.HTMLgetScale(), isDisplay = values.displaystyle;
var a = HTMLCSS.TeX.axis_height * scale;
@ -1951,7 +1951,7 @@
var BASE = this.HTMLboxChild(0,base);
H = BASE.bbox.h + BASE.bbox.d + q + t;
HTMLCSS.createDelimiter(surd,0x221A,H,scale);
HTMLCSS.MeasureSpans(BASE,surd);
HTMLCSS.MeasureSpans([BASE,surd]);
W = BASE.bbox.w;
var x = 0;
if (surd.isMultiChar || (HTMLCSS.AdjustSurd && HTMLCSS.imgFonts)) {surd.bbox.w *= .95}
@ -2083,7 +2083,7 @@
}
}
}
HTMLCSS.MeasureSpans.apply(HTMLCSS,children);
HTMLCSS.MeasureSpans(children);
var W = -HTMLCSS.BIGDIMEN, WW = W;
for (i = 0, m = this.data.length; i < m; i++) {
if (this.data[i]) {
@ -2163,7 +2163,7 @@
{sup = HTMLCSS.createBox(stack); children.push(this.data[this.sup].toHTML(sup))}
if (this.HTMLnotEmpty(this.data[this.sub]))
{sub = HTMLCSS.createBox(stack); children.push(this.data[this.sub].toHTML(sub))}
HTMLCSS.MeasureSpans.apply(HTMLCSS,children);
HTMLCSS.MeasureSpans(children);
if (sup) {sup.bbox.w += s; sup.bbox.rw = Math.max(sup.bbox.w,sup.bbox.rw)}
if (sub) {sub.bbox.w += s; sub.bbox.rw = Math.max(sub.bbox.w,sub.bbox.rw)}
HTMLCSS.placeBox(base,0,0);