From da75c0ffea2340db06f44a424f907ba4f56d79ae Mon Sep 17 00:00:00 2001 From: kipp Date: Thu, 4 Jun 1998 21:04:07 +0000 Subject: [PATCH] Made absolute frame a container too to work around the pseudo-frame problem --- layout/html/base/src/nsAbsoluteFrame.cpp | 107 ++++------------------- layout/html/base/src/nsAbsoluteFrame.h | 16 +--- 2 files changed, 21 insertions(+), 102 deletions(-) diff --git a/layout/html/base/src/nsAbsoluteFrame.cpp b/layout/html/base/src/nsAbsoluteFrame.cpp index a613704c6fd..e300dbaf7a7 100644 --- a/layout/html/base/src/nsAbsoluteFrame.cpp +++ b/layout/html/base/src/nsAbsoluteFrame.cpp @@ -49,15 +49,21 @@ nsAbsoluteFrame::NewFrame(nsIFrame** aInstancePtrResult, } nsAbsoluteFrame::nsAbsoluteFrame(nsIContent* aContent, nsIFrame* aParent) - : nsFrame(aContent, aParent) + : nsContainerFrame(aContent, aParent) { - mFrame = nsnull; } nsAbsoluteFrame::~nsAbsoluteFrame() { } +NS_IMETHODIMP +nsAbsoluteFrame::IsSplittable(nsSplittableType& aIsSplittable) const +{ + aIsSplittable = NS_FRAME_NOT_SPLITTABLE; + return NS_OK; +} + nsIView* nsAbsoluteFrame::CreateView(nsIView* aContainingView, const nsRect& aRect, nsStylePosition* aPosition, @@ -275,13 +281,13 @@ NS_METHOD nsAbsoluteFrame::Reflow(nsIPresContext* aPresContext, nsReflowStatus& aStatus) { // Have we created the absolutely positioned item yet? - if (nsnull == mFrame) { + if (nsnull == mFirstChild) { // If the content object is a container then wrap it in a body pseudo-frame if (mContent->CanContainChildren()) { - nsBodyFrame::NewFrame(&mFrame, mContent, this); + nsBodyFrame::NewFrame(&mFirstChild, mContent, this); // Use our style context for the pseudo-frame - mFrame->SetStyleContext(aPresContext, mStyleContext); + mFirstChild->SetStyleContext(aPresContext, mStyleContext); } else { // Create the absolutely positioned item as a pseudo-frame child. We'll @@ -289,7 +295,7 @@ NS_METHOD nsAbsoluteFrame::Reflow(nsIPresContext* aPresContext, nsIContentDelegate* delegate = mContent->GetDelegate(aPresContext); nsresult rv = delegate->CreateFrame(aPresContext, mContent, this, - mStyleContext, mFrame); + mStyleContext, mFirstChild); NS_RELEASE(delegate); if (NS_OK != rv) { return rv; @@ -312,7 +318,7 @@ NS_METHOD nsAbsoluteFrame::Reflow(nsIPresContext* aPresContext, nsIView* view = CreateView(containingView, rect, position, display); NS_RELEASE(containingView); - mFrame->SetView(view); + mFirstChild->SetView(view); NS_RELEASE(view); // Resize reflow the absolutely positioned element @@ -325,9 +331,9 @@ NS_METHOD nsAbsoluteFrame::Reflow(nsIPresContext* aPresContext, } nsReflowMetrics desiredSize(nsnull); - nsReflowState reflowState(mFrame, aReflowState, availSize, eReflowReason_Initial); - mFrame->WillReflow(*aPresContext); - mFrame->Reflow(aPresContext, desiredSize, reflowState, aStatus); + nsReflowState reflowState(mFirstChild, aReflowState, availSize, eReflowReason_Initial); + mFirstChild->WillReflow(*aPresContext); + mFirstChild->Reflow(aPresContext, desiredSize, reflowState, aStatus); // Figure out what size to actually use. If the position style is 'auto' or // the container should be enlarged to contain overflowing frames then use @@ -340,63 +346,14 @@ NS_METHOD nsAbsoluteFrame::Reflow(nsIPresContext* aPresContext, if (eStyleUnit_Auto == position->mHeight.GetUnit()) { rect.height = desiredSize.height; } - mFrame->SizeTo(rect.width, rect.height); - mFrame->DidReflow(*aPresContext, NS_FRAME_REFLOW_FINISHED); + mFirstChild->SetRect(rect); + mFirstChild->DidReflow(*aPresContext, NS_FRAME_REFLOW_FINISHED); } // Return our desired size as (0, 0) return nsFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus); } -NS_METHOD -nsAbsoluteFrame::ChildCount(PRInt32& aChildCount) const -{ - aChildCount = 1; - return NS_OK; -} - -NS_METHOD -nsAbsoluteFrame::ChildAt(PRInt32 aIndex, nsIFrame*& aFrame) const -{ - aFrame = (0 == aIndex) ? mFrame : nsnull; - return NS_OK; -} - -NS_METHOD -nsAbsoluteFrame::IndexOf(const nsIFrame* aChild, PRInt32& aIndex) const -{ - aIndex = (aChild == mFrame) ? 0 : -1; - return NS_OK; -} - -NS_METHOD -nsAbsoluteFrame::FirstChild(nsIFrame*& aFirstChild) const -{ - aFirstChild = mFrame; - return NS_OK; -} - -NS_METHOD -nsAbsoluteFrame::NextChild(const nsIFrame* aChild, nsIFrame*& aNextChild) const -{ - aNextChild = nsnull; - return NS_OK; -} - -NS_METHOD -nsAbsoluteFrame::PrevChild(const nsIFrame* aChild, nsIFrame*& aPrevChild) const -{ - aPrevChild = nsnull; - return NS_OK; -} - -NS_METHOD -nsAbsoluteFrame::LastChild(nsIFrame*& aLastChild) const -{ - aLastChild = mFrame; - return NS_OK; -} - NS_METHOD nsAbsoluteFrame::ListTag(FILE* out) const { fputs("*absolute", out); @@ -405,31 +362,3 @@ NS_METHOD nsAbsoluteFrame::ListTag(FILE* out) const fprintf(out, "(%d)@%p", contentIndex, this); return NS_OK; } - -NS_METHOD nsAbsoluteFrame::List(FILE* out, PRInt32 aIndent) const -{ - // Indent - for (PRInt32 i = aIndent; --i >= 0; ) fputs(" ", out); - - // Output the tag - ListTag(out); - nsIView* view; - GetView(view); - if (nsnull != view) { - fprintf(out, " [view=%p]", view); - NS_RELEASE(view); - } - - // Output the rect - out << mRect; - - // List the absolutely positioned frame - if (0 != mState) { - fprintf(out, " [state=%08x]", mState); - } - fputs("<\n", out); - mFrame->List(out, aIndent + 1); - fputs(">\n", out); - - return NS_OK; -} diff --git a/layout/html/base/src/nsAbsoluteFrame.h b/layout/html/base/src/nsAbsoluteFrame.h index 8e55a629f32..b8f17c21acd 100644 --- a/layout/html/base/src/nsAbsoluteFrame.h +++ b/layout/html/base/src/nsAbsoluteFrame.h @@ -18,14 +18,13 @@ #ifndef nsAbsoluteFrame_h___ #define nsAbsoluteFrame_h___ -#include "nsFrame.h" +#include "nsContainerFrame.h" struct nsStylePosition; struct nsStyleDisplay; // Implementation of a frame that's used as a placeholder for an absolutely // positioned frame -class nsAbsoluteFrame : public nsFrame -{ +class nsAbsoluteFrame : public nsContainerFrame { public: /** * Create a new absolutely positioned frame @@ -35,23 +34,14 @@ public: nsIFrame* aParent); // nsIFrame overrides - NS_IMETHOD ChildCount(PRInt32& aChildCount) const; - NS_IMETHOD ChildAt(PRInt32 aIndex, nsIFrame*& aFrame) const; - NS_IMETHOD IndexOf(const nsIFrame* aChild, PRInt32& aIndex) const; - NS_IMETHOD FirstChild(nsIFrame*& aFirstChild) const; - NS_IMETHOD NextChild(const nsIFrame* aChild, nsIFrame*& aNextChild) const; - NS_IMETHOD PrevChild(const nsIFrame* aChild, nsIFrame*& aPrevChild) const; - NS_IMETHOD LastChild(nsIFrame*& aLastChild) const; + NS_IMETHOD IsSplittable(nsSplittableType& aIsSplittable) const; NS_IMETHOD Reflow(nsIPresContext* aPresContext, nsReflowMetrics& aDesiredSize, const nsReflowState& aReflowState, nsReflowStatus& aStatus); - NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const; NS_IMETHOD ListTag(FILE* out = stdout) const; protected: - nsIFrame* mFrame; // the actual absolutely positioned frame - // Constructor. Takes as arguments the content object, the index in parent, // and the Frame for the content parent nsAbsoluteFrame(nsIContent* aContent, nsIFrame* aParent);