From bc190884230cfccf4fc514598fbeca7889d45f6e Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Mon, 17 Feb 2014 11:17:29 -0500 Subject: [PATCH] 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. --- unpacked/jax/output/HTML-CSS/jax.js | 26 +++++++++++++++++++------- unpacked/jax/output/SVG/jax.js | 8 +++++--- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/unpacked/jax/output/HTML-CSS/jax.js b/unpacked/jax/output/HTML-CSS/jax.js index c3eb585c1..287418d1a 100644 --- a/unpacked/jax/output/HTML-CSS/jax.js +++ b/unpacked/jax/output/HTML-CSS/jax.js @@ -1614,9 +1614,13 @@ for (var i = 0, m = this.data.length; i < m; i++) {if (this.data[i]) {this.data[i].toHTML(span)}} var stretchy = this.HTMLcomputeBBox(span); - var h = span.bbox.h, d = span.bbox.d; - for (i = 0, m = stretchy.length; i < m; i++) {stretchy[i].HTMLstretchV(span,h,d)} - if (stretchy.length) {this.HTMLcomputeBBox(span,true)} + var h = span.bbox.h, d = span.bbox.d, stretched = false; + for (i = 0, m = stretchy.length; i < m; i++) { + 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)} this.HTMLhandleSpace(span); this.HTMLhandleColor(span); @@ -2740,23 +2744,31 @@ }); MML.TeXAtom.Augment({ - toHTML: function (span) { + toHTML: function (span,HW,D) { span = this.HTMLcreateSpan(span); if (this.data[0] != null) { if (this.texClass === MML.TEXCLASS.VCENTER) { var stack = HTMLCSS.createStack(span); 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? HTMLCSS.placeBox(box,0,HTMLCSS.TeX.axis_height-(box.bbox.h+box.bbox.d)/2+box.bbox.d); } 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.HTMLhandleColor(span); return span; - } + }, + HTMLstretchH: MML.mbase.HTMLstretchH, + HTMLstretchV: MML.mbase.HTMLstretchV }); // diff --git a/unpacked/jax/output/SVG/jax.js b/unpacked/jax/output/SVG/jax.js index 41e912cb3..1615c50f8 100644 --- a/unpacked/jax/output/SVG/jax.js +++ b/unpacked/jax/output/SVG/jax.js @@ -893,7 +893,9 @@ { var svg = this.svg[i], mml = svg.mml; if (mml) { - svg = mml.SVGstretchV(this.sh,this.sd); + if (mml.SVGdata.h !== this.sh || mml.SVGdata.d !== this.sd) { + svg = mml.SVGstretchV(this.sh,this.sd); + } mml.SVGdata.HW = this.sh; mml.SVGdata.D = this.sd; } if (svg.ic) {this.ic = svg.ic} else {delete this.ic} @@ -1995,12 +1997,12 @@ }); MML.TeXAtom.Augment({ - toSVG: function () { + toSVG: function (HW,D) { this.SVGgetStyles(); var svg = this.SVG(); this.SVGhandleSpace(svg); 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) { // FIXME: should the axis height be scaled? y = SVG.TeX.axis_height - (box.h+box.d)/2 + box.d;