Add GetIntrinsicWidth for <msqrt>. b=363240, r+sr=roc

git-svn-id: svn://10.0.0.236/trunk@248045 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
karlt+%karlt.net 2008-03-18 05:06:23 +00:00
parent 67df0737ac
commit eb12a7a910
4 changed files with 50 additions and 2 deletions

View File

@ -1039,7 +1039,7 @@ nsMathMLContainerFrame::GetPrefWidth(nsIRenderingContext *aRenderingContext)
}
/* virtual */ nscoord
nsMathMLContainerFrame::GetIntrinsicWidth(nsIRenderingContext *aRenderingContext)
nsMathMLContainerFrame::GetIntrinsicWidth(nsIRenderingContext* aRenderingContext)
{
// Get child widths
nsIFrame* childFrame = mFrames.FirstChild();
@ -1066,7 +1066,7 @@ nsMathMLContainerFrame::GetIntrinsicWidth(nsIRenderingContext *aRenderingContext
// Measure
nsHTMLReflowMetrics desiredSize;
nsresult rv = Place(*aRenderingContext, PR_FALSE, desiredSize);
nsresult rv = MeasureChildFrames(*aRenderingContext, desiredSize);
if (NS_FAILED(rv)) {
ReflowError(*aRenderingContext, desiredSize);
}
@ -1076,6 +1076,14 @@ nsMathMLContainerFrame::GetIntrinsicWidth(nsIRenderingContext *aRenderingContext
return desiredSize.width;
}
/* virtual */ nsresult
nsMathMLContainerFrame::MeasureChildFrames(nsIRenderingContext& aRenderingContext,
nsHTMLReflowMetrics& aDesiredSize)
{
return Place(aRenderingContext, PR_FALSE, aDesiredSize);
}
// see spacing table in Chapter 18, TeXBook (p.170)
// Our table isn't quite identical to TeX because operators have
// built-in values for lspace & rspace in the Operator Dictionary.

View File

@ -228,6 +228,19 @@ protected:
PRBool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize);
// MeasureChildFrames:
//
// A method used by nsMathMLContainerFrame::GetIntrinsicWidth to get the
// width that a particular Place method desires. For most frames, this will
// just call the object's Place method. However <msqrt> uses
// nsMathMLContainerFrame::GetIntrinsicWidth to measure the child frames as
// if in an <mrow>, and so <msqrt> frames implement MeasureChildFrames to
// use nsMathMLContainerFrame::Place.
virtual nsresult
MeasureChildFrames(nsIRenderingContext& aRenderingContext,
nsHTMLReflowMetrics& aDesiredSize);
// helper to re-sync the automatic data in our children and notify our parent to
// reflow us when changes (e.g., append/insert/remove) happen in our child list
virtual nsresult

View File

@ -282,6 +282,26 @@ nsMathMLmsqrtFrame::Place(nsIRenderingContext& aRenderingContext,
return NS_OK;
}
/* virtual */ nscoord
nsMathMLmsqrtFrame::GetIntrinsicWidth(nsIRenderingContext* aRenderingContext)
{
// The child frames form an mrow
nscoord width = nsMathMLContainerFrame::GetIntrinsicWidth(aRenderingContext);
// Add the width of the radical symbol
width += mSqrChar.GetMaxWidth(PresContext(), *aRenderingContext);
return width;
}
/* virtual */ nsresult
nsMathMLmsqrtFrame::MeasureChildFrames(nsIRenderingContext& aRenderingContext,
nsHTMLReflowMetrics& aDesiredSize)
{
return nsMathMLContainerFrame::Place(aRenderingContext, PR_FALSE,
aDesiredSize);
}
nscoord
nsMathMLmsqrtFrame::FixInterFrameSpacing(nsHTMLReflowMetrics& aDesiredSize)
{

View File

@ -92,6 +92,9 @@ public:
PRBool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize);
virtual nscoord
GetIntrinsicWidth(nsIRenderingContext* aRenderingContext);
NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsRect& aDirtyRect,
const nsDisplayListSet& aLists);
@ -115,6 +118,10 @@ protected:
virtual PRIntn GetSkipSides() const { return 0; }
virtual nsresult
MeasureChildFrames(nsIRenderingContext& aRenderingContext,
nsHTMLReflowMetrics& aDesiredSize);
nsMathMLChar mSqrChar;
nsRect mBarRect;
};