From a490d835184a20c781190c848094d365dd475218 Mon Sep 17 00:00:00 2001 From: "rbs%maths.uq.edu.au" Date: Fri, 15 Feb 2002 14:39:50 +0000 Subject: [PATCH] [MathML only] fix weirdness in the edge case of an empty git-svn-id: svn://10.0.0.236/trunk@114595 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/gfx/public/nsIRenderingContext.h | 4 ++++ .../layout/mathml/base/src/nsMathMLChar.cpp | 2 +- .../mathml/base/src/nsMathMLmfencedFrame.cpp | 20 ++++++++++--------- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/mozilla/gfx/public/nsIRenderingContext.h b/mozilla/gfx/public/nsIRenderingContext.h index 7f24bd11537..c20fc4f0999 100644 --- a/mozilla/gfx/public/nsIRenderingContext.h +++ b/mozilla/gfx/public/nsIRenderingContext.h @@ -981,6 +981,10 @@ struct nsBoundingMetrics { to follow the current one. Depending on the font, this could be greater than or less than the right bearing. */ + nsBoundingMetrics() { + Clear(); + } + ////////// // Utility methods and operators: diff --git a/mozilla/layout/mathml/base/src/nsMathMLChar.cpp b/mozilla/layout/mathml/base/src/nsMathMLChar.cpp index e308503c6ee..85b7caa31aa 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLChar.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLChar.cpp @@ -1491,7 +1491,7 @@ nsMathMLChar::Stretch(nsIPresContext* aPresContext, targetSize = aContainerSize.width; } // if we are not a largeop in display mode, return if size fits - if (!largeop && IsSizeOK(charSize, targetSize, aStretchHint)) { + if (targetSize <= 0 || (!largeop && IsSizeOK(charSize, targetSize, aStretchHint))) { // ensure that the char later behaves like a normal char // (will be reset back to its intrinsic value in case of dynamic updates) mDirection = NS_STRETCH_DIRECTION_UNSUPPORTED; diff --git a/mozilla/layout/mathml/base/src/nsMathMLmfencedFrame.cpp b/mozilla/layout/mathml/base/src/nsMathMLmfencedFrame.cpp index a7d755b8f05..eb835400a93 100644 --- a/mozilla/layout/mathml/base/src/nsMathMLmfencedFrame.cpp +++ b/mozilla/layout/mathml/base/src/nsMathMLmfencedFrame.cpp @@ -289,9 +289,9 @@ nsMathMLmfencedFrame::doReflow(nsIPresContext* aPresContext, nsSize availSize(aReflowState.mComputedWidth, aReflowState.mComputedHeight); nsHTMLReflowMetrics childDesiredSize(aDesiredSize.maxElementSize, aDesiredSize.mFlags | NS_REFLOW_CALC_BOUNDING_METRICS); - nsIFrame* fisrtChild; - aForFrame->FirstChild(aPresContext, nsnull, &fisrtChild); - nsIFrame* childFrame = fisrtChild; + nsIFrame* firstChild; + aForFrame->FirstChild(aPresContext, nsnull, &firstChild); + nsIFrame* childFrame = firstChild; while (childFrame) { nsHTMLReflowState childReflowState(aPresContext, aReflowState, childFrame, availSize); @@ -337,7 +337,7 @@ nsMathMLmfencedFrame::doReflow(nsIPresContext* aPresContext, mathMLFrame->GetPreferredStretchSize(aPresContext, *aReflowState.rendContext, 0, /* i.e., without embellishments */ stretchDir, containerSize); - childFrame = fisrtChild; + childFrame = firstChild; while (childFrame) { nsIMathMLFrame* mathmlChild; childFrame->QueryInterface(NS_GET_IID(nsIMathMLFrame), (void**)&mathmlChild); @@ -376,10 +376,12 @@ nsMathMLmfencedFrame::doReflow(nsIPresContext* aPresContext, GetEmHeight(fm, em); // we need to center around the axis - nscoord delta = PR_MAX(containerSize.ascent - axisHeight, - containerSize.descent + axisHeight); - containerSize.ascent = delta + axisHeight; - containerSize.descent = delta - axisHeight; + if (firstChild) { // do nothing for an empty + nscoord delta = PR_MAX(containerSize.ascent - axisHeight, + containerSize.descent + axisHeight); + containerSize.ascent = delta + axisHeight; + containerSize.descent = delta - axisHeight; + } ///////////////// // opening fence ... @@ -413,7 +415,7 @@ nsMathMLmfencedFrame::doReflow(nsIPresContext* aPresContext, firstTime = PR_FALSE; } - childFrame = fisrtChild; + childFrame = firstChild; while (childFrame) { nsHTMLReflowMetrics childSize(nsnull); GetReflowAndBoundingMetricsFor(childFrame, childSize, bm);