Add noReflows flag to prevent taking measurements that cause reflows, when possible. This provides a 30 to 40% speed improvement, but can cause poor results in some browsers.
This commit is contained in:
parent
7aab884fd0
commit
1aa86d7cf6
|
@ -35,6 +35,7 @@ MathJax.OutputJax["HTML-CSS"] = MathJax.OutputJax({
|
||||||
webfontDir: MathJax.OutputJax.fontDir + "/HTML-CSS", // font name added later
|
webfontDir: MathJax.OutputJax.fontDir + "/HTML-CSS", // font name added later
|
||||||
|
|
||||||
config: {
|
config: {
|
||||||
|
noReflows: false, // true will use internal measurements and avoid browser reflows
|
||||||
matchFontHeight: true, // try to match math font height to surrounding font?
|
matchFontHeight: true, // try to match math font height to surrounding font?
|
||||||
scale: 100, minScaleAdjust: 50, // global math scaling factor, and minimum adjusted scale factor
|
scale: 100, minScaleAdjust: 50, // global math scaling factor, and minimum adjusted scale factor
|
||||||
availableFonts: ["STIX","TeX"], // list of local fonts to check for
|
availableFonts: ["STIX","TeX"], // list of local fonts to check for
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
(function (AJAX,HUB,HTMLCSS) {
|
(function (AJAX,HUB,HTMLCSS) {
|
||||||
var MML, isMobile = HUB.Browser.isMobile;
|
var MML, isMobile = HUB.Browser.isMobile;
|
||||||
|
|
||||||
|
@ -177,6 +176,7 @@
|
||||||
loadWebFont: function (font) {
|
loadWebFont: function (font) {
|
||||||
HUB.Startup.signal.Post("HTML-CSS Jax - Web-Font "+HTMLCSS.fontInUse+"/"+font.directory);
|
HUB.Startup.signal.Post("HTML-CSS Jax - Web-Font "+HTMLCSS.fontInUse+"/"+font.directory);
|
||||||
var n = MESSAGE(["LoadWebFont","Loading web-font %1",HTMLCSS.fontInUse+"/"+font.directory]);
|
var n = MESSAGE(["LoadWebFont","Loading web-font %1",HTMLCSS.fontInUse+"/"+font.directory]);
|
||||||
|
if (HTMLCSS.noReflows) return;
|
||||||
var done = MathJax.Callback({}); // called when font is loaded
|
var done = MathJax.Callback({}); // called when font is loaded
|
||||||
var callback = MathJax.Callback(["loadComplete",this,font,n,done]);
|
var callback = MathJax.Callback(["loadComplete",this,font,n,done]);
|
||||||
AJAX.timer.start(AJAX,[this.checkWebFont,font,callback],0,this.timeout);
|
AJAX.timer.start(AJAX,[this.checkWebFont,font,callback],0,this.timeout);
|
||||||
|
@ -832,6 +832,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
getHD: function (span) {
|
getHD: function (span) {
|
||||||
|
if (span.bbox && this.config.noReflows) {return {h:span.bbox.h, d:span.bbox.d}}
|
||||||
var position = span.style.position;
|
var position = span.style.position;
|
||||||
span.style.position = "absolute";
|
span.style.position = "absolute";
|
||||||
this.HDimg.style.height = "0px";
|
this.HDimg.style.height = "0px";
|
||||||
|
@ -845,6 +846,7 @@
|
||||||
return HD;
|
return HD;
|
||||||
},
|
},
|
||||||
getW: function (span) {
|
getW: function (span) {
|
||||||
|
if (span.bbox && this.config.noReflows) {return span.bbox.w}
|
||||||
var W, H, w = (span.bbox||{}).w, start = span;
|
var W, H, w = (span.bbox||{}).w, start = span;
|
||||||
if (span.bbox && span.bbox.exactW) {return w}
|
if (span.bbox && span.bbox.exactW) {return w}
|
||||||
if ((span.bbox && w >= 0 && !this.initialSkipBug && !this.msieItalicWidthBug) ||
|
if ((span.bbox && w >= 0 && !this.initialSkipBug && !this.msieItalicWidthBug) ||
|
||||||
|
@ -886,7 +888,7 @@
|
||||||
for (i = 0, m = SPANS.length; i < m; i++) {
|
for (i = 0, m = SPANS.length; i < m; i++) {
|
||||||
span = SPANS[i]; if (!span) continue;
|
span = SPANS[i]; if (!span) continue;
|
||||||
bbox = span.bbox; parent = this.parentNode(span);
|
bbox = span.bbox; parent = this.parentNode(span);
|
||||||
if (bbox.exactW || bbox.width || bbox.w === 0 || bbox.isMultiline) {
|
if (bbox.exactW || bbox.width || bbox.w === 0 || bbox.isMultiline || this.config.noReflows) {
|
||||||
if (!parent.bbox) {parent.bbox = bbox}
|
if (!parent.bbox) {parent.bbox = bbox}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1077,7 +1079,8 @@
|
||||||
width:0, height:H, verticalAlign:D},
|
width:0, height:H, verticalAlign:D},
|
||||||
bbox: {h:h, d:d, w:w, rw:w, lw:0, exactW:true}, noAdjust:true, HH:h+d, isMathJax:true
|
bbox: {h:h, d:d, w:w, rw:w, lw:0, exactW:true}, noAdjust:true, HH:h+d, isMathJax:true
|
||||||
});
|
});
|
||||||
if (w > 0 && rule.offsetWidth == 0) {rule.style.width = this.Em(w)}
|
// ### FIXME: figure out which IE has this bug and make a flag for it
|
||||||
|
if (w > 0 && !this.noReflows && rule.offsetWidth == 0) {rule.style.width = this.Em(w)}
|
||||||
if (span.isBox || span.className == "mspace") {span.bbox = rule.bbox, span.HH = h+d}
|
if (span.isBox || span.className == "mspace") {span.bbox = rule.bbox, span.HH = h+d}
|
||||||
return rule;
|
return rule;
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue
Block a user