frames with a percentage based width should report a 0 MEW bug 246999 r/sr=roc

This commit is contained in:
bmlk%gmx.de 2004-08-31 18:50:40 +00:00
parent 6c8a47e2ae
commit 7884179497
19 changed files with 70 additions and 28 deletions

View File

@ -187,7 +187,21 @@ struct nsHTMLReflowMetrics {
width = height = 0;
ascent = descent = 0;
}
/**
* set the maxElementWidth to the desired width. If the frame has a percent
* width specification it can be shrinked to 0 if the containing frame shrinks
* so we need to report 0 otherwise the incr. reflow will fail
* @param aWidthUnit - the width unit from the corresponding reflowstate
*/
void nsHTMLReflowMetrics::SetMEWToActualWidth(nsStyleUnit aWidthUnit) {
if (aWidthUnit != eStyleUnit_Percent) {
mMaxElementWidth = width;
} else {
mMaxElementWidth = 0;
}
}
nsHTMLReflowMetrics& operator=(const nsHTMLReflowMetrics& aOther)
{
mMaxElementWidth = aOther.mMaxElementWidth;

View File

@ -1038,7 +1038,7 @@ nsComboboxControlFrame::ReflowCombobox(nsPresContext * aPresContext,
REFLOW_NOISY_MSG3("**AdjustCombobox - Reflow: WW: %d HH: %d\n", aDesiredSize.width, aDesiredSize.height);
if (aDesiredSize.mComputeMEW) {
aDesiredSize.mMaxElementWidth = aDesiredSize.width;
aDesiredSize.SetMEWToActualWidth(aReflowState.mStylePosition->mWidth.GetUnit());
}
aDesiredSize.ascent =
@ -1549,7 +1549,7 @@ nsComboboxControlFrame::Reflow(nsPresContext* aPresContext,
// Set the max element size to be the same as the desired element size.
if (aDesiredSize.mComputeMEW) {
aDesiredSize.mMaxElementWidth = aDesiredSize.width;
aDesiredSize.SetMEWToActualWidth(aReflowState.mStylePosition->mWidth.GetUnit());
}
#if 0
@ -1590,6 +1590,7 @@ nsComboboxControlFrame::Reflow(nsPresContext* aPresContext,
aDesiredSize.mOverflowArea.width = aDesiredSize.width;
aDesiredSize.mOverflowArea.height = aDesiredSize.height;
FinishAndStoreOverflow(&aDesiredSize);
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
return rv;

View File

@ -593,12 +593,12 @@ nsFieldSetFrame::Reflow(nsPresContext* aPresContext,
aDesiredSize.descent = 0;
aDesiredSize.mMaximumWidth = aDesiredSize.width;
if (aDesiredSize.mComputeMEW) {
// if the legend is wider use it
if (aDesiredSize.mMaxElementWidth < mLegendRect.width)
aDesiredSize.mMaxElementWidth = mLegendRect.width;
aDesiredSize.SetMEWToActualWidth(aReflowState.mStylePosition->mWidth.GetUnit());
// if the legend is wider use it
if (aDesiredSize.mMaxElementWidth < mLegendRect.width + borderPadding.left + borderPadding.right)
aDesiredSize.mMaxElementWidth = mLegendRect.width + borderPadding.left + borderPadding.right;
// add in padding.
aDesiredSize.mMaxElementWidth += borderPadding.left + borderPadding.right;
}
aDesiredSize.mOverflowArea = nsRect(0, 0, aDesiredSize.width, aDesiredSize.height);
if (mLegendFrame)

View File

@ -441,6 +441,9 @@ NS_IMETHODIMP nsFileControlFrame::Reflow(nsPresContext* aPresContext,
txtRect.height = aDesiredSize.height;
mTextFrame->SetRect(txtRect);
}
if (aDesiredSize.mComputeMEW) {
aDesiredSize.SetMEWToActualWidth(aReflowState.mStylePosition->mWidth.GetUnit());
}
}
// Do RTL positioning

View File

@ -470,7 +470,7 @@ nsFormControlFrame::GetDesiredSize(nsPresContext* aPresContext,
aDesiredLayoutSize.ascent = aDesiredLayoutSize.height;
aDesiredLayoutSize.descent = 0;
if (aDesiredLayoutSize.mComputeMEW) {
aDesiredLayoutSize.mMaxElementWidth = aDesiredLayoutSize.width;
aDesiredLayoutSize.SetMEWToActualWidth(aReflowState.mStylePosition->mWidth.GetUnit());
}
aDesiredWidgetSize.width = aDesiredLayoutSize.width;
aDesiredWidgetSize.height = aDesiredLayoutSize.height;

View File

@ -460,7 +460,7 @@ nsHTMLButtonControlFrame::Reflow(nsPresContext* aPresContext,
//aDesiredSize.height += aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom;
if (aDesiredSize.mComputeMEW) {
aDesiredSize.mMaxElementWidth = aDesiredSize.width;
aDesiredSize.SetMEWToActualWidth(aReflowState.mStylePosition->mWidth.GetUnit());
}
// Make sure we obey min/max-width and min/max-height

View File

@ -315,6 +315,9 @@ NS_IMETHODIMP nsIsIndexFrame::Reflow(nsPresContext* aPresContext,
// The Areaframe takes care of all our reflow
// (except for when style is used to change its size?)
nsresult rv = nsAreaFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
if (aDesiredSize.mComputeMEW) {
aDesiredSize.SetMEWToActualWidth(aReflowState.mStylePosition->mWidth.GetUnit());
}
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
return rv;
}

View File

@ -187,7 +187,21 @@ struct nsHTMLReflowMetrics {
width = height = 0;
ascent = descent = 0;
}
/**
* set the maxElementWidth to the desired width. If the frame has a percent
* width specification it can be shrinked to 0 if the containing frame shrinks
* so we need to report 0 otherwise the incr. reflow will fail
* @param aWidthUnit - the width unit from the corresponding reflowstate
*/
void nsHTMLReflowMetrics::SetMEWToActualWidth(nsStyleUnit aWidthUnit) {
if (aWidthUnit != eStyleUnit_Percent) {
mMaxElementWidth = width;
} else {
mMaxElementWidth = 0;
}
}
nsHTMLReflowMetrics& operator=(const nsHTMLReflowMetrics& aOther)
{
mMaxElementWidth = aOther.mMaxElementWidth;

View File

@ -81,7 +81,7 @@ nsLeafFrame::Reflow(nsPresContext* aPresContext,
nsMargin borderPadding;
AddBordersAndPadding(aPresContext, aReflowState, aMetrics, borderPadding);
if (aMetrics.mComputeMEW) {
aMetrics.mMaxElementWidth = aMetrics.width;
aMetrics.SetMEWToActualWidth(aReflowState.mStylePosition->mWidth.GetUnit());
}
aStatus = NS_FRAME_COMPLETE;

View File

@ -159,7 +159,7 @@ SpacerFrame::Reflow(nsPresContext* aPresContext,
}
if (aMetrics.mComputeMEW) {
aMetrics.mMaxElementWidth = aMetrics.width;
aMetrics.SetMEWToActualWidth(aReflowState.mStylePosition->mWidth.GetUnit());
}
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aMetrics);

View File

@ -81,7 +81,7 @@ nsLeafFrame::Reflow(nsPresContext* aPresContext,
nsMargin borderPadding;
AddBordersAndPadding(aPresContext, aReflowState, aMetrics, borderPadding);
if (aMetrics.mComputeMEW) {
aMetrics.mMaxElementWidth = aMetrics.width;
aMetrics.SetMEWToActualWidth(aReflowState.mStylePosition->mWidth.GetUnit());
}
aStatus = NS_FRAME_COMPLETE;

View File

@ -159,7 +159,7 @@ SpacerFrame::Reflow(nsPresContext* aPresContext,
}
if (aMetrics.mComputeMEW) {
aMetrics.mMaxElementWidth = aMetrics.width;
aMetrics.SetMEWToActualWidth(aReflowState.mStylePosition->mWidth.GetUnit());
}
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aMetrics);

View File

@ -1038,7 +1038,7 @@ nsComboboxControlFrame::ReflowCombobox(nsPresContext * aPresContext,
REFLOW_NOISY_MSG3("**AdjustCombobox - Reflow: WW: %d HH: %d\n", aDesiredSize.width, aDesiredSize.height);
if (aDesiredSize.mComputeMEW) {
aDesiredSize.mMaxElementWidth = aDesiredSize.width;
aDesiredSize.SetMEWToActualWidth(aReflowState.mStylePosition->mWidth.GetUnit());
}
aDesiredSize.ascent =
@ -1549,7 +1549,7 @@ nsComboboxControlFrame::Reflow(nsPresContext* aPresContext,
// Set the max element size to be the same as the desired element size.
if (aDesiredSize.mComputeMEW) {
aDesiredSize.mMaxElementWidth = aDesiredSize.width;
aDesiredSize.SetMEWToActualWidth(aReflowState.mStylePosition->mWidth.GetUnit());
}
#if 0
@ -1590,6 +1590,7 @@ nsComboboxControlFrame::Reflow(nsPresContext* aPresContext,
aDesiredSize.mOverflowArea.width = aDesiredSize.width;
aDesiredSize.mOverflowArea.height = aDesiredSize.height;
FinishAndStoreOverflow(&aDesiredSize);
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
return rv;

View File

@ -593,12 +593,12 @@ nsFieldSetFrame::Reflow(nsPresContext* aPresContext,
aDesiredSize.descent = 0;
aDesiredSize.mMaximumWidth = aDesiredSize.width;
if (aDesiredSize.mComputeMEW) {
// if the legend is wider use it
if (aDesiredSize.mMaxElementWidth < mLegendRect.width)
aDesiredSize.mMaxElementWidth = mLegendRect.width;
aDesiredSize.SetMEWToActualWidth(aReflowState.mStylePosition->mWidth.GetUnit());
// if the legend is wider use it
if (aDesiredSize.mMaxElementWidth < mLegendRect.width + borderPadding.left + borderPadding.right)
aDesiredSize.mMaxElementWidth = mLegendRect.width + borderPadding.left + borderPadding.right;
// add in padding.
aDesiredSize.mMaxElementWidth += borderPadding.left + borderPadding.right;
}
aDesiredSize.mOverflowArea = nsRect(0, 0, aDesiredSize.width, aDesiredSize.height);
if (mLegendFrame)

View File

@ -441,6 +441,9 @@ NS_IMETHODIMP nsFileControlFrame::Reflow(nsPresContext* aPresContext,
txtRect.height = aDesiredSize.height;
mTextFrame->SetRect(txtRect);
}
if (aDesiredSize.mComputeMEW) {
aDesiredSize.SetMEWToActualWidth(aReflowState.mStylePosition->mWidth.GetUnit());
}
}
// Do RTL positioning

View File

@ -470,7 +470,7 @@ nsFormControlFrame::GetDesiredSize(nsPresContext* aPresContext,
aDesiredLayoutSize.ascent = aDesiredLayoutSize.height;
aDesiredLayoutSize.descent = 0;
if (aDesiredLayoutSize.mComputeMEW) {
aDesiredLayoutSize.mMaxElementWidth = aDesiredLayoutSize.width;
aDesiredLayoutSize.SetMEWToActualWidth(aReflowState.mStylePosition->mWidth.GetUnit());
}
aDesiredWidgetSize.width = aDesiredLayoutSize.width;
aDesiredWidgetSize.height = aDesiredLayoutSize.height;

View File

@ -460,7 +460,7 @@ nsHTMLButtonControlFrame::Reflow(nsPresContext* aPresContext,
//aDesiredSize.height += aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom;
if (aDesiredSize.mComputeMEW) {
aDesiredSize.mMaxElementWidth = aDesiredSize.width;
aDesiredSize.SetMEWToActualWidth(aReflowState.mStylePosition->mWidth.GetUnit());
}
// Make sure we obey min/max-width and min/max-height

View File

@ -315,6 +315,9 @@ NS_IMETHODIMP nsIsIndexFrame::Reflow(nsPresContext* aPresContext,
// The Areaframe takes care of all our reflow
// (except for when style is used to change its size?)
nsresult rv = nsAreaFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
if (aDesiredSize.mComputeMEW) {
aDesiredSize.SetMEWToActualWidth(aReflowState.mStylePosition->mWidth.GetUnit());
}
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
return rv;
}

View File

@ -904,10 +904,10 @@ nsBoxFrame::Reflow(nsPresContext* aPresContext,
{
nsSize minSize(0,0);
GetMinSize(state, minSize);
if (mRect.width > minSize.width &&
aReflowState.mComputedWidth == NS_INTRINSICSIZE)
*maxElementWidth = minSize.width;
if (aReflowState.mStylePosition->mWidth.GetUnit() == eStyleUnit_Percent ||
(mRect.width > minSize.width &&
aReflowState.mComputedWidth == NS_INTRINSICSIZE))
*maxElementWidth = minSize.width;
else
*maxElementWidth = mRect.width;
}