diff --git a/mozilla/layout/base/public/nsHTMLReflowMetrics.h b/mozilla/layout/base/public/nsHTMLReflowMetrics.h
index 46b0f201003..4ad294a1681 100644
--- a/mozilla/layout/base/public/nsHTMLReflowMetrics.h
+++ b/mozilla/layout/base/public/nsHTMLReflowMetrics.h
@@ -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;
diff --git a/mozilla/layout/forms/nsComboboxControlFrame.cpp b/mozilla/layout/forms/nsComboboxControlFrame.cpp
index 360ad1cd101..4ffff02f002 100644
--- a/mozilla/layout/forms/nsComboboxControlFrame.cpp
+++ b/mozilla/layout/forms/nsComboboxControlFrame.cpp
@@ -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;
diff --git a/mozilla/layout/forms/nsFieldSetFrame.cpp b/mozilla/layout/forms/nsFieldSetFrame.cpp
index 0ed1a7484a1..8a98676ab64 100644
--- a/mozilla/layout/forms/nsFieldSetFrame.cpp
+++ b/mozilla/layout/forms/nsFieldSetFrame.cpp
@@ -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)
diff --git a/mozilla/layout/forms/nsFileControlFrame.cpp b/mozilla/layout/forms/nsFileControlFrame.cpp
index cad3beaacda..0f12db664f6 100644
--- a/mozilla/layout/forms/nsFileControlFrame.cpp
+++ b/mozilla/layout/forms/nsFileControlFrame.cpp
@@ -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
diff --git a/mozilla/layout/forms/nsFormControlFrame.cpp b/mozilla/layout/forms/nsFormControlFrame.cpp
index aef97c0373e..c7ffea01a17 100644
--- a/mozilla/layout/forms/nsFormControlFrame.cpp
+++ b/mozilla/layout/forms/nsFormControlFrame.cpp
@@ -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;
diff --git a/mozilla/layout/forms/nsHTMLButtonControlFrame.cpp b/mozilla/layout/forms/nsHTMLButtonControlFrame.cpp
index 3349173cddd..8e014762484 100644
--- a/mozilla/layout/forms/nsHTMLButtonControlFrame.cpp
+++ b/mozilla/layout/forms/nsHTMLButtonControlFrame.cpp
@@ -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
diff --git a/mozilla/layout/forms/nsIsIndexFrame.cpp b/mozilla/layout/forms/nsIsIndexFrame.cpp
index b401acf7603..104551a4bbf 100644
--- a/mozilla/layout/forms/nsIsIndexFrame.cpp
+++ b/mozilla/layout/forms/nsIsIndexFrame.cpp
@@ -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;
}
diff --git a/mozilla/layout/generic/nsHTMLReflowMetrics.h b/mozilla/layout/generic/nsHTMLReflowMetrics.h
index 46b0f201003..4ad294a1681 100644
--- a/mozilla/layout/generic/nsHTMLReflowMetrics.h
+++ b/mozilla/layout/generic/nsHTMLReflowMetrics.h
@@ -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;
diff --git a/mozilla/layout/generic/nsLeafFrame.cpp b/mozilla/layout/generic/nsLeafFrame.cpp
index da5f7649c12..2434b5a090c 100644
--- a/mozilla/layout/generic/nsLeafFrame.cpp
+++ b/mozilla/layout/generic/nsLeafFrame.cpp
@@ -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;
diff --git a/mozilla/layout/generic/nsSpacerFrame.cpp b/mozilla/layout/generic/nsSpacerFrame.cpp
index 22748a50684..4532c6f91cc 100644
--- a/mozilla/layout/generic/nsSpacerFrame.cpp
+++ b/mozilla/layout/generic/nsSpacerFrame.cpp
@@ -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);
diff --git a/mozilla/layout/html/base/src/nsLeafFrame.cpp b/mozilla/layout/html/base/src/nsLeafFrame.cpp
index da5f7649c12..2434b5a090c 100644
--- a/mozilla/layout/html/base/src/nsLeafFrame.cpp
+++ b/mozilla/layout/html/base/src/nsLeafFrame.cpp
@@ -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;
diff --git a/mozilla/layout/html/base/src/nsSpacerFrame.cpp b/mozilla/layout/html/base/src/nsSpacerFrame.cpp
index 22748a50684..4532c6f91cc 100644
--- a/mozilla/layout/html/base/src/nsSpacerFrame.cpp
+++ b/mozilla/layout/html/base/src/nsSpacerFrame.cpp
@@ -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);
diff --git a/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp b/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp
index 360ad1cd101..4ffff02f002 100644
--- a/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp
+++ b/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp
@@ -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;
diff --git a/mozilla/layout/html/forms/src/nsFieldSetFrame.cpp b/mozilla/layout/html/forms/src/nsFieldSetFrame.cpp
index 0ed1a7484a1..8a98676ab64 100644
--- a/mozilla/layout/html/forms/src/nsFieldSetFrame.cpp
+++ b/mozilla/layout/html/forms/src/nsFieldSetFrame.cpp
@@ -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)
diff --git a/mozilla/layout/html/forms/src/nsFileControlFrame.cpp b/mozilla/layout/html/forms/src/nsFileControlFrame.cpp
index cad3beaacda..0f12db664f6 100644
--- a/mozilla/layout/html/forms/src/nsFileControlFrame.cpp
+++ b/mozilla/layout/html/forms/src/nsFileControlFrame.cpp
@@ -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
diff --git a/mozilla/layout/html/forms/src/nsFormControlFrame.cpp b/mozilla/layout/html/forms/src/nsFormControlFrame.cpp
index aef97c0373e..c7ffea01a17 100644
--- a/mozilla/layout/html/forms/src/nsFormControlFrame.cpp
+++ b/mozilla/layout/html/forms/src/nsFormControlFrame.cpp
@@ -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;
diff --git a/mozilla/layout/html/forms/src/nsHTMLButtonControlFrame.cpp b/mozilla/layout/html/forms/src/nsHTMLButtonControlFrame.cpp
index 3349173cddd..8e014762484 100644
--- a/mozilla/layout/html/forms/src/nsHTMLButtonControlFrame.cpp
+++ b/mozilla/layout/html/forms/src/nsHTMLButtonControlFrame.cpp
@@ -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
diff --git a/mozilla/layout/html/forms/src/nsIsIndexFrame.cpp b/mozilla/layout/html/forms/src/nsIsIndexFrame.cpp
index b401acf7603..104551a4bbf 100644
--- a/mozilla/layout/html/forms/src/nsIsIndexFrame.cpp
+++ b/mozilla/layout/html/forms/src/nsIsIndexFrame.cpp
@@ -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;
}
diff --git a/mozilla/layout/xul/base/src/nsBoxFrame.cpp b/mozilla/layout/xul/base/src/nsBoxFrame.cpp
index 6c39e7bbf54..64e545631a2 100644
--- a/mozilla/layout/xul/base/src/nsBoxFrame.cpp
+++ b/mozilla/layout/xul/base/src/nsBoxFrame.cpp
@@ -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;
}