From 5cdd7daa801f4cf55bc52595ba598a5afb11b5af Mon Sep 17 00:00:00 2001 From: "kipp%netscape.com" Date: Wed, 14 Jul 1999 17:26:12 +0000 Subject: [PATCH] Tweaked area frame shrink wrapping for bug #5999 git-svn-id: svn://10.0.0.236/trunk@39297 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/generic/nsAreaFrame.cpp | 35 +++++++++++++------- mozilla/layout/generic/nsHTMLParts.h | 10 +++--- mozilla/layout/html/base/src/nsAreaFrame.cpp | 35 +++++++++++++------- mozilla/layout/html/base/src/nsHTMLParts.h | 10 +++--- 4 files changed, 56 insertions(+), 34 deletions(-) diff --git a/mozilla/layout/generic/nsAreaFrame.cpp b/mozilla/layout/generic/nsAreaFrame.cpp index 519158a7be8..b23b120184a 100644 --- a/mozilla/layout/generic/nsAreaFrame.cpp +++ b/mozilla/layout/generic/nsAreaFrame.cpp @@ -30,6 +30,8 @@ #include "nsHTMLParts.h" #include "nsLayoutAtoms.h" +#undef NOISY_MAX_ELEMENT_SIZE + static NS_DEFINE_IID(kAreaFrameIID, NS_IAREAFRAME_IID); nsresult @@ -291,21 +293,30 @@ nsAreaFrame::Reflow(nsIPresContext& aPresContext, rv = mAbsoluteContainer.Reflow(aPresContext, aReflowState); } - // Compute our desired size taking into account floaters and child frames - // that stick outside our box. Note that if this frame has a height specified - // by CSS then we don't do this - if ((mFlags & NS_AREA_WRAP_HEIGHT) && - (NS_UNCONSTRAINEDSIZE == aReflowState.computedHeight) && - (NS_FRAME_OUTSIDE_CHILDREN & mState)) { - nscoord contentYMost = aDesiredSize.height; - nscoord yMost = aDesiredSize.mCombinedArea.YMost(); - if (yMost > contentYMost) { - // retain the border+padding for this element after the bottom - // most object. - aDesiredSize.height = yMost; + if (mFlags & NS_AREA_WRAP_SIZE) { + // When the area frame is supposed to wrap around all in-flow + // children, make sure its big enough to include those that stick + // outside the box. + if (NS_FRAME_OUTSIDE_CHILDREN & mState) { + nscoord xMost = aDesiredSize.mCombinedArea.XMost(); + if (xMost > aDesiredSize.width) { + aDesiredSize.width = xMost; + } + nscoord yMost = aDesiredSize.mCombinedArea.YMost(); + if (yMost > aDesiredSize.height) { + aDesiredSize.height = yMost; + } } } +#ifdef NOISY_MAX_ELEMENT_SIZE + ListTag(stdout); + printf(": maxElementSize=%d,%d desiredSize=%d,%d\n", + aDesiredSize.maxElementSize ? aDesiredSize.maxElementSize->width : 0, + aDesiredSize.maxElementSize ? aDesiredSize.maxElementSize->height : 0, + aDesiredSize.width, aDesiredSize.height); +#endif + // If we have children that stick outside our box, then remember the // combined area, because we'll need it later when sizing our view if (mState & NS_FRAME_OUTSIDE_CHILDREN) { diff --git a/mozilla/layout/generic/nsHTMLParts.h b/mozilla/layout/generic/nsHTMLParts.h index 1bb8d3ddaf9..f8d2b73a0e6 100644 --- a/mozilla/layout/generic/nsHTMLParts.h +++ b/mozilla/layout/generic/nsHTMLParts.h @@ -245,19 +245,19 @@ NS_CreateHTMLElement(nsIHTMLContent** aResult, #define NS_BLOCK_MARGIN_ROOT 0x4 #define NS_BLOCK_DOCUMENT_ROOT 0x8 #define NS_AREA_NO_SPACE_MGR 0x10 -#define NS_AREA_WRAP_HEIGHT 0x20 +#define NS_AREA_WRAP_SIZE 0x20 // Create a basic area frame. By default, area frames will extend // their height to cover any children that "stick out". extern nsresult NS_NewAreaFrame(nsIFrame** aNewFrame, - PRUint32 aFlags = NS_AREA_WRAP_HEIGHT); + PRUint32 aFlags = NS_AREA_WRAP_SIZE); // These AreaFrame's shrink wrap around their contents inline nsresult NS_NewTableCellInnerFrame(nsIFrame** aNewFrame) { - return NS_NewAreaFrame(aNewFrame, NS_AREA_WRAP_HEIGHT); + return NS_NewAreaFrame(aNewFrame, NS_AREA_WRAP_SIZE); } inline nsresult NS_NewTableCaptionFrame(nsIFrame** aNewFrame) { - return NS_NewAreaFrame(aNewFrame, NS_AREA_WRAP_HEIGHT); + return NS_NewAreaFrame(aNewFrame, NS_AREA_WRAP_SIZE); } // This type of AreaFrame is the document root and is a margin root for @@ -273,7 +273,7 @@ inline nsresult NS_NewAbsoluteItemWrapperFrame(nsIFrame** aNewFrame) { // This type of AreaFrame shrink wraps inline nsresult NS_NewFloatingItemWrapperFrame(nsIFrame** aNewFrame) { - return NS_NewAreaFrame(aNewFrame, NS_AREA_WRAP_HEIGHT|NS_BLOCK_SHRINK_WRAP); + return NS_NewAreaFrame(aNewFrame, NS_AREA_WRAP_SIZE|NS_BLOCK_SHRINK_WRAP); } // This type of AreaFrame doesn't use its own space manager and diff --git a/mozilla/layout/html/base/src/nsAreaFrame.cpp b/mozilla/layout/html/base/src/nsAreaFrame.cpp index 519158a7be8..b23b120184a 100644 --- a/mozilla/layout/html/base/src/nsAreaFrame.cpp +++ b/mozilla/layout/html/base/src/nsAreaFrame.cpp @@ -30,6 +30,8 @@ #include "nsHTMLParts.h" #include "nsLayoutAtoms.h" +#undef NOISY_MAX_ELEMENT_SIZE + static NS_DEFINE_IID(kAreaFrameIID, NS_IAREAFRAME_IID); nsresult @@ -291,21 +293,30 @@ nsAreaFrame::Reflow(nsIPresContext& aPresContext, rv = mAbsoluteContainer.Reflow(aPresContext, aReflowState); } - // Compute our desired size taking into account floaters and child frames - // that stick outside our box. Note that if this frame has a height specified - // by CSS then we don't do this - if ((mFlags & NS_AREA_WRAP_HEIGHT) && - (NS_UNCONSTRAINEDSIZE == aReflowState.computedHeight) && - (NS_FRAME_OUTSIDE_CHILDREN & mState)) { - nscoord contentYMost = aDesiredSize.height; - nscoord yMost = aDesiredSize.mCombinedArea.YMost(); - if (yMost > contentYMost) { - // retain the border+padding for this element after the bottom - // most object. - aDesiredSize.height = yMost; + if (mFlags & NS_AREA_WRAP_SIZE) { + // When the area frame is supposed to wrap around all in-flow + // children, make sure its big enough to include those that stick + // outside the box. + if (NS_FRAME_OUTSIDE_CHILDREN & mState) { + nscoord xMost = aDesiredSize.mCombinedArea.XMost(); + if (xMost > aDesiredSize.width) { + aDesiredSize.width = xMost; + } + nscoord yMost = aDesiredSize.mCombinedArea.YMost(); + if (yMost > aDesiredSize.height) { + aDesiredSize.height = yMost; + } } } +#ifdef NOISY_MAX_ELEMENT_SIZE + ListTag(stdout); + printf(": maxElementSize=%d,%d desiredSize=%d,%d\n", + aDesiredSize.maxElementSize ? aDesiredSize.maxElementSize->width : 0, + aDesiredSize.maxElementSize ? aDesiredSize.maxElementSize->height : 0, + aDesiredSize.width, aDesiredSize.height); +#endif + // If we have children that stick outside our box, then remember the // combined area, because we'll need it later when sizing our view if (mState & NS_FRAME_OUTSIDE_CHILDREN) { diff --git a/mozilla/layout/html/base/src/nsHTMLParts.h b/mozilla/layout/html/base/src/nsHTMLParts.h index 1bb8d3ddaf9..f8d2b73a0e6 100644 --- a/mozilla/layout/html/base/src/nsHTMLParts.h +++ b/mozilla/layout/html/base/src/nsHTMLParts.h @@ -245,19 +245,19 @@ NS_CreateHTMLElement(nsIHTMLContent** aResult, #define NS_BLOCK_MARGIN_ROOT 0x4 #define NS_BLOCK_DOCUMENT_ROOT 0x8 #define NS_AREA_NO_SPACE_MGR 0x10 -#define NS_AREA_WRAP_HEIGHT 0x20 +#define NS_AREA_WRAP_SIZE 0x20 // Create a basic area frame. By default, area frames will extend // their height to cover any children that "stick out". extern nsresult NS_NewAreaFrame(nsIFrame** aNewFrame, - PRUint32 aFlags = NS_AREA_WRAP_HEIGHT); + PRUint32 aFlags = NS_AREA_WRAP_SIZE); // These AreaFrame's shrink wrap around their contents inline nsresult NS_NewTableCellInnerFrame(nsIFrame** aNewFrame) { - return NS_NewAreaFrame(aNewFrame, NS_AREA_WRAP_HEIGHT); + return NS_NewAreaFrame(aNewFrame, NS_AREA_WRAP_SIZE); } inline nsresult NS_NewTableCaptionFrame(nsIFrame** aNewFrame) { - return NS_NewAreaFrame(aNewFrame, NS_AREA_WRAP_HEIGHT); + return NS_NewAreaFrame(aNewFrame, NS_AREA_WRAP_SIZE); } // This type of AreaFrame is the document root and is a margin root for @@ -273,7 +273,7 @@ inline nsresult NS_NewAbsoluteItemWrapperFrame(nsIFrame** aNewFrame) { // This type of AreaFrame shrink wraps inline nsresult NS_NewFloatingItemWrapperFrame(nsIFrame** aNewFrame) { - return NS_NewAreaFrame(aNewFrame, NS_AREA_WRAP_HEIGHT|NS_BLOCK_SHRINK_WRAP); + return NS_NewAreaFrame(aNewFrame, NS_AREA_WRAP_SIZE|NS_BLOCK_SHRINK_WRAP); } // This type of AreaFrame doesn't use its own space manager and