Skip to content

Commit cf0221e

Browse files
author
dpvc
committed
Bring jsMath up to version 3.6e. Changes include:
* Changed the way IE is detected to be more robust for IE8 in its various modes. * More fixes for vertical and horizontal alignment in IE8 in all its various modes, and in jsMath's various disoplay modes. More thurough testing than with 3.6d, which introduced some problems in some modes. * Add <code> to the list of node types that are not scanned for mathematics by the tex2math plugin. * Updated the unicode fallback mode font tables for Mac and PC to handle current font configurations better. git-svn-id: http://svn.webwork.maa.org/system/trunk/webwork2@6212 c0722133-6baf-4dd8-8699-98d999cd4f06
1 parent 2692c4b commit cf0221e

File tree

7 files changed

+313
-377
lines changed

7 files changed

+313
-377
lines changed

htdocs/jsMath/jsMath-fallback-mac.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

htdocs/jsMath/jsMath-fallback-pc.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

htdocs/jsMath/jsMath.js

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

htdocs/jsMath/plugins/tex2math.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ jsMath.Add(jsMath.tex2math,{
154154
if (element.className == null) {element.className = ''}
155155
if (element.firstChild && element.className != 'math') {
156156
var off = ignore || element.className.match(/(^| )tex2math_ignore( |$)/) ||
157-
(element.tagName && element.tagName.match(/^(script|noscript|style|textarea|pre)$/i));
157+
(element.tagName && element.tagName.match(/^(script|noscript|style|textarea|pre|code)$/i));
158158
off = off && !element.className.match(/(^| )tex2math_process( |$)/);
159159
this.ScanElement(element.firstChild,off);
160160
}

htdocs/jsMath/uncompressed/jsMath-fallback-mac.js

+133-179
Large diffs are not rendered by default.

htdocs/jsMath/uncompressed/jsMath-fallback-pc.js

+125-131
Large diffs are not rendered by default.

htdocs/jsMath/uncompressed/jsMath.js

+43-55
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ if (!document.getElementById || !document.childNodes || !document.createElement)
6767

6868
window.jsMath = {
6969

70-
version: "3.6d", // change this if you edit the file, but don't edit this file
70+
version: "3.6e", // change this if you edit the file, but don't edit this file
7171

7272
document: document, // the document loading jsMath
7373
window: window, // the window of the of loading document
@@ -306,7 +306,8 @@ window.jsMath = {
306306
BBoxFor: function (s) {
307307
this.hidden.innerHTML =
308308
'<nobr><span class="typeset"><span class="scale">'+s+'</span></span></nobr>';
309-
var bbox = {w: this.hidden.offsetWidth, h: this.hidden.offsetHeight};
309+
var math = (jsMath.Browser.msieBBoxBug ? this.hidden.firstChild.firstChild : this.hidden);
310+
var bbox = {w: math.offsetWidth, h: this.hidden.offsetHeight};
310311
this.hidden.innerHTML = '';
311312
return bbox;
312313
},
@@ -325,24 +326,6 @@ window.jsMath = {
325326
return cache[this.em][s];
326327
},
327328

328-
/*
329-
* For browsers that don't handle sizes of italics properly (MSIE).
330-
* Check the cache first to see if we've already measured it.
331-
*/
332-
EmBoxForItalics: function (s) {
333-
var cache = jsMath.Global.cache.R;
334-
if (!cache[this.em]) {cache[this.em] = {}}
335-
if (!cache[this.em][s]) {
336-
var bbox = this.BBoxFor(s);
337-
if (s.match(/<i>|class=\"(icm|italic|igreek|iaccent)/i)) {
338-
bbox.w = bbox.Mw = this.BBoxFor(s+jsMath.Browser.italicString).w
339-
- jsMath.Browser.italicCorrection;
340-
}
341-
cache[this.em][s] = {w: bbox.w/this.em, h: bbox.h/this.em};
342-
}
343-
return cache[this.em][s];
344-
},
345-
346329
/*
347330
* Initialize jsMath. This determines the em size, and a variety
348331
* of other parameters used throughout jsMath.
@@ -363,9 +346,7 @@ window.jsMath = {
363346
if (!cache[this.em]) {
364347
cache[this.em] = {};
365348
cache[this.em].bb = this.BBoxFor('x'); var hh = cache[this.em].bb.h;
366-
cache[this.em].d = this.BBoxFor('x'+jsMath.HTML.Rule(1,hh/jsMath.em)).h - hh;
367-
if (jsMath.Browser.italicString)
368-
{cache[this.em].ic = jsMath.BBoxFor(jsMath.Browser.italicString).w}
349+
cache[this.em].d = this.BBoxFor('x'+jsMath.HTML.Strut(hh/this.em)).h - hh;
369350
}
370351
jsMath.Browser.italicCorrection = cache[this.em].ic;
371352
var bb = cache[this.em].bb; var h = bb.h; var d = cache[this.em].d
@@ -1099,10 +1080,8 @@ jsMath.Setup = {
10991080
*/
11001081
TeXfont: function (name) {
11011082
var font = jsMath.TeX[name]; if (font == null) return;
1102-
var WH = jsMath.EmBoxFor('<span class="'+name+'">'+font[65].c+'</span>');
1103-
font.hd = WH.h;
1104-
font.d = jsMath.EmBoxFor('<span class="'+name+'">'+ font[65].c +
1105-
jsMath.HTML.Rule(1,font.hd) + '</span>').h - font.hd;
1083+
font.hd = jsMath.EmBoxFor('<span class="'+name+'">'+font[65].c+'</span>').h;
1084+
font.d = jsMath.EmBoxFor('<span class="'+name+'">'+font[65].c+jsMath.HTML.Strut(font.hd)+'</span>').h - font.hd;
11061085
font.h = font.hd - font.d;
11071086
if (name == 'cmmi10') {font.skewchar = 0177}
11081087
else if (name == 'cmsy10') {font.skewchar = 060}
@@ -1298,7 +1277,7 @@ jsMath.Browser = {
12981277
* or varies with the height of the rest of the line (MSIE).
12991278
*/
13001279
TestSpanHeight: function () {
1301-
jsMath.hidden.innerHTML = '<span><span style="'+this.block+';height:2em;width:1px"></span></span>';
1280+
jsMath.hidden.innerHTML = '<span><span style="'+this.block+';height:2em;width:1px"></span>x</span>';
13021281
var span = jsMath.hidden.firstChild;
13031282
var img = span.firstChild;
13041283
this.spanHeightVaries = (span.offsetHeight >= img.offsetHeight && span.offsetHeight > 0);
@@ -1328,11 +1307,12 @@ jsMath.Browser = {
13281307
'<span style="'+this.block+';height:'+h+'px;width:1px;vertical-align:-'+h+'px"></span>').h > 2*h;
13291308
this.widthAddsBorder = jsMath.BBoxFor('<span style="'+this.block+
13301309
';overflow:hidden;height:1px;width:10px;border-left:10px solid"></span>').w > 10;
1331-
this.msieBorderBug =
1332-
jsMath.BBoxFor('<span style="'+this.block+';height:'+h+'px;width:1px"></span>x').h !=
1333-
jsMath.BBoxFor('<span style="'+this.block+';height:'+h+'px;width:1px;border-left:1px solid"></span>x').h;
1334-
this.blankWidthBug = this.msieBorderBug ||
1335-
jsMath.BBoxFor('<span style="'+this.block+';height:2em;width:0px"></span>').h == 0;
1310+
var h1 = jsMath.BBoxFor('<span style="'+this.block+';height:'+h+'px;width:1px"></span>x').h,
1311+
h2 = jsMath.BBoxFor('<span style="'+this.block+';height:'+h+'px;width:1px;border-left:1px solid"></span>x').h,
1312+
h3 = jsMath.BBoxFor('<span style="'+this.block+';height:2em"></span>').h;
1313+
this.msieBlockDepthBug = (h1 == h);
1314+
this.msieRuleDepthBug = (h2 == h);
1315+
this.blankWidthBug = (h3 == 0);
13361316
},
13371317

13381318
/*
@@ -1409,12 +1389,14 @@ jsMath.Browser = {
14091389
// Handle bug-filled Internet Explorer
14101390
//
14111391
MSIE: function () {
1412-
if (this.spanHeightVaries && !this.spanHeightTooBig) {
1392+
if (jsMath.BBoxFor("<!--[if IE]>IE<![endif]-->").w) {
14131393
jsMath.browser = 'MSIE';
14141394
if (jsMath.platform == 'pc') {
14151395
this.IE7 = (window.XMLHttpRequest != null);
1416-
this.IE8 = (jsMath.BBoxFor("<!--[if gte IE 8]>hi<![endif]-->").w > 0);
1396+
this.IE8 = (jsMath.BBoxFor("<!--[if gte IE 8]>IE8<![endif]-->").w > 0);
1397+
this.isReallyIE8 = (jsMath.document.documentMode != null);
14171398
this.quirks = (jsMath.document.compatMode == "BackCompat");
1399+
this.msieMode = (jsMath.document.documentMode || (this.quirks ? 5 : 7));
14181400
this.msieStandard6 = !this.quirks && !this.IE7;
14191401
this.allowAbsoluteDelim = 1; this.separateSkips = 1;
14201402
this.buttonCheck = 1; this.msieBlankBug = 1;
@@ -1424,10 +1406,11 @@ jsMath.Browser = {
14241406
this.msieAlphaBug = !this.IE7; this.alphaPrintBug = !this.IE7;
14251407
this.msieCenterBugFix = 'position:relative; ';
14261408
this.msieInlineBlockFix = ' display:inline-block;';
1427-
this.msie8HeightBug = (this.IE8 && !this.quirks);
1428-
this.msieTeXfontBaselineBug = !this.quirks;
1429-
this.msieBorderBug = this.blankWidthBug = 1; // force these, since IE7 doesn't register it
1430-
this.msieSpaceFix = '<span style="margin-right:-1px"></span><span style="display:inline-block; width:1px"></span>';
1409+
this.msie8HeightBug = this.msieBBoxBug = (this.msieMode == 8);
1410+
this.blankWidthBug = (this.msieMode != 8);
1411+
this.msieSpaceFix = (this.isReallyIE8 ?
1412+
'<span style="display:inline-block; margin-right:-1px; width:1px"></span>' :
1413+
'<span style="margin-right:-1px; width:1px"></span>');
14311414
jsMath.Macro('joinrel','\\mathrel{\\kern-5mu}'),
14321415
jsMath.Parser.prototype.mathchardef.mapstocharOrig = jsMath.Parser.prototype.mathchardef.mapstochar;
14331416
delete jsMath.Parser.prototype.mathchardef.mapstochar;
@@ -1463,9 +1446,8 @@ jsMath.Browser = {
14631446
this.imgScale *= screen.logicalXDPI/screen.deviceXDPI;
14641447
jsMath.Controls.cookie.alpha = 0;
14651448
}
1466-
// Handle bug with getting width of italic text
1467-
this.italicString = '<i>x</i>';
1468-
jsMath.EmBoxFor = jsMath.EmBoxForItalics;
1449+
// IE8 doesn't puts ALL boxes at the bottom rather than on the baseline
1450+
if (this.msieRuleDepthBug) {jsMath.HTML.Strut = jsMath.HTML.msieStrut}
14691451
} else if (jsMath.platform == 'mac') {
14701452
this.msieAbsoluteBug = 1; this.msieButtonBug = 1;
14711453
this.msieDivWidthBug = 1; this.msieBlankBug = 1;
@@ -2795,7 +2777,7 @@ jsMath.HTML = {
27952777
style += 'height:'+H+';';
27962778
}
27972779
if (jsMath.Browser.mozInlineBlockBug) {d = -h}
2798-
if (jsMath.Browser.msieBorderBug && !isRule) {d -= jsMath.d}
2780+
if (jsMath.Browser.msieBlockDepthBug && !isRule) {d -= jsMath.d}
27992781
if (d) {style += 'vertical-align:'+this.Em(-d)}
28002782
return backspace+'<span class="blank" style="'+style+'"></span>';
28012783
},
@@ -2807,6 +2789,14 @@ jsMath.HTML = {
28072789
if (h == null) {h = jsMath.TeX.default_rule_thickness}
28082790
return this.Blank(w,h,0,1);
28092791
},
2792+
2793+
/*
2794+
* Create a strut for measuring position of baseline
2795+
*/
2796+
Strut: function (h) {return this.Blank(1,h,0,1)},
2797+
msieStrut: function (h) {
2798+
return '<img style="width:1px; height:'+this.Em(h)+'"/>'
2799+
},
28102800

28112801
/*
28122802
* Add a <SPAN> tag to activate a specific CSS class
@@ -2896,7 +2886,7 @@ jsMath.HTML = {
28962886
if (jsMath.Browser.msieAbsoluteBug) { // for MSIE (Mac)
28972887
html = '<span style="position:relative;">' + html + '</span>';
28982888
}
2899-
html = '<span style="position:relative; '
2889+
html = '<span style="position:relative;'
29002890
+ jsMath.Browser.msieInlineBlockFix
29012891
+ '">' + html + '</span>';
29022892
if (jsMath.Browser.lineBreakBug)
@@ -2998,7 +2988,7 @@ jsMath.Add(jsMath.Box,{
29982988
var h = box.bd+box.bh;
29992989
var html = jsMath.Typeset.AddClass(box.tclass,box.html);
30002990
html = jsMath.Typeset.AddStyle(style,size,html);
3001-
box.bd = jsMath.EmBoxFor(html+jsMath.HTML.Blank(1,h)).h - h;
2991+
box.bd = jsMath.EmBoxFor(html + jsMath.HTML.Strut(h)).h - h;
30022992
box.bh = h - box.bd;
30032993
if (scale == 1) {c.bh = box.bh; c.bd = box.bd}
30042994
}
@@ -3184,7 +3174,7 @@ jsMath.Add(jsMath.Box,{
31843174

31853175
html = jsMath.HTML.PlaceAbsolute(jsMath.Typeset.AddClass(top.tclass,top.c),0,0);
31863176
h = rep.h+rep.d - .05; y = top.d-.05 + rep.h;
3187-
ext = jsMath.Typeset.AddClass(font,rep.c)
3177+
ext = jsMath.Typeset.AddClass(rep.tclass,rep.c)
31883178
for (i = 0; i < n; i++) {html += jsMath.HTML.PlaceAbsolute(ext,0,y+i*h)}
31893179
html += jsMath.HTML.PlaceAbsolute(jsMath.Typeset.AddClass(mid.tclass,mid.c),0,y+n*h-rep.h+mid.h);
31903180
y += n*h + mid.h+mid.d - .05;
@@ -3203,6 +3193,10 @@ jsMath.Add(jsMath.Box,{
32033193

32043194
var w = top.w;
32053195
if (nocenter) {h = top.h; y = 0} else {h = H/2 + a; y = h - top.h}
3196+
if (jsMath.Controls.cookie.font === "unicode") {
3197+
if (jsMath.Browser.msie8HeightBug) {y -= jsMath.hd}
3198+
else if (jsMath.Browser.msieBlockDepthBug) {y += jsMath.d}
3199+
}
32063200
html = jsMath.HTML.Absolute(html,w,Font.h,"none",-y);
32073201
var box = new jsMath.Box('html',html,rep.w,h,H-h);
32083202
box.bh = jsMath.TeX[font].h; box.bd = jsMath.TeX[font].d;
@@ -3401,6 +3395,7 @@ jsMath.Add(jsMath.Box,{
34013395

34023396
html = jsMath.HTML.Spacer(addWidth*scale/6)+html+jsMath.HTML.Spacer(addWidth*scale/6);
34033397
if (jsMath.Browser.spanHeightVaries) {y = h-jsMath.h} else {y = 0}
3398+
if (jsMath.Browser.msie8HeightBug) {y = d-jsMath.d}
34043399
html = jsMath.HTML.Absolute(html,w,h+d,d,y);
34053400
var box = new jsMath.Box('html',html,w+addWidth*scale/3,h,d);
34063401
return box;
@@ -4534,7 +4529,7 @@ jsMath.Package(jsMath.Typeset,{
45344529
item.html =
45354530
jsMath.HTML.Spacer(lw-rw) +
45364531
'<span style="position: relative; '
4537-
+ 'top:'+jsMath.HTML.Em(-item.y)+';'
4532+
+ 'top:'+jsMath.HTML.Em(-item.y)+'; '
45384533
+ 'left:'+jsMath.HTML.Em(rw)+'; width:'+jsMath.HTML.Em(W)+';">' +
45394534
jsMath.HTML.Spacer(-lw) +
45404535
item.html +
@@ -6110,15 +6105,8 @@ jsMath.Package(jsMath.Parser,{
61106105
var html = box.html;
61116106
if (isSmall) {// hide the extra size
61126107
if (jsMath.Browser.allowAbsolute) {
6113-
var y = 0;
6114-
if (box.bh > jsMath.h+.001) {y = jsMath.h - box.bh}
6108+
var y = (box.bh > jsMath.h+.001 ? jsMath.h - box.bh : 0);
61156109
html = jsMath.HTML.Absolute(html,box.w,jsMath.h,0,y);
6116-
if (jsMath.Browser.msie8HeightBug) {
6117-
html = html.replace(/relative/,
6118-
"relative; height:"+jsMath.HTML.Em(jsMath.hd)+"; " +
6119-
"vertical-align:"+jsMath.HTML.Em(-jsMath.d)
6120-
);
6121-
}
61226110
} else if (jsMath.Browser.valignBug) {
61236111
// remove line height
61246112
html = '<span style="line-height:'+jsMath.HTML.Em(jsMath.d)+';">'

0 commit comments

Comments
 (0)