From c22f41cbf98544b15d55b270d202ca96f5539493 Mon Sep 17 00:00:00 2001 From: "troy%netscape.com" Date: Wed, 30 Dec 1998 17:50:00 +0000 Subject: [PATCH] Changed width/height constraints in nsHTMLReflowState struct git-svn-id: svn://10.0.0.236/trunk@16998 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/forms/nsFieldSetFrame.cpp | 10 +- mozilla/layout/forms/nsFormControlFrame.cpp | 4 +- .../layout/forms/nsHTMLButtonControlFrame.cpp | 8 +- mozilla/layout/forms/nsLegendFrame.cpp | 8 +- mozilla/layout/generic/nsBlockFrame.cpp | 34 +++--- mozilla/layout/generic/nsBlockReflowState.cpp | 34 +++--- mozilla/layout/generic/nsBlockReflowState.h | 34 +++--- mozilla/layout/generic/nsFrameFrame.cpp | 4 +- mozilla/layout/generic/nsHTMLFrame.cpp | 28 ++--- mozilla/layout/generic/nsImageFrame.cpp | 12 +- mozilla/layout/generic/nsObjectFrame.cpp | 4 +- mozilla/layout/html/base/src/nsBlockFrame.cpp | 34 +++--- .../html/base/src/nsBlockReflowState.cpp | 34 +++--- .../layout/html/base/src/nsBlockReflowState.h | 34 +++--- .../html/base/src/nsFrameReflowState.cpp | 107 ++++++++--------- mozilla/layout/html/base/src/nsHRFrame.cpp | 4 +- mozilla/layout/html/base/src/nsHTMLFrame.cpp | 28 ++--- mozilla/layout/html/base/src/nsIHTMLReflow.h | 89 +++++++-------- mozilla/layout/html/base/src/nsImageFrame.cpp | 12 +- .../layout/html/base/src/nsObjectFrame.cpp | 4 +- .../layout/html/base/src/nsScrollFrame.cpp | 108 ++++++------------ .../layout/html/document/src/nsFrameFrame.cpp | 4 +- .../layout/html/forms/src/nsFieldSetFrame.cpp | 10 +- .../html/forms/src/nsFormControlFrame.cpp | 4 +- .../forms/src/nsHTMLButtonControlFrame.cpp | 8 +- .../layout/html/forms/src/nsLabelFrame.cpp | 8 +- .../layout/html/forms/src/nsLegendFrame.cpp | 8 +- .../layout/html/table/src/nsTableFrame.cpp | 5 +- .../layout/html/table/src/nsTableRowFrame.cpp | 2 - mozilla/layout/tables/nsTableFrame.cpp | 5 +- mozilla/layout/tables/nsTableRowFrame.cpp | 2 - 31 files changed, 308 insertions(+), 382 deletions(-) diff --git a/mozilla/layout/forms/nsFieldSetFrame.cpp b/mozilla/layout/forms/nsFieldSetFrame.cpp index 46d9334d9bc..8d9e5d65776 100644 --- a/mozilla/layout/forms/nsFieldSetFrame.cpp +++ b/mozilla/layout/forms/nsFieldSetFrame.cpp @@ -276,7 +276,7 @@ nsFieldSetFrame::Reflow(nsIPresContext& aPresContext, legendMargin.left + legendMargin.right; nscoord verTaken = padding.top + borderPadding.bottom + legendMargin.top + legendMargin.bottom; if (aReflowState.HaveFixedContentWidth()) { - availSize.width = aReflowState.minWidth; + availSize.width = aReflowState.computedWidth; } else { if (NS_UNCONSTRAINEDSIZE != availSize.width) @@ -356,8 +356,8 @@ nsFieldSetFrame::Reflow(nsIPresContext& aPresContext, nscoord contentWidth = contentSize.width + borderPadding.left + borderPadding.right; aDesiredSize.width = (legendWidth > contentWidth) ? legendWidth : contentWidth; - if (aReflowState.HaveFixedContentWidth() && (aReflowState.minWidth > aDesiredSize.width)) { - aDesiredSize.width = aReflowState.minWidth; + if (aReflowState.HaveFixedContentWidth() && (aReflowState.computedWidth > aDesiredSize.width)) { + aDesiredSize.width = aReflowState.computedWidth; } // Place the legend @@ -419,8 +419,8 @@ nsFieldSetFrame::Reflow(nsIPresContext& aPresContext, aDesiredSize.height = contentTopOffset + contentSize.height + borderPadding.bottom; if (mInline) // XXX parents don't yet ...... aDesiredSize.height += margin.bottom; - if (aReflowState.HaveFixedContentHeight() && (aReflowState.minHeight > aDesiredSize.height)) { - aDesiredSize.height = aReflowState.minHeight; + if (aReflowState.HaveFixedContentHeight() && (aReflowState.computedHeight > aDesiredSize.height)) { + aDesiredSize.height = aReflowState.computedHeight; } aDesiredSize.ascent = aDesiredSize.height; aDesiredSize.descent = 0; diff --git a/mozilla/layout/forms/nsFormControlFrame.cpp b/mozilla/layout/forms/nsFormControlFrame.cpp index d77ae733dbd..863909dcd1e 100644 --- a/mozilla/layout/forms/nsFormControlFrame.cpp +++ b/mozilla/layout/forms/nsFormControlFrame.cpp @@ -680,13 +680,13 @@ nsFormControlFrame::GetStyleSize(nsIPresContext& aPresContext, nsSize& aSize) { if (aReflowState.HaveFixedContentWidth()) { - aSize.width = aReflowState.minWidth; + aSize.width = aReflowState.computedWidth; } else { aSize.width = CSS_NOTSET; } if (aReflowState.HaveFixedContentHeight()) { - aSize.height = aReflowState.minHeight; + aSize.height = aReflowState.computedHeight; } else { aSize.height = CSS_NOTSET; diff --git a/mozilla/layout/forms/nsHTMLButtonControlFrame.cpp b/mozilla/layout/forms/nsHTMLButtonControlFrame.cpp index 64157787f08..1582d3efc79 100644 --- a/mozilla/layout/forms/nsHTMLButtonControlFrame.cpp +++ b/mozilla/layout/forms/nsHTMLButtonControlFrame.cpp @@ -627,11 +627,11 @@ nsHTMLButtonControlFrame::Reflow(nsIPresContext& aPresContext, } // if we are constrained and the child is smaller, use the constrained values - if (aReflowState.HaveFixedContentWidth() && (aDesiredSize.width < aReflowState.minWidth)) { - aDesiredSize.width = aReflowState.minWidth; + if (aReflowState.HaveFixedContentWidth() && (aDesiredSize.width < aReflowState.computedWidth)) { + aDesiredSize.width = aReflowState.computedWidth; } - if (aReflowState.HaveFixedContentHeight() && (aDesiredSize.height < aReflowState.minHeight)) { - aDesiredSize.height = aReflowState.minHeight; + if (aReflowState.HaveFixedContentHeight() && (aDesiredSize.height < aReflowState.computedHeight)) { + aDesiredSize.height = aReflowState.computedHeight; } aDesiredSize.ascent = aDesiredSize.height; diff --git a/mozilla/layout/forms/nsLegendFrame.cpp b/mozilla/layout/forms/nsLegendFrame.cpp index 5ba65b3730d..868e87b7468 100644 --- a/mozilla/layout/forms/nsLegendFrame.cpp +++ b/mozilla/layout/forms/nsLegendFrame.cpp @@ -142,13 +142,13 @@ nsLegendFrame::Reflow(nsIPresContext& aPresContext, // add in our border and padding to the size of the child aDesiredSize.width += borderPadding.left + borderPadding.right; - if (aReflowState.HaveFixedContentWidth() && (aReflowState.minWidth > aDesiredSize.width)) { - aDesiredSize.width = aReflowState.minWidth; + if (aReflowState.HaveFixedContentWidth() && (aReflowState.computedWidth > aDesiredSize.width)) { + aDesiredSize.width = aReflowState.computedWidth; } aDesiredSize.height += borderPadding.top + borderPadding.bottom; - if (aReflowState.HaveFixedContentHeight() && (aReflowState.minHeight > aDesiredSize.height)) { - aDesiredSize.height = aReflowState.minHeight; + if (aReflowState.HaveFixedContentHeight() && (aReflowState.computedHeight > aDesiredSize.height)) { + aDesiredSize.height = aReflowState.computedHeight; } // adjust our max element size, if necessary diff --git a/mozilla/layout/generic/nsBlockFrame.cpp b/mozilla/layout/generic/nsBlockFrame.cpp index 2c6382f658b..40a5681b428 100644 --- a/mozilla/layout/generic/nsBlockFrame.cpp +++ b/mozilla/layout/generic/nsBlockFrame.cpp @@ -329,12 +329,13 @@ nsBlockReflowState::nsBlockReflowState(nsIPresContext& aPresContext, nscoord lr = mBorderPadding.left + mBorderPadding.right; mY = mBorderPadding.top; - if (eHTMLFrameConstraint_FixedContent == widthConstraint) { + + if (HaveFixedContentWidth()) { // The CSS2 spec says that the width attribute defines the width // of the "content area" which does not include the border // padding. So we add those back in. - mBorderArea.width = minWidth + lr; - mContentArea.width = minWidth; + mBorderArea.width = computedWidth + lr; + mContentArea.width = computedWidth; } else { if (mUnconstrainedWidth) { @@ -346,6 +347,7 @@ nsBlockReflowState::nsBlockReflowState(nsIPresContext& aPresContext, mContentArea.width = maxSize.width - lr; } } + mBorderArea.height = maxSize.height; mContentArea.height = maxSize.height; mBottomEdge = maxSize.height; @@ -692,10 +694,8 @@ nsBaseIBFrame::ComputeFinalSize(nsBlockReflowState& aState, nsHTMLReflowMetrics& aMetrics) { // XXX handle floater problems this way... - PRBool isFixedWidth = - eHTMLFrameConstraint_FixedContent == aState.widthConstraint; - PRBool isFixedHeight = - eHTMLFrameConstraint_FixedContent == aState.heightConstraint; + PRBool isFixedWidth = aState.HaveFixedContentWidth(); + PRBool isFixedHeight = NS_AUTOHEIGHT != aState.computedHeight; #if 0 if (NS_BODY_SHRINK_WRAP & mFlags) { @@ -707,8 +707,8 @@ nsBaseIBFrame::ComputeFinalSize(nsBlockReflowState& aState, // Compute final width if (isFixedWidth) { // Use style defined width - aMetrics.width = aState.mBorderPadding.left + - aState.minWidth + aState.mBorderPadding.right; + aMetrics.width = aState.mBorderPadding.left + aState.computedWidth + + aState.mBorderPadding.right; } else { nscoord computedWidth = aState.mKidXMost + aState.mBorderPadding.right; @@ -745,8 +745,8 @@ nsBaseIBFrame::ComputeFinalSize(nsBlockReflowState& aState, // Compute final height if (isFixedHeight) { // Use style defined height - aMetrics.height = aState.mBorderPadding.top + - aState.minHeight + aState.mBorderPadding.bottom; + aMetrics.height = aState.mBorderPadding.top + aState.computedHeight + + aState.mBorderPadding.bottom; } else { // Shrink wrap our height around our contents. @@ -773,8 +773,12 @@ nsBaseIBFrame::ComputeFinalSize(nsBlockReflowState& aState, // Special check for zero sized content: If our content is zero // sized then we collapse into nothingness. PRBool emptyFrame = PR_FALSE; - if ((eHTMLFrameConstraint_Unconstrained == aState.widthConstraint) && - (eHTMLFrameConstraint_Unconstrained == aState.heightConstraint) && + // We need to check the specified width and see if it's 'auto' + const nsStylePosition* position; + aState.frame->GetStyleData(eStyleStruct_Position, (const nsStyleStruct*&) position); + PRIntn specifiedWidthUnit = position->mWidth.GetUnit(); + if ((eStyleUnit_Auto == specifiedWidthUnit) && + (NS_AUTOHEIGHT == aState.computedHeight) && ((0 == aState.mKidXMost - aState.mBorderPadding.left) && (0 == aState.mY - aState.mBorderPadding.top))) { aMetrics.width = 0; @@ -3473,7 +3477,7 @@ nsBaseIBFrame::ReflowFloater(nsIPresContext& aPresContext, if (aFloaterReflowState.HaveFixedContentWidth()) { // When the floater has a contrained width, give it just enough // space for its styled width plus its borders and paddings. - kidAvailSize.width = aFloaterReflowState.minWidth + bp.left + bp.right; + kidAvailSize.width = aFloaterReflowState.computedWidth + bp.left + bp.right; } else { // CSS2 section 10.3.5: Floating non-replaced elements with an @@ -3493,7 +3497,7 @@ nsBaseIBFrame::ReflowFloater(nsIPresContext& aPresContext, // Compute the available height for the floater if (aFloaterReflowState.HaveFixedContentHeight()) { - kidAvailSize.height = aFloaterReflowState.minHeight + bp.top + bp.bottom; + kidAvailSize.height = aFloaterReflowState.computedHeight + bp.top + bp.bottom; } else { kidAvailSize.height = NS_UNCONSTRAINEDSIZE; diff --git a/mozilla/layout/generic/nsBlockReflowState.cpp b/mozilla/layout/generic/nsBlockReflowState.cpp index 2c6382f658b..40a5681b428 100644 --- a/mozilla/layout/generic/nsBlockReflowState.cpp +++ b/mozilla/layout/generic/nsBlockReflowState.cpp @@ -329,12 +329,13 @@ nsBlockReflowState::nsBlockReflowState(nsIPresContext& aPresContext, nscoord lr = mBorderPadding.left + mBorderPadding.right; mY = mBorderPadding.top; - if (eHTMLFrameConstraint_FixedContent == widthConstraint) { + + if (HaveFixedContentWidth()) { // The CSS2 spec says that the width attribute defines the width // of the "content area" which does not include the border // padding. So we add those back in. - mBorderArea.width = minWidth + lr; - mContentArea.width = minWidth; + mBorderArea.width = computedWidth + lr; + mContentArea.width = computedWidth; } else { if (mUnconstrainedWidth) { @@ -346,6 +347,7 @@ nsBlockReflowState::nsBlockReflowState(nsIPresContext& aPresContext, mContentArea.width = maxSize.width - lr; } } + mBorderArea.height = maxSize.height; mContentArea.height = maxSize.height; mBottomEdge = maxSize.height; @@ -692,10 +694,8 @@ nsBaseIBFrame::ComputeFinalSize(nsBlockReflowState& aState, nsHTMLReflowMetrics& aMetrics) { // XXX handle floater problems this way... - PRBool isFixedWidth = - eHTMLFrameConstraint_FixedContent == aState.widthConstraint; - PRBool isFixedHeight = - eHTMLFrameConstraint_FixedContent == aState.heightConstraint; + PRBool isFixedWidth = aState.HaveFixedContentWidth(); + PRBool isFixedHeight = NS_AUTOHEIGHT != aState.computedHeight; #if 0 if (NS_BODY_SHRINK_WRAP & mFlags) { @@ -707,8 +707,8 @@ nsBaseIBFrame::ComputeFinalSize(nsBlockReflowState& aState, // Compute final width if (isFixedWidth) { // Use style defined width - aMetrics.width = aState.mBorderPadding.left + - aState.minWidth + aState.mBorderPadding.right; + aMetrics.width = aState.mBorderPadding.left + aState.computedWidth + + aState.mBorderPadding.right; } else { nscoord computedWidth = aState.mKidXMost + aState.mBorderPadding.right; @@ -745,8 +745,8 @@ nsBaseIBFrame::ComputeFinalSize(nsBlockReflowState& aState, // Compute final height if (isFixedHeight) { // Use style defined height - aMetrics.height = aState.mBorderPadding.top + - aState.minHeight + aState.mBorderPadding.bottom; + aMetrics.height = aState.mBorderPadding.top + aState.computedHeight + + aState.mBorderPadding.bottom; } else { // Shrink wrap our height around our contents. @@ -773,8 +773,12 @@ nsBaseIBFrame::ComputeFinalSize(nsBlockReflowState& aState, // Special check for zero sized content: If our content is zero // sized then we collapse into nothingness. PRBool emptyFrame = PR_FALSE; - if ((eHTMLFrameConstraint_Unconstrained == aState.widthConstraint) && - (eHTMLFrameConstraint_Unconstrained == aState.heightConstraint) && + // We need to check the specified width and see if it's 'auto' + const nsStylePosition* position; + aState.frame->GetStyleData(eStyleStruct_Position, (const nsStyleStruct*&) position); + PRIntn specifiedWidthUnit = position->mWidth.GetUnit(); + if ((eStyleUnit_Auto == specifiedWidthUnit) && + (NS_AUTOHEIGHT == aState.computedHeight) && ((0 == aState.mKidXMost - aState.mBorderPadding.left) && (0 == aState.mY - aState.mBorderPadding.top))) { aMetrics.width = 0; @@ -3473,7 +3477,7 @@ nsBaseIBFrame::ReflowFloater(nsIPresContext& aPresContext, if (aFloaterReflowState.HaveFixedContentWidth()) { // When the floater has a contrained width, give it just enough // space for its styled width plus its borders and paddings. - kidAvailSize.width = aFloaterReflowState.minWidth + bp.left + bp.right; + kidAvailSize.width = aFloaterReflowState.computedWidth + bp.left + bp.right; } else { // CSS2 section 10.3.5: Floating non-replaced elements with an @@ -3493,7 +3497,7 @@ nsBaseIBFrame::ReflowFloater(nsIPresContext& aPresContext, // Compute the available height for the floater if (aFloaterReflowState.HaveFixedContentHeight()) { - kidAvailSize.height = aFloaterReflowState.minHeight + bp.top + bp.bottom; + kidAvailSize.height = aFloaterReflowState.computedHeight + bp.top + bp.bottom; } else { kidAvailSize.height = NS_UNCONSTRAINEDSIZE; diff --git a/mozilla/layout/generic/nsBlockReflowState.h b/mozilla/layout/generic/nsBlockReflowState.h index 2c6382f658b..40a5681b428 100644 --- a/mozilla/layout/generic/nsBlockReflowState.h +++ b/mozilla/layout/generic/nsBlockReflowState.h @@ -329,12 +329,13 @@ nsBlockReflowState::nsBlockReflowState(nsIPresContext& aPresContext, nscoord lr = mBorderPadding.left + mBorderPadding.right; mY = mBorderPadding.top; - if (eHTMLFrameConstraint_FixedContent == widthConstraint) { + + if (HaveFixedContentWidth()) { // The CSS2 spec says that the width attribute defines the width // of the "content area" which does not include the border // padding. So we add those back in. - mBorderArea.width = minWidth + lr; - mContentArea.width = minWidth; + mBorderArea.width = computedWidth + lr; + mContentArea.width = computedWidth; } else { if (mUnconstrainedWidth) { @@ -346,6 +347,7 @@ nsBlockReflowState::nsBlockReflowState(nsIPresContext& aPresContext, mContentArea.width = maxSize.width - lr; } } + mBorderArea.height = maxSize.height; mContentArea.height = maxSize.height; mBottomEdge = maxSize.height; @@ -692,10 +694,8 @@ nsBaseIBFrame::ComputeFinalSize(nsBlockReflowState& aState, nsHTMLReflowMetrics& aMetrics) { // XXX handle floater problems this way... - PRBool isFixedWidth = - eHTMLFrameConstraint_FixedContent == aState.widthConstraint; - PRBool isFixedHeight = - eHTMLFrameConstraint_FixedContent == aState.heightConstraint; + PRBool isFixedWidth = aState.HaveFixedContentWidth(); + PRBool isFixedHeight = NS_AUTOHEIGHT != aState.computedHeight; #if 0 if (NS_BODY_SHRINK_WRAP & mFlags) { @@ -707,8 +707,8 @@ nsBaseIBFrame::ComputeFinalSize(nsBlockReflowState& aState, // Compute final width if (isFixedWidth) { // Use style defined width - aMetrics.width = aState.mBorderPadding.left + - aState.minWidth + aState.mBorderPadding.right; + aMetrics.width = aState.mBorderPadding.left + aState.computedWidth + + aState.mBorderPadding.right; } else { nscoord computedWidth = aState.mKidXMost + aState.mBorderPadding.right; @@ -745,8 +745,8 @@ nsBaseIBFrame::ComputeFinalSize(nsBlockReflowState& aState, // Compute final height if (isFixedHeight) { // Use style defined height - aMetrics.height = aState.mBorderPadding.top + - aState.minHeight + aState.mBorderPadding.bottom; + aMetrics.height = aState.mBorderPadding.top + aState.computedHeight + + aState.mBorderPadding.bottom; } else { // Shrink wrap our height around our contents. @@ -773,8 +773,12 @@ nsBaseIBFrame::ComputeFinalSize(nsBlockReflowState& aState, // Special check for zero sized content: If our content is zero // sized then we collapse into nothingness. PRBool emptyFrame = PR_FALSE; - if ((eHTMLFrameConstraint_Unconstrained == aState.widthConstraint) && - (eHTMLFrameConstraint_Unconstrained == aState.heightConstraint) && + // We need to check the specified width and see if it's 'auto' + const nsStylePosition* position; + aState.frame->GetStyleData(eStyleStruct_Position, (const nsStyleStruct*&) position); + PRIntn specifiedWidthUnit = position->mWidth.GetUnit(); + if ((eStyleUnit_Auto == specifiedWidthUnit) && + (NS_AUTOHEIGHT == aState.computedHeight) && ((0 == aState.mKidXMost - aState.mBorderPadding.left) && (0 == aState.mY - aState.mBorderPadding.top))) { aMetrics.width = 0; @@ -3473,7 +3477,7 @@ nsBaseIBFrame::ReflowFloater(nsIPresContext& aPresContext, if (aFloaterReflowState.HaveFixedContentWidth()) { // When the floater has a contrained width, give it just enough // space for its styled width plus its borders and paddings. - kidAvailSize.width = aFloaterReflowState.minWidth + bp.left + bp.right; + kidAvailSize.width = aFloaterReflowState.computedWidth + bp.left + bp.right; } else { // CSS2 section 10.3.5: Floating non-replaced elements with an @@ -3493,7 +3497,7 @@ nsBaseIBFrame::ReflowFloater(nsIPresContext& aPresContext, // Compute the available height for the floater if (aFloaterReflowState.HaveFixedContentHeight()) { - kidAvailSize.height = aFloaterReflowState.minHeight + bp.top + bp.bottom; + kidAvailSize.height = aFloaterReflowState.computedHeight + bp.top + bp.bottom; } else { kidAvailSize.height = NS_UNCONSTRAINEDSIZE; diff --git a/mozilla/layout/generic/nsFrameFrame.cpp b/mozilla/layout/generic/nsFrameFrame.cpp index 78e66424804..f399adf3815 100644 --- a/mozilla/layout/generic/nsFrameFrame.cpp +++ b/mozilla/layout/generic/nsFrameFrame.cpp @@ -244,13 +244,13 @@ nsHTMLFrameOuterFrame::GetDesiredSize(nsIPresContext* aPresContext, // XXX this needs to be changed from (200,200) to a better default for inline frames if (aReflowState.HaveFixedContentWidth()) { - aDesiredSize.width = aReflowState.minWidth; + aDesiredSize.width = aReflowState.computedWidth; } else { aDesiredSize.width = NSIntPixelsToTwips(200, p2t); } if (aReflowState.HaveFixedContentHeight()) { - aDesiredSize.height = aReflowState.minHeight; + aDesiredSize.height = aReflowState.computedHeight; } else { aDesiredSize.height = NSIntPixelsToTwips(200, p2t); diff --git a/mozilla/layout/generic/nsHTMLFrame.cpp b/mozilla/layout/generic/nsHTMLFrame.cpp index 481ed370680..eaf986eff23 100644 --- a/mozilla/layout/generic/nsHTMLFrame.cpp +++ b/mozilla/layout/generic/nsHTMLFrame.cpp @@ -185,15 +185,15 @@ RootFrame::Reflow(nsIPresContext& aPresContext, kidReflowState.reflowCommand = nsnull; } - // For a width or height that's 'auto', make the frame as big as the - // available space - if (eHTMLFrameConstraint_FixedContent != kidReflowState.widthConstraint) { - kidReflowState.widthConstraint = eHTMLFrameConstraint_Fixed; - kidReflowState.minWidth = kidMaxSize.width; - } - if (eHTMLFrameConstraint_FixedContent != kidReflowState.heightConstraint) { - kidReflowState.heightConstraint = eHTMLFrameConstraint_Fixed; - kidReflowState.minHeight = kidMaxSize.height; + // For a height that's 'auto', make the frame as big as the available space + if (!kidReflowState.HaveFixedContentHeight()) { + kidReflowState.computedHeight = kidMaxSize.height; + + // Computed height is for the content area so reduce it by the amount of + // space taken up by border and padding + nsMargin borderPadding; + kidReflowState.ComputeBorderPaddingFor(mFirstChild, &aReflowState, borderPadding); + kidReflowState.computedHeight -= borderPadding.top + borderPadding.bottom; } // Reflow the frame @@ -201,16 +201,6 @@ RootFrame::Reflow(nsIPresContext& aPresContext, if (NS_OK == mFirstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { ReflowChild(mFirstChild, aPresContext, desiredSize, kidReflowState, aStatus); - // Place and size the child. Because we told the child it was - // fixed make sure it's at least as big as we told it. This - // handles the case where the child ignores the reflow state - // constraints - if (desiredSize.width < kidReflowState.minWidth) { - desiredSize.width = kidReflowState.minWidth; - } - if (desiredSize.height < kidReflowState.minHeight) { - desiredSize.height = kidReflowState.minHeight; - } nsRect rect(childMargin.left, childMargin.top, desiredSize.width, desiredSize.height); mFirstChild->SetRect(rect); diff --git a/mozilla/layout/generic/nsImageFrame.cpp b/mozilla/layout/generic/nsImageFrame.cpp index 3bb33e1501b..e5e6286d950 100644 --- a/mozilla/layout/generic/nsImageFrame.cpp +++ b/mozilla/layout/generic/nsImageFrame.cpp @@ -232,8 +232,8 @@ nsHTMLImageLoader::GetDesiredSize(nsIPresContext* aPresContext, if (aReflowState.HaveFixedContentWidth() && aReflowState.HaveFixedContentHeight()) { // The image is fully constrained. Use the constraints directly. - aDesiredSize.width = aReflowState.minWidth; - aDesiredSize.height = aReflowState.minHeight; + aDesiredSize.width = aReflowState.computedWidth; + aDesiredSize.height = aReflowState.computedHeight; } else { // The image is partially constrained. Preserve aspect ratio of @@ -256,16 +256,16 @@ nsHTMLImageLoader::GetDesiredSize(nsIPresContext* aPresContext, if (aReflowState.HaveFixedContentWidth()) { // We have a width, and an auto height. Compute height // from width. - aDesiredSize.width = aReflowState.minWidth; + aDesiredSize.width = aReflowState.computedWidth; aDesiredSize.height = (nscoord) - NSToIntRound(aReflowState.minWidth * imageHeight / imageWidth); + NSToIntRound(aReflowState.computedWidth * imageHeight / imageWidth); } else { // We have a height and an auto width. Compute width from // height. - aDesiredSize.height = aReflowState.minHeight; + aDesiredSize.height = aReflowState.computedHeight; aDesiredSize.width = (nscoord) - NSToIntRound(aReflowState.minHeight * imageWidth / imageHeight); + NSToIntRound(aReflowState.computedHeight * imageWidth / imageHeight); } } else { diff --git a/mozilla/layout/generic/nsObjectFrame.cpp b/mozilla/layout/generic/nsObjectFrame.cpp index c6ee3613bac..0d1627cceb8 100644 --- a/mozilla/layout/generic/nsObjectFrame.cpp +++ b/mozilla/layout/generic/nsObjectFrame.cpp @@ -306,11 +306,11 @@ nsObjectFrame::GetDesiredSize(nsIPresContext* aPresContext, } if (aReflowState.HaveFixedContentWidth()) { - aMetrics.width = aReflowState.minWidth; + aMetrics.width = aReflowState.computedWidth; haveWidth = PR_TRUE; } if (aReflowState.HaveFixedContentHeight()) { - aMetrics.height = aReflowState.minHeight; + aMetrics.height = aReflowState.computedHeight; haveHeight = PR_TRUE; } diff --git a/mozilla/layout/html/base/src/nsBlockFrame.cpp b/mozilla/layout/html/base/src/nsBlockFrame.cpp index 2c6382f658b..40a5681b428 100644 --- a/mozilla/layout/html/base/src/nsBlockFrame.cpp +++ b/mozilla/layout/html/base/src/nsBlockFrame.cpp @@ -329,12 +329,13 @@ nsBlockReflowState::nsBlockReflowState(nsIPresContext& aPresContext, nscoord lr = mBorderPadding.left + mBorderPadding.right; mY = mBorderPadding.top; - if (eHTMLFrameConstraint_FixedContent == widthConstraint) { + + if (HaveFixedContentWidth()) { // The CSS2 spec says that the width attribute defines the width // of the "content area" which does not include the border // padding. So we add those back in. - mBorderArea.width = minWidth + lr; - mContentArea.width = minWidth; + mBorderArea.width = computedWidth + lr; + mContentArea.width = computedWidth; } else { if (mUnconstrainedWidth) { @@ -346,6 +347,7 @@ nsBlockReflowState::nsBlockReflowState(nsIPresContext& aPresContext, mContentArea.width = maxSize.width - lr; } } + mBorderArea.height = maxSize.height; mContentArea.height = maxSize.height; mBottomEdge = maxSize.height; @@ -692,10 +694,8 @@ nsBaseIBFrame::ComputeFinalSize(nsBlockReflowState& aState, nsHTMLReflowMetrics& aMetrics) { // XXX handle floater problems this way... - PRBool isFixedWidth = - eHTMLFrameConstraint_FixedContent == aState.widthConstraint; - PRBool isFixedHeight = - eHTMLFrameConstraint_FixedContent == aState.heightConstraint; + PRBool isFixedWidth = aState.HaveFixedContentWidth(); + PRBool isFixedHeight = NS_AUTOHEIGHT != aState.computedHeight; #if 0 if (NS_BODY_SHRINK_WRAP & mFlags) { @@ -707,8 +707,8 @@ nsBaseIBFrame::ComputeFinalSize(nsBlockReflowState& aState, // Compute final width if (isFixedWidth) { // Use style defined width - aMetrics.width = aState.mBorderPadding.left + - aState.minWidth + aState.mBorderPadding.right; + aMetrics.width = aState.mBorderPadding.left + aState.computedWidth + + aState.mBorderPadding.right; } else { nscoord computedWidth = aState.mKidXMost + aState.mBorderPadding.right; @@ -745,8 +745,8 @@ nsBaseIBFrame::ComputeFinalSize(nsBlockReflowState& aState, // Compute final height if (isFixedHeight) { // Use style defined height - aMetrics.height = aState.mBorderPadding.top + - aState.minHeight + aState.mBorderPadding.bottom; + aMetrics.height = aState.mBorderPadding.top + aState.computedHeight + + aState.mBorderPadding.bottom; } else { // Shrink wrap our height around our contents. @@ -773,8 +773,12 @@ nsBaseIBFrame::ComputeFinalSize(nsBlockReflowState& aState, // Special check for zero sized content: If our content is zero // sized then we collapse into nothingness. PRBool emptyFrame = PR_FALSE; - if ((eHTMLFrameConstraint_Unconstrained == aState.widthConstraint) && - (eHTMLFrameConstraint_Unconstrained == aState.heightConstraint) && + // We need to check the specified width and see if it's 'auto' + const nsStylePosition* position; + aState.frame->GetStyleData(eStyleStruct_Position, (const nsStyleStruct*&) position); + PRIntn specifiedWidthUnit = position->mWidth.GetUnit(); + if ((eStyleUnit_Auto == specifiedWidthUnit) && + (NS_AUTOHEIGHT == aState.computedHeight) && ((0 == aState.mKidXMost - aState.mBorderPadding.left) && (0 == aState.mY - aState.mBorderPadding.top))) { aMetrics.width = 0; @@ -3473,7 +3477,7 @@ nsBaseIBFrame::ReflowFloater(nsIPresContext& aPresContext, if (aFloaterReflowState.HaveFixedContentWidth()) { // When the floater has a contrained width, give it just enough // space for its styled width plus its borders and paddings. - kidAvailSize.width = aFloaterReflowState.minWidth + bp.left + bp.right; + kidAvailSize.width = aFloaterReflowState.computedWidth + bp.left + bp.right; } else { // CSS2 section 10.3.5: Floating non-replaced elements with an @@ -3493,7 +3497,7 @@ nsBaseIBFrame::ReflowFloater(nsIPresContext& aPresContext, // Compute the available height for the floater if (aFloaterReflowState.HaveFixedContentHeight()) { - kidAvailSize.height = aFloaterReflowState.minHeight + bp.top + bp.bottom; + kidAvailSize.height = aFloaterReflowState.computedHeight + bp.top + bp.bottom; } else { kidAvailSize.height = NS_UNCONSTRAINEDSIZE; diff --git a/mozilla/layout/html/base/src/nsBlockReflowState.cpp b/mozilla/layout/html/base/src/nsBlockReflowState.cpp index 2c6382f658b..40a5681b428 100644 --- a/mozilla/layout/html/base/src/nsBlockReflowState.cpp +++ b/mozilla/layout/html/base/src/nsBlockReflowState.cpp @@ -329,12 +329,13 @@ nsBlockReflowState::nsBlockReflowState(nsIPresContext& aPresContext, nscoord lr = mBorderPadding.left + mBorderPadding.right; mY = mBorderPadding.top; - if (eHTMLFrameConstraint_FixedContent == widthConstraint) { + + if (HaveFixedContentWidth()) { // The CSS2 spec says that the width attribute defines the width // of the "content area" which does not include the border // padding. So we add those back in. - mBorderArea.width = minWidth + lr; - mContentArea.width = minWidth; + mBorderArea.width = computedWidth + lr; + mContentArea.width = computedWidth; } else { if (mUnconstrainedWidth) { @@ -346,6 +347,7 @@ nsBlockReflowState::nsBlockReflowState(nsIPresContext& aPresContext, mContentArea.width = maxSize.width - lr; } } + mBorderArea.height = maxSize.height; mContentArea.height = maxSize.height; mBottomEdge = maxSize.height; @@ -692,10 +694,8 @@ nsBaseIBFrame::ComputeFinalSize(nsBlockReflowState& aState, nsHTMLReflowMetrics& aMetrics) { // XXX handle floater problems this way... - PRBool isFixedWidth = - eHTMLFrameConstraint_FixedContent == aState.widthConstraint; - PRBool isFixedHeight = - eHTMLFrameConstraint_FixedContent == aState.heightConstraint; + PRBool isFixedWidth = aState.HaveFixedContentWidth(); + PRBool isFixedHeight = NS_AUTOHEIGHT != aState.computedHeight; #if 0 if (NS_BODY_SHRINK_WRAP & mFlags) { @@ -707,8 +707,8 @@ nsBaseIBFrame::ComputeFinalSize(nsBlockReflowState& aState, // Compute final width if (isFixedWidth) { // Use style defined width - aMetrics.width = aState.mBorderPadding.left + - aState.minWidth + aState.mBorderPadding.right; + aMetrics.width = aState.mBorderPadding.left + aState.computedWidth + + aState.mBorderPadding.right; } else { nscoord computedWidth = aState.mKidXMost + aState.mBorderPadding.right; @@ -745,8 +745,8 @@ nsBaseIBFrame::ComputeFinalSize(nsBlockReflowState& aState, // Compute final height if (isFixedHeight) { // Use style defined height - aMetrics.height = aState.mBorderPadding.top + - aState.minHeight + aState.mBorderPadding.bottom; + aMetrics.height = aState.mBorderPadding.top + aState.computedHeight + + aState.mBorderPadding.bottom; } else { // Shrink wrap our height around our contents. @@ -773,8 +773,12 @@ nsBaseIBFrame::ComputeFinalSize(nsBlockReflowState& aState, // Special check for zero sized content: If our content is zero // sized then we collapse into nothingness. PRBool emptyFrame = PR_FALSE; - if ((eHTMLFrameConstraint_Unconstrained == aState.widthConstraint) && - (eHTMLFrameConstraint_Unconstrained == aState.heightConstraint) && + // We need to check the specified width and see if it's 'auto' + const nsStylePosition* position; + aState.frame->GetStyleData(eStyleStruct_Position, (const nsStyleStruct*&) position); + PRIntn specifiedWidthUnit = position->mWidth.GetUnit(); + if ((eStyleUnit_Auto == specifiedWidthUnit) && + (NS_AUTOHEIGHT == aState.computedHeight) && ((0 == aState.mKidXMost - aState.mBorderPadding.left) && (0 == aState.mY - aState.mBorderPadding.top))) { aMetrics.width = 0; @@ -3473,7 +3477,7 @@ nsBaseIBFrame::ReflowFloater(nsIPresContext& aPresContext, if (aFloaterReflowState.HaveFixedContentWidth()) { // When the floater has a contrained width, give it just enough // space for its styled width plus its borders and paddings. - kidAvailSize.width = aFloaterReflowState.minWidth + bp.left + bp.right; + kidAvailSize.width = aFloaterReflowState.computedWidth + bp.left + bp.right; } else { // CSS2 section 10.3.5: Floating non-replaced elements with an @@ -3493,7 +3497,7 @@ nsBaseIBFrame::ReflowFloater(nsIPresContext& aPresContext, // Compute the available height for the floater if (aFloaterReflowState.HaveFixedContentHeight()) { - kidAvailSize.height = aFloaterReflowState.minHeight + bp.top + bp.bottom; + kidAvailSize.height = aFloaterReflowState.computedHeight + bp.top + bp.bottom; } else { kidAvailSize.height = NS_UNCONSTRAINEDSIZE; diff --git a/mozilla/layout/html/base/src/nsBlockReflowState.h b/mozilla/layout/html/base/src/nsBlockReflowState.h index 2c6382f658b..40a5681b428 100644 --- a/mozilla/layout/html/base/src/nsBlockReflowState.h +++ b/mozilla/layout/html/base/src/nsBlockReflowState.h @@ -329,12 +329,13 @@ nsBlockReflowState::nsBlockReflowState(nsIPresContext& aPresContext, nscoord lr = mBorderPadding.left + mBorderPadding.right; mY = mBorderPadding.top; - if (eHTMLFrameConstraint_FixedContent == widthConstraint) { + + if (HaveFixedContentWidth()) { // The CSS2 spec says that the width attribute defines the width // of the "content area" which does not include the border // padding. So we add those back in. - mBorderArea.width = minWidth + lr; - mContentArea.width = minWidth; + mBorderArea.width = computedWidth + lr; + mContentArea.width = computedWidth; } else { if (mUnconstrainedWidth) { @@ -346,6 +347,7 @@ nsBlockReflowState::nsBlockReflowState(nsIPresContext& aPresContext, mContentArea.width = maxSize.width - lr; } } + mBorderArea.height = maxSize.height; mContentArea.height = maxSize.height; mBottomEdge = maxSize.height; @@ -692,10 +694,8 @@ nsBaseIBFrame::ComputeFinalSize(nsBlockReflowState& aState, nsHTMLReflowMetrics& aMetrics) { // XXX handle floater problems this way... - PRBool isFixedWidth = - eHTMLFrameConstraint_FixedContent == aState.widthConstraint; - PRBool isFixedHeight = - eHTMLFrameConstraint_FixedContent == aState.heightConstraint; + PRBool isFixedWidth = aState.HaveFixedContentWidth(); + PRBool isFixedHeight = NS_AUTOHEIGHT != aState.computedHeight; #if 0 if (NS_BODY_SHRINK_WRAP & mFlags) { @@ -707,8 +707,8 @@ nsBaseIBFrame::ComputeFinalSize(nsBlockReflowState& aState, // Compute final width if (isFixedWidth) { // Use style defined width - aMetrics.width = aState.mBorderPadding.left + - aState.minWidth + aState.mBorderPadding.right; + aMetrics.width = aState.mBorderPadding.left + aState.computedWidth + + aState.mBorderPadding.right; } else { nscoord computedWidth = aState.mKidXMost + aState.mBorderPadding.right; @@ -745,8 +745,8 @@ nsBaseIBFrame::ComputeFinalSize(nsBlockReflowState& aState, // Compute final height if (isFixedHeight) { // Use style defined height - aMetrics.height = aState.mBorderPadding.top + - aState.minHeight + aState.mBorderPadding.bottom; + aMetrics.height = aState.mBorderPadding.top + aState.computedHeight + + aState.mBorderPadding.bottom; } else { // Shrink wrap our height around our contents. @@ -773,8 +773,12 @@ nsBaseIBFrame::ComputeFinalSize(nsBlockReflowState& aState, // Special check for zero sized content: If our content is zero // sized then we collapse into nothingness. PRBool emptyFrame = PR_FALSE; - if ((eHTMLFrameConstraint_Unconstrained == aState.widthConstraint) && - (eHTMLFrameConstraint_Unconstrained == aState.heightConstraint) && + // We need to check the specified width and see if it's 'auto' + const nsStylePosition* position; + aState.frame->GetStyleData(eStyleStruct_Position, (const nsStyleStruct*&) position); + PRIntn specifiedWidthUnit = position->mWidth.GetUnit(); + if ((eStyleUnit_Auto == specifiedWidthUnit) && + (NS_AUTOHEIGHT == aState.computedHeight) && ((0 == aState.mKidXMost - aState.mBorderPadding.left) && (0 == aState.mY - aState.mBorderPadding.top))) { aMetrics.width = 0; @@ -3473,7 +3477,7 @@ nsBaseIBFrame::ReflowFloater(nsIPresContext& aPresContext, if (aFloaterReflowState.HaveFixedContentWidth()) { // When the floater has a contrained width, give it just enough // space for its styled width plus its borders and paddings. - kidAvailSize.width = aFloaterReflowState.minWidth + bp.left + bp.right; + kidAvailSize.width = aFloaterReflowState.computedWidth + bp.left + bp.right; } else { // CSS2 section 10.3.5: Floating non-replaced elements with an @@ -3493,7 +3497,7 @@ nsBaseIBFrame::ReflowFloater(nsIPresContext& aPresContext, // Compute the available height for the floater if (aFloaterReflowState.HaveFixedContentHeight()) { - kidAvailSize.height = aFloaterReflowState.minHeight + bp.top + bp.bottom; + kidAvailSize.height = aFloaterReflowState.computedHeight + bp.top + bp.bottom; } else { kidAvailSize.height = NS_UNCONSTRAINEDSIZE; diff --git a/mozilla/layout/html/base/src/nsFrameReflowState.cpp b/mozilla/layout/html/base/src/nsFrameReflowState.cpp index 8e3360397e4..665a7965a49 100644 --- a/mozilla/layout/html/base/src/nsFrameReflowState.cpp +++ b/mozilla/layout/html/base/src/nsFrameReflowState.cpp @@ -24,6 +24,24 @@ #include "nsIContent.h" #include "nsHTMLAtoms.h" +PRBool +nsHTMLReflowState::HaveFixedContentWidth() const +{ + const nsStylePosition* pos; + frame->GetStyleData(eStyleStruct_Position, (const nsStyleStruct*&)pos); + // What about 'inherit'? + return eStyleUnit_Auto != pos->mWidth.GetUnit(); +} + +PRBool +nsHTMLReflowState::HaveFixedContentHeight() const +{ + const nsStylePosition* pos; + frame->GetStyleData(eStyleStruct_Position, (const nsStyleStruct*&)pos); + // What about 'inherit'? + return eStyleUnit_Auto != pos->mHeight.GetUnit(); +} + const nsHTMLReflowState* nsHTMLReflowState::GetContainingBlockReflowState(const nsReflowState* aParentRS) { @@ -54,36 +72,7 @@ nsHTMLReflowState::GetContainingBlockContentWidth(const nsReflowState* aParentRS const nsHTMLReflowState* rs = GetContainingBlockReflowState(aParentRS); if (nsnull != rs) { - return ((nsHTMLReflowState*)aParentRS)->GetContentWidth();/* XXX cast */ - } - return width; -} - -nscoord -nsHTMLReflowState::GetContentWidth() const -{ - nscoord width = 0; - if (HaveFixedContentWidth()) { - width = minWidth; - } - else if (NS_UNCONSTRAINEDSIZE != maxSize.width) { - width = maxSize.width; - if (nsnull != frame) { - // Subtract out the border and padding values because the - // percentage is to be computed relative to the content - // width, not the outer width. - const nsStyleSpacing* spacing; - nsresult rv; - rv = frame->GetStyleData(eStyleStruct_Spacing, - (const nsStyleStruct*&) spacing); - if (NS_SUCCEEDED(rv) && (nsnull != spacing)) { - nsMargin borderPadding; - ComputeBorderPaddingFor(frame, - parentReflowState, - borderPadding); - width -= borderPadding.left + borderPadding.right; - } - } + return ((nsHTMLReflowState*)aParentRS)->computedWidth;/* XXX cast */ } return width; } @@ -182,16 +171,16 @@ nsHTMLReflowState::DetermineFrameType(nsIPresContext& aPresContext) void nsHTMLReflowState::InitConstraints(nsIPresContext& aPresContext) { - // Determine whether the values are constrained or unconstrained - // by looking at the maxSize - widthConstraint = NS_UNCONSTRAINEDSIZE == maxSize.width ? - eHTMLFrameConstraint_Unconstrained : - eHTMLFrameConstraint_Constrained; - heightConstraint = NS_UNCONSTRAINEDSIZE == maxSize.height ? - eHTMLFrameConstraint_Unconstrained : - eHTMLFrameConstraint_Constrained; - minWidth = 0; - minHeight = 0; + const nsStylePosition* pos; + nsresult result = frame->GetStyleData(eStyleStruct_Position, + (const nsStyleStruct*&)pos); + + // Initialize the computed values to default values + // XXX Use specified values as defaults + computedWidth = 0; + computedLeftMargin = computedRightMargin = 0; + computedHeight = 0; + computedTopMargin = computedBottomMargin = 0; mLineHeight = CalcLineHeight(aPresContext, frame); @@ -203,12 +192,7 @@ nsHTMLReflowState::InitConstraints(nsIPresContext& aPresContext) case eCSSFrameType_Inline: if (mLineHeight >= 0) { -#if 0 - minHeight = maxSize.height = mLineHeight; -#else - minHeight = mLineHeight; -#endif - heightConstraint = eHTMLFrameConstraint_FixedContent; + computedHeight = mLineHeight; } return; @@ -217,9 +201,6 @@ nsHTMLReflowState::InitConstraints(nsIPresContext& aPresContext) } // Look for stylistic constraints on the width/height - const nsStylePosition* pos; - nsresult result = frame->GetStyleData(eStyleStruct_Position, - (const nsStyleStruct*&)pos); if (NS_OK == result) { nscoord containingBlockWidth, containingBlockHeight; nscoord width = -1, height = -1; @@ -245,7 +226,7 @@ nsHTMLReflowState::InitConstraints(nsIPresContext& aPresContext) } else { if (eStyleUnit_Percent == widthUnit) { - containingBlockWidth = cbrs->GetContentWidth(); + containingBlockWidth = cbrs->computedWidth; } if (eStyleUnit_Percent == heightUnit) { if (NS_UNCONSTRAINEDSIZE == cbrs->maxSize.height) { @@ -269,8 +250,16 @@ nsHTMLReflowState::InitConstraints(nsIPresContext& aPresContext) width = nscoord(pos->mWidth.GetPercentValue() * containingBlockWidth); break; case eStyleUnit_Auto: - // XXX See section 10.3 of the css2 spec and then write this code! - break; + { + // XXX See section 10.3 of the css2 spec and then write this code! + nsMargin margin; + nsMargin borderPadding; + ComputeMarginFor(frame, parentReflowState, margin); + ComputeBorderPaddingFor(frame, parentReflowState, borderPadding); + width = maxSize.width - margin.left - margin.right - borderPadding.left - + borderPadding.right; + break; + } } switch (heightUnit) { case eStyleUnit_Coord: @@ -285,16 +274,10 @@ nsHTMLReflowState::InitConstraints(nsIPresContext& aPresContext) } if (width > 0) { - // XXX If the size constraint is a fixed content width then we also - // need to set the max width as well, but then we bust tables... - minWidth = width; - widthConstraint = eHTMLFrameConstraint_FixedContent; + computedWidth = width; } if (height > 0) { - // XXX If the size constraint is a fixed content width then we also - // need to set the max height as well... - minHeight = height; - heightConstraint = eHTMLFrameConstraint_FixedContent; + computedHeight = height; } } @@ -378,7 +361,7 @@ nsHTMLReflowState::ComputeHorizontalValue(const nsHTMLReflowState& aRS, { aResult = 0; if (eStyleUnit_Percent == aUnit) { - nscoord width = aRS.GetContentWidth(); + nscoord width = aRS.computedWidth; float pct = aCoord.GetPercentValue(); aResult = NSToCoordFloor(width * pct); } @@ -393,7 +376,7 @@ nsHTMLReflowState::ComputeVerticalValue(const nsHTMLReflowState& aRS, aResult = 0; if (eStyleUnit_Percent == aUnit) { // XXX temporary! - nscoord width = aRS.GetContentWidth(); + nscoord width = aRS.computedWidth; float pct = aCoord.GetPercentValue(); aResult = NSToCoordFloor(width * pct); } diff --git a/mozilla/layout/html/base/src/nsHRFrame.cpp b/mozilla/layout/html/base/src/nsHRFrame.cpp index c51cd47b63d..cd076c7c2d3 100644 --- a/mozilla/layout/html/base/src/nsHRFrame.cpp +++ b/mozilla/layout/html/base/src/nsHRFrame.cpp @@ -242,7 +242,7 @@ HRuleFrame::Reflow(nsIPresContext& aPresContext, aDesiredSize.maxElementSize->width = onePixel; } else { - aDesiredSize.maxElementSize->width = aReflowState.minWidth; + aDesiredSize.maxElementSize->width = aReflowState.computedWidth; } aDesiredSize.maxElementSize->height = onePixel; } @@ -265,7 +265,7 @@ HRuleFrame::GetDesiredSize(nsIPresContext* aPresContext, aPresContext->GetScaledPixelsToTwips(p2t); if (aReflowState.HaveFixedContentWidth()) { - aDesiredSize.width = aReflowState.minWidth; + aDesiredSize.width = aReflowState.computedWidth; } else { if (NS_UNCONSTRAINEDSIZE == aReflowState.maxSize.width) { diff --git a/mozilla/layout/html/base/src/nsHTMLFrame.cpp b/mozilla/layout/html/base/src/nsHTMLFrame.cpp index 481ed370680..eaf986eff23 100644 --- a/mozilla/layout/html/base/src/nsHTMLFrame.cpp +++ b/mozilla/layout/html/base/src/nsHTMLFrame.cpp @@ -185,15 +185,15 @@ RootFrame::Reflow(nsIPresContext& aPresContext, kidReflowState.reflowCommand = nsnull; } - // For a width or height that's 'auto', make the frame as big as the - // available space - if (eHTMLFrameConstraint_FixedContent != kidReflowState.widthConstraint) { - kidReflowState.widthConstraint = eHTMLFrameConstraint_Fixed; - kidReflowState.minWidth = kidMaxSize.width; - } - if (eHTMLFrameConstraint_FixedContent != kidReflowState.heightConstraint) { - kidReflowState.heightConstraint = eHTMLFrameConstraint_Fixed; - kidReflowState.minHeight = kidMaxSize.height; + // For a height that's 'auto', make the frame as big as the available space + if (!kidReflowState.HaveFixedContentHeight()) { + kidReflowState.computedHeight = kidMaxSize.height; + + // Computed height is for the content area so reduce it by the amount of + // space taken up by border and padding + nsMargin borderPadding; + kidReflowState.ComputeBorderPaddingFor(mFirstChild, &aReflowState, borderPadding); + kidReflowState.computedHeight -= borderPadding.top + borderPadding.bottom; } // Reflow the frame @@ -201,16 +201,6 @@ RootFrame::Reflow(nsIPresContext& aPresContext, if (NS_OK == mFirstChild->QueryInterface(kIHTMLReflowIID, (void**)&htmlReflow)) { ReflowChild(mFirstChild, aPresContext, desiredSize, kidReflowState, aStatus); - // Place and size the child. Because we told the child it was - // fixed make sure it's at least as big as we told it. This - // handles the case where the child ignores the reflow state - // constraints - if (desiredSize.width < kidReflowState.minWidth) { - desiredSize.width = kidReflowState.minWidth; - } - if (desiredSize.height < kidReflowState.minHeight) { - desiredSize.height = kidReflowState.minHeight; - } nsRect rect(childMargin.left, childMargin.top, desiredSize.width, desiredSize.height); mFirstChild->SetRect(rect); diff --git a/mozilla/layout/html/base/src/nsIHTMLReflow.h b/mozilla/layout/html/base/src/nsIHTMLReflow.h index a31a661706f..782401be6dc 100644 --- a/mozilla/layout/html/base/src/nsIHTMLReflow.h +++ b/mozilla/layout/html/base/src/nsIHTMLReflow.h @@ -72,33 +72,6 @@ struct nsHTMLReflowMetrics : nsReflowMetrics { //---------------------------------------------------------------------- -/** - * The type of size constraint that applies to a particular - * dimension. For the fixed and fixed content cases the min/max - * width/height in the reflow state structure is ignored and you - * should use the max size value when reflowing the frame. - * - * @see nsHTMLReflowState - */ -enum nsHTMLFrameConstraint { - // Choose whatever frame size you want (there is no stylistic limitation - // on the size of the frame) - eHTMLFrameConstraint_Unconstrained, - - // Choose a frame size between the min and max sizes - eHTMLFrameConstraint_Constrained, - - // Frame size is fixed. The nsReflowState::maxSize.width value - // determines the fixed width. - eHTMLFrameConstraint_Fixed, - - // Content size is fixed. The nsReflowState::maxSize.width value - // determines the fixed width. - eHTMLFrameConstraint_FixedContent -}; - -//---------------------------------------------------------------------- - /** * CSS Frame type. Included as part of the reflow state. * @@ -149,6 +122,9 @@ enum nsCSSFrameType { //---------------------------------------------------------------------- +#define NS_INTRINSICSIZE 0 +#define NS_AUTOHEIGHT 0 + /** * HTML version of the reflow state. * @@ -157,30 +133,50 @@ enum nsCSSFrameType { struct nsHTMLReflowState : nsReflowState { // The type of frame, from css's perspective. This value is // initialized by the Init method below. - nsCSSFrameType frameType; + nsCSSFrameType frameType; - nsISpaceManager* spaceManager; + nsISpaceManager* spaceManager; // LineLayout object (only for inline reflow; set to NULL otherwise) - nsLineLayout* lineLayout; + nsLineLayout* lineLayout; - // Constraint that applies to width dimension - nsHTMLFrameConstraint widthConstraint; - nscoord minWidth; + // Computed width and margins. The computed width specifies the frame's + // content width, and it does not apply to inline non-replaced elements + // + // For replaced inline frames, a value of NS_INTRINSICSIZE means you should + // use your intrinsic width as the computed width + // + // For block-level frames, the computed width is based on the width of the + // containing block and the margin/border/padding areas and the min/max + // width + nscoord computedWidth; + nscoord computedLeftMargin, computedRightMargin; - // Constraint that applies to height dimension - nsHTMLFrameConstraint heightConstraint; - nscoord minHeight; + // Computed height and margins. The computed height specifies the frame's + // content height, and it does not apply to inline non-replaced elements + // + // For replaced inline frames, a value of NS_INTRINSICSIZE means you should + // use your intrinsic height as the computed height + // + // For non-replaced block-level frames in the flow and floated, a value of + // NS_AUTOHEIGHT means you choose a height to shrink wrap around the normal + // flow child frames. The height must be within the limit of the min/max + // height if there is such a limit + // + // For replaced block-level frames, a value of NS_INTRINSICSIZE + // means you use your intrinsic height as the computed height + nscoord computedHeight; + nscoord computedTopMargin, computedBottomMargin; // Run-in frame made available for reflow - nsBlockFrame* mRunInFrame; + nsBlockFrame* mRunInFrame; // Compact margin available space - nscoord mCompactMarginWidth; + nscoord mCompactMarginWidth; // The line-height for the frame. If the frame has no specific // line-height value then this field will be "-1". - nscoord mLineHeight; + nscoord mLineHeight; // Constructs an initial reflow state (no parent reflow state) for a // non-incremental reflow command. Sets reflowType to eReflowType_Block @@ -229,19 +225,12 @@ struct nsHTMLReflowState : nsReflowState { const nsSize& aMaxSize, nsReflowReason aReflowReason); - PRBool HaveFixedContentWidth() const { - return eHTMLFrameConstraint_FixedContent == widthConstraint; - } - - PRBool HaveFixedContentHeight() const { - return eHTMLFrameConstraint_FixedContent == heightConstraint; - } - /** - * Return the width of the content area based on this reflow state's - * state. + * Returns PR_TRUE if the specified width or height has an value other + * than 'auto' */ - nscoord GetContentWidth() const; + PRBool HaveFixedContentWidth() const; + PRBool HaveFixedContentHeight() const; /** * Get the containing block reflow state, starting from a frames diff --git a/mozilla/layout/html/base/src/nsImageFrame.cpp b/mozilla/layout/html/base/src/nsImageFrame.cpp index 3bb33e1501b..e5e6286d950 100644 --- a/mozilla/layout/html/base/src/nsImageFrame.cpp +++ b/mozilla/layout/html/base/src/nsImageFrame.cpp @@ -232,8 +232,8 @@ nsHTMLImageLoader::GetDesiredSize(nsIPresContext* aPresContext, if (aReflowState.HaveFixedContentWidth() && aReflowState.HaveFixedContentHeight()) { // The image is fully constrained. Use the constraints directly. - aDesiredSize.width = aReflowState.minWidth; - aDesiredSize.height = aReflowState.minHeight; + aDesiredSize.width = aReflowState.computedWidth; + aDesiredSize.height = aReflowState.computedHeight; } else { // The image is partially constrained. Preserve aspect ratio of @@ -256,16 +256,16 @@ nsHTMLImageLoader::GetDesiredSize(nsIPresContext* aPresContext, if (aReflowState.HaveFixedContentWidth()) { // We have a width, and an auto height. Compute height // from width. - aDesiredSize.width = aReflowState.minWidth; + aDesiredSize.width = aReflowState.computedWidth; aDesiredSize.height = (nscoord) - NSToIntRound(aReflowState.minWidth * imageHeight / imageWidth); + NSToIntRound(aReflowState.computedWidth * imageHeight / imageWidth); } else { // We have a height and an auto width. Compute width from // height. - aDesiredSize.height = aReflowState.minHeight; + aDesiredSize.height = aReflowState.computedHeight; aDesiredSize.width = (nscoord) - NSToIntRound(aReflowState.minHeight * imageWidth / imageHeight); + NSToIntRound(aReflowState.computedHeight * imageWidth / imageHeight); } } else { diff --git a/mozilla/layout/html/base/src/nsObjectFrame.cpp b/mozilla/layout/html/base/src/nsObjectFrame.cpp index c6ee3613bac..0d1627cceb8 100644 --- a/mozilla/layout/html/base/src/nsObjectFrame.cpp +++ b/mozilla/layout/html/base/src/nsObjectFrame.cpp @@ -306,11 +306,11 @@ nsObjectFrame::GetDesiredSize(nsIPresContext* aPresContext, } if (aReflowState.HaveFixedContentWidth()) { - aMetrics.width = aReflowState.minWidth; + aMetrics.width = aReflowState.computedWidth; haveWidth = PR_TRUE; } if (aReflowState.HaveFixedContentHeight()) { - aMetrics.height = aReflowState.minHeight; + aMetrics.height = aReflowState.computedHeight; haveHeight = PR_TRUE; } diff --git a/mozilla/layout/html/base/src/nsScrollFrame.cpp b/mozilla/layout/html/base/src/nsScrollFrame.cpp index 56b897b3817..e2e50434acb 100644 --- a/mozilla/layout/html/base/src/nsScrollFrame.cpp +++ b/mozilla/layout/html/base/src/nsScrollFrame.cpp @@ -292,66 +292,30 @@ nsScrollFrame::Reflow(nsIPresContext& aPresContext, dc->GetScrollBarDimensions(sbWidth, sbHeight); NS_RELEASE(dc); - //@ Make me a subroutine... - // Compute the scroll area size. This is the area inside of our border edge // and inside of any vertical and horizontal scrollbars nsSize scrollAreaSize; - if ((eHTMLFrameConstraint_Fixed == aReflowState.widthConstraint) || - (eHTMLFrameConstraint_FixedContent == aReflowState.widthConstraint)) { - // The reflow state width reflects space for the content area only, so don't - // subtract for borders... - scrollAreaSize.width = aReflowState.minWidth; - - if (eHTMLFrameConstraint_Fixed == aReflowState.widthConstraint) { - scrollAreaSize.width -= border.left + border.right; - scrollAreaSize.width -= NSToCoordRound(sbWidth); - } - } - else { - // Use the max width in the reflow state - scrollAreaSize.width = aReflowState.maxSize.width; - if (NS_UNCONSTRAINEDSIZE != scrollAreaSize.width) { - // The width is constrained so subtract for borders - scrollAreaSize.width -= border.left + border.right; - - // Subtract for the width of the vertical scrollbar. We always do this - // regardless of whether scrollbars are auto or always visible - scrollAreaSize.width -= NSToCoordRound(sbWidth); - } - } - - if ((eHTMLFrameConstraint_Fixed == aReflowState.heightConstraint) || - (eHTMLFrameConstraint_FixedContent == aReflowState.heightConstraint)) { - // The reflow state height reflects space for the content area only, so don't - // subtract for borders... - scrollAreaSize.height = aReflowState.minHeight; - - if (eHTMLFrameConstraint_Fixed == aReflowState.heightConstraint) { - scrollAreaSize.height -= border.top + border.bottom; - - // If scrollbars are always visible then subtract for the - // height of the horizontal scrollbar - if (NS_STYLE_OVERFLOW_SCROLL == display->mOverflow) { - scrollAreaSize.height -= NSToCoordRound(sbHeight); - } - } - } - else { - // Use the max height in the reflow state + scrollAreaSize.width = aReflowState.computedWidth; + // Subtract for the width of the vertical scrollbar. We always do this + // regardless of whether scrollbars are auto or always visible + scrollAreaSize.width -= NSToCoordRound(sbWidth); + if (NS_AUTOHEIGHT == aReflowState.computedHeight) { + // We have an 'auto' height and so we should shrink wrap around the + // scrolled frame. Let the scrolled frame be as high as the available + // height scrollAreaSize.height = aReflowState.maxSize.height; - if (NS_UNCONSTRAINEDSIZE != scrollAreaSize.height) { - // The height is constrained so subtract for borders - scrollAreaSize.height -= border.top + border.bottom; + scrollAreaSize.height -= border.top + border.bottom; - // If scrollbars are always visible then subtract for the - // height of the horizontal scrollbar - if (NS_STYLE_OVERFLOW_SCROLL == display->mOverflow) { - scrollAreaSize.height -= NSToCoordRound(sbHeight); - } - } + // XXX Check for min/max limits... + } else { + // We have a fixed height so use the computed height + scrollAreaSize.height = aReflowState.computedHeight; + } + // If scrollbars are always visible then subtract for the height of the + // horizontal scrollbar + if (NS_STYLE_OVERFLOW_SCROLL == display->mOverflow) { + scrollAreaSize.height -= NSToCoordRound(sbHeight); } - //@ Make me a subroutine... // Reflow the child and get its desired size. Let it be as high as it // wants @@ -363,10 +327,9 @@ nsScrollFrame::Reflow(nsIPresContext& aPresContext, ReflowChild(mFirstChild, aPresContext, kidDesiredSize, kidReflowState, aStatus); NS_ASSERTION(NS_FRAME_IS_COMPLETE(aStatus), "bad status"); - // Make sure the scrolled frame fills the entire scroll area along a - // fixed dimension - if ((eHTMLFrameConstraint_Fixed == aReflowState.heightConstraint) || - (eHTMLFrameConstraint_FixedContent == aReflowState.heightConstraint)) { + // Make sure the height of the scrolled frame fills the entire scroll area, + // unless we're shrink wrapping + if (NS_AUTOHEIGHT != aReflowState.computedHeight) { if (kidDesiredSize.height < scrollAreaSize.height) { kidDesiredSize.height = scrollAreaSize.height; @@ -389,11 +352,9 @@ nsScrollFrame::Reflow(nsIPresContext& aPresContext, } } } - if ((eHTMLFrameConstraint_Fixed == aReflowState.widthConstraint) || - (eHTMLFrameConstraint_FixedContent == aReflowState.widthConstraint)) { - if (kidDesiredSize.width < scrollAreaSize.width) { - kidDesiredSize.width = scrollAreaSize.width; - } + // Make sure the width of the scrolled frame fills the entire scroll area + if (kidDesiredSize.width < scrollAreaSize.width) { + kidDesiredSize.width = scrollAreaSize.width; } // Place and size the child. @@ -415,21 +376,16 @@ nsScrollFrame::Reflow(nsIPresContext& aPresContext, } #endif - // Compute our desired size. If our size was fixed then use the fixed size; - // otherwise, shrink wrap around the scrolled frame - if ((eHTMLFrameConstraint_Fixed == aReflowState.widthConstraint) || - (eHTMLFrameConstraint_FixedContent == aReflowState.widthConstraint)) { - aDesiredSize.width = scrollAreaSize.width; - } else { - aDesiredSize.width = kidDesiredSize.width; - } + // Compute our desired size + aDesiredSize.width = scrollAreaSize.width; aDesiredSize.width += border.left + border.right + NSToCoordRound(sbWidth); - - if ((eHTMLFrameConstraint_Fixed == aReflowState.heightConstraint) || - (eHTMLFrameConstraint_FixedContent == aReflowState.heightConstraint)) { - aDesiredSize.height = scrollAreaSize.height; - } else { + + // For the height if we're shrink wrapping then use the child's desired size; + // otherwise, use the scroll area size + if (NS_AUTOHEIGHT == aReflowState.computedHeight) { aDesiredSize.height = kidDesiredSize.height; + } else { + aDesiredSize.height = scrollAreaSize.height; } aDesiredSize.height += border.top + border.bottom; // XXX This should really be "if we have a visible horizontal scrollbar"... diff --git a/mozilla/layout/html/document/src/nsFrameFrame.cpp b/mozilla/layout/html/document/src/nsFrameFrame.cpp index 78e66424804..f399adf3815 100644 --- a/mozilla/layout/html/document/src/nsFrameFrame.cpp +++ b/mozilla/layout/html/document/src/nsFrameFrame.cpp @@ -244,13 +244,13 @@ nsHTMLFrameOuterFrame::GetDesiredSize(nsIPresContext* aPresContext, // XXX this needs to be changed from (200,200) to a better default for inline frames if (aReflowState.HaveFixedContentWidth()) { - aDesiredSize.width = aReflowState.minWidth; + aDesiredSize.width = aReflowState.computedWidth; } else { aDesiredSize.width = NSIntPixelsToTwips(200, p2t); } if (aReflowState.HaveFixedContentHeight()) { - aDesiredSize.height = aReflowState.minHeight; + aDesiredSize.height = aReflowState.computedHeight; } else { aDesiredSize.height = NSIntPixelsToTwips(200, p2t); diff --git a/mozilla/layout/html/forms/src/nsFieldSetFrame.cpp b/mozilla/layout/html/forms/src/nsFieldSetFrame.cpp index 46d9334d9bc..8d9e5d65776 100644 --- a/mozilla/layout/html/forms/src/nsFieldSetFrame.cpp +++ b/mozilla/layout/html/forms/src/nsFieldSetFrame.cpp @@ -276,7 +276,7 @@ nsFieldSetFrame::Reflow(nsIPresContext& aPresContext, legendMargin.left + legendMargin.right; nscoord verTaken = padding.top + borderPadding.bottom + legendMargin.top + legendMargin.bottom; if (aReflowState.HaveFixedContentWidth()) { - availSize.width = aReflowState.minWidth; + availSize.width = aReflowState.computedWidth; } else { if (NS_UNCONSTRAINEDSIZE != availSize.width) @@ -356,8 +356,8 @@ nsFieldSetFrame::Reflow(nsIPresContext& aPresContext, nscoord contentWidth = contentSize.width + borderPadding.left + borderPadding.right; aDesiredSize.width = (legendWidth > contentWidth) ? legendWidth : contentWidth; - if (aReflowState.HaveFixedContentWidth() && (aReflowState.minWidth > aDesiredSize.width)) { - aDesiredSize.width = aReflowState.minWidth; + if (aReflowState.HaveFixedContentWidth() && (aReflowState.computedWidth > aDesiredSize.width)) { + aDesiredSize.width = aReflowState.computedWidth; } // Place the legend @@ -419,8 +419,8 @@ nsFieldSetFrame::Reflow(nsIPresContext& aPresContext, aDesiredSize.height = contentTopOffset + contentSize.height + borderPadding.bottom; if (mInline) // XXX parents don't yet ...... aDesiredSize.height += margin.bottom; - if (aReflowState.HaveFixedContentHeight() && (aReflowState.minHeight > aDesiredSize.height)) { - aDesiredSize.height = aReflowState.minHeight; + if (aReflowState.HaveFixedContentHeight() && (aReflowState.computedHeight > aDesiredSize.height)) { + aDesiredSize.height = aReflowState.computedHeight; } aDesiredSize.ascent = aDesiredSize.height; aDesiredSize.descent = 0; diff --git a/mozilla/layout/html/forms/src/nsFormControlFrame.cpp b/mozilla/layout/html/forms/src/nsFormControlFrame.cpp index d77ae733dbd..863909dcd1e 100644 --- a/mozilla/layout/html/forms/src/nsFormControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsFormControlFrame.cpp @@ -680,13 +680,13 @@ nsFormControlFrame::GetStyleSize(nsIPresContext& aPresContext, nsSize& aSize) { if (aReflowState.HaveFixedContentWidth()) { - aSize.width = aReflowState.minWidth; + aSize.width = aReflowState.computedWidth; } else { aSize.width = CSS_NOTSET; } if (aReflowState.HaveFixedContentHeight()) { - aSize.height = aReflowState.minHeight; + aSize.height = aReflowState.computedHeight; } else { aSize.height = CSS_NOTSET; diff --git a/mozilla/layout/html/forms/src/nsHTMLButtonControlFrame.cpp b/mozilla/layout/html/forms/src/nsHTMLButtonControlFrame.cpp index 64157787f08..1582d3efc79 100644 --- a/mozilla/layout/html/forms/src/nsHTMLButtonControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsHTMLButtonControlFrame.cpp @@ -627,11 +627,11 @@ nsHTMLButtonControlFrame::Reflow(nsIPresContext& aPresContext, } // if we are constrained and the child is smaller, use the constrained values - if (aReflowState.HaveFixedContentWidth() && (aDesiredSize.width < aReflowState.minWidth)) { - aDesiredSize.width = aReflowState.minWidth; + if (aReflowState.HaveFixedContentWidth() && (aDesiredSize.width < aReflowState.computedWidth)) { + aDesiredSize.width = aReflowState.computedWidth; } - if (aReflowState.HaveFixedContentHeight() && (aDesiredSize.height < aReflowState.minHeight)) { - aDesiredSize.height = aReflowState.minHeight; + if (aReflowState.HaveFixedContentHeight() && (aDesiredSize.height < aReflowState.computedHeight)) { + aDesiredSize.height = aReflowState.computedHeight; } aDesiredSize.ascent = aDesiredSize.height; diff --git a/mozilla/layout/html/forms/src/nsLabelFrame.cpp b/mozilla/layout/html/forms/src/nsLabelFrame.cpp index 2296dda40d7..dc4ae35c35e 100644 --- a/mozilla/layout/html/forms/src/nsLabelFrame.cpp +++ b/mozilla/layout/html/forms/src/nsLabelFrame.cpp @@ -449,11 +449,11 @@ nsLabelFrame::Reflow(nsIPresContext& aPresContext, } // if we are constrained and the child is smaller, use the constrained values - if (aReflowState.HaveFixedContentWidth() && (aDesiredSize.width < aReflowState.minWidth)) { - aDesiredSize.width = aReflowState.minWidth; + if (aReflowState.HaveFixedContentWidth() && (aDesiredSize.width < aReflowState.computedWidth)) { + aDesiredSize.width = aReflowState.computedWidth; } - if (aReflowState.HaveFixedContentHeight() && (aDesiredSize.height < aReflowState.minHeight)) { - aDesiredSize.height = aReflowState.minHeight; + if (aReflowState.HaveFixedContentHeight() && (aDesiredSize.height < aReflowState.computedHeight)) { + aDesiredSize.height = aReflowState.computedHeight; } aDesiredSize.ascent = aDesiredSize.height; diff --git a/mozilla/layout/html/forms/src/nsLegendFrame.cpp b/mozilla/layout/html/forms/src/nsLegendFrame.cpp index 5ba65b3730d..868e87b7468 100644 --- a/mozilla/layout/html/forms/src/nsLegendFrame.cpp +++ b/mozilla/layout/html/forms/src/nsLegendFrame.cpp @@ -142,13 +142,13 @@ nsLegendFrame::Reflow(nsIPresContext& aPresContext, // add in our border and padding to the size of the child aDesiredSize.width += borderPadding.left + borderPadding.right; - if (aReflowState.HaveFixedContentWidth() && (aReflowState.minWidth > aDesiredSize.width)) { - aDesiredSize.width = aReflowState.minWidth; + if (aReflowState.HaveFixedContentWidth() && (aReflowState.computedWidth > aDesiredSize.width)) { + aDesiredSize.width = aReflowState.computedWidth; } aDesiredSize.height += borderPadding.top + borderPadding.bottom; - if (aReflowState.HaveFixedContentHeight() && (aReflowState.minHeight > aDesiredSize.height)) { - aDesiredSize.height = aReflowState.minHeight; + if (aReflowState.HaveFixedContentHeight() && (aReflowState.computedHeight > aDesiredSize.height)) { + aDesiredSize.height = aReflowState.computedHeight; } // adjust our max element size, if necessary diff --git a/mozilla/layout/html/table/src/nsTableFrame.cpp b/mozilla/layout/html/table/src/nsTableFrame.cpp index c79d8608df7..e9cbdd0b38f 100644 --- a/mozilla/layout/html/table/src/nsTableFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableFrame.cpp @@ -3698,10 +3698,9 @@ nscoord nsTableFrame::GetEffectiveContainerHeight(const nsHTMLReflowState& aRefl break; } } - if (eHTMLFrameConstraint_Fixed==rs->heightConstraint || - eHTMLFrameConstraint_FixedContent==rs->heightConstraint) + if (NS_AUTOHEIGHT != rs->computedHeight) { - result = rs->maxSize.height; + result = rs->computedHeight; break; } // XXX: evil cast! diff --git a/mozilla/layout/html/table/src/nsTableRowFrame.cpp b/mozilla/layout/html/table/src/nsTableRowFrame.cpp index 27a40ce48cc..35e9a4a5c92 100644 --- a/mozilla/layout/html/table/src/nsTableRowFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableRowFrame.cpp @@ -1280,7 +1280,6 @@ NS_METHOD nsTableRowFrame::IR_TargetIsChild(nsIPresContext& aPresContext, kidReflowState.reason = eReflowReason_Resize; kidReflowState.reflowCommand = nsnull; kidReflowState.maxSize.width = NS_UNCONSTRAINEDSIZE; - kidReflowState.widthConstraint = eHTMLFrameConstraint_Unconstrained; rv = ReflowChild(aNextFrame, aPresContext, desiredSize, kidReflowState, aStatus); if (gsDebug) printf ("TR %p for cell %p Incremental Reflow: desired=%d, MES=%d\n", @@ -1298,7 +1297,6 @@ NS_METHOD nsTableRowFrame::IR_TargetIsChild(nsIPresContext& aPresContext, // Now reflow the cell again this time constraining the width // XXX Ignore for now the possibility that the column width has changed... kidReflowState.maxSize.width = availWidth; - kidReflowState.widthConstraint = eHTMLFrameConstraint_Constrained; rv = ReflowChild(aNextFrame, aPresContext, desiredSize, kidReflowState, aStatus); // Place the child after taking into account it's margin and attributes diff --git a/mozilla/layout/tables/nsTableFrame.cpp b/mozilla/layout/tables/nsTableFrame.cpp index c79d8608df7..e9cbdd0b38f 100644 --- a/mozilla/layout/tables/nsTableFrame.cpp +++ b/mozilla/layout/tables/nsTableFrame.cpp @@ -3698,10 +3698,9 @@ nscoord nsTableFrame::GetEffectiveContainerHeight(const nsHTMLReflowState& aRefl break; } } - if (eHTMLFrameConstraint_Fixed==rs->heightConstraint || - eHTMLFrameConstraint_FixedContent==rs->heightConstraint) + if (NS_AUTOHEIGHT != rs->computedHeight) { - result = rs->maxSize.height; + result = rs->computedHeight; break; } // XXX: evil cast! diff --git a/mozilla/layout/tables/nsTableRowFrame.cpp b/mozilla/layout/tables/nsTableRowFrame.cpp index 27a40ce48cc..35e9a4a5c92 100644 --- a/mozilla/layout/tables/nsTableRowFrame.cpp +++ b/mozilla/layout/tables/nsTableRowFrame.cpp @@ -1280,7 +1280,6 @@ NS_METHOD nsTableRowFrame::IR_TargetIsChild(nsIPresContext& aPresContext, kidReflowState.reason = eReflowReason_Resize; kidReflowState.reflowCommand = nsnull; kidReflowState.maxSize.width = NS_UNCONSTRAINEDSIZE; - kidReflowState.widthConstraint = eHTMLFrameConstraint_Unconstrained; rv = ReflowChild(aNextFrame, aPresContext, desiredSize, kidReflowState, aStatus); if (gsDebug) printf ("TR %p for cell %p Incremental Reflow: desired=%d, MES=%d\n", @@ -1298,7 +1297,6 @@ NS_METHOD nsTableRowFrame::IR_TargetIsChild(nsIPresContext& aPresContext, // Now reflow the cell again this time constraining the width // XXX Ignore for now the possibility that the column width has changed... kidReflowState.maxSize.width = availWidth; - kidReflowState.widthConstraint = eHTMLFrameConstraint_Constrained; rv = ReflowChild(aNextFrame, aPresContext, desiredSize, kidReflowState, aStatus); // Place the child after taking into account it's margin and attributes