From 3bdf67212965236fb4fdc622293a1ff9fde66a2f Mon Sep 17 00:00:00 2001 From: "troy%netscape.com" Date: Thu, 25 Feb 1999 05:31:15 +0000 Subject: [PATCH] Removed nsIFrame::CreateContinuingFrame() --- layout/base/nsCSSFrameConstructor.cpp | 190 ++++++++++++------ layout/base/public/nsIFrame.h | 8 +- layout/generic/nsAreaFrame.cpp | 23 +-- layout/generic/nsAreaFrame.h | 4 - layout/generic/nsBlockFrame.cpp | 34 ++-- layout/generic/nsBlockFrame.h | 9 +- layout/generic/nsBlockReflowState.cpp | 34 ++-- layout/generic/nsBlockReflowState.h | 34 ++-- layout/generic/nsFrame.cpp | 10 - layout/generic/nsFrame.h | 4 - layout/generic/nsIFrame.h | 8 +- layout/generic/nsInlineFrame.cpp | 21 -- layout/generic/nsPageFrame.cpp | 15 -- layout/generic/nsPageFrame.h | 5 - layout/generic/nsSplittableFrame.h | 2 - layout/generic/nsTextFrame.cpp | 20 -- layout/html/base/src/nsAreaFrame.cpp | 23 +-- layout/html/base/src/nsAreaFrame.h | 4 - layout/html/base/src/nsBlockFrame.cpp | 34 ++-- layout/html/base/src/nsBlockFrame.h | 9 +- layout/html/base/src/nsBlockReflowState.cpp | 34 ++-- layout/html/base/src/nsBlockReflowState.h | 34 ++-- layout/html/base/src/nsFrame.cpp | 10 - layout/html/base/src/nsFrame.h | 4 - layout/html/base/src/nsInlineFrame.cpp | 21 -- layout/html/base/src/nsPageFrame.cpp | 15 -- layout/html/base/src/nsPageFrame.h | 5 - layout/html/base/src/nsSplittableFrame.h | 2 - layout/html/base/src/nsTextFrame.cpp | 20 -- .../html/style/src/nsCSSFrameConstructor.cpp | 190 ++++++++++++------ layout/html/table/src/nsTableCellFrame.cpp | 54 +++-- layout/html/table/src/nsTableCellFrame.h | 14 +- layout/html/table/src/nsTableFrame.cpp | 83 ++------ layout/html/table/src/nsTableFrame.h | 6 - layout/html/table/src/nsTableOuterFrame.cpp | 27 --- layout/html/table/src/nsTableOuterFrame.h | 6 - layout/html/table/src/nsTableRowFrame.cpp | 67 +++--- layout/html/table/src/nsTableRowFrame.h | 12 +- .../html/table/src/nsTableRowGroupFrame.cpp | 17 -- layout/html/table/src/nsTableRowGroupFrame.h | 6 - layout/tables/nsTableCellFrame.cpp | 54 +++-- layout/tables/nsTableCellFrame.h | 14 +- layout/tables/nsTableFrame.cpp | 83 ++------ layout/tables/nsTableFrame.h | 6 - layout/tables/nsTableOuterFrame.cpp | 27 --- layout/tables/nsTableOuterFrame.h | 6 - layout/tables/nsTableRowFrame.cpp | 67 +++--- layout/tables/nsTableRowFrame.h | 12 +- layout/tables/nsTableRowGroupFrame.cpp | 17 -- layout/tables/nsTableRowGroupFrame.h | 6 - 50 files changed, 538 insertions(+), 872 deletions(-) diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index b413db39bed4..4a4f9290d21c 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -3575,100 +3575,164 @@ nsCSSFrameConstructor::CreateContinuingFrame(nsIPresContext* aPresContext, nsIFrame* aParentFrame, nsIFrame** aContinuingFrame) { -#if 1 - nsresult rv; - nsIFrame* continuingFrame; - - nsIStyleContext* styleContext; - aFrame->GetStyleContext(&styleContext); - rv = aFrame->CreateContinuingFrame(*aPresContext, aParentFrame, styleContext, - continuingFrame); - NS_RELEASE(styleContext); - *aContinuingFrame = continuingFrame; - return rv; -#else - nsIAtom* frameType; - nsIFrame* newFrame = nsnull; - PRBool forceView = PR_FALSE; - nsresult rv; + nsIAtom* frameType; + nsIContent* content; + nsIStyleContext* styleContext; + nsIFrame* newFrame = nsnull; + nsresult rv; + // Use the frame type to determine what type of frame to create aFrame->GetFrameType(&frameType); + aFrame->GetContent(&content); + aFrame->GetStyleContext(&styleContext); if (nsLayoutAtoms::textFrame == frameType) { rv = NS_NewTextFrame(newFrame); + if (NS_SUCCEEDED(rv)) { + newFrame->Init(*aPresContext, content, aParentFrame, styleContext, aFrame); + nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, newFrame, + styleContext, PR_FALSE); + } } else if (nsHTMLAtoms::inlineFrame == frameType) { - NS_NewInlineFrame(newFrame); + rv = NS_NewInlineFrame(newFrame); + if (NS_SUCCEEDED(rv)) { + newFrame->Init(*aPresContext, content, aParentFrame, styleContext, aFrame); + nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, newFrame, + styleContext, PR_FALSE); + } } else if (nsHTMLAtoms::blockFrame == frameType) { - NS_NewBlockFrame(newFrame, 0); + rv = NS_NewBlockFrame(newFrame, 0); + if (NS_SUCCEEDED(rv)) { + newFrame->Init(*aPresContext, content, aParentFrame, styleContext, aFrame); + nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, newFrame, + styleContext, PR_FALSE); + } } else if (nsLayoutAtoms::areaFrame == frameType) { - // XXX What should be used for the flags? - NS_NewAreaFrame(newFrame, 0); + rv = NS_NewAreaFrame(newFrame, 0); + if (NS_SUCCEEDED(rv)) { + newFrame->Init(*aPresContext, content, aParentFrame, styleContext, aFrame); + nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, newFrame, + styleContext, PR_FALSE); + } } else if (nsLayoutAtoms::pageFrame == frameType) { - NS_NewPageFrame(newFrame); - forceView = PR_TRUE; + rv = NS_NewPageFrame(newFrame); + if (NS_SUCCEEDED(rv)) { + newFrame->Init(*aPresContext, content, aParentFrame, styleContext, aFrame); + nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, newFrame, + styleContext, PR_TRUE); + } } else if (nsLayoutAtoms::tableOuterFrame == frameType) { - NS_NewTableOuterFrame(newFrame); + rv = NS_NewTableOuterFrame(newFrame); + if (NS_SUCCEEDED(rv)) { + newFrame->Init(*aPresContext, content, aParentFrame, styleContext, aFrame); + nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, newFrame, + styleContext, PR_FALSE); + + // Create a continuing inner table frame + nsIFrame* childFrame; + nsFrameItems newChildFrames; + + aFrame->FirstChild(nsnull, &childFrame); + while (childFrame) { + nsIAtom* tableType; + + // See if it's the inner table frame + childFrame->GetFrameType(&tableType); + if (nsLayoutAtoms::tableFrame == tableType) { + nsIFrame* continuingTableFrame; + + // It's the inner table frame, so create a continuing frame + CreateContinuingFrame(aPresContext, childFrame, newFrame, &continuingTableFrame); + newChildFrames.AddChild(continuingTableFrame); + } + NS_IF_RELEASE(tableType); + childFrame->GetNextSibling(&childFrame); + } + + // Set the outer table's initial child list + newFrame->SetInitialChildList(*aPresContext, nsnull, newChildFrames.childList); + } } else if (nsLayoutAtoms::tableFrame == frameType) { - NS_NewTableFrame(newFrame); + rv = NS_NewTableFrame(newFrame); + if (NS_SUCCEEDED(rv)) { + newFrame->Init(*aPresContext, content, aParentFrame, styleContext, aFrame); + nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, newFrame, + styleContext, PR_FALSE); + } } else if (nsLayoutAtoms::tableRowGroupFrame == frameType) { - NS_NewTableRowGroupFrame(newFrame); + rv = NS_NewTableRowGroupFrame(newFrame); + if (NS_SUCCEEDED(rv)) { + newFrame->Init(*aPresContext, content, aParentFrame, styleContext, aFrame); + nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, newFrame, + styleContext, PR_FALSE); + } } else if (nsLayoutAtoms::tableRowFrame == frameType) { - NS_NewTableRowFrame(newFrame); + rv = NS_NewTableRowFrame(newFrame); + if (NS_SUCCEEDED(rv)) { + newFrame->Init(*aPresContext, content, aParentFrame, styleContext, aFrame); + nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, newFrame, + styleContext, PR_FALSE); + + // Create a continuing frame for each table cell frame + nsIFrame* cellFrame; + nsFrameItems newChildList; + + aFrame->FirstChild(nsnull, &cellFrame); + while (cellFrame) { + nsIAtom* tableType; + + // See if it's a table cell frame + cellFrame->GetFrameType(&tableType); + if (nsLayoutAtoms::tableCellFrame == tableType) { + nsIFrame* continuingCellFrame; + + CreateContinuingFrame(aPresContext, cellFrame, newFrame, &continuingCellFrame); + newChildList.AddChild(continuingCellFrame); + } + + NS_IF_RELEASE(tableType); + cellFrame->GetNextSibling(&cellFrame); + } + + // Set the table cell's initial child list + newFrame->SetInitialChildList(*aPresContext, nsnull, newChildList.childList); + } } else if (nsLayoutAtoms::tableCellFrame == frameType) { - NS_NewTableCellFrame(newFrame); + rv = NS_NewTableCellFrame(newFrame); + if (NS_SUCCEEDED(rv)) { + newFrame->Init(*aPresContext, content, aParentFrame, styleContext, aFrame); + nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, newFrame, + styleContext, PR_FALSE); + + // Create a continuing area frame + nsIFrame* areaFrame; + nsIFrame* continuingAreaFrame; + aFrame->FirstChild(nsnull, &areaFrame); + CreateContinuingFrame(aPresContext, areaFrame, newFrame, &continuingAreaFrame); + + // Set the table cell's initial child list + newFrame->SetInitialChildList(*aPresContext, nsnull, continuingAreaFrame); + } } else { NS_ASSERTION(PR_FALSE, "unexpected frame type"); rv = NS_ERROR_UNEXPECTED; } - if (NS_SUCCEEDED(rv) && newFrame) { - nsIContent* content; - nsIStyleContext* styleContext; - - // Initialize the continuing frame, and create a view for it if appropriate - aFrame->GetContent(&content); - aFrame->GetStyleContext(&styleContext); - newFrame->Init(*aPresContext, content, aParentFrame, styleContext); - nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, newFrame, - styleContext, forceView); - NS_RELEASE(styleContext); - NS_RELEASE(content); - - // Append it to the flow - newFrame->AppendToFlow(aFrame); - - // Make sure some of the flag bits are set - // XXX Maybe it would be better if we passed the prev-in-flow into the Init() - // call, and that way the frame can add itself to the flow and replicate any - // state... - nsFrameState state; - nsFrameState newState; - aFrame->GetFrameState(&state); - newFrame->GetFrameState(&newState); - - if (state & NS_FRAME_SYNC_FRAME_AND_VIEW) { - newState |= NS_FRAME_SYNC_FRAME_AND_VIEW; - } - if (state & NS_FRAME_REPLACED_ELEMENT) { - newState |= NS_FRAME_REPLACED_ELEMENT; - } - newFrame->SetFrameState(newState); - } - NS_RELEASE(frameType); - *aContinuingFrame = newFrame; + NS_RELEASE(styleContext); + NS_IF_RELEASE(content); + NS_IF_RELEASE(frameType); return rv; -#endif } nsresult diff --git a/layout/base/public/nsIFrame.h b/layout/base/public/nsIFrame.h index 33846151e2d1..c5344b08d5c2 100644 --- a/layout/base/public/nsIFrame.h +++ b/layout/base/public/nsIFrame.h @@ -467,14 +467,8 @@ public: NS_IMETHOD IsSplittable(nsSplittableType& aIsSplittable) const = 0; /** - * Flow member functions. CreateContinuingFrame() is responsible for - * appending the continuing frame to the flow. + * Flow member functions */ - NS_IMETHOD CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame) = 0; - NS_IMETHOD GetPrevInFlow(nsIFrame** aPrevInFlow) const = 0; NS_IMETHOD SetPrevInFlow(nsIFrame*) = 0; NS_IMETHOD GetNextInFlow(nsIFrame** aNextInFlow) const = 0; diff --git a/layout/generic/nsAreaFrame.cpp b/layout/generic/nsAreaFrame.cpp index 0194fd02dabc..785a6b784fd8 100644 --- a/layout/generic/nsAreaFrame.cpp +++ b/layout/generic/nsAreaFrame.cpp @@ -80,13 +80,18 @@ nsAreaFrame::Init(nsIPresContext& aPresContext, nsIStyleContext* aContext, nsIFrame* aPrevInFlow) { + nsresult rv; + + // Let the block frame do its initialization + rv = nsBlockFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); + // Create a space manager if requested if (0 == (mFlags & NS_AREA_NO_SPACE_MGR)) { mSpaceManager = new nsSpaceManager(this); NS_ADDREF(mSpaceManager); } - return nsBlockFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); + return rv; } NS_IMETHODIMP @@ -583,22 +588,6 @@ nsAreaFrame::Reflow(nsIPresContext& aPresContext, return rv; } -NS_METHOD -nsAreaFrame::CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame) -{ - nsAreaFrame* cf = new nsAreaFrame; - if (nsnull == cf) { - return NS_ERROR_OUT_OF_MEMORY; - } - cf->Init(aPresContext, mContent, aParent, aStyleContext, this); - cf->SetFlags(mFlags); - aContinuingFrame = cf; - return NS_OK; -} - ///////////////////////////////////////////////////////////////////////////// // Helper functions diff --git a/layout/generic/nsAreaFrame.h b/layout/generic/nsAreaFrame.h index 4dbb1916c7ea..a7a62ea12290 100644 --- a/layout/generic/nsAreaFrame.h +++ b/layout/generic/nsAreaFrame.h @@ -81,10 +81,6 @@ public: NS_IMETHOD DidReflow(nsIPresContext& aPresContext, nsDidReflowStatus aStatus); - NS_IMETHOD CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame); /** * Get the "type" of the frame * diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp index ab64c72835af..7fdaa1c31bd4 100644 --- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -4473,6 +4473,24 @@ nsBlockFrame::VerifyTree() const //---------------------------------------------------------------------- +NS_IMETHODIMP +nsBlockFrame::Init(nsIPresContext& aPresContext, + nsIContent* aContent, + nsIFrame* aParent, + nsIStyleContext* aContext, + nsIFrame* aPrevInFlow) +{ + if (aPrevInFlow) { + // Copy over the block/area frame flags + nsBlockFrame* blockFrame = (nsBlockFrame*)aPrevInFlow; + + SetFlags(blockFrame->mFlags); + } + + return nsBlockFrameSuper::Init(aPresContext, aContent, aParent, + aContext, aPrevInFlow); +} + NS_IMETHODIMP nsBlockFrame::SetInitialChildList(nsIPresContext& aPresContext, nsIAtom* aListName, @@ -4541,22 +4559,6 @@ nsBlockFrame::SetInitialChildList(nsIPresContext& aPresContext, return NS_OK; } -NS_IMETHODIMP -nsBlockFrame::CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame) -{ - nsBlockFrame* cf = new nsBlockFrame; - if (nsnull == cf) { - return NS_ERROR_OUT_OF_MEMORY; - } - cf->Init(aPresContext, mContent, aParent, aStyleContext, this); - cf->SetFlags(mFlags); - aContinuingFrame = cf; - return NS_OK; -} - void nsBlockFrame::RenumberLists() { diff --git a/layout/generic/nsBlockFrame.h b/layout/generic/nsBlockFrame.h index cbb82e2b4fd0..901e8e51d940 100644 --- a/layout/generic/nsBlockFrame.h +++ b/layout/generic/nsBlockFrame.h @@ -51,6 +51,11 @@ public: NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); // nsIFrame + NS_IMETHOD Init(nsIPresContext& aPresContext, + nsIContent* aContent, + nsIFrame* aParent, + nsIStyleContext* aContext, + nsIFrame* aPrevInFlow); NS_IMETHOD SetInitialChildList(nsIPresContext& aPresContext, nsIAtom* aListName, nsIFrame* aChildList); @@ -74,10 +79,6 @@ public: NS_IMETHOD IsSplittable(nsSplittableType& aIsSplittable) const; NS_IMETHOD ReResolveStyleContext(nsIPresContext* aPresContext, nsIStyleContext* aParentContext); - NS_IMETHOD CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame); NS_IMETHOD IsPercentageBase(PRBool& aBase) const; NS_IMETHOD Paint(nsIPresContext& aPresContext, nsIRenderingContext& aRenderingContext, diff --git a/layout/generic/nsBlockReflowState.cpp b/layout/generic/nsBlockReflowState.cpp index ab64c72835af..7fdaa1c31bd4 100644 --- a/layout/generic/nsBlockReflowState.cpp +++ b/layout/generic/nsBlockReflowState.cpp @@ -4473,6 +4473,24 @@ nsBlockFrame::VerifyTree() const //---------------------------------------------------------------------- +NS_IMETHODIMP +nsBlockFrame::Init(nsIPresContext& aPresContext, + nsIContent* aContent, + nsIFrame* aParent, + nsIStyleContext* aContext, + nsIFrame* aPrevInFlow) +{ + if (aPrevInFlow) { + // Copy over the block/area frame flags + nsBlockFrame* blockFrame = (nsBlockFrame*)aPrevInFlow; + + SetFlags(blockFrame->mFlags); + } + + return nsBlockFrameSuper::Init(aPresContext, aContent, aParent, + aContext, aPrevInFlow); +} + NS_IMETHODIMP nsBlockFrame::SetInitialChildList(nsIPresContext& aPresContext, nsIAtom* aListName, @@ -4541,22 +4559,6 @@ nsBlockFrame::SetInitialChildList(nsIPresContext& aPresContext, return NS_OK; } -NS_IMETHODIMP -nsBlockFrame::CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame) -{ - nsBlockFrame* cf = new nsBlockFrame; - if (nsnull == cf) { - return NS_ERROR_OUT_OF_MEMORY; - } - cf->Init(aPresContext, mContent, aParent, aStyleContext, this); - cf->SetFlags(mFlags); - aContinuingFrame = cf; - return NS_OK; -} - void nsBlockFrame::RenumberLists() { diff --git a/layout/generic/nsBlockReflowState.h b/layout/generic/nsBlockReflowState.h index ab64c72835af..7fdaa1c31bd4 100644 --- a/layout/generic/nsBlockReflowState.h +++ b/layout/generic/nsBlockReflowState.h @@ -4473,6 +4473,24 @@ nsBlockFrame::VerifyTree() const //---------------------------------------------------------------------- +NS_IMETHODIMP +nsBlockFrame::Init(nsIPresContext& aPresContext, + nsIContent* aContent, + nsIFrame* aParent, + nsIStyleContext* aContext, + nsIFrame* aPrevInFlow) +{ + if (aPrevInFlow) { + // Copy over the block/area frame flags + nsBlockFrame* blockFrame = (nsBlockFrame*)aPrevInFlow; + + SetFlags(blockFrame->mFlags); + } + + return nsBlockFrameSuper::Init(aPresContext, aContent, aParent, + aContext, aPrevInFlow); +} + NS_IMETHODIMP nsBlockFrame::SetInitialChildList(nsIPresContext& aPresContext, nsIAtom* aListName, @@ -4541,22 +4559,6 @@ nsBlockFrame::SetInitialChildList(nsIPresContext& aPresContext, return NS_OK; } -NS_IMETHODIMP -nsBlockFrame::CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame) -{ - nsBlockFrame* cf = new nsBlockFrame; - if (nsnull == cf) { - return NS_ERROR_OUT_OF_MEMORY; - } - cf->Init(aPresContext, mContent, aParent, aStyleContext, this); - cf->SetFlags(mFlags); - aContinuingFrame = cf; - return NS_OK; -} - void nsBlockFrame::RenumberLists() { diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index 2aef268316ca..3366bd42f2a9 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -1098,16 +1098,6 @@ NS_IMETHODIMP nsFrame::IsSplittable(nsSplittableType& aIsSplittable) const return NS_OK; } -NS_IMETHODIMP nsFrame::CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame) -{ - NS_ERROR("not splittable"); - aContinuingFrame = nsnull; - return NS_ERROR_NOT_IMPLEMENTED; -} - NS_IMETHODIMP nsFrame::GetPrevInFlow(nsIFrame** aPrevInFlow) const { *aPrevInFlow = nsnull; diff --git a/layout/generic/nsFrame.h b/layout/generic/nsFrame.h index 7369335d6dc8..94bfb5ccbe41 100644 --- a/layout/generic/nsFrame.h +++ b/layout/generic/nsFrame.h @@ -183,10 +183,6 @@ public: nsIAtom* aAttribute, PRInt32 aHint); NS_IMETHOD IsSplittable(nsSplittableType& aIsSplittable) const; - NS_IMETHOD CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame); NS_IMETHOD GetPrevInFlow(nsIFrame** aPrevInFlow) const; NS_IMETHOD SetPrevInFlow(nsIFrame*); NS_IMETHOD GetNextInFlow(nsIFrame** aNextInFlow) const; diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h index 33846151e2d1..c5344b08d5c2 100644 --- a/layout/generic/nsIFrame.h +++ b/layout/generic/nsIFrame.h @@ -467,14 +467,8 @@ public: NS_IMETHOD IsSplittable(nsSplittableType& aIsSplittable) const = 0; /** - * Flow member functions. CreateContinuingFrame() is responsible for - * appending the continuing frame to the flow. + * Flow member functions */ - NS_IMETHOD CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame) = 0; - NS_IMETHOD GetPrevInFlow(nsIFrame** aPrevInFlow) const = 0; NS_IMETHOD SetPrevInFlow(nsIFrame*) = 0; NS_IMETHOD GetNextInFlow(nsIFrame** aNextInFlow) const = 0; diff --git a/layout/generic/nsInlineFrame.cpp b/layout/generic/nsInlineFrame.cpp index cb399db7f02a..1a49b5a25e01 100644 --- a/layout/generic/nsInlineFrame.cpp +++ b/layout/generic/nsInlineFrame.cpp @@ -75,10 +75,6 @@ public: nsIAtom* aListName, nsIFrame* aOldFrame); NS_IMETHOD DeleteFrame(nsIPresContext& aPresContext); - NS_IMETHOD CreateContinuingFrame(nsIPresContext& aCX, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame); NS_IMETHOD GetFrameName(nsString& aResult) const; NS_IMETHOD GetFrameType(nsIAtom** aType) const; @@ -1763,23 +1759,6 @@ nsInlineFrame::ReflowBlockFrame(ReflowState& rs, ////////////////////////////////////////////////////////////////////// -NS_IMETHODIMP -nsInlineFrame::CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame) -{ - nsInlineFrame* cf = new nsInlineFrame; - if (nsnull == cf) { - return NS_ERROR_OUT_OF_MEMORY; - } - cf->Init(aPresContext, mContent, aParent, aStyleContext, this); - aContinuingFrame = cf; - return NS_OK; -} - -////////////////////////////////////////////////////////////////////// - PRIntn nsInlineFrame::GetSkipSides() const { diff --git a/layout/generic/nsPageFrame.cpp b/layout/generic/nsPageFrame.cpp index c0b967d7a36d..2b4d311751ba 100644 --- a/layout/generic/nsPageFrame.cpp +++ b/layout/generic/nsPageFrame.cpp @@ -138,21 +138,6 @@ NS_METHOD nsPageFrame::Reflow(nsIPresContext& aPresContext, return NS_OK; } -NS_METHOD -nsPageFrame::CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame) -{ - nsPageFrame* cf = new nsPageFrame; - if (nsnull == cf) { - return NS_ERROR_OUT_OF_MEMORY; - } - cf->Init(aPresContext, mContent, aParent, aStyleContext, this); - aContinuingFrame = cf; - return NS_OK; -} - NS_IMETHODIMP nsPageFrame::GetFrameType(nsIAtom** aType) const { diff --git a/layout/generic/nsPageFrame.h b/layout/generic/nsPageFrame.h index e6e41c6b72af..9f38b7e266f5 100644 --- a/layout/generic/nsPageFrame.h +++ b/layout/generic/nsPageFrame.h @@ -30,11 +30,6 @@ public: const nsHTMLReflowState& aMaxSize, nsReflowStatus& aStatus); - NS_IMETHOD CreateContinuingFrame(nsIPresContext& aCX, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame); - /** * Get the "type" of the frame * diff --git a/layout/generic/nsSplittableFrame.h b/layout/generic/nsSplittableFrame.h index c7ea437bd761..5d7d3d592156 100644 --- a/layout/generic/nsSplittableFrame.h +++ b/layout/generic/nsSplittableFrame.h @@ -30,8 +30,6 @@ public: nsIStyleContext* aContext, nsIFrame* aPrevInFlow); - // CreateContinuingFrame() does the default behavior of using the - // content delegate to create a new frame NS_IMETHOD IsSplittable(nsSplittableType& aIsSplittable) const; // Flow member functions. diff --git a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp index 7d8352a29823..072cd4f47e28 100644 --- a/layout/generic/nsTextFrame.cpp +++ b/layout/generic/nsTextFrame.cpp @@ -97,11 +97,6 @@ public: TextFrame(); // nsIFrame - NS_IMETHOD CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame); - NS_IMETHOD Paint(nsIPresContext& aPresContext, nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect, @@ -493,21 +488,6 @@ TextFrame::GetCursor(nsIPresContext& aPresContext, return NS_OK; } -NS_IMETHODIMP -TextFrame::CreateContinuingFrame(nsIPresContext& aCX, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame) -{ - TextFrame* cf = new TextFrame; - if (nsnull == cf) { - return NS_ERROR_OUT_OF_MEMORY; - } - cf->Init(aCX, mContent, aParent, aStyleContext, this); - aContinuingFrame = cf; - return NS_OK; -} - NS_IMETHODIMP TextFrame::ContentChanged(nsIPresContext* aPresContext, nsIContent* aChild, diff --git a/layout/html/base/src/nsAreaFrame.cpp b/layout/html/base/src/nsAreaFrame.cpp index 0194fd02dabc..785a6b784fd8 100644 --- a/layout/html/base/src/nsAreaFrame.cpp +++ b/layout/html/base/src/nsAreaFrame.cpp @@ -80,13 +80,18 @@ nsAreaFrame::Init(nsIPresContext& aPresContext, nsIStyleContext* aContext, nsIFrame* aPrevInFlow) { + nsresult rv; + + // Let the block frame do its initialization + rv = nsBlockFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); + // Create a space manager if requested if (0 == (mFlags & NS_AREA_NO_SPACE_MGR)) { mSpaceManager = new nsSpaceManager(this); NS_ADDREF(mSpaceManager); } - return nsBlockFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow); + return rv; } NS_IMETHODIMP @@ -583,22 +588,6 @@ nsAreaFrame::Reflow(nsIPresContext& aPresContext, return rv; } -NS_METHOD -nsAreaFrame::CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame) -{ - nsAreaFrame* cf = new nsAreaFrame; - if (nsnull == cf) { - return NS_ERROR_OUT_OF_MEMORY; - } - cf->Init(aPresContext, mContent, aParent, aStyleContext, this); - cf->SetFlags(mFlags); - aContinuingFrame = cf; - return NS_OK; -} - ///////////////////////////////////////////////////////////////////////////// // Helper functions diff --git a/layout/html/base/src/nsAreaFrame.h b/layout/html/base/src/nsAreaFrame.h index 4dbb1916c7ea..a7a62ea12290 100644 --- a/layout/html/base/src/nsAreaFrame.h +++ b/layout/html/base/src/nsAreaFrame.h @@ -81,10 +81,6 @@ public: NS_IMETHOD DidReflow(nsIPresContext& aPresContext, nsDidReflowStatus aStatus); - NS_IMETHOD CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame); /** * Get the "type" of the frame * diff --git a/layout/html/base/src/nsBlockFrame.cpp b/layout/html/base/src/nsBlockFrame.cpp index ab64c72835af..7fdaa1c31bd4 100644 --- a/layout/html/base/src/nsBlockFrame.cpp +++ b/layout/html/base/src/nsBlockFrame.cpp @@ -4473,6 +4473,24 @@ nsBlockFrame::VerifyTree() const //---------------------------------------------------------------------- +NS_IMETHODIMP +nsBlockFrame::Init(nsIPresContext& aPresContext, + nsIContent* aContent, + nsIFrame* aParent, + nsIStyleContext* aContext, + nsIFrame* aPrevInFlow) +{ + if (aPrevInFlow) { + // Copy over the block/area frame flags + nsBlockFrame* blockFrame = (nsBlockFrame*)aPrevInFlow; + + SetFlags(blockFrame->mFlags); + } + + return nsBlockFrameSuper::Init(aPresContext, aContent, aParent, + aContext, aPrevInFlow); +} + NS_IMETHODIMP nsBlockFrame::SetInitialChildList(nsIPresContext& aPresContext, nsIAtom* aListName, @@ -4541,22 +4559,6 @@ nsBlockFrame::SetInitialChildList(nsIPresContext& aPresContext, return NS_OK; } -NS_IMETHODIMP -nsBlockFrame::CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame) -{ - nsBlockFrame* cf = new nsBlockFrame; - if (nsnull == cf) { - return NS_ERROR_OUT_OF_MEMORY; - } - cf->Init(aPresContext, mContent, aParent, aStyleContext, this); - cf->SetFlags(mFlags); - aContinuingFrame = cf; - return NS_OK; -} - void nsBlockFrame::RenumberLists() { diff --git a/layout/html/base/src/nsBlockFrame.h b/layout/html/base/src/nsBlockFrame.h index cbb82e2b4fd0..901e8e51d940 100644 --- a/layout/html/base/src/nsBlockFrame.h +++ b/layout/html/base/src/nsBlockFrame.h @@ -51,6 +51,11 @@ public: NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); // nsIFrame + NS_IMETHOD Init(nsIPresContext& aPresContext, + nsIContent* aContent, + nsIFrame* aParent, + nsIStyleContext* aContext, + nsIFrame* aPrevInFlow); NS_IMETHOD SetInitialChildList(nsIPresContext& aPresContext, nsIAtom* aListName, nsIFrame* aChildList); @@ -74,10 +79,6 @@ public: NS_IMETHOD IsSplittable(nsSplittableType& aIsSplittable) const; NS_IMETHOD ReResolveStyleContext(nsIPresContext* aPresContext, nsIStyleContext* aParentContext); - NS_IMETHOD CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame); NS_IMETHOD IsPercentageBase(PRBool& aBase) const; NS_IMETHOD Paint(nsIPresContext& aPresContext, nsIRenderingContext& aRenderingContext, diff --git a/layout/html/base/src/nsBlockReflowState.cpp b/layout/html/base/src/nsBlockReflowState.cpp index ab64c72835af..7fdaa1c31bd4 100644 --- a/layout/html/base/src/nsBlockReflowState.cpp +++ b/layout/html/base/src/nsBlockReflowState.cpp @@ -4473,6 +4473,24 @@ nsBlockFrame::VerifyTree() const //---------------------------------------------------------------------- +NS_IMETHODIMP +nsBlockFrame::Init(nsIPresContext& aPresContext, + nsIContent* aContent, + nsIFrame* aParent, + nsIStyleContext* aContext, + nsIFrame* aPrevInFlow) +{ + if (aPrevInFlow) { + // Copy over the block/area frame flags + nsBlockFrame* blockFrame = (nsBlockFrame*)aPrevInFlow; + + SetFlags(blockFrame->mFlags); + } + + return nsBlockFrameSuper::Init(aPresContext, aContent, aParent, + aContext, aPrevInFlow); +} + NS_IMETHODIMP nsBlockFrame::SetInitialChildList(nsIPresContext& aPresContext, nsIAtom* aListName, @@ -4541,22 +4559,6 @@ nsBlockFrame::SetInitialChildList(nsIPresContext& aPresContext, return NS_OK; } -NS_IMETHODIMP -nsBlockFrame::CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame) -{ - nsBlockFrame* cf = new nsBlockFrame; - if (nsnull == cf) { - return NS_ERROR_OUT_OF_MEMORY; - } - cf->Init(aPresContext, mContent, aParent, aStyleContext, this); - cf->SetFlags(mFlags); - aContinuingFrame = cf; - return NS_OK; -} - void nsBlockFrame::RenumberLists() { diff --git a/layout/html/base/src/nsBlockReflowState.h b/layout/html/base/src/nsBlockReflowState.h index ab64c72835af..7fdaa1c31bd4 100644 --- a/layout/html/base/src/nsBlockReflowState.h +++ b/layout/html/base/src/nsBlockReflowState.h @@ -4473,6 +4473,24 @@ nsBlockFrame::VerifyTree() const //---------------------------------------------------------------------- +NS_IMETHODIMP +nsBlockFrame::Init(nsIPresContext& aPresContext, + nsIContent* aContent, + nsIFrame* aParent, + nsIStyleContext* aContext, + nsIFrame* aPrevInFlow) +{ + if (aPrevInFlow) { + // Copy over the block/area frame flags + nsBlockFrame* blockFrame = (nsBlockFrame*)aPrevInFlow; + + SetFlags(blockFrame->mFlags); + } + + return nsBlockFrameSuper::Init(aPresContext, aContent, aParent, + aContext, aPrevInFlow); +} + NS_IMETHODIMP nsBlockFrame::SetInitialChildList(nsIPresContext& aPresContext, nsIAtom* aListName, @@ -4541,22 +4559,6 @@ nsBlockFrame::SetInitialChildList(nsIPresContext& aPresContext, return NS_OK; } -NS_IMETHODIMP -nsBlockFrame::CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame) -{ - nsBlockFrame* cf = new nsBlockFrame; - if (nsnull == cf) { - return NS_ERROR_OUT_OF_MEMORY; - } - cf->Init(aPresContext, mContent, aParent, aStyleContext, this); - cf->SetFlags(mFlags); - aContinuingFrame = cf; - return NS_OK; -} - void nsBlockFrame::RenumberLists() { diff --git a/layout/html/base/src/nsFrame.cpp b/layout/html/base/src/nsFrame.cpp index 2aef268316ca..3366bd42f2a9 100644 --- a/layout/html/base/src/nsFrame.cpp +++ b/layout/html/base/src/nsFrame.cpp @@ -1098,16 +1098,6 @@ NS_IMETHODIMP nsFrame::IsSplittable(nsSplittableType& aIsSplittable) const return NS_OK; } -NS_IMETHODIMP nsFrame::CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame) -{ - NS_ERROR("not splittable"); - aContinuingFrame = nsnull; - return NS_ERROR_NOT_IMPLEMENTED; -} - NS_IMETHODIMP nsFrame::GetPrevInFlow(nsIFrame** aPrevInFlow) const { *aPrevInFlow = nsnull; diff --git a/layout/html/base/src/nsFrame.h b/layout/html/base/src/nsFrame.h index 7369335d6dc8..94bfb5ccbe41 100644 --- a/layout/html/base/src/nsFrame.h +++ b/layout/html/base/src/nsFrame.h @@ -183,10 +183,6 @@ public: nsIAtom* aAttribute, PRInt32 aHint); NS_IMETHOD IsSplittable(nsSplittableType& aIsSplittable) const; - NS_IMETHOD CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame); NS_IMETHOD GetPrevInFlow(nsIFrame** aPrevInFlow) const; NS_IMETHOD SetPrevInFlow(nsIFrame*); NS_IMETHOD GetNextInFlow(nsIFrame** aNextInFlow) const; diff --git a/layout/html/base/src/nsInlineFrame.cpp b/layout/html/base/src/nsInlineFrame.cpp index cb399db7f02a..1a49b5a25e01 100644 --- a/layout/html/base/src/nsInlineFrame.cpp +++ b/layout/html/base/src/nsInlineFrame.cpp @@ -75,10 +75,6 @@ public: nsIAtom* aListName, nsIFrame* aOldFrame); NS_IMETHOD DeleteFrame(nsIPresContext& aPresContext); - NS_IMETHOD CreateContinuingFrame(nsIPresContext& aCX, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame); NS_IMETHOD GetFrameName(nsString& aResult) const; NS_IMETHOD GetFrameType(nsIAtom** aType) const; @@ -1763,23 +1759,6 @@ nsInlineFrame::ReflowBlockFrame(ReflowState& rs, ////////////////////////////////////////////////////////////////////// -NS_IMETHODIMP -nsInlineFrame::CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame) -{ - nsInlineFrame* cf = new nsInlineFrame; - if (nsnull == cf) { - return NS_ERROR_OUT_OF_MEMORY; - } - cf->Init(aPresContext, mContent, aParent, aStyleContext, this); - aContinuingFrame = cf; - return NS_OK; -} - -////////////////////////////////////////////////////////////////////// - PRIntn nsInlineFrame::GetSkipSides() const { diff --git a/layout/html/base/src/nsPageFrame.cpp b/layout/html/base/src/nsPageFrame.cpp index c0b967d7a36d..2b4d311751ba 100644 --- a/layout/html/base/src/nsPageFrame.cpp +++ b/layout/html/base/src/nsPageFrame.cpp @@ -138,21 +138,6 @@ NS_METHOD nsPageFrame::Reflow(nsIPresContext& aPresContext, return NS_OK; } -NS_METHOD -nsPageFrame::CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame) -{ - nsPageFrame* cf = new nsPageFrame; - if (nsnull == cf) { - return NS_ERROR_OUT_OF_MEMORY; - } - cf->Init(aPresContext, mContent, aParent, aStyleContext, this); - aContinuingFrame = cf; - return NS_OK; -} - NS_IMETHODIMP nsPageFrame::GetFrameType(nsIAtom** aType) const { diff --git a/layout/html/base/src/nsPageFrame.h b/layout/html/base/src/nsPageFrame.h index e6e41c6b72af..9f38b7e266f5 100644 --- a/layout/html/base/src/nsPageFrame.h +++ b/layout/html/base/src/nsPageFrame.h @@ -30,11 +30,6 @@ public: const nsHTMLReflowState& aMaxSize, nsReflowStatus& aStatus); - NS_IMETHOD CreateContinuingFrame(nsIPresContext& aCX, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame); - /** * Get the "type" of the frame * diff --git a/layout/html/base/src/nsSplittableFrame.h b/layout/html/base/src/nsSplittableFrame.h index c7ea437bd761..5d7d3d592156 100644 --- a/layout/html/base/src/nsSplittableFrame.h +++ b/layout/html/base/src/nsSplittableFrame.h @@ -30,8 +30,6 @@ public: nsIStyleContext* aContext, nsIFrame* aPrevInFlow); - // CreateContinuingFrame() does the default behavior of using the - // content delegate to create a new frame NS_IMETHOD IsSplittable(nsSplittableType& aIsSplittable) const; // Flow member functions. diff --git a/layout/html/base/src/nsTextFrame.cpp b/layout/html/base/src/nsTextFrame.cpp index 7d8352a29823..072cd4f47e28 100644 --- a/layout/html/base/src/nsTextFrame.cpp +++ b/layout/html/base/src/nsTextFrame.cpp @@ -97,11 +97,6 @@ public: TextFrame(); // nsIFrame - NS_IMETHOD CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame); - NS_IMETHOD Paint(nsIPresContext& aPresContext, nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect, @@ -493,21 +488,6 @@ TextFrame::GetCursor(nsIPresContext& aPresContext, return NS_OK; } -NS_IMETHODIMP -TextFrame::CreateContinuingFrame(nsIPresContext& aCX, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame) -{ - TextFrame* cf = new TextFrame; - if (nsnull == cf) { - return NS_ERROR_OUT_OF_MEMORY; - } - cf->Init(aCX, mContent, aParent, aStyleContext, this); - aContinuingFrame = cf; - return NS_OK; -} - NS_IMETHODIMP TextFrame::ContentChanged(nsIPresContext* aPresContext, nsIContent* aChild, diff --git a/layout/html/style/src/nsCSSFrameConstructor.cpp b/layout/html/style/src/nsCSSFrameConstructor.cpp index b413db39bed4..4a4f9290d21c 100644 --- a/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -3575,100 +3575,164 @@ nsCSSFrameConstructor::CreateContinuingFrame(nsIPresContext* aPresContext, nsIFrame* aParentFrame, nsIFrame** aContinuingFrame) { -#if 1 - nsresult rv; - nsIFrame* continuingFrame; - - nsIStyleContext* styleContext; - aFrame->GetStyleContext(&styleContext); - rv = aFrame->CreateContinuingFrame(*aPresContext, aParentFrame, styleContext, - continuingFrame); - NS_RELEASE(styleContext); - *aContinuingFrame = continuingFrame; - return rv; -#else - nsIAtom* frameType; - nsIFrame* newFrame = nsnull; - PRBool forceView = PR_FALSE; - nsresult rv; + nsIAtom* frameType; + nsIContent* content; + nsIStyleContext* styleContext; + nsIFrame* newFrame = nsnull; + nsresult rv; + // Use the frame type to determine what type of frame to create aFrame->GetFrameType(&frameType); + aFrame->GetContent(&content); + aFrame->GetStyleContext(&styleContext); if (nsLayoutAtoms::textFrame == frameType) { rv = NS_NewTextFrame(newFrame); + if (NS_SUCCEEDED(rv)) { + newFrame->Init(*aPresContext, content, aParentFrame, styleContext, aFrame); + nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, newFrame, + styleContext, PR_FALSE); + } } else if (nsHTMLAtoms::inlineFrame == frameType) { - NS_NewInlineFrame(newFrame); + rv = NS_NewInlineFrame(newFrame); + if (NS_SUCCEEDED(rv)) { + newFrame->Init(*aPresContext, content, aParentFrame, styleContext, aFrame); + nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, newFrame, + styleContext, PR_FALSE); + } } else if (nsHTMLAtoms::blockFrame == frameType) { - NS_NewBlockFrame(newFrame, 0); + rv = NS_NewBlockFrame(newFrame, 0); + if (NS_SUCCEEDED(rv)) { + newFrame->Init(*aPresContext, content, aParentFrame, styleContext, aFrame); + nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, newFrame, + styleContext, PR_FALSE); + } } else if (nsLayoutAtoms::areaFrame == frameType) { - // XXX What should be used for the flags? - NS_NewAreaFrame(newFrame, 0); + rv = NS_NewAreaFrame(newFrame, 0); + if (NS_SUCCEEDED(rv)) { + newFrame->Init(*aPresContext, content, aParentFrame, styleContext, aFrame); + nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, newFrame, + styleContext, PR_FALSE); + } } else if (nsLayoutAtoms::pageFrame == frameType) { - NS_NewPageFrame(newFrame); - forceView = PR_TRUE; + rv = NS_NewPageFrame(newFrame); + if (NS_SUCCEEDED(rv)) { + newFrame->Init(*aPresContext, content, aParentFrame, styleContext, aFrame); + nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, newFrame, + styleContext, PR_TRUE); + } } else if (nsLayoutAtoms::tableOuterFrame == frameType) { - NS_NewTableOuterFrame(newFrame); + rv = NS_NewTableOuterFrame(newFrame); + if (NS_SUCCEEDED(rv)) { + newFrame->Init(*aPresContext, content, aParentFrame, styleContext, aFrame); + nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, newFrame, + styleContext, PR_FALSE); + + // Create a continuing inner table frame + nsIFrame* childFrame; + nsFrameItems newChildFrames; + + aFrame->FirstChild(nsnull, &childFrame); + while (childFrame) { + nsIAtom* tableType; + + // See if it's the inner table frame + childFrame->GetFrameType(&tableType); + if (nsLayoutAtoms::tableFrame == tableType) { + nsIFrame* continuingTableFrame; + + // It's the inner table frame, so create a continuing frame + CreateContinuingFrame(aPresContext, childFrame, newFrame, &continuingTableFrame); + newChildFrames.AddChild(continuingTableFrame); + } + NS_IF_RELEASE(tableType); + childFrame->GetNextSibling(&childFrame); + } + + // Set the outer table's initial child list + newFrame->SetInitialChildList(*aPresContext, nsnull, newChildFrames.childList); + } } else if (nsLayoutAtoms::tableFrame == frameType) { - NS_NewTableFrame(newFrame); + rv = NS_NewTableFrame(newFrame); + if (NS_SUCCEEDED(rv)) { + newFrame->Init(*aPresContext, content, aParentFrame, styleContext, aFrame); + nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, newFrame, + styleContext, PR_FALSE); + } } else if (nsLayoutAtoms::tableRowGroupFrame == frameType) { - NS_NewTableRowGroupFrame(newFrame); + rv = NS_NewTableRowGroupFrame(newFrame); + if (NS_SUCCEEDED(rv)) { + newFrame->Init(*aPresContext, content, aParentFrame, styleContext, aFrame); + nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, newFrame, + styleContext, PR_FALSE); + } } else if (nsLayoutAtoms::tableRowFrame == frameType) { - NS_NewTableRowFrame(newFrame); + rv = NS_NewTableRowFrame(newFrame); + if (NS_SUCCEEDED(rv)) { + newFrame->Init(*aPresContext, content, aParentFrame, styleContext, aFrame); + nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, newFrame, + styleContext, PR_FALSE); + + // Create a continuing frame for each table cell frame + nsIFrame* cellFrame; + nsFrameItems newChildList; + + aFrame->FirstChild(nsnull, &cellFrame); + while (cellFrame) { + nsIAtom* tableType; + + // See if it's a table cell frame + cellFrame->GetFrameType(&tableType); + if (nsLayoutAtoms::tableCellFrame == tableType) { + nsIFrame* continuingCellFrame; + + CreateContinuingFrame(aPresContext, cellFrame, newFrame, &continuingCellFrame); + newChildList.AddChild(continuingCellFrame); + } + + NS_IF_RELEASE(tableType); + cellFrame->GetNextSibling(&cellFrame); + } + + // Set the table cell's initial child list + newFrame->SetInitialChildList(*aPresContext, nsnull, newChildList.childList); + } } else if (nsLayoutAtoms::tableCellFrame == frameType) { - NS_NewTableCellFrame(newFrame); + rv = NS_NewTableCellFrame(newFrame); + if (NS_SUCCEEDED(rv)) { + newFrame->Init(*aPresContext, content, aParentFrame, styleContext, aFrame); + nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, newFrame, + styleContext, PR_FALSE); + + // Create a continuing area frame + nsIFrame* areaFrame; + nsIFrame* continuingAreaFrame; + aFrame->FirstChild(nsnull, &areaFrame); + CreateContinuingFrame(aPresContext, areaFrame, newFrame, &continuingAreaFrame); + + // Set the table cell's initial child list + newFrame->SetInitialChildList(*aPresContext, nsnull, continuingAreaFrame); + } } else { NS_ASSERTION(PR_FALSE, "unexpected frame type"); rv = NS_ERROR_UNEXPECTED; } - if (NS_SUCCEEDED(rv) && newFrame) { - nsIContent* content; - nsIStyleContext* styleContext; - - // Initialize the continuing frame, and create a view for it if appropriate - aFrame->GetContent(&content); - aFrame->GetStyleContext(&styleContext); - newFrame->Init(*aPresContext, content, aParentFrame, styleContext); - nsHTMLContainerFrame::CreateViewForFrame(*aPresContext, newFrame, - styleContext, forceView); - NS_RELEASE(styleContext); - NS_RELEASE(content); - - // Append it to the flow - newFrame->AppendToFlow(aFrame); - - // Make sure some of the flag bits are set - // XXX Maybe it would be better if we passed the prev-in-flow into the Init() - // call, and that way the frame can add itself to the flow and replicate any - // state... - nsFrameState state; - nsFrameState newState; - aFrame->GetFrameState(&state); - newFrame->GetFrameState(&newState); - - if (state & NS_FRAME_SYNC_FRAME_AND_VIEW) { - newState |= NS_FRAME_SYNC_FRAME_AND_VIEW; - } - if (state & NS_FRAME_REPLACED_ELEMENT) { - newState |= NS_FRAME_REPLACED_ELEMENT; - } - newFrame->SetFrameState(newState); - } - NS_RELEASE(frameType); - *aContinuingFrame = newFrame; + NS_RELEASE(styleContext); + NS_IF_RELEASE(content); + NS_IF_RELEASE(frameType); return rv; -#endif } nsresult diff --git a/layout/html/table/src/nsTableCellFrame.cpp b/layout/html/table/src/nsTableCellFrame.cpp index 2a8f27e0023f..034a67d98169 100644 --- a/layout/html/table/src/nsTableCellFrame.cpp +++ b/layout/html/table/src/nsTableCellFrame.cpp @@ -56,6 +56,31 @@ NS_IMPL_ADDREF(nsTableCellFrame) NS_IMPL_RELEASE(nsTableCellFrame) +NS_IMETHODIMP +nsTableCellFrame::Init(nsIPresContext& aPresContext, + nsIContent* aContent, + nsIFrame* aParent, + nsIStyleContext* aContext, + nsIFrame* aPrevInFlow) +{ + nsresult rv; + + // Let the base class do its initialization + rv = nsHTMLContainerFrame::Init(aPresContext, aContent, aParent, aContext, + aPrevInFlow); + + if (aPrevInFlow) { + // Set the column index + nsTableCellFrame* cellFrame = (nsTableCellFrame*)aPrevInFlow; + PRInt32 baseColIndex; + + cellFrame->GetColIndex(baseColIndex); + InitCellFrame(baseColIndex); + } + + return rv; +} + void nsTableCellFrame::InitCellFrame(PRInt32 aColIndex) { NS_PRECONDITION(0<=aColIndex, "bad col index arg"); @@ -586,35 +611,6 @@ NS_METHOD nsTableCellFrame::IR_StyleChanged(nsIPresContext& aPresContex return rv; } -NS_METHOD -nsTableCellFrame::CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame) -{ - nsTableCellFrame* cf = new nsTableCellFrame; - if (nsnull == cf) { - return NS_ERROR_OUT_OF_MEMORY; - } - cf->Init(aPresContext, mContent, aParent, aStyleContext, this); - PRInt32 baseColIndex; - GetColIndex(baseColIndex); - cf->InitCellFrame(baseColIndex); - aContinuingFrame = cf; - - // Create a continuing body frame - nsIFrame* childList; - nsIStyleContext* kidSC; - - nsIFrame* firstKid = mFrames.FirstChild(); - firstKid->GetStyleContext(&kidSC); - firstKid->CreateContinuingFrame(aPresContext, cf, kidSC, childList); - NS_RELEASE(kidSC); - cf->SetInitialChildList(aPresContext, nsnull, childList); - return NS_OK; -} - - /** * * Update the border style to map to the HTML border style diff --git a/layout/html/table/src/nsTableCellFrame.h b/layout/html/table/src/nsTableCellFrame.h index 7af87b1f5ee7..ed3c046142af 100644 --- a/layout/html/table/src/nsTableCellFrame.h +++ b/layout/html/table/src/nsTableCellFrame.h @@ -48,6 +48,12 @@ public: // default constructor supplied by the compiler + NS_IMETHOD Init(nsIPresContext& aPresContext, + nsIContent* aContent, + nsIFrame* aParent, + nsIStyleContext* aContext, + nsIFrame* aPrevInFlow); + void InitCellFrame(PRInt32 aColIndex); void SetBorderEdge(PRUint8 aSide, @@ -79,14 +85,6 @@ public: const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus); - /** - * @see nsContainerFrame - */ - NS_IMETHOD CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame); - /** * Get the "type" of the frame * diff --git a/layout/html/table/src/nsTableFrame.cpp b/layout/html/table/src/nsTableFrame.cpp index 26c2ea3399b8..d147003f9388 100644 --- a/layout/html/table/src/nsTableFrame.cpp +++ b/layout/html/table/src/nsTableFrame.cpp @@ -308,14 +308,27 @@ nsTableFrame::Init(nsIPresContext& aPresContext, nsIStyleContext* aContext, nsIFrame* aPrevInFlow) { - float p2t; + nsresult rv; + float p2t; + aPresContext.GetPixelsToTwips(&p2t); mDefaultCellSpacingX = NSIntPixelsToTwips(2, p2t); mDefaultCellSpacingY = NSIntPixelsToTwips(2, p2t); mDefaultCellPadding = NSIntPixelsToTwips(1, p2t); - return nsHTMLContainerFrame::Init(aPresContext, aContent, aParent, aContext, - aPrevInFlow); + // Let the base class do its processing + rv = nsHTMLContainerFrame::Init(aPresContext, aContent, aParent, aContext, + aPrevInFlow); + + if (aPrevInFlow) { + // set my width, because all frames in a table flow are the same width and + // code in nsTableOuterFrame depends on this being set + nsSize size; + aPrevInFlow->GetSize(size); + mRect.width = size.width; + } + + return rv; } @@ -4452,70 +4465,6 @@ void nsTableFrame::InvalidateCellMap() if (PR_TRUE==gsDebugIR) printf("TIF: CellMap invalidated.\n"); } -NS_METHOD -nsTableFrame::CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame) -{ - nsTableFrame* cf = new nsTableFrame; - if (nsnull == cf) { - return NS_ERROR_OUT_OF_MEMORY; - } - cf->Init(aPresContext, mContent, aParent, aStyleContext, this); - if (PR_TRUE==gsDebug) printf("nsTableFrame::CCF parent = %p, this=%p, cf=%p\n", aParent, this, cf); - // set my width, because all frames in a table flow are the same width - // code in nsTableOuterFrame depends on this being set - cf->SetRect(nsRect(0, 0, mRect.width, 0)); - // add headers and footers to cf - nsTableFrame * firstInFlow = (nsTableFrame *)GetFirstInFlow(); - nsIFrame * rg = nsnull; - firstInFlow->FirstChild(nsnull, &rg); - NS_ASSERTION (nsnull!=rg, "previous frame has no children"); - PRInt32 index = 0; - nsIFrame * bodyRowGroupFromOverflow = mOverflowFrames.FirstChild(); - nsIFrame * lastSib = nsnull; - for ( ; nsnull!=rg; index++) - { - nsIContent *content = nsnull; - rg->GetContent(&content); // content: REFCNT++ - NS_ASSERTION(nsnull!=content, "bad frame, returned null content."); - const nsStyleDisplay* display; - //XXX: TROY: this was just this->GetStyleData which can't be right - rg->GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&)display); - if ((display->mDisplay == NS_STYLE_DISPLAY_TABLE_HEADER_GROUP) || - (display->mDisplay == NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP)) - { - printf("found a head or foot in continuing frame\n"); - // Resolve style for the child - nsIStyleContext* kidStyleContext; - aPresContext.ResolveStyleContextFor(content, aStyleContext, - PR_FALSE, &kidStyleContext); // kidStyleContext: REFCNT++ - - nsIFrame* duplicateFrame; - NS_NewTableRowGroupFrame(duplicateFrame); - duplicateFrame->Init(aPresContext, content, cf, kidStyleContext, nsnull); - NS_RELEASE(kidStyleContext); // kidStyleContenxt: REFCNT-- - - if (nsnull==lastSib) - { - mOverflowFrames.SetFrames(duplicateFrame); - } - else - { - lastSib->SetNextSibling(duplicateFrame); - } - duplicateFrame->SetNextSibling(bodyRowGroupFromOverflow); - lastSib = duplicateFrame; - } - NS_RELEASE(content); // content: REFCNT-- - // get the next row group - rg->GetNextSibling(&rg); - } - aContinuingFrame = cf; - return NS_OK; -} - PRInt32 nsTableFrame::GetColumnWidth(PRInt32 aColIndex) { nsTableFrame * firstInFlow = (nsTableFrame *)GetFirstInFlow(); diff --git a/layout/html/table/src/nsTableFrame.h b/layout/html/table/src/nsTableFrame.h index 55f78738c673..779b6f1d627f 100644 --- a/layout/html/table/src/nsTableFrame.h +++ b/layout/html/table/src/nsTableFrame.h @@ -182,12 +182,6 @@ public: const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus); - /** @see nsContainerFrame::CreateContinuingFrame */ - NS_IMETHOD CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame); - /** allow the cell and row attributes to effect the column frame * currently, the only reason this exists is to support the HTML "rule" * that a width attribute on a cell in the first column sets the column width. diff --git a/layout/html/table/src/nsTableOuterFrame.cpp b/layout/html/table/src/nsTableOuterFrame.cpp index 623ba938c45c..c246f3c8ef9b 100644 --- a/layout/html/table/src/nsTableOuterFrame.cpp +++ b/layout/html/table/src/nsTableOuterFrame.cpp @@ -1083,33 +1083,6 @@ void nsTableOuterFrame::PlaceChild( OuterTableReflowState& aReflowState, } } - -NS_METHOD -nsTableOuterFrame::CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame) -{ - nsTableOuterFrame* cf = new nsTableOuterFrame; - if (nsnull == cf) { - return NS_ERROR_OUT_OF_MEMORY; - } - cf->Init(aPresContext, mContent, aParent, aStyleContext, this); - if (PR_TRUE==gsDebug) - printf("nsTableOuterFrame::CCF parent = %p, this=%p, cf=%p\n", aParent, this, cf); - aContinuingFrame = cf; - - // Create a continuing inner table frame - nsIFrame* childList; - nsIStyleContext* kidSC; - - mInnerTableFrame->GetStyleContext(&kidSC); - mInnerTableFrame->CreateContinuingFrame(aPresContext, cf, kidSC, childList); - NS_RELEASE(kidSC); - cf->SetInitialChildList(aPresContext, nsnull, childList); - return NS_OK; -} - NS_METHOD nsTableOuterFrame::VerifyTree() const { #ifdef NS_DEBUG diff --git a/layout/html/table/src/nsTableOuterFrame.h b/layout/html/table/src/nsTableOuterFrame.h index c6d57025428d..ba83b9e69910 100644 --- a/layout/html/table/src/nsTableOuterFrame.h +++ b/layout/html/table/src/nsTableOuterFrame.h @@ -69,12 +69,6 @@ public: const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus); - /** @see nsIFrame::CreateContinuingFrame */ - NS_IMETHOD CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame); - /** * Get the "type" of the frame * diff --git a/layout/html/table/src/nsTableRowFrame.cpp b/layout/html/table/src/nsTableRowFrame.cpp index 5a2f3d42cd85..ba4aba08a75e 100644 --- a/layout/html/table/src/nsTableRowFrame.cpp +++ b/layout/html/table/src/nsTableRowFrame.cpp @@ -92,6 +92,29 @@ nsTableRowFrame::nsTableRowFrame() { } +NS_IMETHODIMP +nsTableRowFrame::Init(nsIPresContext& aPresContext, + nsIContent* aContent, + nsIFrame* aParent, + nsIStyleContext* aContext, + nsIFrame* aPrevInFlow) +{ + nsresult rv; + + // Let the the base class do its initialization + rv = nsHTMLContainerFrame::Init(aPresContext, aContent, aParent, aContext, + aPrevInFlow); + + if (aPrevInFlow) { + // Set the row index + nsTableRowFrame* rowFrame = (nsTableRowFrame*)aPrevInFlow; + + SetRowIndex(rowFrame->GetRowIndex()); + } + + return rv; +} + NS_IMETHODIMP nsTableRowFrame::SetInitialChildList(nsIPresContext& aPresContext, nsIAtom* aListName, @@ -1430,50 +1453,6 @@ nsTableRowFrame::Reflow(nsIPresContext& aPresContext, return rv; } -NS_METHOD -nsTableRowFrame::CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame) -{ - nsTableRowFrame* cf = new nsTableRowFrame; - if (nsnull == cf) { - return NS_ERROR_OUT_OF_MEMORY; - } - cf->Init(aPresContext, mContent, aParent, aStyleContext, this); - cf->SetRowIndex(GetRowIndex()); - - // Create a continuing frame for each table cell frame - nsIFrame* newChildList; - for (nsIFrame* kidFrame = mFrames.FirstChild(); - nsnull != kidFrame; - kidFrame->GetNextSibling(&kidFrame)) { - - const nsStyleDisplay *kidDisplay; - kidFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)kidDisplay)); - if (NS_STYLE_DISPLAY_TABLE_CELL == kidDisplay->mDisplay) { - nsIFrame* contCellFrame; - nsIStyleContext* kidSC; - - // Create a continuing cell frame - kidFrame->GetStyleContext(&kidSC); - kidFrame->CreateContinuingFrame(aPresContext, cf, kidSC, contCellFrame); - NS_RELEASE(kidSC); - - // Link it into the list of child frames - if (nsnull == cf->mFrames.FirstChild()) { - cf->mFrames.SetFrames(contCellFrame); - } else { - newChildList->SetNextSibling(contCellFrame); - } - newChildList = contCellFrame; - } - } - - aContinuingFrame = cf; - return NS_OK; -} - /* we overload this here because rows have children that can span outside of themselves. * so the default "get the child rect, see if it contains the event point" action isn't * sufficient. We have to ask the row if it has a child that contains the point. diff --git a/layout/html/table/src/nsTableRowFrame.h b/layout/html/table/src/nsTableRowFrame.h index f9afafaa2ad2..812692559556 100644 --- a/layout/html/table/src/nsTableRowFrame.h +++ b/layout/html/table/src/nsTableRowFrame.h @@ -38,6 +38,12 @@ struct RowReflowState; class nsTableRowFrame : public nsHTMLContainerFrame { public: + NS_IMETHOD Init(nsIPresContext& aPresContext, + nsIContent* aContent, + nsIFrame* aParent, + nsIStyleContext* aContext, + nsIFrame* aPrevInFlow); + /** Initialization of data */ NS_IMETHOD InitChildren(PRInt32 aRowIndex=-1); @@ -93,12 +99,6 @@ public: virtual void DidResize(nsIPresContext& aPresContext, const nsHTMLReflowState& aReflowState); - /** @see nsContainerFrame::CreateContinuingFrame */ - NS_IMETHOD CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame); - /** * Get the "type" of the frame * diff --git a/layout/html/table/src/nsTableRowGroupFrame.cpp b/layout/html/table/src/nsTableRowGroupFrame.cpp index f06768cba14b..696c7a32f776 100644 --- a/layout/html/table/src/nsTableRowGroupFrame.cpp +++ b/layout/html/table/src/nsTableRowGroupFrame.cpp @@ -1296,23 +1296,6 @@ NS_METHOD nsTableRowGroupFrame::IR_StyleChanged(nsIPresContext& aPresContex return rv; } -// XXX this doesn't handle scrolling, it that is even possible in this context -NS_METHOD -nsTableRowGroupFrame::CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame) -{ - nsTableRowGroupFrame* cf = new nsTableRowGroupFrame; - if (nsnull == cf) { - return NS_ERROR_OUT_OF_MEMORY; - } - cf->Init(aPresContext, mContent, aParent, aStyleContext, this); - if (PR_TRUE==gsDebug) printf("nsTableRowGroupFrame::CCF parent = %p, this=%p, cf=%p\n", aParent, this, cf); - aContinuingFrame = cf; - return NS_OK; -} - NS_IMETHODIMP nsTableRowGroupFrame::GetFrameType(nsIAtom** aType) const { diff --git a/layout/html/table/src/nsTableRowGroupFrame.h b/layout/html/table/src/nsTableRowGroupFrame.h index 1d10a85218c5..6db0fb8b54db 100644 --- a/layout/html/table/src/nsTableRowGroupFrame.h +++ b/layout/html/table/src/nsTableRowGroupFrame.h @@ -184,12 +184,6 @@ protected: PRBool NoRowsFollow(); - /** @see nsContainerFrame::CreateContinuingFrame */ - NS_IMETHOD CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame); - nsresult AdjustSiblingsAfterReflow(nsIPresContext& aPresContext, RowGroupReflowState& aReflowState, nsIFrame* aKidFrame, diff --git a/layout/tables/nsTableCellFrame.cpp b/layout/tables/nsTableCellFrame.cpp index 2a8f27e0023f..034a67d98169 100644 --- a/layout/tables/nsTableCellFrame.cpp +++ b/layout/tables/nsTableCellFrame.cpp @@ -56,6 +56,31 @@ NS_IMPL_ADDREF(nsTableCellFrame) NS_IMPL_RELEASE(nsTableCellFrame) +NS_IMETHODIMP +nsTableCellFrame::Init(nsIPresContext& aPresContext, + nsIContent* aContent, + nsIFrame* aParent, + nsIStyleContext* aContext, + nsIFrame* aPrevInFlow) +{ + nsresult rv; + + // Let the base class do its initialization + rv = nsHTMLContainerFrame::Init(aPresContext, aContent, aParent, aContext, + aPrevInFlow); + + if (aPrevInFlow) { + // Set the column index + nsTableCellFrame* cellFrame = (nsTableCellFrame*)aPrevInFlow; + PRInt32 baseColIndex; + + cellFrame->GetColIndex(baseColIndex); + InitCellFrame(baseColIndex); + } + + return rv; +} + void nsTableCellFrame::InitCellFrame(PRInt32 aColIndex) { NS_PRECONDITION(0<=aColIndex, "bad col index arg"); @@ -586,35 +611,6 @@ NS_METHOD nsTableCellFrame::IR_StyleChanged(nsIPresContext& aPresContex return rv; } -NS_METHOD -nsTableCellFrame::CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame) -{ - nsTableCellFrame* cf = new nsTableCellFrame; - if (nsnull == cf) { - return NS_ERROR_OUT_OF_MEMORY; - } - cf->Init(aPresContext, mContent, aParent, aStyleContext, this); - PRInt32 baseColIndex; - GetColIndex(baseColIndex); - cf->InitCellFrame(baseColIndex); - aContinuingFrame = cf; - - // Create a continuing body frame - nsIFrame* childList; - nsIStyleContext* kidSC; - - nsIFrame* firstKid = mFrames.FirstChild(); - firstKid->GetStyleContext(&kidSC); - firstKid->CreateContinuingFrame(aPresContext, cf, kidSC, childList); - NS_RELEASE(kidSC); - cf->SetInitialChildList(aPresContext, nsnull, childList); - return NS_OK; -} - - /** * * Update the border style to map to the HTML border style diff --git a/layout/tables/nsTableCellFrame.h b/layout/tables/nsTableCellFrame.h index 7af87b1f5ee7..ed3c046142af 100644 --- a/layout/tables/nsTableCellFrame.h +++ b/layout/tables/nsTableCellFrame.h @@ -48,6 +48,12 @@ public: // default constructor supplied by the compiler + NS_IMETHOD Init(nsIPresContext& aPresContext, + nsIContent* aContent, + nsIFrame* aParent, + nsIStyleContext* aContext, + nsIFrame* aPrevInFlow); + void InitCellFrame(PRInt32 aColIndex); void SetBorderEdge(PRUint8 aSide, @@ -79,14 +85,6 @@ public: const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus); - /** - * @see nsContainerFrame - */ - NS_IMETHOD CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame); - /** * Get the "type" of the frame * diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index 26c2ea3399b8..d147003f9388 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -308,14 +308,27 @@ nsTableFrame::Init(nsIPresContext& aPresContext, nsIStyleContext* aContext, nsIFrame* aPrevInFlow) { - float p2t; + nsresult rv; + float p2t; + aPresContext.GetPixelsToTwips(&p2t); mDefaultCellSpacingX = NSIntPixelsToTwips(2, p2t); mDefaultCellSpacingY = NSIntPixelsToTwips(2, p2t); mDefaultCellPadding = NSIntPixelsToTwips(1, p2t); - return nsHTMLContainerFrame::Init(aPresContext, aContent, aParent, aContext, - aPrevInFlow); + // Let the base class do its processing + rv = nsHTMLContainerFrame::Init(aPresContext, aContent, aParent, aContext, + aPrevInFlow); + + if (aPrevInFlow) { + // set my width, because all frames in a table flow are the same width and + // code in nsTableOuterFrame depends on this being set + nsSize size; + aPrevInFlow->GetSize(size); + mRect.width = size.width; + } + + return rv; } @@ -4452,70 +4465,6 @@ void nsTableFrame::InvalidateCellMap() if (PR_TRUE==gsDebugIR) printf("TIF: CellMap invalidated.\n"); } -NS_METHOD -nsTableFrame::CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame) -{ - nsTableFrame* cf = new nsTableFrame; - if (nsnull == cf) { - return NS_ERROR_OUT_OF_MEMORY; - } - cf->Init(aPresContext, mContent, aParent, aStyleContext, this); - if (PR_TRUE==gsDebug) printf("nsTableFrame::CCF parent = %p, this=%p, cf=%p\n", aParent, this, cf); - // set my width, because all frames in a table flow are the same width - // code in nsTableOuterFrame depends on this being set - cf->SetRect(nsRect(0, 0, mRect.width, 0)); - // add headers and footers to cf - nsTableFrame * firstInFlow = (nsTableFrame *)GetFirstInFlow(); - nsIFrame * rg = nsnull; - firstInFlow->FirstChild(nsnull, &rg); - NS_ASSERTION (nsnull!=rg, "previous frame has no children"); - PRInt32 index = 0; - nsIFrame * bodyRowGroupFromOverflow = mOverflowFrames.FirstChild(); - nsIFrame * lastSib = nsnull; - for ( ; nsnull!=rg; index++) - { - nsIContent *content = nsnull; - rg->GetContent(&content); // content: REFCNT++ - NS_ASSERTION(nsnull!=content, "bad frame, returned null content."); - const nsStyleDisplay* display; - //XXX: TROY: this was just this->GetStyleData which can't be right - rg->GetStyleData(eStyleStruct_Display, (const nsStyleStruct*&)display); - if ((display->mDisplay == NS_STYLE_DISPLAY_TABLE_HEADER_GROUP) || - (display->mDisplay == NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP)) - { - printf("found a head or foot in continuing frame\n"); - // Resolve style for the child - nsIStyleContext* kidStyleContext; - aPresContext.ResolveStyleContextFor(content, aStyleContext, - PR_FALSE, &kidStyleContext); // kidStyleContext: REFCNT++ - - nsIFrame* duplicateFrame; - NS_NewTableRowGroupFrame(duplicateFrame); - duplicateFrame->Init(aPresContext, content, cf, kidStyleContext, nsnull); - NS_RELEASE(kidStyleContext); // kidStyleContenxt: REFCNT-- - - if (nsnull==lastSib) - { - mOverflowFrames.SetFrames(duplicateFrame); - } - else - { - lastSib->SetNextSibling(duplicateFrame); - } - duplicateFrame->SetNextSibling(bodyRowGroupFromOverflow); - lastSib = duplicateFrame; - } - NS_RELEASE(content); // content: REFCNT-- - // get the next row group - rg->GetNextSibling(&rg); - } - aContinuingFrame = cf; - return NS_OK; -} - PRInt32 nsTableFrame::GetColumnWidth(PRInt32 aColIndex) { nsTableFrame * firstInFlow = (nsTableFrame *)GetFirstInFlow(); diff --git a/layout/tables/nsTableFrame.h b/layout/tables/nsTableFrame.h index 55f78738c673..779b6f1d627f 100644 --- a/layout/tables/nsTableFrame.h +++ b/layout/tables/nsTableFrame.h @@ -182,12 +182,6 @@ public: const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus); - /** @see nsContainerFrame::CreateContinuingFrame */ - NS_IMETHOD CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame); - /** allow the cell and row attributes to effect the column frame * currently, the only reason this exists is to support the HTML "rule" * that a width attribute on a cell in the first column sets the column width. diff --git a/layout/tables/nsTableOuterFrame.cpp b/layout/tables/nsTableOuterFrame.cpp index 623ba938c45c..c246f3c8ef9b 100644 --- a/layout/tables/nsTableOuterFrame.cpp +++ b/layout/tables/nsTableOuterFrame.cpp @@ -1083,33 +1083,6 @@ void nsTableOuterFrame::PlaceChild( OuterTableReflowState& aReflowState, } } - -NS_METHOD -nsTableOuterFrame::CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame) -{ - nsTableOuterFrame* cf = new nsTableOuterFrame; - if (nsnull == cf) { - return NS_ERROR_OUT_OF_MEMORY; - } - cf->Init(aPresContext, mContent, aParent, aStyleContext, this); - if (PR_TRUE==gsDebug) - printf("nsTableOuterFrame::CCF parent = %p, this=%p, cf=%p\n", aParent, this, cf); - aContinuingFrame = cf; - - // Create a continuing inner table frame - nsIFrame* childList; - nsIStyleContext* kidSC; - - mInnerTableFrame->GetStyleContext(&kidSC); - mInnerTableFrame->CreateContinuingFrame(aPresContext, cf, kidSC, childList); - NS_RELEASE(kidSC); - cf->SetInitialChildList(aPresContext, nsnull, childList); - return NS_OK; -} - NS_METHOD nsTableOuterFrame::VerifyTree() const { #ifdef NS_DEBUG diff --git a/layout/tables/nsTableOuterFrame.h b/layout/tables/nsTableOuterFrame.h index c6d57025428d..ba83b9e69910 100644 --- a/layout/tables/nsTableOuterFrame.h +++ b/layout/tables/nsTableOuterFrame.h @@ -69,12 +69,6 @@ public: const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus); - /** @see nsIFrame::CreateContinuingFrame */ - NS_IMETHOD CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame); - /** * Get the "type" of the frame * diff --git a/layout/tables/nsTableRowFrame.cpp b/layout/tables/nsTableRowFrame.cpp index 5a2f3d42cd85..ba4aba08a75e 100644 --- a/layout/tables/nsTableRowFrame.cpp +++ b/layout/tables/nsTableRowFrame.cpp @@ -92,6 +92,29 @@ nsTableRowFrame::nsTableRowFrame() { } +NS_IMETHODIMP +nsTableRowFrame::Init(nsIPresContext& aPresContext, + nsIContent* aContent, + nsIFrame* aParent, + nsIStyleContext* aContext, + nsIFrame* aPrevInFlow) +{ + nsresult rv; + + // Let the the base class do its initialization + rv = nsHTMLContainerFrame::Init(aPresContext, aContent, aParent, aContext, + aPrevInFlow); + + if (aPrevInFlow) { + // Set the row index + nsTableRowFrame* rowFrame = (nsTableRowFrame*)aPrevInFlow; + + SetRowIndex(rowFrame->GetRowIndex()); + } + + return rv; +} + NS_IMETHODIMP nsTableRowFrame::SetInitialChildList(nsIPresContext& aPresContext, nsIAtom* aListName, @@ -1430,50 +1453,6 @@ nsTableRowFrame::Reflow(nsIPresContext& aPresContext, return rv; } -NS_METHOD -nsTableRowFrame::CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame) -{ - nsTableRowFrame* cf = new nsTableRowFrame; - if (nsnull == cf) { - return NS_ERROR_OUT_OF_MEMORY; - } - cf->Init(aPresContext, mContent, aParent, aStyleContext, this); - cf->SetRowIndex(GetRowIndex()); - - // Create a continuing frame for each table cell frame - nsIFrame* newChildList; - for (nsIFrame* kidFrame = mFrames.FirstChild(); - nsnull != kidFrame; - kidFrame->GetNextSibling(&kidFrame)) { - - const nsStyleDisplay *kidDisplay; - kidFrame->GetStyleData(eStyleStruct_Display, ((const nsStyleStruct *&)kidDisplay)); - if (NS_STYLE_DISPLAY_TABLE_CELL == kidDisplay->mDisplay) { - nsIFrame* contCellFrame; - nsIStyleContext* kidSC; - - // Create a continuing cell frame - kidFrame->GetStyleContext(&kidSC); - kidFrame->CreateContinuingFrame(aPresContext, cf, kidSC, contCellFrame); - NS_RELEASE(kidSC); - - // Link it into the list of child frames - if (nsnull == cf->mFrames.FirstChild()) { - cf->mFrames.SetFrames(contCellFrame); - } else { - newChildList->SetNextSibling(contCellFrame); - } - newChildList = contCellFrame; - } - } - - aContinuingFrame = cf; - return NS_OK; -} - /* we overload this here because rows have children that can span outside of themselves. * so the default "get the child rect, see if it contains the event point" action isn't * sufficient. We have to ask the row if it has a child that contains the point. diff --git a/layout/tables/nsTableRowFrame.h b/layout/tables/nsTableRowFrame.h index f9afafaa2ad2..812692559556 100644 --- a/layout/tables/nsTableRowFrame.h +++ b/layout/tables/nsTableRowFrame.h @@ -38,6 +38,12 @@ struct RowReflowState; class nsTableRowFrame : public nsHTMLContainerFrame { public: + NS_IMETHOD Init(nsIPresContext& aPresContext, + nsIContent* aContent, + nsIFrame* aParent, + nsIStyleContext* aContext, + nsIFrame* aPrevInFlow); + /** Initialization of data */ NS_IMETHOD InitChildren(PRInt32 aRowIndex=-1); @@ -93,12 +99,6 @@ public: virtual void DidResize(nsIPresContext& aPresContext, const nsHTMLReflowState& aReflowState); - /** @see nsContainerFrame::CreateContinuingFrame */ - NS_IMETHOD CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame); - /** * Get the "type" of the frame * diff --git a/layout/tables/nsTableRowGroupFrame.cpp b/layout/tables/nsTableRowGroupFrame.cpp index f06768cba14b..696c7a32f776 100644 --- a/layout/tables/nsTableRowGroupFrame.cpp +++ b/layout/tables/nsTableRowGroupFrame.cpp @@ -1296,23 +1296,6 @@ NS_METHOD nsTableRowGroupFrame::IR_StyleChanged(nsIPresContext& aPresContex return rv; } -// XXX this doesn't handle scrolling, it that is even possible in this context -NS_METHOD -nsTableRowGroupFrame::CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame) -{ - nsTableRowGroupFrame* cf = new nsTableRowGroupFrame; - if (nsnull == cf) { - return NS_ERROR_OUT_OF_MEMORY; - } - cf->Init(aPresContext, mContent, aParent, aStyleContext, this); - if (PR_TRUE==gsDebug) printf("nsTableRowGroupFrame::CCF parent = %p, this=%p, cf=%p\n", aParent, this, cf); - aContinuingFrame = cf; - return NS_OK; -} - NS_IMETHODIMP nsTableRowGroupFrame::GetFrameType(nsIAtom** aType) const { diff --git a/layout/tables/nsTableRowGroupFrame.h b/layout/tables/nsTableRowGroupFrame.h index 1d10a85218c5..6db0fb8b54db 100644 --- a/layout/tables/nsTableRowGroupFrame.h +++ b/layout/tables/nsTableRowGroupFrame.h @@ -184,12 +184,6 @@ protected: PRBool NoRowsFollow(); - /** @see nsContainerFrame::CreateContinuingFrame */ - NS_IMETHOD CreateContinuingFrame(nsIPresContext& aPresContext, - nsIFrame* aParent, - nsIStyleContext* aStyleContext, - nsIFrame*& aContinuingFrame); - nsresult AdjustSiblingsAfterReflow(nsIPresContext& aPresContext, RowGroupReflowState& aReflowState, nsIFrame* aKidFrame,