Make zoom box large enough for overlaps (e.g., when \llap, \rlap, or \smash are used) in SVG and HTML-CSS output. Can't do it effectively for NativeMML, since we don't know anything about overlaps in that case. Resolves issue #835.

This commit is contained in:
Davide P. Cervone 2014-09-13 15:34:52 -04:00
parent 74253a955f
commit f07278d3db
2 changed files with 20 additions and 1 deletions

View File

@ -794,13 +794,22 @@
} }
} }
// //
// Adjust margins to prevent overlaps at the edges
//
var child = span.firstChild.firstChild.style;
if (bbox.H != null && bbox.H > bbox.h)
{child.marginTop = HTMLCSS.Em(bbox.H-Math.max(bbox.h,HTMLCSS.FONTDATA.lineH))}
if (bbox.D != null && bbox.D > bbox.d)
{child.marginBottom = HTMLCSS.Em(bbox.D-Math.max(bbox.d,HTMLCSS.FONTDATA.lineD))}
if (bbox.lw < 0) {child.paddingLeft = HTMLCSS.Em(-bbox.lw)}
if (bbox.rw > bbox.w) {child.marginRight = HTMLCSS.Em(bbox.rw-bbox.w)}
//
// Get height and width of zoomed math and original math // Get height and width of zoomed math and original math
// //
span.style.position = "absolute"; span.style.position = "absolute";
if (!width) {math.style.position = "absolute"} if (!width) {math.style.position = "absolute"}
var zW = span.offsetWidth, zH = span.offsetHeight, var zW = span.offsetWidth, zH = span.offsetHeight,
mH = math.offsetHeight, mW = math.offsetWidth; mH = math.offsetHeight, mW = math.offsetWidth;
if (mW === 0) {mW = math.parentNode.offsetWidth}; // IE7 gets mW == 0?
span.style.position = math.style.position = ""; span.style.position = math.style.position = "";
// //
return {Y:-EVENT.getBBox(span).h, mW:mW, mH:mH, zW:zW, zH:zH}; return {Y:-EVENT.getBBox(span).h, mW:mW, mH:mH, zW:zW, zH:zH};
@ -2806,6 +2815,8 @@
var p = 1/HTMLCSS.em, f = HTMLCSS.em / HTMLCSS.outerEm; HTMLCSS.em /= f; var p = 1/HTMLCSS.em, f = HTMLCSS.em / HTMLCSS.outerEm; HTMLCSS.em /= f;
span.bbox.h *= f; span.bbox.d *= f; span.bbox.w *= f; span.bbox.h *= f; span.bbox.d *= f; span.bbox.w *= f;
span.bbox.lw *= f; span.bbox.rw *= f; span.bbox.lw *= f; span.bbox.rw *= f;
if (span.bbox.H) {span.bbox.H *= f}
if (span.bbox.D) {span.bbox.D *= f}
if (math && math.bbox.width != null) { if (math && math.bbox.width != null) {
span.style.minWidth = (math.bbox.minWidth || span.style.width); span.style.minWidth = (math.bbox.minWidth || span.style.width);
span.style.width = math.bbox.width; span.style.width = math.bbox.width;

View File

@ -442,6 +442,14 @@
this.zoomScale = 1; this.zoomScale = 1;
span.removeChild(this.textSVG); span.removeChild(this.textSVG);
//
// Don't allow overlaps on any edge
//
var svg = span.getElementsByTagName("svg")[0].style;
svg.marginTop = svg.marginRight = svg.marginLeft = 0;
if (svg.marginBottom.charAt(0) === "-")
span.style.marginBottom = svg.marginBottom.substr(1);
if (this.operaZoomRefresh) if (this.operaZoomRefresh)
{setTimeout(function () {span.firstChild.style.border="1px solid transparent"},1)} {setTimeout(function () {span.firstChild.style.border="1px solid transparent"},1)}
// //