From dc4362fa13b396fba0c4c294658e0d3e71b55df0 Mon Sep 17 00:00:00 2001 From: "kipp%netscape.com" Date: Tue, 29 Sep 1998 03:44:25 +0000 Subject: [PATCH] Changed factory method to parameterize the shrink wrapping behavior --- content/html/style/src/nsHTMLStyleSheet.cpp | 6 +-- layout/generic/nsBlockFrame.cpp | 22 ++++++-- layout/generic/nsBlockReflowState.cpp | 22 ++++++-- layout/generic/nsBlockReflowState.h | 22 ++++++-- layout/generic/nsHTMLContainerFrame.cpp | 4 +- layout/generic/nsHTMLParts.h | 4 +- layout/html/base/src/nsBlockFrame.cpp | 22 ++++++-- layout/html/base/src/nsBlockReflowState.cpp | 22 ++++++-- layout/html/base/src/nsBlockReflowState.h | 22 ++++++-- layout/html/base/src/nsBodyFrame.cpp | 51 +++++++------------ layout/html/base/src/nsBodyFrame.h | 13 ++--- layout/html/base/src/nsHTMLContainerFrame.cpp | 4 +- layout/html/base/src/nsHTMLParts.h | 4 +- layout/html/style/src/nsHTMLStyleSheet.cpp | 6 +-- layout/html/table/src/nsTableCellFrame.cpp | 4 +- layout/style/nsHTMLStyleSheet.cpp | 6 +-- layout/tables/nsTableCellFrame.cpp | 4 +- 17 files changed, 147 insertions(+), 91 deletions(-) diff --git a/content/html/style/src/nsHTMLStyleSheet.cpp b/content/html/style/src/nsHTMLStyleSheet.cpp index 99adcef6ea8..c4322b21bf4 100644 --- a/content/html/style/src/nsHTMLStyleSheet.cpp +++ b/content/html/style/src/nsHTMLStyleSheet.cpp @@ -1047,7 +1047,7 @@ HTMLStyleSheetImpl::ConstructTableFrame(nsIPresContext* aPresContext, case NS_STYLE_DISPLAY_TABLE_CAPTION: // Have we already created a caption? If so, ignore this caption if (nsnull == captionFrame) { - NS_NewBodyFrame(childContent, aNewFrame, captionFrame); + NS_NewBodyFrame(childContent, aNewFrame, captionFrame, PR_FALSE); captionFrame->SetStyleContext(aPresContext, childStyleContext); // Process the caption's child content and initialize it nsIFrame* captionChildList; @@ -1206,7 +1206,7 @@ HTMLStyleSheetImpl::ConstructFrameByTag(nsIPresContext* aPresContext, // processChildren = PR_TRUE; } else if (nsHTMLAtoms::body == aTag) { - rv = NS_NewBodyFrame(aContent, aParentFrame, aNewFrame); + rv = NS_NewBodyFrame(aContent, aParentFrame, aNewFrame, PR_TRUE); processChildren = PR_TRUE; } else if (nsHTMLAtoms::form == aTag) { @@ -1260,7 +1260,7 @@ HTMLStyleSheetImpl::ConstructFrameByDisplayType(nsIPresContext* aPresContext, switch (styleDisplay->mDisplay) { case NS_STYLE_DISPLAY_BLOCK: case NS_STYLE_DISPLAY_LIST_ITEM: - rv = NS_NewBlockFrame(aContent, aParentFrame, aNewFrame); + rv = NS_NewBlockFrame(aContent, aParentFrame, aNewFrame, PR_FALSE); processChildren = PR_TRUE; break; diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp index dbdf36adfc6..e993056f48a 100644 --- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -280,6 +280,10 @@ public: virtual PRBool DeleteChildsNextInFlow(nsIPresContext& aPresContext, nsIFrame* aNextInFlow); + void SetShrinkWrap(PRBool aShrinkWrap) { + mShrinkWrap = aShrinkWrap; + } + PRBool DrainOverflowLines(); PRBool RemoveChild(LineData* aLines, nsIFrame* aChild); @@ -378,6 +382,11 @@ public: // For list-item frames, this is the bullet frame. BulletFrame* mBullet; + + // If true then this frame doesn't act like css says, instead it + // shrink wraps around its contents instead of filling out to its + // parents size. + PRBool mShrinkWrap; }; //---------------------------------------------------------------------- @@ -1420,12 +1429,14 @@ nsBlockReflowState::GetAvailableSpace() nsresult NS_NewBlockFrame(nsIContent* aContent, nsIFrame* aParentFrame, - nsIFrame*& aNewFrame) + nsIFrame*& aNewFrame, PRBool aShrinkWrap) { - aNewFrame = new nsBlockFrame(aContent, aParentFrame); - if (nsnull == aNewFrame) { + nsBlockFrame* it = new nsBlockFrame(aContent, aParentFrame); + if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } + aNewFrame = it; + it->SetShrinkWrap(aShrinkWrap); return NS_OK; } @@ -1855,9 +1866,10 @@ nsBlockFrame::ComputeFinalSize(nsBlockReflowState& aState, } else { // There are two options here. We either shrink wrap around our - // contents or we fluff out to the maximum available width. + // contents or we fluff out to the maximum available width. Note: + // We always shrink wrap when given an unconstrained width. nscoord contentWidth = aState.mKidXMost + aState.mBorderPadding.right; - if (!aState.mUnconstrainedWidth) { + if (!mShrinkWrap && !aState.mUnconstrainedWidth) { // Fluff out to the max width if we aren't already that wide if (contentWidth < aState.maxSize.width) { contentWidth = aState.maxSize.width; diff --git a/layout/generic/nsBlockReflowState.cpp b/layout/generic/nsBlockReflowState.cpp index dbdf36adfc6..e993056f48a 100644 --- a/layout/generic/nsBlockReflowState.cpp +++ b/layout/generic/nsBlockReflowState.cpp @@ -280,6 +280,10 @@ public: virtual PRBool DeleteChildsNextInFlow(nsIPresContext& aPresContext, nsIFrame* aNextInFlow); + void SetShrinkWrap(PRBool aShrinkWrap) { + mShrinkWrap = aShrinkWrap; + } + PRBool DrainOverflowLines(); PRBool RemoveChild(LineData* aLines, nsIFrame* aChild); @@ -378,6 +382,11 @@ public: // For list-item frames, this is the bullet frame. BulletFrame* mBullet; + + // If true then this frame doesn't act like css says, instead it + // shrink wraps around its contents instead of filling out to its + // parents size. + PRBool mShrinkWrap; }; //---------------------------------------------------------------------- @@ -1420,12 +1429,14 @@ nsBlockReflowState::GetAvailableSpace() nsresult NS_NewBlockFrame(nsIContent* aContent, nsIFrame* aParentFrame, - nsIFrame*& aNewFrame) + nsIFrame*& aNewFrame, PRBool aShrinkWrap) { - aNewFrame = new nsBlockFrame(aContent, aParentFrame); - if (nsnull == aNewFrame) { + nsBlockFrame* it = new nsBlockFrame(aContent, aParentFrame); + if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } + aNewFrame = it; + it->SetShrinkWrap(aShrinkWrap); return NS_OK; } @@ -1855,9 +1866,10 @@ nsBlockFrame::ComputeFinalSize(nsBlockReflowState& aState, } else { // There are two options here. We either shrink wrap around our - // contents or we fluff out to the maximum available width. + // contents or we fluff out to the maximum available width. Note: + // We always shrink wrap when given an unconstrained width. nscoord contentWidth = aState.mKidXMost + aState.mBorderPadding.right; - if (!aState.mUnconstrainedWidth) { + if (!mShrinkWrap && !aState.mUnconstrainedWidth) { // Fluff out to the max width if we aren't already that wide if (contentWidth < aState.maxSize.width) { contentWidth = aState.maxSize.width; diff --git a/layout/generic/nsBlockReflowState.h b/layout/generic/nsBlockReflowState.h index dbdf36adfc6..e993056f48a 100644 --- a/layout/generic/nsBlockReflowState.h +++ b/layout/generic/nsBlockReflowState.h @@ -280,6 +280,10 @@ public: virtual PRBool DeleteChildsNextInFlow(nsIPresContext& aPresContext, nsIFrame* aNextInFlow); + void SetShrinkWrap(PRBool aShrinkWrap) { + mShrinkWrap = aShrinkWrap; + } + PRBool DrainOverflowLines(); PRBool RemoveChild(LineData* aLines, nsIFrame* aChild); @@ -378,6 +382,11 @@ public: // For list-item frames, this is the bullet frame. BulletFrame* mBullet; + + // If true then this frame doesn't act like css says, instead it + // shrink wraps around its contents instead of filling out to its + // parents size. + PRBool mShrinkWrap; }; //---------------------------------------------------------------------- @@ -1420,12 +1429,14 @@ nsBlockReflowState::GetAvailableSpace() nsresult NS_NewBlockFrame(nsIContent* aContent, nsIFrame* aParentFrame, - nsIFrame*& aNewFrame) + nsIFrame*& aNewFrame, PRBool aShrinkWrap) { - aNewFrame = new nsBlockFrame(aContent, aParentFrame); - if (nsnull == aNewFrame) { + nsBlockFrame* it = new nsBlockFrame(aContent, aParentFrame); + if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } + aNewFrame = it; + it->SetShrinkWrap(aShrinkWrap); return NS_OK; } @@ -1855,9 +1866,10 @@ nsBlockFrame::ComputeFinalSize(nsBlockReflowState& aState, } else { // There are two options here. We either shrink wrap around our - // contents or we fluff out to the maximum available width. + // contents or we fluff out to the maximum available width. Note: + // We always shrink wrap when given an unconstrained width. nscoord contentWidth = aState.mKidXMost + aState.mBorderPadding.right; - if (!aState.mUnconstrainedWidth) { + if (!mShrinkWrap && !aState.mUnconstrainedWidth) { // Fluff out to the max width if we aren't already that wide if (contentWidth < aState.maxSize.width) { contentWidth = aState.maxSize.width; diff --git a/layout/generic/nsHTMLContainerFrame.cpp b/layout/generic/nsHTMLContainerFrame.cpp index 6688541e0a6..2b2a1d606d4 100644 --- a/layout/generic/nsHTMLContainerFrame.cpp +++ b/layout/generic/nsHTMLContainerFrame.cpp @@ -194,7 +194,7 @@ nsHTMLContainerFrame::CreateWrapperFrame(nsIPresContext& aPresContext, content->CanContainChildren(isContainer); if (isContainer) { // Wrap the floated element in a BODY frame. - NS_NewBodyFrame(content, this, aWrapperFrame); + NS_NewBodyFrame(content, this, aWrapperFrame, PR_FALSE); // The body wrapper frame gets the original style context, and the floated // frame gets a pseudo style context @@ -363,7 +363,7 @@ nsHTMLContainerFrame::WrapFrames(nsIPresContext& aPresContext, if (isContainer) { // Wrap the floated element in a BODY frame. nsIFrame* wrapperFrame; - rv = NS_NewBodyFrame(content, this, wrapperFrame); + rv = NS_NewBodyFrame(content, this, wrapperFrame, PR_FALSE); if (NS_OK != rv) { return rv; } diff --git a/layout/generic/nsHTMLParts.h b/layout/generic/nsHTMLParts.h index 886a065c64e..92de130da52 100644 --- a/layout/generic/nsHTMLParts.h +++ b/layout/generic/nsHTMLParts.h @@ -244,11 +244,11 @@ NS_NewBRFrame(nsIContent* aContent, nsIFrame* aParentFrame, extern nsresult NS_NewBodyFrame(nsIContent* aContent, nsIFrame* aParentFrame, - nsIFrame*& aNewFrame); + nsIFrame*& aNewFrame, PRBool aIsTopLevel); extern nsresult NS_NewBlockFrame(nsIContent* aContent, nsIFrame* aParentFrame, - nsIFrame*& aNewFrame); + nsIFrame*& aNewFrame, PRBool aShrinkWrap); extern nsresult NS_NewCommentFrame(nsIContent* aContent, nsIFrame* aParentFrame, diff --git a/layout/html/base/src/nsBlockFrame.cpp b/layout/html/base/src/nsBlockFrame.cpp index dbdf36adfc6..e993056f48a 100644 --- a/layout/html/base/src/nsBlockFrame.cpp +++ b/layout/html/base/src/nsBlockFrame.cpp @@ -280,6 +280,10 @@ public: virtual PRBool DeleteChildsNextInFlow(nsIPresContext& aPresContext, nsIFrame* aNextInFlow); + void SetShrinkWrap(PRBool aShrinkWrap) { + mShrinkWrap = aShrinkWrap; + } + PRBool DrainOverflowLines(); PRBool RemoveChild(LineData* aLines, nsIFrame* aChild); @@ -378,6 +382,11 @@ public: // For list-item frames, this is the bullet frame. BulletFrame* mBullet; + + // If true then this frame doesn't act like css says, instead it + // shrink wraps around its contents instead of filling out to its + // parents size. + PRBool mShrinkWrap; }; //---------------------------------------------------------------------- @@ -1420,12 +1429,14 @@ nsBlockReflowState::GetAvailableSpace() nsresult NS_NewBlockFrame(nsIContent* aContent, nsIFrame* aParentFrame, - nsIFrame*& aNewFrame) + nsIFrame*& aNewFrame, PRBool aShrinkWrap) { - aNewFrame = new nsBlockFrame(aContent, aParentFrame); - if (nsnull == aNewFrame) { + nsBlockFrame* it = new nsBlockFrame(aContent, aParentFrame); + if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } + aNewFrame = it; + it->SetShrinkWrap(aShrinkWrap); return NS_OK; } @@ -1855,9 +1866,10 @@ nsBlockFrame::ComputeFinalSize(nsBlockReflowState& aState, } else { // There are two options here. We either shrink wrap around our - // contents or we fluff out to the maximum available width. + // contents or we fluff out to the maximum available width. Note: + // We always shrink wrap when given an unconstrained width. nscoord contentWidth = aState.mKidXMost + aState.mBorderPadding.right; - if (!aState.mUnconstrainedWidth) { + if (!mShrinkWrap && !aState.mUnconstrainedWidth) { // Fluff out to the max width if we aren't already that wide if (contentWidth < aState.maxSize.width) { contentWidth = aState.maxSize.width; diff --git a/layout/html/base/src/nsBlockReflowState.cpp b/layout/html/base/src/nsBlockReflowState.cpp index dbdf36adfc6..e993056f48a 100644 --- a/layout/html/base/src/nsBlockReflowState.cpp +++ b/layout/html/base/src/nsBlockReflowState.cpp @@ -280,6 +280,10 @@ public: virtual PRBool DeleteChildsNextInFlow(nsIPresContext& aPresContext, nsIFrame* aNextInFlow); + void SetShrinkWrap(PRBool aShrinkWrap) { + mShrinkWrap = aShrinkWrap; + } + PRBool DrainOverflowLines(); PRBool RemoveChild(LineData* aLines, nsIFrame* aChild); @@ -378,6 +382,11 @@ public: // For list-item frames, this is the bullet frame. BulletFrame* mBullet; + + // If true then this frame doesn't act like css says, instead it + // shrink wraps around its contents instead of filling out to its + // parents size. + PRBool mShrinkWrap; }; //---------------------------------------------------------------------- @@ -1420,12 +1429,14 @@ nsBlockReflowState::GetAvailableSpace() nsresult NS_NewBlockFrame(nsIContent* aContent, nsIFrame* aParentFrame, - nsIFrame*& aNewFrame) + nsIFrame*& aNewFrame, PRBool aShrinkWrap) { - aNewFrame = new nsBlockFrame(aContent, aParentFrame); - if (nsnull == aNewFrame) { + nsBlockFrame* it = new nsBlockFrame(aContent, aParentFrame); + if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } + aNewFrame = it; + it->SetShrinkWrap(aShrinkWrap); return NS_OK; } @@ -1855,9 +1866,10 @@ nsBlockFrame::ComputeFinalSize(nsBlockReflowState& aState, } else { // There are two options here. We either shrink wrap around our - // contents or we fluff out to the maximum available width. + // contents or we fluff out to the maximum available width. Note: + // We always shrink wrap when given an unconstrained width. nscoord contentWidth = aState.mKidXMost + aState.mBorderPadding.right; - if (!aState.mUnconstrainedWidth) { + if (!mShrinkWrap && !aState.mUnconstrainedWidth) { // Fluff out to the max width if we aren't already that wide if (contentWidth < aState.maxSize.width) { contentWidth = aState.maxSize.width; diff --git a/layout/html/base/src/nsBlockReflowState.h b/layout/html/base/src/nsBlockReflowState.h index dbdf36adfc6..e993056f48a 100644 --- a/layout/html/base/src/nsBlockReflowState.h +++ b/layout/html/base/src/nsBlockReflowState.h @@ -280,6 +280,10 @@ public: virtual PRBool DeleteChildsNextInFlow(nsIPresContext& aPresContext, nsIFrame* aNextInFlow); + void SetShrinkWrap(PRBool aShrinkWrap) { + mShrinkWrap = aShrinkWrap; + } + PRBool DrainOverflowLines(); PRBool RemoveChild(LineData* aLines, nsIFrame* aChild); @@ -378,6 +382,11 @@ public: // For list-item frames, this is the bullet frame. BulletFrame* mBullet; + + // If true then this frame doesn't act like css says, instead it + // shrink wraps around its contents instead of filling out to its + // parents size. + PRBool mShrinkWrap; }; //---------------------------------------------------------------------- @@ -1420,12 +1429,14 @@ nsBlockReflowState::GetAvailableSpace() nsresult NS_NewBlockFrame(nsIContent* aContent, nsIFrame* aParentFrame, - nsIFrame*& aNewFrame) + nsIFrame*& aNewFrame, PRBool aShrinkWrap) { - aNewFrame = new nsBlockFrame(aContent, aParentFrame); - if (nsnull == aNewFrame) { + nsBlockFrame* it = new nsBlockFrame(aContent, aParentFrame); + if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } + aNewFrame = it; + it->SetShrinkWrap(aShrinkWrap); return NS_OK; } @@ -1855,9 +1866,10 @@ nsBlockFrame::ComputeFinalSize(nsBlockReflowState& aState, } else { // There are two options here. We either shrink wrap around our - // contents or we fluff out to the maximum available width. + // contents or we fluff out to the maximum available width. Note: + // We always shrink wrap when given an unconstrained width. nscoord contentWidth = aState.mKidXMost + aState.mBorderPadding.right; - if (!aState.mUnconstrainedWidth) { + if (!mShrinkWrap && !aState.mUnconstrainedWidth) { // Fluff out to the max width if we aren't already that wide if (contentWidth < aState.maxSize.width) { contentWidth = aState.maxSize.width; diff --git a/layout/html/base/src/nsBodyFrame.cpp b/layout/html/base/src/nsBodyFrame.cpp index 18e85a7248b..f972e98c455 100644 --- a/layout/html/base/src/nsBodyFrame.cpp +++ b/layout/html/base/src/nsBodyFrame.cpp @@ -41,39 +41,21 @@ static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID); nsresult -NS_NewBodyFrame(nsIContent* aContent, nsIFrame* aParent, nsIFrame*& aResult) +NS_NewBodyFrame(nsIContent* aContent, nsIFrame* aParent, nsIFrame*& aResult, + PRBool aIsTopLevel) { - nsIFrame* it = new nsBodyFrame(aContent, aParent); + nsBodyFrame* it = new nsBodyFrame(aContent, aParent); if (nsnull == it) { return NS_ERROR_OUT_OF_MEMORY; } + it->SetIsTopLevel(aIsTopLevel); aResult = it; return NS_OK; } -// XXX FIX ME... -// Returns true if this frame is being used a pseudo frame -PRBool nsBodyFrame::IsPseudoFrame() const -{ - PRBool result = PR_FALSE; - - if (nsnull != mGeometricParent) { - nsIContent* parentContent; - - mGeometricParent->GetContent(parentContent); - if (parentContent == mContent) { - result = PR_TRUE; - } - NS_RELEASE(parentContent); - } - - return result; -} - nsBodyFrame::nsBodyFrame(nsIContent* aContent, nsIFrame* aParentFrame) : nsHTMLContainerFrame(aContent, aParentFrame) { - mIsPseudoFrame = IsPseudoFrame(); mSpaceManager = new nsSpaceManager(this); NS_ADDREF(mSpaceManager); } @@ -111,7 +93,7 @@ NS_IMETHODIMP nsBodyFrame::Init(nsIPresContext& aPresContext, nsIFrame* aChildList) { // Create a block frame and set its style context - nsresult rv = NS_NewBlockFrame(mContent, this, mFirstChild); + nsresult rv = NS_NewBlockFrame(mContent, this, mFirstChild, !mIsTopLevel); if (NS_OK != rv) { return rv; } @@ -250,7 +232,7 @@ nsBodyFrame::Reflow(nsIPresContext& aPresContext, mySpacing->CalcBorderPaddingFor(this, borderPadding); // Compute the child frame's max size - nsSize kidMaxSize = GetColumnAvailSpace(&aPresContext, borderPadding, + nsSize kidMaxSize = GetColumnAvailSpace(aPresContext, borderPadding, rsp->maxSize); mSpaceManager->Translate(borderPadding.left, borderPadding.top); @@ -350,7 +332,7 @@ nsBodyFrame::Reflow(nsIPresContext& aPresContext, } // Now force a repaint of the damage area - if (!mIsPseudoFrame && !damageArea.IsEmpty()) { + if (mIsTopLevel && !damageArea.IsEmpty()) { Invalidate(damageArea); } @@ -403,7 +385,7 @@ AddToPadding(nsIPresContext* aPresContext, NS_METHOD nsBodyFrame::DidSetStyleContext(nsIPresContext* aPresContext) { - if (mIsPseudoFrame) { + if (!mIsTopLevel) { return NS_OK; } @@ -486,15 +468,16 @@ nsBodyFrame::DidSetStyleContext(nsIPresContext* aPresContext) ///////////////////////////////////////////////////////////////////////////// // Helper functions -nsSize nsBodyFrame::GetColumnAvailSpace(nsIPresContext* aPresContext, - const nsMargin& aBorderPadding, - const nsSize& aMaxSize) +nsSize +nsBodyFrame::GetColumnAvailSpace(nsIPresContext& aPresContext, + const nsMargin& aBorderPadding, + const nsSize& aMaxSize) { nsSize result(aMaxSize); - // If we're not being used as a pseudo frame then make adjustments + // If we are being used as a top-level frame then make adjustments // for border/padding and a vertical scrollbar - if (!mIsPseudoFrame) { + if (mIsTopLevel) { // If our width is constrained then subtract for the border/padding if (aMaxSize.width != NS_UNCONSTRAINEDSIZE) { result.width -= aBorderPadding.left + @@ -549,7 +532,7 @@ nsBodyFrame::ComputeDesiredSize(nsIPresContext& aPresContext, width = styleSize.width + aBorderPadding.left + aBorderPadding.right; } else { - if (!mIsPseudoFrame) { + if (mIsTopLevel) { // Make sure we're at least as wide as our available width width = PR_MAX(aMetrics.width, aMaxSize.width); } @@ -559,12 +542,12 @@ nsBodyFrame::ComputeDesiredSize(nsIPresContext& aPresContext, height = styleSize.width + aBorderPadding.top + aBorderPadding.bottom; } else { - if (!mIsPseudoFrame) { + if (mIsTopLevel) { height += aBorderPadding.top + aBorderPadding.bottom; } } - if (!mIsPseudoFrame) { + if (mIsTopLevel) { // Make sure we're at least as wide as our available width width = PR_MAX(aMetrics.width, aMaxSize.width); height += aBorderPadding.top + aBorderPadding.bottom; diff --git a/layout/html/base/src/nsBodyFrame.h b/layout/html/base/src/nsBodyFrame.h index ccd0cf42328..4febcb7f141 100644 --- a/layout/html/base/src/nsBodyFrame.h +++ b/layout/html/base/src/nsBodyFrame.h @@ -34,7 +34,7 @@ class nsBodyFrame : public nsHTMLContainerFrame, { public: friend nsresult NS_NewBodyFrame(nsIContent* aContent, nsIFrame* aParent, - nsIFrame*& aResult); + nsIFrame*& aResult, PRBool aIsTopLevel); NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); @@ -73,8 +73,12 @@ public: NS_IMETHOD VerifyTree() const; + void SetIsTopLevel(PRBool aIsTopLevel) { + mIsTopLevel = aIsTopLevel; + } + protected: - PRBool mIsPseudoFrame; + PRBool mIsTopLevel; nsBodyFrame(nsIContent* aContent, nsIFrame* aParentFrame); @@ -109,12 +113,9 @@ private: nsVoidArray mAbsoluteItems; PRInt32 mChildCount; - nsSize GetColumnAvailSpace(nsIPresContext* aPresContext, + nsSize GetColumnAvailSpace(nsIPresContext& aPresContext, const nsMargin& aBorderPadding, const nsSize& aMaxSize); - - // XXX FIX ME... - PRBool IsPseudoFrame() const; }; #endif /* nsBodyFrame_h___ */ diff --git a/layout/html/base/src/nsHTMLContainerFrame.cpp b/layout/html/base/src/nsHTMLContainerFrame.cpp index 6688541e0a6..2b2a1d606d4 100644 --- a/layout/html/base/src/nsHTMLContainerFrame.cpp +++ b/layout/html/base/src/nsHTMLContainerFrame.cpp @@ -194,7 +194,7 @@ nsHTMLContainerFrame::CreateWrapperFrame(nsIPresContext& aPresContext, content->CanContainChildren(isContainer); if (isContainer) { // Wrap the floated element in a BODY frame. - NS_NewBodyFrame(content, this, aWrapperFrame); + NS_NewBodyFrame(content, this, aWrapperFrame, PR_FALSE); // The body wrapper frame gets the original style context, and the floated // frame gets a pseudo style context @@ -363,7 +363,7 @@ nsHTMLContainerFrame::WrapFrames(nsIPresContext& aPresContext, if (isContainer) { // Wrap the floated element in a BODY frame. nsIFrame* wrapperFrame; - rv = NS_NewBodyFrame(content, this, wrapperFrame); + rv = NS_NewBodyFrame(content, this, wrapperFrame, PR_FALSE); if (NS_OK != rv) { return rv; } diff --git a/layout/html/base/src/nsHTMLParts.h b/layout/html/base/src/nsHTMLParts.h index 886a065c64e..92de130da52 100644 --- a/layout/html/base/src/nsHTMLParts.h +++ b/layout/html/base/src/nsHTMLParts.h @@ -244,11 +244,11 @@ NS_NewBRFrame(nsIContent* aContent, nsIFrame* aParentFrame, extern nsresult NS_NewBodyFrame(nsIContent* aContent, nsIFrame* aParentFrame, - nsIFrame*& aNewFrame); + nsIFrame*& aNewFrame, PRBool aIsTopLevel); extern nsresult NS_NewBlockFrame(nsIContent* aContent, nsIFrame* aParentFrame, - nsIFrame*& aNewFrame); + nsIFrame*& aNewFrame, PRBool aShrinkWrap); extern nsresult NS_NewCommentFrame(nsIContent* aContent, nsIFrame* aParentFrame, diff --git a/layout/html/style/src/nsHTMLStyleSheet.cpp b/layout/html/style/src/nsHTMLStyleSheet.cpp index 99adcef6ea8..c4322b21bf4 100644 --- a/layout/html/style/src/nsHTMLStyleSheet.cpp +++ b/layout/html/style/src/nsHTMLStyleSheet.cpp @@ -1047,7 +1047,7 @@ HTMLStyleSheetImpl::ConstructTableFrame(nsIPresContext* aPresContext, case NS_STYLE_DISPLAY_TABLE_CAPTION: // Have we already created a caption? If so, ignore this caption if (nsnull == captionFrame) { - NS_NewBodyFrame(childContent, aNewFrame, captionFrame); + NS_NewBodyFrame(childContent, aNewFrame, captionFrame, PR_FALSE); captionFrame->SetStyleContext(aPresContext, childStyleContext); // Process the caption's child content and initialize it nsIFrame* captionChildList; @@ -1206,7 +1206,7 @@ HTMLStyleSheetImpl::ConstructFrameByTag(nsIPresContext* aPresContext, // processChildren = PR_TRUE; } else if (nsHTMLAtoms::body == aTag) { - rv = NS_NewBodyFrame(aContent, aParentFrame, aNewFrame); + rv = NS_NewBodyFrame(aContent, aParentFrame, aNewFrame, PR_TRUE); processChildren = PR_TRUE; } else if (nsHTMLAtoms::form == aTag) { @@ -1260,7 +1260,7 @@ HTMLStyleSheetImpl::ConstructFrameByDisplayType(nsIPresContext* aPresContext, switch (styleDisplay->mDisplay) { case NS_STYLE_DISPLAY_BLOCK: case NS_STYLE_DISPLAY_LIST_ITEM: - rv = NS_NewBlockFrame(aContent, aParentFrame, aNewFrame); + rv = NS_NewBlockFrame(aContent, aParentFrame, aNewFrame, PR_FALSE); processChildren = PR_TRUE; break; diff --git a/layout/html/table/src/nsTableCellFrame.cpp b/layout/html/table/src/nsTableCellFrame.cpp index f185d0199b8..a9108a7f406 100644 --- a/layout/html/table/src/nsTableCellFrame.cpp +++ b/layout/html/table/src/nsTableCellFrame.cpp @@ -74,7 +74,7 @@ NS_IMETHODIMP nsTableCellFrame::Init(nsIPresContext& aPresContext, nsIFrame* aChildList) { // Create body pseudo frame - NS_NewBodyFrame(mContent, this, mFirstChild); + NS_NewBodyFrame(mContent, this, mFirstChild, PR_FALSE); // Resolve style and set the style context nsIStyleContext* styleContext = @@ -190,7 +190,7 @@ void nsTableCellFrame::CreatePsuedoFrame(nsIPresContext* aPresContext) // Do we have a prev-in-flow? if (nsnull == mPrevInFlow) { // No, create a body pseudo frame - NS_NewBodyFrame(mContent, this, mFirstChild); + NS_NewBodyFrame(mContent, this, mFirstChild, PR_FALSE); // Resolve style and set the style context nsIStyleContext* styleContext = diff --git a/layout/style/nsHTMLStyleSheet.cpp b/layout/style/nsHTMLStyleSheet.cpp index 99adcef6ea8..c4322b21bf4 100644 --- a/layout/style/nsHTMLStyleSheet.cpp +++ b/layout/style/nsHTMLStyleSheet.cpp @@ -1047,7 +1047,7 @@ HTMLStyleSheetImpl::ConstructTableFrame(nsIPresContext* aPresContext, case NS_STYLE_DISPLAY_TABLE_CAPTION: // Have we already created a caption? If so, ignore this caption if (nsnull == captionFrame) { - NS_NewBodyFrame(childContent, aNewFrame, captionFrame); + NS_NewBodyFrame(childContent, aNewFrame, captionFrame, PR_FALSE); captionFrame->SetStyleContext(aPresContext, childStyleContext); // Process the caption's child content and initialize it nsIFrame* captionChildList; @@ -1206,7 +1206,7 @@ HTMLStyleSheetImpl::ConstructFrameByTag(nsIPresContext* aPresContext, // processChildren = PR_TRUE; } else if (nsHTMLAtoms::body == aTag) { - rv = NS_NewBodyFrame(aContent, aParentFrame, aNewFrame); + rv = NS_NewBodyFrame(aContent, aParentFrame, aNewFrame, PR_TRUE); processChildren = PR_TRUE; } else if (nsHTMLAtoms::form == aTag) { @@ -1260,7 +1260,7 @@ HTMLStyleSheetImpl::ConstructFrameByDisplayType(nsIPresContext* aPresContext, switch (styleDisplay->mDisplay) { case NS_STYLE_DISPLAY_BLOCK: case NS_STYLE_DISPLAY_LIST_ITEM: - rv = NS_NewBlockFrame(aContent, aParentFrame, aNewFrame); + rv = NS_NewBlockFrame(aContent, aParentFrame, aNewFrame, PR_FALSE); processChildren = PR_TRUE; break; diff --git a/layout/tables/nsTableCellFrame.cpp b/layout/tables/nsTableCellFrame.cpp index f185d0199b8..a9108a7f406 100644 --- a/layout/tables/nsTableCellFrame.cpp +++ b/layout/tables/nsTableCellFrame.cpp @@ -74,7 +74,7 @@ NS_IMETHODIMP nsTableCellFrame::Init(nsIPresContext& aPresContext, nsIFrame* aChildList) { // Create body pseudo frame - NS_NewBodyFrame(mContent, this, mFirstChild); + NS_NewBodyFrame(mContent, this, mFirstChild, PR_FALSE); // Resolve style and set the style context nsIStyleContext* styleContext = @@ -190,7 +190,7 @@ void nsTableCellFrame::CreatePsuedoFrame(nsIPresContext* aPresContext) // Do we have a prev-in-flow? if (nsnull == mPrevInFlow) { // No, create a body pseudo frame - NS_NewBodyFrame(mContent, this, mFirstChild); + NS_NewBodyFrame(mContent, this, mFirstChild, PR_FALSE); // Resolve style and set the style context nsIStyleContext* styleContext =