Prevent mo's from being stretched more often than needed (check that they aren't already the right size when matching mrow size). Also, allow TeXAtom to stretch properly when part of an embellished operator. Issue #701.

This commit is contained in:
Davide P. Cervone 2014-02-17 11:17:29 -05:00
parent c855a35eff
commit bc19088423
2 changed files with 24 additions and 10 deletions

View File

@ -1614,9 +1614,13 @@
for (var i = 0, m = this.data.length; i < m; i++) for (var i = 0, m = this.data.length; i < m; i++)
{if (this.data[i]) {this.data[i].toHTML(span)}} {if (this.data[i]) {this.data[i].toHTML(span)}}
var stretchy = this.HTMLcomputeBBox(span); var stretchy = this.HTMLcomputeBBox(span);
var h = span.bbox.h, d = span.bbox.d; var h = span.bbox.h, d = span.bbox.d, stretched = false;
for (i = 0, m = stretchy.length; i < m; i++) {stretchy[i].HTMLstretchV(span,h,d)} for (i = 0, m = stretchy.length; i < m; i++) {
if (stretchy.length) {this.HTMLcomputeBBox(span,true)} var bbox = stretchy[i].HTMLspanElement().bbox;
if (bbox.h !== h || bbox.d !== d)
{stretchy[i].HTMLstretchV(span,h,d); stretched = true}
}
if (stretched) {this.HTMLcomputeBBox(span,true)}
if (this.HTMLlineBreaks(span)) {span = this.HTMLmultiline(span)} if (this.HTMLlineBreaks(span)) {span = this.HTMLmultiline(span)}
this.HTMLhandleSpace(span); this.HTMLhandleSpace(span);
this.HTMLhandleColor(span); this.HTMLhandleColor(span);
@ -2740,23 +2744,31 @@
}); });
MML.TeXAtom.Augment({ MML.TeXAtom.Augment({
toHTML: function (span) { toHTML: function (span,HW,D) {
span = this.HTMLcreateSpan(span); span = this.HTMLcreateSpan(span);
if (this.data[0] != null) { if (this.data[0] != null) {
if (this.texClass === MML.TEXCLASS.VCENTER) { if (this.texClass === MML.TEXCLASS.VCENTER) {
var stack = HTMLCSS.createStack(span); var stack = HTMLCSS.createStack(span);
var box = HTMLCSS.createBox(stack); var box = HTMLCSS.createBox(stack);
HTMLCSS.Measured(this.data[0].toHTML(box),box); var child = this.data[0].toHTML(box);
if (D != null) {HTMLCSS.Remeasured(this.data[0].HTMLstretchV(box,HW,D),box)}
else if (HW != null) {HTMLCSS.Remeasured(this.data[0].HTMLstretchH(box,HW),box)}
else {HTMLCSS.Measured(child,box)}
// FIXME: should the axis height be scaled? // FIXME: should the axis height be scaled?
HTMLCSS.placeBox(box,0,HTMLCSS.TeX.axis_height-(box.bbox.h+box.bbox.d)/2+box.bbox.d); HTMLCSS.placeBox(box,0,HTMLCSS.TeX.axis_height-(box.bbox.h+box.bbox.d)/2+box.bbox.d);
} else { } else {
span.bbox = this.data[0].toHTML(span).bbox; var html = this.data[0].toHTML(span,HW,D);
if (D != null) {html = this.data[0].HTMLstretchV(box,HW,D)}
else if (HW != null) {html = this.data[0].HTMLstretchH(box,HW)}
span.bbox = html.bbox;
} }
} }
this.HTMLhandleSpace(span); this.HTMLhandleSpace(span);
this.HTMLhandleColor(span); this.HTMLhandleColor(span);
return span; return span;
} },
HTMLstretchH: MML.mbase.HTMLstretchH,
HTMLstretchV: MML.mbase.HTMLstretchV
}); });
// //

View File

@ -893,7 +893,9 @@
{ {
var svg = this.svg[i], mml = svg.mml; var svg = this.svg[i], mml = svg.mml;
if (mml) { if (mml) {
if (mml.SVGdata.h !== this.sh || mml.SVGdata.d !== this.sd) {
svg = mml.SVGstretchV(this.sh,this.sd); svg = mml.SVGstretchV(this.sh,this.sd);
}
mml.SVGdata.HW = this.sh; mml.SVGdata.D = this.sd; mml.SVGdata.HW = this.sh; mml.SVGdata.D = this.sd;
} }
if (svg.ic) {this.ic = svg.ic} else {delete this.ic} if (svg.ic) {this.ic = svg.ic} else {delete this.ic}
@ -1995,12 +1997,12 @@
}); });
MML.TeXAtom.Augment({ MML.TeXAtom.Augment({
toSVG: function () { toSVG: function (HW,D) {
this.SVGgetStyles(); this.SVGgetStyles();
var svg = this.SVG(); var svg = this.SVG();
this.SVGhandleSpace(svg); this.SVGhandleSpace(svg);
if (this.data[0] != null) { if (this.data[0] != null) {
var box = this.data[0].toSVG(), y = 0; var box = this.data[0].SVGdataStretched(0,HW,D), y = 0;
if (this.texClass === MML.TEXCLASS.VCENTER) { if (this.texClass === MML.TEXCLASS.VCENTER) {
// FIXME: should the axis height be scaled? // FIXME: should the axis height be scaled?
y = SVG.TeX.axis_height - (box.h+box.d)/2 + box.d; y = SVG.TeX.axis_height - (box.h+box.d)/2 + box.d;