From 86d4cc000337821f73f271fec01897f5c4557947 Mon Sep 17 00:00:00 2001 From: Mats Palmgren Date: Wed, 9 Jul 2008 17:42:44 +0200 Subject: [PATCH] Use the post-reflow GetUsedMargin() value when placing the legend. b=433700 r+sr=dbaron --- layout/forms/nsFieldSetFrame.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/layout/forms/nsFieldSetFrame.cpp b/layout/forms/nsFieldSetFrame.cpp index 4b4dc160f09b..55a966efde5f 100644 --- a/layout/forms/nsFieldSetFrame.cpp +++ b/layout/forms/nsFieldSetFrame.cpp @@ -418,7 +418,6 @@ nsFieldSetFrame::Reflow(nsPresContext* aPresContext, reflowLegend = mLegendFrame != nsnull; } else { reflowContent = mContentFrame && NS_SUBTREE_DIRTY(mContentFrame); - reflowLegend = mLegendFrame && NS_SUBTREE_DIRTY(mLegendFrame); } @@ -438,17 +437,13 @@ nsFieldSetFrame::Reflow(nsPresContext* aPresContext, // get our border and padding const nsMargin &borderPadding = aReflowState.mComputedBorderPadding; - const nsMargin &padding = aReflowState.mComputedPadding; - nsMargin border = borderPadding - padding; + nsMargin border = borderPadding - aReflowState.mComputedPadding; // Figure out how big the legend is if there is one. // get the legend's margin nsMargin legendMargin(0,0,0,0); // reflow the legend only if needed if (reflowLegend) { - const nsStyleMargin* marginStyle = mLegendFrame->GetStyleMargin(); - marginStyle->GetMargin(legendMargin); - nsHTMLReflowState legendReflowState(aPresContext, aReflowState, mLegendFrame, availSize); @@ -460,6 +455,7 @@ nsFieldSetFrame::Reflow(nsPresContext* aPresContext, printf(" returned (%d, %d)\n", legendDesiredSize.width, legendDesiredSize.height); #endif // figure out the legend's rectangle + legendMargin = mLegendFrame->GetUsedMargin(); mLegendRect.width = legendDesiredSize.width + legendMargin.left + legendMargin.right; mLegendRect.height = legendDesiredSize.height + legendMargin.top + legendMargin.bottom; mLegendRect.x = borderPadding.left; @@ -491,7 +487,11 @@ nsFieldSetFrame::Reflow(nsPresContext* aPresContext, } else if (!mLegendFrame) { mLegendRect.Empty(); mLegendSpace = 0; - } // else mLegendSpace and mLegendRect haven't changed... + } else { + // mLegendSpace and mLegendRect haven't changed, but we need + // the used margin when placing the legend. + legendMargin = mLegendFrame->GetUsedMargin(); + } // reflow the content frame only if needed if (reflowContent) { @@ -519,7 +519,7 @@ nsFieldSetFrame::Reflow(nsPresContext* aPresContext, nsRect contentRect(0,0,0,0); if (mContentFrame) { - // We don't support margins on mContentFrame, so our "content rect" is jut + // We don't support margins on mContentFrame, so our "content rect" is just // its rect. contentRect = mContentFrame->GetRect(); } @@ -532,7 +532,7 @@ nsFieldSetFrame::Reflow(nsPresContext* aPresContext, if (mLegendFrame) { // if the content rect is larger then the legend we can align the legend if (contentRect.width > mLegendRect.width) { - PRInt32 align = ((nsLegendFrame*)mLegendFrame)->GetAlign(); + PRInt32 align = static_cast(mLegendFrame)->GetAlign(); switch(align) { case NS_STYLE_TEXT_ALIGN_RIGHT: @@ -545,7 +545,7 @@ nsFieldSetFrame::Reflow(nsPresContext* aPresContext, } } else { - //otherwise make place for the legend + // otherwise make place for the legend contentRect.width = mLegendRect.width; } // place the legend