From 7653fb2f79366d3c389e8147b9275d360848fe6d Mon Sep 17 00:00:00 2001 From: kipp Date: Tue, 12 May 1998 01:31:22 +0000 Subject: [PATCH] Added container methods for the singly contained frame git-svn-id: svn://10.0.0.236/trunk@1437 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/generic/nsPlaceholderFrame.cpp | 86 ++++++++++++++++++- mozilla/layout/generic/nsPlaceholderFrame.h | 10 ++- .../layout/html/base/src/nsAbsoluteFrame.cpp | 49 +++++++++++ .../layout/html/base/src/nsAbsoluteFrame.h | 10 ++- .../html/base/src/nsPlaceholderFrame.cpp | 86 ++++++++++++++++++- .../layout/html/base/src/nsPlaceholderFrame.h | 10 ++- 6 files changed, 245 insertions(+), 6 deletions(-) diff --git a/mozilla/layout/generic/nsPlaceholderFrame.cpp b/mozilla/layout/generic/nsPlaceholderFrame.cpp index 80cad9608bb..e068ae9ad4c 100644 --- a/mozilla/layout/generic/nsPlaceholderFrame.cpp +++ b/mozilla/layout/generic/nsPlaceholderFrame.cpp @@ -79,18 +79,75 @@ NS_METHOD PlaceholderFrame::ResizeReflow(nsIPresContext* aPresContext, // Resize reflow the anchored item into the available space // XXX Check for complete? - mAnchoredItem->ResizeReflow(aPresContext, aDesiredSize, aMaxSize, nsnull, aStatus); + mAnchoredItem->ResizeReflow(aPresContext, aDesiredSize, aMaxSize, + nsnull, aStatus); mAnchoredItem->SizeTo(aDesiredSize.width, aDesiredSize.height); // Now notify our containing block that there's a new floater container->AddFloater(aPresContext, mAnchoredItem, this); } else { + // XXX This causes anchored-items sizes to get fixed up; this is + // not quite right because this class should be implementing one + // of the incremental reflow methods and propogating things down + // properly to the contained frame. + mAnchoredItem->ResizeReflow(aPresContext, aDesiredSize, aMaxSize, + nsnull, aStatus); + mAnchoredItem->SizeTo(aDesiredSize.width, aDesiredSize.height); container->PlaceFloater(aPresContext, mAnchoredItem, this); } return nsFrame::ResizeReflow(aPresContext, aDesiredSize, aMaxSize, aMaxElementSize, aStatus); } +NS_METHOD +PlaceholderFrame::ChildCount(PRInt32& aChildCount) const +{ + aChildCount = 1; + return NS_OK; +} + +NS_METHOD +PlaceholderFrame::ChildAt(PRInt32 aIndex, nsIFrame*& aFrame) const +{ + aFrame = (0 == aIndex) ? mAnchoredItem : nsnull; + return NS_OK; +} + +NS_METHOD +PlaceholderFrame::IndexOf(const nsIFrame* aChild, PRInt32& aIndex) const +{ + aIndex = (aChild == mAnchoredItem) ? 0 : -1; + return NS_OK; +} + +NS_METHOD +PlaceholderFrame::FirstChild(nsIFrame*& aFirstChild) const +{ + aFirstChild = mAnchoredItem; + return NS_OK; +} + +NS_METHOD +PlaceholderFrame::NextChild(const nsIFrame* aChild, nsIFrame*& aNextChild) const +{ + aNextChild = nsnull; + return NS_OK; +} + +NS_METHOD +PlaceholderFrame::PrevChild(const nsIFrame* aChild, nsIFrame*& aPrevChild) const +{ + aPrevChild = nsnull; + return NS_OK; +} + +NS_METHOD +PlaceholderFrame::LastChild(nsIFrame*& aLastChild) const +{ + aLastChild = mAnchoredItem; + return NS_OK; +} + NS_METHOD PlaceholderFrame::ListTag(FILE* out) const { fputs("*placeholder", out); @@ -99,3 +156,30 @@ NS_METHOD PlaceholderFrame::ListTag(FILE* out) const fprintf(out, "(%d)@%p", contentIndex, this); return NS_OK; } + +NS_METHOD +PlaceholderFrame::List(FILE* out, PRInt32 aIndent) const +{ + PRInt32 i; + + // Indent + for (i = aIndent; --i >= 0; ) fputs(" ", out); + + // Output the tag + ListTag(out); + + // Output the rect + out << mRect; + + // Output the children + if (nsnull != mAnchoredItem) { + fputs("<\n", out); + mAnchoredItem->List(out, aIndent + 1); + for (i = aIndent; --i >= 0; ) fputs(" ", out); + fputs(">\n", out); + } else { + fputs("<>\n", out); + } + + return NS_OK; +} diff --git a/mozilla/layout/generic/nsPlaceholderFrame.h b/mozilla/layout/generic/nsPlaceholderFrame.h index 1a56bb3b913..036f98eebec 100644 --- a/mozilla/layout/generic/nsPlaceholderFrame.h +++ b/mozilla/layout/generic/nsPlaceholderFrame.h @@ -34,12 +34,20 @@ public: // Returns the associated anchored item nsIFrame* GetAnchoredItem() const {return mAnchoredItem;} - // Resize reflow methods + // 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 ResizeReflow(nsIPresContext* aPresContext, nsReflowMetrics& aDesiredSize, const nsSize& aMaxSize, nsSize* aMaxElementSize, ReflowStatus& aStatus); + NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const; NS_IMETHOD ListTag(FILE* out = stdout) const; protected: diff --git a/mozilla/layout/html/base/src/nsAbsoluteFrame.cpp b/mozilla/layout/html/base/src/nsAbsoluteFrame.cpp index ccc547babc8..3bbae4c24e5 100644 --- a/mozilla/layout/html/base/src/nsAbsoluteFrame.cpp +++ b/mozilla/layout/html/base/src/nsAbsoluteFrame.cpp @@ -310,6 +310,55 @@ NS_METHOD AbsoluteFrame::ResizeReflow(nsIPresContext* aPresContext, return nsFrame::ResizeReflow(aPresContext, aDesiredSize, aMaxSize, aMaxElementSize, aStatus); } +NS_METHOD +AbsoluteFrame::ChildCount(PRInt32& aChildCount) const +{ + aChildCount = 1; + return NS_OK; +} + +NS_METHOD +AbsoluteFrame::ChildAt(PRInt32 aIndex, nsIFrame*& aFrame) const +{ + aFrame = (0 == aIndex) ? mFrame : nsnull; + return NS_OK; +} + +NS_METHOD +AbsoluteFrame::IndexOf(const nsIFrame* aChild, PRInt32& aIndex) const +{ + aIndex = (aChild == mFrame) ? 0 : -1; + return NS_OK; +} + +NS_METHOD +AbsoluteFrame::FirstChild(nsIFrame*& aFirstChild) const +{ + aFirstChild = mFrame; + return NS_OK; +} + +NS_METHOD +AbsoluteFrame::NextChild(const nsIFrame* aChild, nsIFrame*& aNextChild) const +{ + aNextChild = nsnull; + return NS_OK; +} + +NS_METHOD +AbsoluteFrame::PrevChild(const nsIFrame* aChild, nsIFrame*& aPrevChild) const +{ + aPrevChild = nsnull; + return NS_OK; +} + +NS_METHOD +AbsoluteFrame::LastChild(nsIFrame*& aLastChild) const +{ + aLastChild = mFrame; + return NS_OK; +} + NS_METHOD AbsoluteFrame::List(FILE* out, PRInt32 aIndent) const { // Indent diff --git a/mozilla/layout/html/base/src/nsAbsoluteFrame.h b/mozilla/layout/html/base/src/nsAbsoluteFrame.h index f72862a0011..9214a8ee130 100644 --- a/mozilla/layout/html/base/src/nsAbsoluteFrame.h +++ b/mozilla/layout/html/base/src/nsAbsoluteFrame.h @@ -32,13 +32,19 @@ public: nsIContent* aContent, nsIFrame* aParent); - // Resize reflow methods + // 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 ResizeReflow(nsIPresContext* aPresContext, nsReflowMetrics& aDesiredSize, const nsSize& aMaxSize, nsSize* aMaxElementSize, ReflowStatus& aStatus); - NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const; protected: diff --git a/mozilla/layout/html/base/src/nsPlaceholderFrame.cpp b/mozilla/layout/html/base/src/nsPlaceholderFrame.cpp index 80cad9608bb..e068ae9ad4c 100644 --- a/mozilla/layout/html/base/src/nsPlaceholderFrame.cpp +++ b/mozilla/layout/html/base/src/nsPlaceholderFrame.cpp @@ -79,18 +79,75 @@ NS_METHOD PlaceholderFrame::ResizeReflow(nsIPresContext* aPresContext, // Resize reflow the anchored item into the available space // XXX Check for complete? - mAnchoredItem->ResizeReflow(aPresContext, aDesiredSize, aMaxSize, nsnull, aStatus); + mAnchoredItem->ResizeReflow(aPresContext, aDesiredSize, aMaxSize, + nsnull, aStatus); mAnchoredItem->SizeTo(aDesiredSize.width, aDesiredSize.height); // Now notify our containing block that there's a new floater container->AddFloater(aPresContext, mAnchoredItem, this); } else { + // XXX This causes anchored-items sizes to get fixed up; this is + // not quite right because this class should be implementing one + // of the incremental reflow methods and propogating things down + // properly to the contained frame. + mAnchoredItem->ResizeReflow(aPresContext, aDesiredSize, aMaxSize, + nsnull, aStatus); + mAnchoredItem->SizeTo(aDesiredSize.width, aDesiredSize.height); container->PlaceFloater(aPresContext, mAnchoredItem, this); } return nsFrame::ResizeReflow(aPresContext, aDesiredSize, aMaxSize, aMaxElementSize, aStatus); } +NS_METHOD +PlaceholderFrame::ChildCount(PRInt32& aChildCount) const +{ + aChildCount = 1; + return NS_OK; +} + +NS_METHOD +PlaceholderFrame::ChildAt(PRInt32 aIndex, nsIFrame*& aFrame) const +{ + aFrame = (0 == aIndex) ? mAnchoredItem : nsnull; + return NS_OK; +} + +NS_METHOD +PlaceholderFrame::IndexOf(const nsIFrame* aChild, PRInt32& aIndex) const +{ + aIndex = (aChild == mAnchoredItem) ? 0 : -1; + return NS_OK; +} + +NS_METHOD +PlaceholderFrame::FirstChild(nsIFrame*& aFirstChild) const +{ + aFirstChild = mAnchoredItem; + return NS_OK; +} + +NS_METHOD +PlaceholderFrame::NextChild(const nsIFrame* aChild, nsIFrame*& aNextChild) const +{ + aNextChild = nsnull; + return NS_OK; +} + +NS_METHOD +PlaceholderFrame::PrevChild(const nsIFrame* aChild, nsIFrame*& aPrevChild) const +{ + aPrevChild = nsnull; + return NS_OK; +} + +NS_METHOD +PlaceholderFrame::LastChild(nsIFrame*& aLastChild) const +{ + aLastChild = mAnchoredItem; + return NS_OK; +} + NS_METHOD PlaceholderFrame::ListTag(FILE* out) const { fputs("*placeholder", out); @@ -99,3 +156,30 @@ NS_METHOD PlaceholderFrame::ListTag(FILE* out) const fprintf(out, "(%d)@%p", contentIndex, this); return NS_OK; } + +NS_METHOD +PlaceholderFrame::List(FILE* out, PRInt32 aIndent) const +{ + PRInt32 i; + + // Indent + for (i = aIndent; --i >= 0; ) fputs(" ", out); + + // Output the tag + ListTag(out); + + // Output the rect + out << mRect; + + // Output the children + if (nsnull != mAnchoredItem) { + fputs("<\n", out); + mAnchoredItem->List(out, aIndent + 1); + for (i = aIndent; --i >= 0; ) fputs(" ", out); + fputs(">\n", out); + } else { + fputs("<>\n", out); + } + + return NS_OK; +} diff --git a/mozilla/layout/html/base/src/nsPlaceholderFrame.h b/mozilla/layout/html/base/src/nsPlaceholderFrame.h index 1a56bb3b913..036f98eebec 100644 --- a/mozilla/layout/html/base/src/nsPlaceholderFrame.h +++ b/mozilla/layout/html/base/src/nsPlaceholderFrame.h @@ -34,12 +34,20 @@ public: // Returns the associated anchored item nsIFrame* GetAnchoredItem() const {return mAnchoredItem;} - // Resize reflow methods + // 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 ResizeReflow(nsIPresContext* aPresContext, nsReflowMetrics& aDesiredSize, const nsSize& aMaxSize, nsSize* aMaxElementSize, ReflowStatus& aStatus); + NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const; NS_IMETHOD ListTag(FILE* out = stdout) const; protected: