From 2ad00a5912372209dc2d5910a23c21589f9c91ef Mon Sep 17 00:00:00 2001 From: kipp Date: Thu, 25 Jun 1998 23:09:04 +0000 Subject: [PATCH] Added code to giving floating children a width to reflow into when they don't specify one themselves --- layout/css/layout/src/nsCSSBlockFrame.cpp | 25 ++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/layout/css/layout/src/nsCSSBlockFrame.cpp b/layout/css/layout/src/nsCSSBlockFrame.cpp index 7baedecf092b..60e9d292c351 100644 --- a/layout/css/layout/src/nsCSSBlockFrame.cpp +++ b/layout/css/layout/src/nsCSSBlockFrame.cpp @@ -2540,7 +2540,7 @@ nsCSSBlockFrame::ReflowFloater(nsIPresContext* aPresContext, //XXX fix_me: use the values already stored in the nsCSSBlockReflowState // Compute the available space for the floater. Use the default // 'auto' width and height values - nsSize kidAvailSize(0, NS_UNCONSTRAINEDSIZE); + nsSize kidAvailSize; nsSize styleSize; PRIntn styleSizeFlags = nsCSSLayout::GetStyleSize(aPresContext, aState, styleSize); @@ -2550,9 +2550,32 @@ nsCSSBlockFrame::ReflowFloater(nsIPresContext* aPresContext, if (styleSizeFlags & NS_SIZE_HAS_WIDTH) { kidAvailSize.width = styleSize.width; } + else { + // If we are floating something and we don't know the width then + // find a maximum width for it to reflow into. + + // XXX if the child is a block (instead of a table, say) then this + // will do the wrong thing. A better choice would be + // NS_UNCONSTRAINEDSIZE, but that has special meaning to tables. + const nsReflowState* rsp = &aState; + kidAvailSize.width = 0; + while (nsnull != rsp) { + if ((0 != rsp->maxSize.width) && + (NS_UNCONSTRAINEDSIZE != rsp->maxSize.width)) { + kidAvailSize.width = rsp->maxSize.width; + break; + } + rsp = rsp->parentReflowState; + } + NS_ASSERTION(0 != kidAvailSize.width, "no width for block found"); + } + if (styleSizeFlags & NS_SIZE_HAS_HEIGHT) { kidAvailSize.height = styleSize.height; } + else { + kidAvailSize.width = NS_UNCONSTRAINEDSIZE; + } // Resize reflow the anchored item into the available space // XXX Check for complete?