diff --git a/layout/mathml/base/src/nsMathMLmoFrame.cpp b/layout/mathml/base/src/nsMathMLmoFrame.cpp index bb213c951bc6..e37e8bd67055 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; }