From b44cbc52fe3a9e8de1cfade793f284049ea19260 Mon Sep 17 00:00:00 2001 From: "rbs%maths.uq.edu.au" Date: Fri, 22 Mar 2002 04:49:33 +0000 Subject: [PATCH] bug 130886 - caret doesn't respect character position within certain elements, r=roc+moz, sr=attinasi, a=asa --- layout/mathml/base/src/nsMathMLmoFrame.cpp | 64 ++++++++++++++-------- 1 file changed, 41 insertions(+), 23 deletions(-) diff --git a/layout/mathml/base/src/nsMathMLmoFrame.cpp b/layout/mathml/base/src/nsMathMLmoFrame.cpp index bb213c951bc..e37e8bd6705 100644 --- a/layout/mathml/base/src/nsMathMLmoFrame.cpp +++ b/layout/mathml/base/src/nsMathMLmoFrame.cpp @@ -113,9 +113,17 @@ nsMathMLmoFrame::ProcessTextData(nsIPresContext* aPresContext) { mFlags = 0; + // don't bother doing anything special if we don't have a + // single child with a text content + nsAutoString data; + if (mFrames.GetLength() != 1) { + mMathMLChar.SetData(aPresContext, data); // empty data to reset the char + ResolveMathMLCharStyle(aPresContext, mContent, mStyleContext, &mMathMLChar, PR_FALSE); + return; + } + // kids can be comment-nodes, attribute-nodes, text-nodes... // we use the DOM to ensure that we only look at text-nodes... - nsAutoString data; PRInt32 numKids; mContent->ChildCount(numKids); for (PRInt32 kid=0; kidGetRect(rect); - childFrame->MoveTo(aPresContext, rect.x + dx, rect.y); - childFrame->GetNextSibling(&childFrame); + nsRect rect; + if (useMathMLChar) { + mMathMLChar.GetRect(rect); + mMathMLChar.SetRect(nsRect(rect.x + dx, rect.y, rect.width, rect.height)); + } + else { + nsIFrame* childFrame = mFrames.FirstChild(); + while (childFrame) { + childFrame->GetRect(rect); + childFrame->MoveTo(aPresContext, rect.x + dx, rect.y); + childFrame->GetNextSibling(&childFrame); + } } } } + + if (useMathMLChar && mFrames.FirstChild()) { + // even though our child text frame is not doing the rendering, we make it play + // nice with other operations that the MathMLChar doesn't handle (e.g., caret) + // use our whole height (i.e., with the leading that isn't part of the MathMLChar) + nsRect rect; + mMathMLChar.GetRect(rect); + rect.y = 0; + rect.height = aDesiredStretchSize.height; + mFrames.FirstChild()->SetRect(aPresContext, rect); + } return NS_OK; }