Update CHTML to get the proper node for handling horizontal stretchy characters.

This commit is contained in:
Davide P. Cervone 2015-08-24 08:23:20 -04:00
parent 966444bc31
commit 6e1301e681
2 changed files with 21 additions and 9 deletions

View File

@ -405,7 +405,9 @@ MathJax.ElementJax.mml.Augment({
if (child == null) return; if (child == null) return;
for (var i = 0, m = this.data.length; i < m; i++) if (child === this.data[i]) return i; for (var i = 0, m = this.data.length; i < m; i++) if (child === this.data[i]) return i;
}, },
CoreIndex: function () {return this.childIndex(this.Core())}, CoreIndex: function () {
return (this.inferRow ? this.data[0]||this : this).childIndex(this.Core());
},
hasNewline: function () { hasNewline: function () {
if (this.isEmbellished()) {return this.CoreMO().hasNewline()} if (this.isEmbellished()) {return this.CoreMO().hasNewline()}
if (this.isToken || this.linebreakContainer) {return false} if (this.isToken || this.linebreakContainer) {return false}

View File

@ -1333,6 +1333,16 @@
} else if (options.forceChild) {cnode = HTML.addElement(node,"mjx-box")} } else if (options.forceChild) {cnode = HTML.addElement(node,"mjx-box")}
return cnode; return cnode;
}, },
CHTMLchildNode: function (node,i) {
node = node.childNodes[i];
if (node.nodeName.toLowerCase() === "a") node = node.firstChild;
return node;
},
CHTMLcoreNode: function (node) {
return this.CHTMLchildNode(node,this.CoreIndex());
},
CHTMLstretchChildV: function (i,H,D) { CHTMLstretchChildV: function (i,H,D) {
var data = this.data[i]; var data = this.data[i];
if (data) { if (data) {
@ -1355,7 +1365,7 @@
var bbox = this.CHTML, dbox = data.CHTML; var bbox = this.CHTML, dbox = data.CHTML;
if (dbox.stretch || (dbox.stretch == null && data.CHTMLcanStretch("Horizontal",W))) { if (dbox.stretch || (dbox.stretch == null && data.CHTMLcanStretch("Horizontal",W))) {
var w = dbox.w; var w = dbox.w;
dbox = data.CHTMLstretchH(node,W); dbox = data.CHTMLstretchH(this.CHTMLchildNode(node,i),W);
bbox.w += dbox.w - w; bbox.w += dbox.w - w;
if (bbox.w > bbox.r) bbox.r = bbox.w; if (bbox.w > bbox.r) bbox.r = bbox.w;
if (dbox.h > bbox.h) bbox.h = dbox.h; if (dbox.h > bbox.h) bbox.h = dbox.h;
@ -1380,9 +1390,12 @@
return this.CHTML; return this.CHTML;
}, },
CHTMLstretchH: function (node,w) { CHTMLstretchH: function (node,w) {
this.CHTML.updateFrom(this.Core().CHTMLstretchH(node,w)); this.CHTML.updateFrom(this.CHTMLstretchCoreH(node,w));
return this.CHTML; return this.CHTML;
}, },
CHTMLstretchCoreH: function (node,w) {
return this.Core().CHTMLstretchH(this.CHTMLcoreNode(node),w);
},
CHTMLcreateNode: function (node) { CHTMLcreateNode: function (node) {
if (!this.CHTML) this.CHTML = {}; if (!this.CHTML) this.CHTML = {};
@ -1599,7 +1612,7 @@
return this.CHTML; return this.CHTML;
}, },
CHTMLstretchH: function (node,w) { CHTMLstretchH: function (node,w) {
this.Core().CHTMLstretchH(node,w); this.CHTMLstretchCoreH(node,w);
this.toCommonHTML(node,true); this.toCommonHTML(node,true);
return this.CHTML; return this.CHTML;
} }
@ -2477,10 +2490,7 @@
return this.CHTML; return this.CHTML;
}, },
CHTMLstretchH: function (node,w) { CHTMLstretchH: function (node,w) {
var i = this.CoreIndex() this.CHTMLstretchChildH(this.CoreIndex(),w,node);
node = node.childNodes[i];
if (node.nodeName.toLowerCase() === "a") node = node.firstChild;
this.CHTMLstretchChildH(i,w,node);
return this.CHTML; return this.CHTML;
} }
}); });
@ -2516,7 +2526,7 @@
return this.CHTML; return this.CHTML;
}, },
CHTMLstretchH: function (node,w) { CHTMLstretchH: function (node,w) {
this.CHTML.updateFrom(this.Core().CHTMLstretchH(node.firstChild,w)); this.CHTML.updateFrom(this.CHTMLstretchCoreH(node,w));
this.toCommonHTML(node,true); this.toCommonHTML(node,true);
return this.CHTML; return this.CHTML;
} }