diff --git a/layout/html/table/src/nsTableCellFrame.cpp b/layout/html/table/src/nsTableCellFrame.cpp index b5f753bf396..e8e31513679 100644 --- a/layout/html/table/src/nsTableCellFrame.cpp +++ b/layout/html/table/src/nsTableCellFrame.cpp @@ -52,7 +52,7 @@ static const PRBool gsDebugNT = PR_FALSE; */ nsTableCellFrame::nsTableCellFrame(nsIContent* aContent, nsIFrame* aParentFrame) - : nsContainerFrame(aContent, aParentFrame) + : nsHTMLContainerFrame(aContent, aParentFrame) { mColIndex=0; mPriorAvailWidth=0; @@ -130,12 +130,24 @@ NS_METHOD nsTableCellFrame::Paint(nsIPresContext& aPresContext, return NS_OK; } -/** -* -* Align the cell's child frame within the cell -* -**/ +PRIntn +nsTableCellFrame::GetSkipSides() const +{ + PRIntn skip = 0; + if (nsnull != mPrevInFlow) { + skip |= 1 << NS_SIDE_TOP; + } + if (nsnull != mNextInFlow) { + skip |= 1 << NS_SIDE_BOTTOM; + } + return skip; +} +/** + * + * Align the cell's child frame within the cell + * + */ void nsTableCellFrame::VerticallyAlignChild(nsIPresContext* aPresContext) { const nsStyleSpacing* spacing = diff --git a/layout/html/table/src/nsTableCellFrame.h b/layout/html/table/src/nsTableCellFrame.h index 7d6b19b62ba..3e314054a10 100644 --- a/layout/html/table/src/nsTableCellFrame.h +++ b/layout/html/table/src/nsTableCellFrame.h @@ -19,7 +19,7 @@ #define nsTableCellFrame_h__ #include "nscore.h" -#include "nsContainerFrame.h" +#include "nsHTMLContainerFrame.h" #include "nsTableFrame.h" #include "nsTableRowFrame.h" // need to actually include this here to inline GetRowIndex @@ -37,7 +37,7 @@ extern const nsIID kTableCellFrameCID; * * @author sclark */ -class nsTableCellFrame : public nsContainerFrame +class nsTableCellFrame : public nsHTMLContainerFrame { public: @@ -136,6 +136,10 @@ public: /** destructor */ virtual ~nsTableCellFrame(); +protected: + /** implement abstract method on nsHTMLContainerFrame */ + virtual PRIntn GetSkipSides() const; + private: // All these methods are support methods for RecalcLayoutData diff --git a/layout/html/table/src/nsTableColGroupFrame.cpp b/layout/html/table/src/nsTableColGroupFrame.cpp index 8625630007f..f2ead478ef8 100644 --- a/layout/html/table/src/nsTableColGroupFrame.cpp +++ b/layout/html/table/src/nsTableColGroupFrame.cpp @@ -45,7 +45,7 @@ static const PRBool gsDebugIR = PR_FALSE; nsTableColGroupFrame::nsTableColGroupFrame(nsIContent* aContent, nsIFrame* aParentFrame) - : nsContainerFrame(aContent, aParentFrame) + : nsHTMLContainerFrame(aContent, aParentFrame) { mColCount=0; } @@ -176,6 +176,19 @@ NS_METHOD nsTableColGroupFrame::Paint(nsIPresContext& aPresContext, return NS_OK; } +PRIntn +nsTableColGroupFrame::GetSkipSides() const +{ + PRIntn skip = 0; + if (nsnull != mPrevInFlow) { + skip |= 1 << NS_SIDE_TOP; + } + if (nsnull != mNextInFlow) { + skip |= 1 << NS_SIDE_BOTTOM; + } + return skip; +} + NS_METHOD nsTableColGroupFrame::Reflow(nsIPresContext& aPresContext, nsHTMLReflowMetrics& aDesiredSize, const nsHTMLReflowState& aReflowState, @@ -267,8 +280,7 @@ NS_METHOD nsTableColGroupFrame::IR_TargetIsMe(nsIPresContext& aPresCont } else { - rv = IR_UnknownFrameInserted(aPresContext, aDesiredSize, aReflowState, aStatus, - objectFrame, PR_FALSE); + rv = AddFrame(aReflowState, objectFrame); } break; @@ -280,8 +292,7 @@ NS_METHOD nsTableColGroupFrame::IR_TargetIsMe(nsIPresContext& aPresCont } else { // no optimization to be done for Unknown frame types, so just reuse the Inserted method - rv = IR_UnknownFrameInserted(aPresContext, aDesiredSize, aReflowState, aStatus, - objectFrame, PR_FALSE); + rv = AddFrame(aReflowState, objectFrame); } break; @@ -299,8 +310,7 @@ NS_METHOD nsTableColGroupFrame::IR_TargetIsMe(nsIPresContext& aPresCont else { - rv = IR_UnknownFrameRemoved(aPresContext, aDesiredSize, aReflowState, aStatus, - objectFrame); + rv = RemoveFrame(objectFrame); } break; @@ -337,7 +347,7 @@ NS_METHOD nsTableColGroupFrame::IR_ColInserted(nsIPresContext& aPresCon { nsresult rv=NS_OK; PRBool adjustStartingColIndex=PR_FALSE; - rv = IR_UnknownFrameInserted(aPresContext, aDesiredSize, aReflowState, aStatus, aInsertedFrame, aReplace); + rv = AddFrame(aReflowState, (nsIFrame *)aInsertedFrame); if (NS_FAILED(rv)) return rv; PRInt32 startingColIndex=mStartColIndex; @@ -373,7 +383,7 @@ NS_METHOD nsTableColGroupFrame::IR_ColAppended(nsIPresContext& aPresCon { nsresult rv=NS_OK; PRBool adjustStartingColIndex=PR_FALSE; - rv = IR_UnknownFrameInserted(aPresContext, aDesiredSize, aReflowState, aStatus, aAppendedFrame, PR_FALSE); + rv = AddFrame(aReflowState, (nsIFrame*)aAppendedFrame); if (NS_FAILED(rv)) return rv; PRInt32 startingColIndex=mStartColIndex; @@ -447,85 +457,6 @@ NS_METHOD nsTableColGroupFrame::IR_ColRemoved(nsIPresContext& aPresCont return rv; } -//XXX: handle aReplace -NS_METHOD nsTableColGroupFrame::IR_UnknownFrameInserted(nsIPresContext& aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - const nsHTMLReflowState& aReflowState, - nsReflowStatus& aStatus, - nsIFrame * aInsertedFrame, - PRBool aReplace) -{ - nsIReflowCommand::ReflowType type; - aReflowState.reflowCommand->GetType(type); - // we have a generic frame that gets inserted but doesn't effect reflow - // hook it up then ignore it - if (nsIReflowCommand::FrameAppended==type) - { // frameAppended reflow -- find the last child and make aInsertedFrame its next sibling - if (PR_TRUE==gsDebugIR) printf("TCGF IR: FrameAppended adding unknown frame type.\n"); - nsIFrame *lastChild=mFirstChild; - nsIFrame *nextChild=mFirstChild; - while (nsnull!=nextChild) - { - lastChild=nextChild; - nextChild->GetNextSibling(nextChild); - } - if (nsnull==lastChild) - mFirstChild = aInsertedFrame; - else - lastChild->SetNextSibling(aInsertedFrame); - } - else - { // frameInserted reflow -- hook up aInsertedFrame as prevSibling's next sibling, - // and be sure to hook in aInsertedFrame's nextSibling (from prevSibling) - if (PR_TRUE==gsDebugIR) printf("TCGF IR: FrameInserted adding unknown frame type.\n"); - nsIFrame *prevSibling=nsnull; - nsresult rv = aReflowState.reflowCommand->GetPrevSiblingFrame(prevSibling); - if (NS_SUCCEEDED(rv) && (nsnull!=prevSibling)) - { - nsIFrame *nextSibling=nsnull; - prevSibling->GetNextSibling(nextSibling); - prevSibling->SetNextSibling(aInsertedFrame); - aInsertedFrame->SetNextSibling(nextSibling); - } - else - { - nsIFrame *nextSibling=nsnull; - if (nsnull!=mFirstChild) - mFirstChild->GetNextSibling(nextSibling); - mFirstChild = aInsertedFrame; - aInsertedFrame->SetNextSibling(nextSibling); - } - } - aStatus = NS_FRAME_COMPLETE; - return NS_OK; -} - -NS_METHOD nsTableColGroupFrame::IR_UnknownFrameRemoved(nsIPresContext& aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - const nsHTMLReflowState& aReflowState, - nsReflowStatus& aStatus, - nsIFrame * aRemovedFrame) -{ - // we have a generic frame that gets removed but doesn't effect reflow - // unhook it then ignore it - if (PR_TRUE==gsDebugIR) printf("TCGF IR: FrameRemoved removing unknown frame type.\n"); - nsIFrame *prevChild=nsnull; - nsIFrame *nextChild=mFirstChild; - while (nextChild!=aRemovedFrame) - { - prevChild=nextChild; - nextChild->GetNextSibling(nextChild); - } - nextChild=nsnull; - aRemovedFrame->GetNextSibling(nextChild); - if (nsnull==prevChild) // objectFrame was first child - mFirstChild = nextChild; - else - prevChild->SetNextSibling(nextChild); - aStatus = NS_FRAME_COMPLETE; - return NS_OK; -} - NS_METHOD nsTableColGroupFrame::IR_TargetIsChild(nsIPresContext& aPresContext, nsHTMLReflowMetrics& aDesiredSize, const nsHTMLReflowState& aReflowState, diff --git a/layout/html/table/src/nsTableColGroupFrame.h b/layout/html/table/src/nsTableColGroupFrame.h index fe253434ced..f81dc7f27db 100644 --- a/layout/html/table/src/nsTableColGroupFrame.h +++ b/layout/html/table/src/nsTableColGroupFrame.h @@ -19,7 +19,7 @@ #define nsTableColGroupFrame_h__ #include "nscore.h" -#include "nsContainerFrame.h" +#include "nsHTMLContainerFrame.h" class nsTableColFrame; @@ -30,7 +30,7 @@ class nsTableColFrame; * * @author sclark */ -class nsTableColGroupFrame : public nsContainerFrame +class nsTableColGroupFrame : public nsHTMLContainerFrame { public: /** instantiate a new instance of nsTableColGroupFrame. @@ -98,6 +98,9 @@ protected: ~nsTableColGroupFrame(); + /** implement abstract method on nsHTMLContainerFrame */ + virtual PRIntn GetSkipSides() const; + /** Hook for style post processing. * Since we need to know the full column structure before the COLS attribute * can be interpreted, we can't just use DidSetStyleContext @@ -137,19 +140,6 @@ protected: nsReflowStatus& aStatus, nsTableColFrame * aDeletedFrame); - NS_IMETHOD IR_UnknownFrameInserted(nsIPresContext& aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - const nsHTMLReflowState& aReflowState, - nsReflowStatus& aStatus, - nsIFrame * aInsertedFrame, - PRBool aReplace); - - NS_IMETHOD IR_UnknownFrameRemoved(nsIPresContext& aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - const nsHTMLReflowState& aReflowState, - nsReflowStatus& aStatus, - nsIFrame * aRemovedFrame); - NS_IMETHOD IR_TargetIsChild(nsIPresContext& aPresContext, nsHTMLReflowMetrics& aDesiredSize, const nsHTMLReflowState& aReflowState, diff --git a/layout/html/table/src/nsTableFrame.cpp b/layout/html/table/src/nsTableFrame.cpp index b2da227f758..34f58c140bc 100644 --- a/layout/html/table/src/nsTableFrame.cpp +++ b/layout/html/table/src/nsTableFrame.cpp @@ -267,7 +267,7 @@ void ColumnInfoCache::GetColumnsByType(const nsStyleUnit aType, /* --------------------- nsTableFrame -------------------- */ nsTableFrame::nsTableFrame(nsIContent* aContent, nsIFrame* aParentFrame) - : nsContainerFrame(aContent, aParentFrame), + : nsHTMLContainerFrame(aContent, aParentFrame), mCellMap(nsnull), mColCache(nsnull), mTableLayoutStrategy(nsnull), @@ -1453,6 +1453,7 @@ NS_METHOD nsTableFrame::Paint(nsIPresContext& aPresContext, nsRect rect(0, 0, mRect.width, mRect.height); nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this, aDirtyRect, rect, *color, 0, 0); + // XXX: use GetSkipSides? nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this, aDirtyRect, rect, *spacing, 0); } @@ -1467,6 +1468,19 @@ NS_METHOD nsTableFrame::Paint(nsIPresContext& aPresContext, return NS_OK; } +PRIntn +nsTableFrame::GetSkipSides() const +{ + PRIntn skip = 0; + if (nsnull != mPrevInFlow) { + skip |= 1 << NS_SIDE_TOP; + } + if (nsnull != mNextInFlow) { + skip |= 1 << NS_SIDE_BOTTOM; + } + return skip; +} + PRBool nsTableFrame::NeedsReflow(const nsHTMLReflowState& aReflowState, const nsSize& aMaxSize) { PRBool result = PR_TRUE; @@ -1922,8 +1936,7 @@ NS_METHOD nsTableFrame::IR_TargetIsMe(nsIPresContext& aPresContext, } else { - rv = IR_UnknownFrameInserted(aPresContext, aDesiredSize, aReflowState, aStatus, - objectFrame, PR_FALSE); + rv = AddFrame(aReflowState.reflowState, objectFrame); } break; @@ -1940,8 +1953,7 @@ NS_METHOD nsTableFrame::IR_TargetIsMe(nsIPresContext& aPresContext, } else { // no optimization to be done for Unknown frame types, so just reuse the Inserted method - rv = IR_UnknownFrameInserted(aPresContext, aDesiredSize, aReflowState, aStatus, - objectFrame, PR_FALSE); + rv = AddFrame(aReflowState.reflowState, objectFrame); } break; @@ -1963,9 +1975,7 @@ NS_METHOD nsTableFrame::IR_TargetIsMe(nsIPresContext& aPresContext, } else { - - rv = IR_UnknownFrameRemoved(aPresContext, aDesiredSize, aReflowState, aStatus, - objectFrame); + rv = RemoveFrame(objectFrame); } break; @@ -2193,8 +2203,7 @@ NS_METHOD nsTableFrame::IR_RowGroupInserted(nsIPresContext& aPresContext, nsTableRowGroupFrame * aInsertedFrame, PRBool aReplace) { - nsresult rv = IR_UnknownFrameInserted(aPresContext, aDesiredSize, aReflowState, - aStatus, (nsIFrame*)aInsertedFrame, aReplace); + nsresult rv = AddFrame(aReflowState.reflowState, aInsertedFrame); if (NS_FAILED(rv)) return rv; @@ -2218,8 +2227,7 @@ NS_METHOD nsTableFrame::IR_RowGroupAppended(nsIPresContext& aPresContext, nsTableRowGroupFrame * aAppendedFrame) { // hook aAppendedFrame into the child list - nsresult rv = IR_UnknownFrameInserted(aPresContext, aDesiredSize, aReflowState, - aStatus, (nsIFrame*)aAppendedFrame, PR_FALSE); + nsresult rv = AddFrame(aReflowState.reflowState, aAppendedFrame); if (NS_FAILED(rv)) return rv; @@ -2248,8 +2256,7 @@ NS_METHOD nsTableFrame::IR_RowGroupRemoved(nsIPresContext& aPresContext, nsReflowStatus& aStatus, nsTableRowGroupFrame * aDeletedFrame) { - nsresult rv = IR_UnknownFrameRemoved(aPresContext, aDesiredSize, aReflowState, aStatus, - aDeletedFrame); + nsresult rv = RemoveFrame(aDeletedFrame); InvalidateCellMap(); InvalidateColumnCache(); @@ -2260,82 +2267,6 @@ NS_METHOD nsTableFrame::IR_RowGroupRemoved(nsIPresContext& aPresContext, return rv; } -//XXX: handle aReplace -NS_METHOD nsTableFrame::IR_UnknownFrameInserted(nsIPresContext& aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - InnerTableReflowState& aReflowState, - nsReflowStatus& aStatus, - nsIFrame * aInsertedFrame, - PRBool aReplace) -{ - nsIReflowCommand::ReflowType type; - aReflowState.reflowState.reflowCommand->GetType(type); - // we have a generic frame that gets inserted but doesn't effect reflow - // hook it up then ignore it - if (nsIReflowCommand::FrameAppended==type) - { // frameAppended reflow -- find the last child and make aInsertedFrame its next sibling - if (PR_TRUE==gsDebugIR) printf("TIF IR: FrameAppended adding unknown frame type.\n"); - nsIFrame *lastChild=mFirstChild; - nsIFrame *nextChild=mFirstChild; - while (nsnull!=nextChild) - { - lastChild=nextChild; - nextChild->GetNextSibling(nextChild); - } - if (nsnull==lastChild) - mFirstChild = aInsertedFrame; - else - lastChild->SetNextSibling(aInsertedFrame); - } - else - { // frameInserted reflow -- hook up aInsertedFrame as prevSibling's next sibling, - // and be sure to hook in aInsertedFrame's nextSibling (from prevSibling) - if (PR_TRUE==gsDebugIR) printf("TIF IR: FrameInserted adding unknown frame type.\n"); - nsIFrame *prevSibling=nsnull; - nsresult rv = aReflowState.reflowState.reflowCommand->GetPrevSiblingFrame(prevSibling); - if (NS_SUCCEEDED(rv) && (nsnull!=prevSibling)) - { - nsIFrame *nextSibling=nsnull; - prevSibling->GetNextSibling(nextSibling); - prevSibling->SetNextSibling(aInsertedFrame); - aInsertedFrame->SetNextSibling(nextSibling); - } - else - { - nsIFrame *nextSibling = mFirstChild; - mFirstChild = aInsertedFrame; - aInsertedFrame->SetNextSibling(nextSibling); - } - } - aStatus = NS_FRAME_COMPLETE; - return NS_OK; -} - -NS_METHOD nsTableFrame::IR_UnknownFrameRemoved(nsIPresContext& aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - InnerTableReflowState& aReflowState, - nsReflowStatus& aStatus, - nsIFrame * aRemovedFrame) -{ - // we have a generic frame that gets removed but doesn't effect reflow - // unhook it then ignore it - if (PR_TRUE==gsDebugIR) printf("TIF IR: FrameRemoved removing unknown frame type.\n"); - nsIFrame *prevChild=nsnull; - nsIFrame *nextChild=mFirstChild; - while (nextChild!=aRemovedFrame) - { - prevChild=nextChild; - nextChild->GetNextSibling(nextChild); - } - nextChild=nsnull; - aRemovedFrame->GetNextSibling(nextChild); - if (nsnull==prevChild) // objectFrame was first child - mFirstChild = nextChild; - else - prevChild->SetNextSibling(nextChild); - aStatus = NS_FRAME_COMPLETE; - return NS_OK;; -} NS_METHOD nsTableFrame::IR_TargetIsChild(nsIPresContext& aPresContext, nsHTMLReflowMetrics& aDesiredSize, diff --git a/layout/html/table/src/nsTableFrame.h b/layout/html/table/src/nsTableFrame.h index cb2282ba85b..40259a87260 100644 --- a/layout/html/table/src/nsTableFrame.h +++ b/layout/html/table/src/nsTableFrame.h @@ -19,7 +19,7 @@ #define nsTableFrame_h__ #include "nscore.h" -#include "nsContainerFrame.h" +#include "nsHTMLContainerFrame.h" #include "nsStyleCoord.h" #include "nsStyleConsts.h" #include "nsIFrameReflow.h" // for nsReflowReason enum @@ -56,7 +56,7 @@ extern const nsIID kTableFrameCID; * * TODO: make methods virtual so nsTableFrame can be used as a base class in the future. */ -class nsTableFrame : public nsContainerFrame +class nsTableFrame : public nsHTMLContainerFrame { public: @@ -265,6 +265,9 @@ protected: /** destructor, responsible for mColumnLayoutData and mColumnWidths */ virtual ~nsTableFrame(); + /** implement abstract method on nsHTMLContainerFrame */ + virtual PRIntn GetSkipSides() const; + /** first pass of ResizeReflow. * lays out all table content with aMaxSize(NS_UNCONSTRAINEDSIZE,NS_UNCONSTRAINEDSIZE) and * a non-null aMaxElementSize so we get all the metrics we need to do column balancing. @@ -359,19 +362,6 @@ protected: nsReflowStatus& aStatus, nsTableRowGroupFrame * aDeletedFrame); - NS_IMETHOD IR_UnknownFrameInserted(nsIPresContext& aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - InnerTableReflowState& aReflowState, - nsReflowStatus& aStatus, - nsIFrame * aInsertedFrame, - PRBool aReplace); - - NS_IMETHOD IR_UnknownFrameRemoved(nsIPresContext& aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - InnerTableReflowState& aReflowState, - nsReflowStatus& aStatus, - nsIFrame * aDeletedFrame); - NS_IMETHOD AdjustSiblingsAfterReflow(nsIPresContext& aPresContext, InnerTableReflowState& aState, nsIFrame* aKidFrame, diff --git a/layout/html/table/src/nsTableOuterFrame.cpp b/layout/html/table/src/nsTableOuterFrame.cpp index f002487dfdb..0580b114191 100644 --- a/layout/html/table/src/nsTableOuterFrame.cpp +++ b/layout/html/table/src/nsTableOuterFrame.cpp @@ -97,7 +97,7 @@ struct OuterTableReflowState { /** */ nsTableOuterFrame::nsTableOuterFrame(nsIContent* aContent, nsIFrame* aParentFrame) - : nsContainerFrame(aContent, aParentFrame), + : nsHTMLContainerFrame(aContent, aParentFrame), mInnerTableFrame(nsnull), mCaptionFrame(nsnull), mMinCaptionWidth(0), diff --git a/layout/html/table/src/nsTableOuterFrame.h b/layout/html/table/src/nsTableOuterFrame.h index bcd23d63323..b49e7285ddb 100644 --- a/layout/html/table/src/nsTableOuterFrame.h +++ b/layout/html/table/src/nsTableOuterFrame.h @@ -19,7 +19,7 @@ #define nsTableOuterFrame_h__ #include "nscore.h" -#include "nsContainerFrame.h" +#include "nsHTMLContainerFrame.h" struct OuterTableReflowState; struct nsStyleText; @@ -34,7 +34,7 @@ struct nsStyleText; * are always mapped * */ -class nsTableOuterFrame : public nsContainerFrame +class nsTableOuterFrame : public nsHTMLContainerFrame { public: @@ -80,6 +80,9 @@ protected: */ nsTableOuterFrame(nsIContent* aContent, nsIFrame* aParentFrame); + /** implement abstract method on nsHTMLContainerFrame */ + virtual PRIntn GetSkipSides() const; + /** return PR_TRUE if the table needs to be reflowed. * the outer table needs to be reflowed if the table content has changed, * or if the table style attributes or parent max height/width have @@ -200,6 +203,8 @@ private: inline nscoord nsTableOuterFrame::GetMinCaptionWidth() { return mMinCaptionWidth; } +inline PRIntn nsTableOuterFrame::GetSkipSides() const +{ return 0; } #endif diff --git a/layout/html/table/src/nsTableRowFrame.cpp b/layout/html/table/src/nsTableRowFrame.cpp index bf7af778721..16c5fee073c 100644 --- a/layout/html/table/src/nsTableRowFrame.cpp +++ b/layout/html/table/src/nsTableRowFrame.cpp @@ -84,7 +84,7 @@ struct RowReflowState { nsTableRowFrame::nsTableRowFrame(nsIContent* aContent, nsIFrame* aParentFrame) - : nsContainerFrame(aContent, aParentFrame), + : nsHTMLContainerFrame(aContent, aParentFrame), mTallestCell(0), mCellMaxTopMargin(0), mCellMaxBottomMargin(0), @@ -240,6 +240,19 @@ NS_METHOD nsTableRowFrame::Paint(nsIPresContext& aPresContext, return NS_OK; } +PRIntn +nsTableRowFrame::GetSkipSides() const +{ + PRIntn skip = 0; + if (nsnull != mPrevInFlow) { + skip |= 1 << NS_SIDE_TOP; + } + if (nsnull != mNextInFlow) { + skip |= 1 << NS_SIDE_BOTTOM; + } + return skip; +} + /** overloaded method from nsContainerFrame. The difference is that * we don't want to clip our children, so a cell can do a rowspan */ @@ -866,8 +879,7 @@ NS_METHOD nsTableRowFrame::IR_TargetIsMe(nsIPresContext& aPresContext, } else { - rv = IR_UnknownFrameInserted(aPresContext, aDesiredSize, aReflowState, aStatus, - objectFrame, PR_FALSE); + rv = AddFrame(aReflowState.reflowState, objectFrame); } break; @@ -879,8 +891,7 @@ NS_METHOD nsTableRowFrame::IR_TargetIsMe(nsIPresContext& aPresContext, } else { // no optimization to be done for Unknown frame types, so just reuse the Inserted method - rv = IR_UnknownFrameInserted(aPresContext, aDesiredSize, aReflowState, aStatus, - objectFrame, PR_FALSE); + rv = AddFrame(aReflowState.reflowState, objectFrame); } break; @@ -897,8 +908,7 @@ NS_METHOD nsTableRowFrame::IR_TargetIsMe(nsIPresContext& aPresContext, } else { - rv = IR_UnknownFrameRemoved(aPresContext, aDesiredSize, aReflowState, aStatus, - objectFrame); + rv = RemoveFrame(objectFrame); } break; @@ -934,8 +944,7 @@ NS_METHOD nsTableRowFrame::IR_CellInserted(nsIPresContext& aPresContext, PRBool aReplace) { if (PR_TRUE==gsDebugIR) printf("\nTRF IR: IR_CellInserted\n"); - nsresult rv = IR_UnknownFrameInserted(aPresContext, aDesiredSize, aReflowState, - aStatus, (nsIFrame*)aInsertedFrame, aReplace); + nsresult rv = AddFrame(aReflowState.reflowState, (nsIFrame*)aInsertedFrame); if (NS_FAILED(rv)) return rv; @@ -971,8 +980,7 @@ NS_METHOD nsTableRowFrame::IR_CellAppended(nsIPresContext& aPresContext, { if (PR_TRUE==gsDebugIR) printf("\nTRF IR: IR_CellInserted\n"); - nsresult rv = IR_UnknownFrameInserted(aPresContext, aDesiredSize, aReflowState, - aStatus, (nsIFrame*)aAppendedFrame, PR_FALSE); + nsresult rv = AddFrame(aReflowState.reflowState, (nsIFrame*)aAppendedFrame); if (NS_FAILED(rv)) return rv; @@ -1037,9 +1045,8 @@ NS_METHOD nsTableRowFrame::IR_CellRemoved(nsIPresContext& aPresContext, nsReflowStatus& aStatus, nsTableCellFrame * aDeletedFrame) { - if (PR_TRUE==gsDebugIR) printf("\nTRGF IR: IR_RowRemoved\n"); - nsresult rv = IR_UnknownFrameRemoved(aPresContext, aDesiredSize, aReflowState, aStatus, - aDeletedFrame); + if (PR_TRUE==gsDebugIR) printf("\nRow IR: IR_RowRemoved\n"); + nsresult rv = RemoveFrame((nsIFrame*)aDeletedFrame); if (NS_SUCCEEDED(rv)) { nsTableFrame *tableFrame=nsnull; @@ -1057,84 +1064,6 @@ NS_METHOD nsTableRowFrame::IR_CellRemoved(nsIPresContext& aPresContext, return rv; } -//XXX: handle aReplace -NS_METHOD nsTableRowFrame::IR_UnknownFrameInserted(nsIPresContext& aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - RowReflowState& aReflowState, - nsReflowStatus& aStatus, - nsIFrame * aInsertedFrame, - PRBool aReplace) -{ - if (PR_TRUE==gsDebugIR) printf("\nTRGF IR: IR_UnknownFrameInserted\n"); - nsIReflowCommand::ReflowType type; - aReflowState.reflowState.reflowCommand->GetType(type); - // we have a generic frame that gets inserted but doesn't effect reflow - // hook it up then ignore it - if (nsIReflowCommand::FrameAppended==type) - { // frameAppended reflow -- find the last child and make aInsertedFrame its next sibling - if (PR_TRUE==gsDebugIR) printf("TRGF IR: FrameAppended adding unknown frame type.\n"); - nsIFrame *lastChild=mFirstChild; - nsIFrame *nextChild=mFirstChild; - while (nsnull!=nextChild) - { - lastChild=nextChild; - nextChild->GetNextSibling(nextChild); - } - if (nsnull==lastChild) - mFirstChild = aInsertedFrame; - else - lastChild->SetNextSibling(aInsertedFrame); - } - else - { // frameInserted reflow -- hook up aInsertedFrame as prevSibling's next sibling, - // and be sure to hook in aInsertedFrame's nextSibling (from prevSibling) - if (PR_TRUE==gsDebugIR) printf("TRGF IR: FrameInserted adding unknown frame type.\n"); - nsIFrame *prevSibling=nsnull; - nsresult rv = aReflowState.reflowState.reflowCommand->GetPrevSiblingFrame(prevSibling); - if (NS_SUCCEEDED(rv) && (nsnull!=prevSibling)) - { - nsIFrame *nextSibling=nsnull; - prevSibling->GetNextSibling(nextSibling); - prevSibling->SetNextSibling(aInsertedFrame); - aInsertedFrame->SetNextSibling(nextSibling); - } - else - { - nsIFrame *nextSibling=mFirstChild; - mFirstChild = aInsertedFrame; - aInsertedFrame->SetNextSibling(nextSibling); - } - } - aStatus = NS_FRAME_COMPLETE; - return NS_OK; -} - -NS_METHOD nsTableRowFrame::IR_UnknownFrameRemoved(nsIPresContext& aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - RowReflowState& aReflowState, - nsReflowStatus& aStatus, - nsIFrame * aRemovedFrame) -{ - if (PR_TRUE==gsDebugIR) printf("\nTRGF IR: IR_UnknownFrameRemoved\n"); - // we have a generic frame that gets removed but doesn't effect reflow - // unhook it then ignore it - if (PR_TRUE==gsDebugIR) printf("TRGF IR: FrameRemoved removing unknown frame type.\n"); - nsIFrame *prevChild=nsnull; - nsIFrame *nextChild=mFirstChild; - while (nextChild!=aRemovedFrame) - { - prevChild=nextChild; - nextChild->GetNextSibling(nextChild); - } - nextChild=nsnull; - aRemovedFrame->GetNextSibling(nextChild); - if (nsnull==prevChild) // objectFrame was first child - mFirstChild = nextChild; - else - prevChild->SetNextSibling(nextChild); - aStatus = NS_FRAME_COMPLETE; - return NS_OK; -} NS_METHOD nsTableRowFrame::IR_TargetIsChild(nsIPresContext& aPresContext, nsHTMLReflowMetrics& aDesiredSize, RowReflowState& aReflowState, diff --git a/layout/html/table/src/nsTableRowFrame.h b/layout/html/table/src/nsTableRowFrame.h index 3fc5e491051..65cc7aded29 100644 --- a/layout/html/table/src/nsTableRowFrame.h +++ b/layout/html/table/src/nsTableRowFrame.h @@ -19,7 +19,7 @@ #define nsTableRowFrame_h__ #include "nscore.h" -#include "nsContainerFrame.h" +#include "nsHTMLContainerFrame.h" class nsTableFrame; class nsTableCellFrame; @@ -35,7 +35,7 @@ struct RowReflowState; * @see nsTableRowGroupFrame * @see nsTableCellFrame */ -class nsTableRowFrame : public nsContainerFrame +class nsTableRowFrame : public nsHTMLContainerFrame { public: /** Initialization of frame as a row */ @@ -131,6 +131,9 @@ protected: /** destructor */ virtual ~nsTableRowFrame(); + /** implement abstract method on nsHTMLContainerFrame */ + virtual PRIntn GetSkipSides() const; + /** Incremental Reflow attempts to do column balancing with the minimum number of reflow * commands to child elements. This is done by processing the reflow command, * rebalancing column widths (if necessary), then comparing the resulting column widths @@ -174,20 +177,6 @@ protected: RowReflowState& aReflowState, nsReflowStatus& aStatus, nsTableCellFrame * aDeletedFrame); - - NS_IMETHOD IR_UnknownFrameInserted(nsIPresContext& aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - RowReflowState& aReflowState, - nsReflowStatus& aStatus, - nsIFrame * aInsertedFrame, - PRBool aReplace); - - NS_IMETHOD IR_UnknownFrameRemoved(nsIPresContext& aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - RowReflowState& aReflowState, - nsReflowStatus& aStatus, - nsIFrame * aDeletedFrame); - // row-specific methods diff --git a/layout/html/table/src/nsTableRowGroupFrame.cpp b/layout/html/table/src/nsTableRowGroupFrame.cpp index f8c11500f50..59cb0a2a538 100644 --- a/layout/html/table/src/nsTableRowGroupFrame.cpp +++ b/layout/html/table/src/nsTableRowGroupFrame.cpp @@ -91,7 +91,7 @@ struct RowGroupReflowState { /* ----------- nsTableRowGroupFrame ---------- */ nsTableRowGroupFrame::nsTableRowGroupFrame(nsIContent* aContent, nsIFrame* aParentFrame) - : nsContainerFrame(aContent, aParentFrame) + : nsHTMLContainerFrame(aContent, aParentFrame) { aContent->GetTag(mType); // mType: REFCNT++ } @@ -152,6 +152,19 @@ NS_METHOD nsTableRowGroupFrame::Paint(nsIPresContext& aPresContext, return NS_OK; } +PRIntn +nsTableRowGroupFrame::GetSkipSides() const +{ + PRIntn skip = 0; + if (nsnull != mPrevInFlow) { + skip |= 1 << NS_SIDE_TOP; + } + if (nsnull != mNextInFlow) { + skip |= 1 << NS_SIDE_BOTTOM; + } + return skip; +} + // aDirtyRect is in our coordinate system // child rect's are also in our coordinate system /** overloaded method from nsContainerFrame. The difference is that @@ -877,8 +890,7 @@ NS_METHOD nsTableRowGroupFrame::IR_TargetIsMe(nsIPresContext& aPresContext, } else { - rv = IR_UnknownFrameInserted(aPresContext, aDesiredSize, aReflowState, aStatus, - objectFrame, PR_FALSE); + rv = AddFrame(aReflowState.reflowState, objectFrame); } break; @@ -890,8 +902,7 @@ NS_METHOD nsTableRowGroupFrame::IR_TargetIsMe(nsIPresContext& aPresContext, } else { // no optimization to be done for Unknown frame types, so just reuse the Inserted method - rv = IR_UnknownFrameInserted(aPresContext, aDesiredSize, aReflowState, aStatus, - objectFrame, PR_FALSE); + rv = AddFrame(aReflowState.reflowState, objectFrame); } break; @@ -908,8 +919,7 @@ NS_METHOD nsTableRowGroupFrame::IR_TargetIsMe(nsIPresContext& aPresContext, } else { - rv = IR_UnknownFrameRemoved(aPresContext, aDesiredSize, aReflowState, aStatus, - objectFrame); + rv = RemoveFrame(objectFrame); } break; @@ -945,8 +955,7 @@ NS_METHOD nsTableRowGroupFrame::IR_RowInserted(nsIPresContext& aPresContext PRBool aReplace) { if (PR_TRUE==gsDebugIR) printf("\nTRGF IR: IR_RowInserted\n"); - nsresult rv = IR_UnknownFrameInserted(aPresContext, aDesiredSize, aReflowState, - aStatus, (nsIFrame*)aInsertedFrame, aReplace); + nsresult rv = AddFrame(aReflowState.reflowState, (nsIFrame*)aInsertedFrame); if (NS_FAILED(rv)) return rv; @@ -1024,8 +1033,7 @@ NS_METHOD nsTableRowGroupFrame::IR_RowAppended(nsIPresContext& aPresContext { if (PR_TRUE==gsDebugIR) printf("\nTRGF IR: IR_RowAppended\n"); // hook aAppendedFrame into the child list - nsresult rv = IR_UnknownFrameInserted(aPresContext, aDesiredSize, aReflowState, - aStatus, (nsIFrame*)aAppendedFrame, PR_FALSE); + nsresult rv = AddFrame(aReflowState.reflowState, (nsIFrame*)aAppendedFrame); if (NS_FAILED(rv)) return rv; @@ -1083,8 +1091,7 @@ NS_METHOD nsTableRowGroupFrame::IR_RowRemoved(nsIPresContext& aPresContext, nsTableRowFrame * aDeletedFrame) { if (PR_TRUE==gsDebugIR) printf("\nTRGF IR: IR_RowRemoved\n"); - nsresult rv = IR_UnknownFrameRemoved(aPresContext, aDesiredSize, aReflowState, aStatus, - aDeletedFrame); + nsresult rv = RemoveFrame((nsIFrame *)aDeletedFrame); if (NS_SUCCEEDED(rv)) { nsTableFrame *tableFrame=nsnull; @@ -1102,85 +1109,6 @@ NS_METHOD nsTableRowGroupFrame::IR_RowRemoved(nsIPresContext& aPresContext, return rv; } -//XXX: handle aReplace -NS_METHOD nsTableRowGroupFrame::IR_UnknownFrameInserted(nsIPresContext& aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - RowGroupReflowState& aReflowState, - nsReflowStatus& aStatus, - nsIFrame * aInsertedFrame, - PRBool aReplace) -{ - if (PR_TRUE==gsDebugIR) printf("\nTRGF IR: IR_UnknownFrameInserted\n"); - nsIReflowCommand::ReflowType type; - aReflowState.reflowState.reflowCommand->GetType(type); - // we have a generic frame that gets inserted but doesn't effect reflow - // hook it up then ignore it - if (nsIReflowCommand::FrameAppended==type) - { // frameAppended reflow -- find the last child and make aInsertedFrame its next sibling - if (PR_TRUE==gsDebugIR) printf("TRGF IR: FrameAppended adding unknown frame type.\n"); - nsIFrame *lastChild=mFirstChild; - nsIFrame *nextChild=mFirstChild; - while (nsnull!=nextChild) - { - lastChild=nextChild; - nextChild->GetNextSibling(nextChild); - } - if (nsnull==lastChild) - mFirstChild = aInsertedFrame; - else - lastChild->SetNextSibling(aInsertedFrame); - } - else - { // frameInserted reflow -- hook up aInsertedFrame as prevSibling's next sibling, - // and be sure to hook in aInsertedFrame's nextSibling (from prevSibling) - if (PR_TRUE==gsDebugIR) printf("TRGF IR: FrameInserted adding unknown frame type.\n"); - nsIFrame *prevSibling=nsnull; - nsresult rv = aReflowState.reflowState.reflowCommand->GetPrevSiblingFrame(prevSibling); - if (NS_SUCCEEDED(rv) && (nsnull!=prevSibling)) - { - nsIFrame *nextSibling=nsnull; - prevSibling->GetNextSibling(nextSibling); - prevSibling->SetNextSibling(aInsertedFrame); - aInsertedFrame->SetNextSibling(nextSibling); - } - else - { - nsIFrame *nextSibling=mFirstChild; - mFirstChild = aInsertedFrame; - aInsertedFrame->SetNextSibling(nextSibling); - } - } - aStatus = NS_FRAME_COMPLETE; - return NS_OK; -} - -NS_METHOD nsTableRowGroupFrame::IR_UnknownFrameRemoved(nsIPresContext& aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - RowGroupReflowState& aReflowState, - nsReflowStatus& aStatus, - nsIFrame * aRemovedFrame) -{ - if (PR_TRUE==gsDebugIR) printf("\nTRGF IR: IR_UnknownFrameRemoved\n"); - // we have a generic frame that gets removed but doesn't effect reflow - // unhook it then ignore it - if (PR_TRUE==gsDebugIR) printf("TRGF IR: FrameRemoved removing unknown frame type.\n"); - nsIFrame *prevChild=nsnull; - nsIFrame *nextChild=mFirstChild; - while (nextChild!=aRemovedFrame) - { - prevChild=nextChild; - nextChild->GetNextSibling(nextChild); - } - nextChild=nsnull; - aRemovedFrame->GetNextSibling(nextChild); - if (nsnull==prevChild) // objectFrame was first child - mFirstChild = nextChild; - else - prevChild->SetNextSibling(nextChild); - aStatus = NS_FRAME_COMPLETE; - return NS_OK; -} - NS_METHOD nsTableRowGroupFrame::IR_TargetIsChild(nsIPresContext& aPresContext, nsHTMLReflowMetrics& aDesiredSize, RowGroupReflowState& aReflowState, diff --git a/layout/html/table/src/nsTableRowGroupFrame.h b/layout/html/table/src/nsTableRowGroupFrame.h index c254981d5fb..319c5638040 100644 --- a/layout/html/table/src/nsTableRowGroupFrame.h +++ b/layout/html/table/src/nsTableRowGroupFrame.h @@ -19,7 +19,7 @@ #define nsTableRowGroupFrame_h__ #include "nscore.h" -#include "nsContainerFrame.h" +#include "nsHTMLContainerFrame.h" #include "nsIAtom.h" class nsTableRowFrame; @@ -36,7 +36,7 @@ struct RowGroupReflowState; * * @author sclark */ -class nsTableRowGroupFrame : public nsContainerFrame +class nsTableRowGroupFrame : public nsHTMLContainerFrame { public: @@ -80,6 +80,49 @@ public: const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus); + /** returns the type of the mapped row group content in aType. + * caller MUST call release on the returned object if it is not null. + * + * @param aType out param filled with the type of the mapped content, or null if none. + * + * @return NS_OK + */ + NS_IMETHOD GetRowGroupType(nsIAtom *& aType); + + /** set aCount to the number of child rows (not necessarily == number of child frames) */ + NS_METHOD GetRowCount(PRInt32 &aCount); + + NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0, nsIListFilter *aFilter = nsnull) const; + + +protected: + + /** protected constructor. + * @see NewFrame + */ + nsTableRowGroupFrame(nsIContent* aContent, nsIFrame* aParentFrame); + + /** protected destructor */ + ~nsTableRowGroupFrame(); + + /** implement abstract method on nsHTMLContainerFrame */ + virtual PRIntn GetSkipSides() const; + + nscoord GetTopMarginFor(nsIPresContext* aCX, + RowGroupReflowState& aReflowState, + const nsMargin& aKidMargin); + + void PlaceChild( nsIPresContext& aPresContext, + RowGroupReflowState& aReflowState, + nsIFrame* aKidFrame, + const nsRect& aKidRect, + nsSize* aMaxElementSize, + nsSize& aKidMaxElementSize); + + void ShrinkWrapChildren(nsIPresContext* aPresContext, + nsHTMLReflowMetrics& aDesiredSize); + + /** Incremental Reflow attempts to do column balancing with the minimum number of reflow * commands to child elements. This is done by processing the reflow command, * rebalancing column widths (if necessary), then comparing the resulting column widths @@ -121,20 +164,6 @@ public: RowGroupReflowState& aReflowState, nsReflowStatus& aStatus, nsTableRowFrame * aDeletedFrame); - - NS_IMETHOD IR_UnknownFrameInserted(nsIPresContext& aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - RowGroupReflowState& aReflowState, - nsReflowStatus& aStatus, - nsIFrame * aInsertedFrame, - PRBool aReplace); - - NS_IMETHOD IR_UnknownFrameRemoved(nsIPresContext& aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - RowGroupReflowState& aReflowState, - nsReflowStatus& aStatus, - nsIFrame * aDeletedFrame); - NS_IMETHOD DidAppendRow(nsTableRowFrame *aRowFrame); @@ -146,45 +175,6 @@ public: nsIStyleContext* aStyleContext, nsIFrame*& aContinuingFrame); - /** returns the type of the mapped row group content in aType. - * caller MUST call release on the returned object if it is not null. - * - * @param aType out param filled with the type of the mapped content, or null if none. - * - * @return NS_OK - */ - NS_IMETHOD GetRowGroupType(nsIAtom *& aType); - - /** set aCount to the number of child rows (not necessarily == number of child frames) */ - NS_METHOD GetRowCount(PRInt32 &aCount); - - NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0, nsIListFilter *aFilter = nsnull) const; - - -protected: - - /** protected constructor. - * @see NewFrame - */ - nsTableRowGroupFrame(nsIContent* aContent, nsIFrame* aParentFrame); - - /** protected destructor */ - ~nsTableRowGroupFrame(); - - nscoord GetTopMarginFor(nsIPresContext* aCX, - RowGroupReflowState& aReflowState, - const nsMargin& aKidMargin); - - void PlaceChild( nsIPresContext& aPresContext, - RowGroupReflowState& aReflowState, - nsIFrame* aKidFrame, - const nsRect& aKidRect, - nsSize* aMaxElementSize, - nsSize& aKidMaxElementSize); - - void ShrinkWrapChildren(nsIPresContext* aPresContext, - nsHTMLReflowMetrics& aDesiredSize); - nsresult AdjustSiblingsAfterReflow(nsIPresContext& aPresContext, RowGroupReflowState& aReflowState, nsIFrame* aKidFrame, diff --git a/layout/tables/nsTableCellFrame.cpp b/layout/tables/nsTableCellFrame.cpp index b5f753bf396..e8e31513679 100644 --- a/layout/tables/nsTableCellFrame.cpp +++ b/layout/tables/nsTableCellFrame.cpp @@ -52,7 +52,7 @@ static const PRBool gsDebugNT = PR_FALSE; */ nsTableCellFrame::nsTableCellFrame(nsIContent* aContent, nsIFrame* aParentFrame) - : nsContainerFrame(aContent, aParentFrame) + : nsHTMLContainerFrame(aContent, aParentFrame) { mColIndex=0; mPriorAvailWidth=0; @@ -130,12 +130,24 @@ NS_METHOD nsTableCellFrame::Paint(nsIPresContext& aPresContext, return NS_OK; } -/** -* -* Align the cell's child frame within the cell -* -**/ +PRIntn +nsTableCellFrame::GetSkipSides() const +{ + PRIntn skip = 0; + if (nsnull != mPrevInFlow) { + skip |= 1 << NS_SIDE_TOP; + } + if (nsnull != mNextInFlow) { + skip |= 1 << NS_SIDE_BOTTOM; + } + return skip; +} +/** + * + * Align the cell's child frame within the cell + * + */ void nsTableCellFrame::VerticallyAlignChild(nsIPresContext* aPresContext) { const nsStyleSpacing* spacing = diff --git a/layout/tables/nsTableCellFrame.h b/layout/tables/nsTableCellFrame.h index 7d6b19b62ba..3e314054a10 100644 --- a/layout/tables/nsTableCellFrame.h +++ b/layout/tables/nsTableCellFrame.h @@ -19,7 +19,7 @@ #define nsTableCellFrame_h__ #include "nscore.h" -#include "nsContainerFrame.h" +#include "nsHTMLContainerFrame.h" #include "nsTableFrame.h" #include "nsTableRowFrame.h" // need to actually include this here to inline GetRowIndex @@ -37,7 +37,7 @@ extern const nsIID kTableCellFrameCID; * * @author sclark */ -class nsTableCellFrame : public nsContainerFrame +class nsTableCellFrame : public nsHTMLContainerFrame { public: @@ -136,6 +136,10 @@ public: /** destructor */ virtual ~nsTableCellFrame(); +protected: + /** implement abstract method on nsHTMLContainerFrame */ + virtual PRIntn GetSkipSides() const; + private: // All these methods are support methods for RecalcLayoutData diff --git a/layout/tables/nsTableColGroupFrame.cpp b/layout/tables/nsTableColGroupFrame.cpp index 8625630007f..f2ead478ef8 100644 --- a/layout/tables/nsTableColGroupFrame.cpp +++ b/layout/tables/nsTableColGroupFrame.cpp @@ -45,7 +45,7 @@ static const PRBool gsDebugIR = PR_FALSE; nsTableColGroupFrame::nsTableColGroupFrame(nsIContent* aContent, nsIFrame* aParentFrame) - : nsContainerFrame(aContent, aParentFrame) + : nsHTMLContainerFrame(aContent, aParentFrame) { mColCount=0; } @@ -176,6 +176,19 @@ NS_METHOD nsTableColGroupFrame::Paint(nsIPresContext& aPresContext, return NS_OK; } +PRIntn +nsTableColGroupFrame::GetSkipSides() const +{ + PRIntn skip = 0; + if (nsnull != mPrevInFlow) { + skip |= 1 << NS_SIDE_TOP; + } + if (nsnull != mNextInFlow) { + skip |= 1 << NS_SIDE_BOTTOM; + } + return skip; +} + NS_METHOD nsTableColGroupFrame::Reflow(nsIPresContext& aPresContext, nsHTMLReflowMetrics& aDesiredSize, const nsHTMLReflowState& aReflowState, @@ -267,8 +280,7 @@ NS_METHOD nsTableColGroupFrame::IR_TargetIsMe(nsIPresContext& aPresCont } else { - rv = IR_UnknownFrameInserted(aPresContext, aDesiredSize, aReflowState, aStatus, - objectFrame, PR_FALSE); + rv = AddFrame(aReflowState, objectFrame); } break; @@ -280,8 +292,7 @@ NS_METHOD nsTableColGroupFrame::IR_TargetIsMe(nsIPresContext& aPresCont } else { // no optimization to be done for Unknown frame types, so just reuse the Inserted method - rv = IR_UnknownFrameInserted(aPresContext, aDesiredSize, aReflowState, aStatus, - objectFrame, PR_FALSE); + rv = AddFrame(aReflowState, objectFrame); } break; @@ -299,8 +310,7 @@ NS_METHOD nsTableColGroupFrame::IR_TargetIsMe(nsIPresContext& aPresCont else { - rv = IR_UnknownFrameRemoved(aPresContext, aDesiredSize, aReflowState, aStatus, - objectFrame); + rv = RemoveFrame(objectFrame); } break; @@ -337,7 +347,7 @@ NS_METHOD nsTableColGroupFrame::IR_ColInserted(nsIPresContext& aPresCon { nsresult rv=NS_OK; PRBool adjustStartingColIndex=PR_FALSE; - rv = IR_UnknownFrameInserted(aPresContext, aDesiredSize, aReflowState, aStatus, aInsertedFrame, aReplace); + rv = AddFrame(aReflowState, (nsIFrame *)aInsertedFrame); if (NS_FAILED(rv)) return rv; PRInt32 startingColIndex=mStartColIndex; @@ -373,7 +383,7 @@ NS_METHOD nsTableColGroupFrame::IR_ColAppended(nsIPresContext& aPresCon { nsresult rv=NS_OK; PRBool adjustStartingColIndex=PR_FALSE; - rv = IR_UnknownFrameInserted(aPresContext, aDesiredSize, aReflowState, aStatus, aAppendedFrame, PR_FALSE); + rv = AddFrame(aReflowState, (nsIFrame*)aAppendedFrame); if (NS_FAILED(rv)) return rv; PRInt32 startingColIndex=mStartColIndex; @@ -447,85 +457,6 @@ NS_METHOD nsTableColGroupFrame::IR_ColRemoved(nsIPresContext& aPresCont return rv; } -//XXX: handle aReplace -NS_METHOD nsTableColGroupFrame::IR_UnknownFrameInserted(nsIPresContext& aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - const nsHTMLReflowState& aReflowState, - nsReflowStatus& aStatus, - nsIFrame * aInsertedFrame, - PRBool aReplace) -{ - nsIReflowCommand::ReflowType type; - aReflowState.reflowCommand->GetType(type); - // we have a generic frame that gets inserted but doesn't effect reflow - // hook it up then ignore it - if (nsIReflowCommand::FrameAppended==type) - { // frameAppended reflow -- find the last child and make aInsertedFrame its next sibling - if (PR_TRUE==gsDebugIR) printf("TCGF IR: FrameAppended adding unknown frame type.\n"); - nsIFrame *lastChild=mFirstChild; - nsIFrame *nextChild=mFirstChild; - while (nsnull!=nextChild) - { - lastChild=nextChild; - nextChild->GetNextSibling(nextChild); - } - if (nsnull==lastChild) - mFirstChild = aInsertedFrame; - else - lastChild->SetNextSibling(aInsertedFrame); - } - else - { // frameInserted reflow -- hook up aInsertedFrame as prevSibling's next sibling, - // and be sure to hook in aInsertedFrame's nextSibling (from prevSibling) - if (PR_TRUE==gsDebugIR) printf("TCGF IR: FrameInserted adding unknown frame type.\n"); - nsIFrame *prevSibling=nsnull; - nsresult rv = aReflowState.reflowCommand->GetPrevSiblingFrame(prevSibling); - if (NS_SUCCEEDED(rv) && (nsnull!=prevSibling)) - { - nsIFrame *nextSibling=nsnull; - prevSibling->GetNextSibling(nextSibling); - prevSibling->SetNextSibling(aInsertedFrame); - aInsertedFrame->SetNextSibling(nextSibling); - } - else - { - nsIFrame *nextSibling=nsnull; - if (nsnull!=mFirstChild) - mFirstChild->GetNextSibling(nextSibling); - mFirstChild = aInsertedFrame; - aInsertedFrame->SetNextSibling(nextSibling); - } - } - aStatus = NS_FRAME_COMPLETE; - return NS_OK; -} - -NS_METHOD nsTableColGroupFrame::IR_UnknownFrameRemoved(nsIPresContext& aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - const nsHTMLReflowState& aReflowState, - nsReflowStatus& aStatus, - nsIFrame * aRemovedFrame) -{ - // we have a generic frame that gets removed but doesn't effect reflow - // unhook it then ignore it - if (PR_TRUE==gsDebugIR) printf("TCGF IR: FrameRemoved removing unknown frame type.\n"); - nsIFrame *prevChild=nsnull; - nsIFrame *nextChild=mFirstChild; - while (nextChild!=aRemovedFrame) - { - prevChild=nextChild; - nextChild->GetNextSibling(nextChild); - } - nextChild=nsnull; - aRemovedFrame->GetNextSibling(nextChild); - if (nsnull==prevChild) // objectFrame was first child - mFirstChild = nextChild; - else - prevChild->SetNextSibling(nextChild); - aStatus = NS_FRAME_COMPLETE; - return NS_OK; -} - NS_METHOD nsTableColGroupFrame::IR_TargetIsChild(nsIPresContext& aPresContext, nsHTMLReflowMetrics& aDesiredSize, const nsHTMLReflowState& aReflowState, diff --git a/layout/tables/nsTableColGroupFrame.h b/layout/tables/nsTableColGroupFrame.h index fe253434ced..f81dc7f27db 100644 --- a/layout/tables/nsTableColGroupFrame.h +++ b/layout/tables/nsTableColGroupFrame.h @@ -19,7 +19,7 @@ #define nsTableColGroupFrame_h__ #include "nscore.h" -#include "nsContainerFrame.h" +#include "nsHTMLContainerFrame.h" class nsTableColFrame; @@ -30,7 +30,7 @@ class nsTableColFrame; * * @author sclark */ -class nsTableColGroupFrame : public nsContainerFrame +class nsTableColGroupFrame : public nsHTMLContainerFrame { public: /** instantiate a new instance of nsTableColGroupFrame. @@ -98,6 +98,9 @@ protected: ~nsTableColGroupFrame(); + /** implement abstract method on nsHTMLContainerFrame */ + virtual PRIntn GetSkipSides() const; + /** Hook for style post processing. * Since we need to know the full column structure before the COLS attribute * can be interpreted, we can't just use DidSetStyleContext @@ -137,19 +140,6 @@ protected: nsReflowStatus& aStatus, nsTableColFrame * aDeletedFrame); - NS_IMETHOD IR_UnknownFrameInserted(nsIPresContext& aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - const nsHTMLReflowState& aReflowState, - nsReflowStatus& aStatus, - nsIFrame * aInsertedFrame, - PRBool aReplace); - - NS_IMETHOD IR_UnknownFrameRemoved(nsIPresContext& aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - const nsHTMLReflowState& aReflowState, - nsReflowStatus& aStatus, - nsIFrame * aRemovedFrame); - NS_IMETHOD IR_TargetIsChild(nsIPresContext& aPresContext, nsHTMLReflowMetrics& aDesiredSize, const nsHTMLReflowState& aReflowState, diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index b2da227f758..34f58c140bc 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -267,7 +267,7 @@ void ColumnInfoCache::GetColumnsByType(const nsStyleUnit aType, /* --------------------- nsTableFrame -------------------- */ nsTableFrame::nsTableFrame(nsIContent* aContent, nsIFrame* aParentFrame) - : nsContainerFrame(aContent, aParentFrame), + : nsHTMLContainerFrame(aContent, aParentFrame), mCellMap(nsnull), mColCache(nsnull), mTableLayoutStrategy(nsnull), @@ -1453,6 +1453,7 @@ NS_METHOD nsTableFrame::Paint(nsIPresContext& aPresContext, nsRect rect(0, 0, mRect.width, mRect.height); nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this, aDirtyRect, rect, *color, 0, 0); + // XXX: use GetSkipSides? nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this, aDirtyRect, rect, *spacing, 0); } @@ -1467,6 +1468,19 @@ NS_METHOD nsTableFrame::Paint(nsIPresContext& aPresContext, return NS_OK; } +PRIntn +nsTableFrame::GetSkipSides() const +{ + PRIntn skip = 0; + if (nsnull != mPrevInFlow) { + skip |= 1 << NS_SIDE_TOP; + } + if (nsnull != mNextInFlow) { + skip |= 1 << NS_SIDE_BOTTOM; + } + return skip; +} + PRBool nsTableFrame::NeedsReflow(const nsHTMLReflowState& aReflowState, const nsSize& aMaxSize) { PRBool result = PR_TRUE; @@ -1922,8 +1936,7 @@ NS_METHOD nsTableFrame::IR_TargetIsMe(nsIPresContext& aPresContext, } else { - rv = IR_UnknownFrameInserted(aPresContext, aDesiredSize, aReflowState, aStatus, - objectFrame, PR_FALSE); + rv = AddFrame(aReflowState.reflowState, objectFrame); } break; @@ -1940,8 +1953,7 @@ NS_METHOD nsTableFrame::IR_TargetIsMe(nsIPresContext& aPresContext, } else { // no optimization to be done for Unknown frame types, so just reuse the Inserted method - rv = IR_UnknownFrameInserted(aPresContext, aDesiredSize, aReflowState, aStatus, - objectFrame, PR_FALSE); + rv = AddFrame(aReflowState.reflowState, objectFrame); } break; @@ -1963,9 +1975,7 @@ NS_METHOD nsTableFrame::IR_TargetIsMe(nsIPresContext& aPresContext, } else { - - rv = IR_UnknownFrameRemoved(aPresContext, aDesiredSize, aReflowState, aStatus, - objectFrame); + rv = RemoveFrame(objectFrame); } break; @@ -2193,8 +2203,7 @@ NS_METHOD nsTableFrame::IR_RowGroupInserted(nsIPresContext& aPresContext, nsTableRowGroupFrame * aInsertedFrame, PRBool aReplace) { - nsresult rv = IR_UnknownFrameInserted(aPresContext, aDesiredSize, aReflowState, - aStatus, (nsIFrame*)aInsertedFrame, aReplace); + nsresult rv = AddFrame(aReflowState.reflowState, aInsertedFrame); if (NS_FAILED(rv)) return rv; @@ -2218,8 +2227,7 @@ NS_METHOD nsTableFrame::IR_RowGroupAppended(nsIPresContext& aPresContext, nsTableRowGroupFrame * aAppendedFrame) { // hook aAppendedFrame into the child list - nsresult rv = IR_UnknownFrameInserted(aPresContext, aDesiredSize, aReflowState, - aStatus, (nsIFrame*)aAppendedFrame, PR_FALSE); + nsresult rv = AddFrame(aReflowState.reflowState, aAppendedFrame); if (NS_FAILED(rv)) return rv; @@ -2248,8 +2256,7 @@ NS_METHOD nsTableFrame::IR_RowGroupRemoved(nsIPresContext& aPresContext, nsReflowStatus& aStatus, nsTableRowGroupFrame * aDeletedFrame) { - nsresult rv = IR_UnknownFrameRemoved(aPresContext, aDesiredSize, aReflowState, aStatus, - aDeletedFrame); + nsresult rv = RemoveFrame(aDeletedFrame); InvalidateCellMap(); InvalidateColumnCache(); @@ -2260,82 +2267,6 @@ NS_METHOD nsTableFrame::IR_RowGroupRemoved(nsIPresContext& aPresContext, return rv; } -//XXX: handle aReplace -NS_METHOD nsTableFrame::IR_UnknownFrameInserted(nsIPresContext& aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - InnerTableReflowState& aReflowState, - nsReflowStatus& aStatus, - nsIFrame * aInsertedFrame, - PRBool aReplace) -{ - nsIReflowCommand::ReflowType type; - aReflowState.reflowState.reflowCommand->GetType(type); - // we have a generic frame that gets inserted but doesn't effect reflow - // hook it up then ignore it - if (nsIReflowCommand::FrameAppended==type) - { // frameAppended reflow -- find the last child and make aInsertedFrame its next sibling - if (PR_TRUE==gsDebugIR) printf("TIF IR: FrameAppended adding unknown frame type.\n"); - nsIFrame *lastChild=mFirstChild; - nsIFrame *nextChild=mFirstChild; - while (nsnull!=nextChild) - { - lastChild=nextChild; - nextChild->GetNextSibling(nextChild); - } - if (nsnull==lastChild) - mFirstChild = aInsertedFrame; - else - lastChild->SetNextSibling(aInsertedFrame); - } - else - { // frameInserted reflow -- hook up aInsertedFrame as prevSibling's next sibling, - // and be sure to hook in aInsertedFrame's nextSibling (from prevSibling) - if (PR_TRUE==gsDebugIR) printf("TIF IR: FrameInserted adding unknown frame type.\n"); - nsIFrame *prevSibling=nsnull; - nsresult rv = aReflowState.reflowState.reflowCommand->GetPrevSiblingFrame(prevSibling); - if (NS_SUCCEEDED(rv) && (nsnull!=prevSibling)) - { - nsIFrame *nextSibling=nsnull; - prevSibling->GetNextSibling(nextSibling); - prevSibling->SetNextSibling(aInsertedFrame); - aInsertedFrame->SetNextSibling(nextSibling); - } - else - { - nsIFrame *nextSibling = mFirstChild; - mFirstChild = aInsertedFrame; - aInsertedFrame->SetNextSibling(nextSibling); - } - } - aStatus = NS_FRAME_COMPLETE; - return NS_OK; -} - -NS_METHOD nsTableFrame::IR_UnknownFrameRemoved(nsIPresContext& aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - InnerTableReflowState& aReflowState, - nsReflowStatus& aStatus, - nsIFrame * aRemovedFrame) -{ - // we have a generic frame that gets removed but doesn't effect reflow - // unhook it then ignore it - if (PR_TRUE==gsDebugIR) printf("TIF IR: FrameRemoved removing unknown frame type.\n"); - nsIFrame *prevChild=nsnull; - nsIFrame *nextChild=mFirstChild; - while (nextChild!=aRemovedFrame) - { - prevChild=nextChild; - nextChild->GetNextSibling(nextChild); - } - nextChild=nsnull; - aRemovedFrame->GetNextSibling(nextChild); - if (nsnull==prevChild) // objectFrame was first child - mFirstChild = nextChild; - else - prevChild->SetNextSibling(nextChild); - aStatus = NS_FRAME_COMPLETE; - return NS_OK;; -} NS_METHOD nsTableFrame::IR_TargetIsChild(nsIPresContext& aPresContext, nsHTMLReflowMetrics& aDesiredSize, diff --git a/layout/tables/nsTableFrame.h b/layout/tables/nsTableFrame.h index cb2282ba85b..40259a87260 100644 --- a/layout/tables/nsTableFrame.h +++ b/layout/tables/nsTableFrame.h @@ -19,7 +19,7 @@ #define nsTableFrame_h__ #include "nscore.h" -#include "nsContainerFrame.h" +#include "nsHTMLContainerFrame.h" #include "nsStyleCoord.h" #include "nsStyleConsts.h" #include "nsIFrameReflow.h" // for nsReflowReason enum @@ -56,7 +56,7 @@ extern const nsIID kTableFrameCID; * * TODO: make methods virtual so nsTableFrame can be used as a base class in the future. */ -class nsTableFrame : public nsContainerFrame +class nsTableFrame : public nsHTMLContainerFrame { public: @@ -265,6 +265,9 @@ protected: /** destructor, responsible for mColumnLayoutData and mColumnWidths */ virtual ~nsTableFrame(); + /** implement abstract method on nsHTMLContainerFrame */ + virtual PRIntn GetSkipSides() const; + /** first pass of ResizeReflow. * lays out all table content with aMaxSize(NS_UNCONSTRAINEDSIZE,NS_UNCONSTRAINEDSIZE) and * a non-null aMaxElementSize so we get all the metrics we need to do column balancing. @@ -359,19 +362,6 @@ protected: nsReflowStatus& aStatus, nsTableRowGroupFrame * aDeletedFrame); - NS_IMETHOD IR_UnknownFrameInserted(nsIPresContext& aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - InnerTableReflowState& aReflowState, - nsReflowStatus& aStatus, - nsIFrame * aInsertedFrame, - PRBool aReplace); - - NS_IMETHOD IR_UnknownFrameRemoved(nsIPresContext& aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - InnerTableReflowState& aReflowState, - nsReflowStatus& aStatus, - nsIFrame * aDeletedFrame); - NS_IMETHOD AdjustSiblingsAfterReflow(nsIPresContext& aPresContext, InnerTableReflowState& aState, nsIFrame* aKidFrame, diff --git a/layout/tables/nsTableOuterFrame.cpp b/layout/tables/nsTableOuterFrame.cpp index f002487dfdb..0580b114191 100644 --- a/layout/tables/nsTableOuterFrame.cpp +++ b/layout/tables/nsTableOuterFrame.cpp @@ -97,7 +97,7 @@ struct OuterTableReflowState { /** */ nsTableOuterFrame::nsTableOuterFrame(nsIContent* aContent, nsIFrame* aParentFrame) - : nsContainerFrame(aContent, aParentFrame), + : nsHTMLContainerFrame(aContent, aParentFrame), mInnerTableFrame(nsnull), mCaptionFrame(nsnull), mMinCaptionWidth(0), diff --git a/layout/tables/nsTableOuterFrame.h b/layout/tables/nsTableOuterFrame.h index bcd23d63323..b49e7285ddb 100644 --- a/layout/tables/nsTableOuterFrame.h +++ b/layout/tables/nsTableOuterFrame.h @@ -19,7 +19,7 @@ #define nsTableOuterFrame_h__ #include "nscore.h" -#include "nsContainerFrame.h" +#include "nsHTMLContainerFrame.h" struct OuterTableReflowState; struct nsStyleText; @@ -34,7 +34,7 @@ struct nsStyleText; * are always mapped * */ -class nsTableOuterFrame : public nsContainerFrame +class nsTableOuterFrame : public nsHTMLContainerFrame { public: @@ -80,6 +80,9 @@ protected: */ nsTableOuterFrame(nsIContent* aContent, nsIFrame* aParentFrame); + /** implement abstract method on nsHTMLContainerFrame */ + virtual PRIntn GetSkipSides() const; + /** return PR_TRUE if the table needs to be reflowed. * the outer table needs to be reflowed if the table content has changed, * or if the table style attributes or parent max height/width have @@ -200,6 +203,8 @@ private: inline nscoord nsTableOuterFrame::GetMinCaptionWidth() { return mMinCaptionWidth; } +inline PRIntn nsTableOuterFrame::GetSkipSides() const +{ return 0; } #endif diff --git a/layout/tables/nsTableRowFrame.cpp b/layout/tables/nsTableRowFrame.cpp index bf7af778721..16c5fee073c 100644 --- a/layout/tables/nsTableRowFrame.cpp +++ b/layout/tables/nsTableRowFrame.cpp @@ -84,7 +84,7 @@ struct RowReflowState { nsTableRowFrame::nsTableRowFrame(nsIContent* aContent, nsIFrame* aParentFrame) - : nsContainerFrame(aContent, aParentFrame), + : nsHTMLContainerFrame(aContent, aParentFrame), mTallestCell(0), mCellMaxTopMargin(0), mCellMaxBottomMargin(0), @@ -240,6 +240,19 @@ NS_METHOD nsTableRowFrame::Paint(nsIPresContext& aPresContext, return NS_OK; } +PRIntn +nsTableRowFrame::GetSkipSides() const +{ + PRIntn skip = 0; + if (nsnull != mPrevInFlow) { + skip |= 1 << NS_SIDE_TOP; + } + if (nsnull != mNextInFlow) { + skip |= 1 << NS_SIDE_BOTTOM; + } + return skip; +} + /** overloaded method from nsContainerFrame. The difference is that * we don't want to clip our children, so a cell can do a rowspan */ @@ -866,8 +879,7 @@ NS_METHOD nsTableRowFrame::IR_TargetIsMe(nsIPresContext& aPresContext, } else { - rv = IR_UnknownFrameInserted(aPresContext, aDesiredSize, aReflowState, aStatus, - objectFrame, PR_FALSE); + rv = AddFrame(aReflowState.reflowState, objectFrame); } break; @@ -879,8 +891,7 @@ NS_METHOD nsTableRowFrame::IR_TargetIsMe(nsIPresContext& aPresContext, } else { // no optimization to be done for Unknown frame types, so just reuse the Inserted method - rv = IR_UnknownFrameInserted(aPresContext, aDesiredSize, aReflowState, aStatus, - objectFrame, PR_FALSE); + rv = AddFrame(aReflowState.reflowState, objectFrame); } break; @@ -897,8 +908,7 @@ NS_METHOD nsTableRowFrame::IR_TargetIsMe(nsIPresContext& aPresContext, } else { - rv = IR_UnknownFrameRemoved(aPresContext, aDesiredSize, aReflowState, aStatus, - objectFrame); + rv = RemoveFrame(objectFrame); } break; @@ -934,8 +944,7 @@ NS_METHOD nsTableRowFrame::IR_CellInserted(nsIPresContext& aPresContext, PRBool aReplace) { if (PR_TRUE==gsDebugIR) printf("\nTRF IR: IR_CellInserted\n"); - nsresult rv = IR_UnknownFrameInserted(aPresContext, aDesiredSize, aReflowState, - aStatus, (nsIFrame*)aInsertedFrame, aReplace); + nsresult rv = AddFrame(aReflowState.reflowState, (nsIFrame*)aInsertedFrame); if (NS_FAILED(rv)) return rv; @@ -971,8 +980,7 @@ NS_METHOD nsTableRowFrame::IR_CellAppended(nsIPresContext& aPresContext, { if (PR_TRUE==gsDebugIR) printf("\nTRF IR: IR_CellInserted\n"); - nsresult rv = IR_UnknownFrameInserted(aPresContext, aDesiredSize, aReflowState, - aStatus, (nsIFrame*)aAppendedFrame, PR_FALSE); + nsresult rv = AddFrame(aReflowState.reflowState, (nsIFrame*)aAppendedFrame); if (NS_FAILED(rv)) return rv; @@ -1037,9 +1045,8 @@ NS_METHOD nsTableRowFrame::IR_CellRemoved(nsIPresContext& aPresContext, nsReflowStatus& aStatus, nsTableCellFrame * aDeletedFrame) { - if (PR_TRUE==gsDebugIR) printf("\nTRGF IR: IR_RowRemoved\n"); - nsresult rv = IR_UnknownFrameRemoved(aPresContext, aDesiredSize, aReflowState, aStatus, - aDeletedFrame); + if (PR_TRUE==gsDebugIR) printf("\nRow IR: IR_RowRemoved\n"); + nsresult rv = RemoveFrame((nsIFrame*)aDeletedFrame); if (NS_SUCCEEDED(rv)) { nsTableFrame *tableFrame=nsnull; @@ -1057,84 +1064,6 @@ NS_METHOD nsTableRowFrame::IR_CellRemoved(nsIPresContext& aPresContext, return rv; } -//XXX: handle aReplace -NS_METHOD nsTableRowFrame::IR_UnknownFrameInserted(nsIPresContext& aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - RowReflowState& aReflowState, - nsReflowStatus& aStatus, - nsIFrame * aInsertedFrame, - PRBool aReplace) -{ - if (PR_TRUE==gsDebugIR) printf("\nTRGF IR: IR_UnknownFrameInserted\n"); - nsIReflowCommand::ReflowType type; - aReflowState.reflowState.reflowCommand->GetType(type); - // we have a generic frame that gets inserted but doesn't effect reflow - // hook it up then ignore it - if (nsIReflowCommand::FrameAppended==type) - { // frameAppended reflow -- find the last child and make aInsertedFrame its next sibling - if (PR_TRUE==gsDebugIR) printf("TRGF IR: FrameAppended adding unknown frame type.\n"); - nsIFrame *lastChild=mFirstChild; - nsIFrame *nextChild=mFirstChild; - while (nsnull!=nextChild) - { - lastChild=nextChild; - nextChild->GetNextSibling(nextChild); - } - if (nsnull==lastChild) - mFirstChild = aInsertedFrame; - else - lastChild->SetNextSibling(aInsertedFrame); - } - else - { // frameInserted reflow -- hook up aInsertedFrame as prevSibling's next sibling, - // and be sure to hook in aInsertedFrame's nextSibling (from prevSibling) - if (PR_TRUE==gsDebugIR) printf("TRGF IR: FrameInserted adding unknown frame type.\n"); - nsIFrame *prevSibling=nsnull; - nsresult rv = aReflowState.reflowState.reflowCommand->GetPrevSiblingFrame(prevSibling); - if (NS_SUCCEEDED(rv) && (nsnull!=prevSibling)) - { - nsIFrame *nextSibling=nsnull; - prevSibling->GetNextSibling(nextSibling); - prevSibling->SetNextSibling(aInsertedFrame); - aInsertedFrame->SetNextSibling(nextSibling); - } - else - { - nsIFrame *nextSibling=mFirstChild; - mFirstChild = aInsertedFrame; - aInsertedFrame->SetNextSibling(nextSibling); - } - } - aStatus = NS_FRAME_COMPLETE; - return NS_OK; -} - -NS_METHOD nsTableRowFrame::IR_UnknownFrameRemoved(nsIPresContext& aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - RowReflowState& aReflowState, - nsReflowStatus& aStatus, - nsIFrame * aRemovedFrame) -{ - if (PR_TRUE==gsDebugIR) printf("\nTRGF IR: IR_UnknownFrameRemoved\n"); - // we have a generic frame that gets removed but doesn't effect reflow - // unhook it then ignore it - if (PR_TRUE==gsDebugIR) printf("TRGF IR: FrameRemoved removing unknown frame type.\n"); - nsIFrame *prevChild=nsnull; - nsIFrame *nextChild=mFirstChild; - while (nextChild!=aRemovedFrame) - { - prevChild=nextChild; - nextChild->GetNextSibling(nextChild); - } - nextChild=nsnull; - aRemovedFrame->GetNextSibling(nextChild); - if (nsnull==prevChild) // objectFrame was first child - mFirstChild = nextChild; - else - prevChild->SetNextSibling(nextChild); - aStatus = NS_FRAME_COMPLETE; - return NS_OK; -} NS_METHOD nsTableRowFrame::IR_TargetIsChild(nsIPresContext& aPresContext, nsHTMLReflowMetrics& aDesiredSize, RowReflowState& aReflowState, diff --git a/layout/tables/nsTableRowFrame.h b/layout/tables/nsTableRowFrame.h index 3fc5e491051..65cc7aded29 100644 --- a/layout/tables/nsTableRowFrame.h +++ b/layout/tables/nsTableRowFrame.h @@ -19,7 +19,7 @@ #define nsTableRowFrame_h__ #include "nscore.h" -#include "nsContainerFrame.h" +#include "nsHTMLContainerFrame.h" class nsTableFrame; class nsTableCellFrame; @@ -35,7 +35,7 @@ struct RowReflowState; * @see nsTableRowGroupFrame * @see nsTableCellFrame */ -class nsTableRowFrame : public nsContainerFrame +class nsTableRowFrame : public nsHTMLContainerFrame { public: /** Initialization of frame as a row */ @@ -131,6 +131,9 @@ protected: /** destructor */ virtual ~nsTableRowFrame(); + /** implement abstract method on nsHTMLContainerFrame */ + virtual PRIntn GetSkipSides() const; + /** Incremental Reflow attempts to do column balancing with the minimum number of reflow * commands to child elements. This is done by processing the reflow command, * rebalancing column widths (if necessary), then comparing the resulting column widths @@ -174,20 +177,6 @@ protected: RowReflowState& aReflowState, nsReflowStatus& aStatus, nsTableCellFrame * aDeletedFrame); - - NS_IMETHOD IR_UnknownFrameInserted(nsIPresContext& aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - RowReflowState& aReflowState, - nsReflowStatus& aStatus, - nsIFrame * aInsertedFrame, - PRBool aReplace); - - NS_IMETHOD IR_UnknownFrameRemoved(nsIPresContext& aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - RowReflowState& aReflowState, - nsReflowStatus& aStatus, - nsIFrame * aDeletedFrame); - // row-specific methods diff --git a/layout/tables/nsTableRowGroupFrame.cpp b/layout/tables/nsTableRowGroupFrame.cpp index f8c11500f50..59cb0a2a538 100644 --- a/layout/tables/nsTableRowGroupFrame.cpp +++ b/layout/tables/nsTableRowGroupFrame.cpp @@ -91,7 +91,7 @@ struct RowGroupReflowState { /* ----------- nsTableRowGroupFrame ---------- */ nsTableRowGroupFrame::nsTableRowGroupFrame(nsIContent* aContent, nsIFrame* aParentFrame) - : nsContainerFrame(aContent, aParentFrame) + : nsHTMLContainerFrame(aContent, aParentFrame) { aContent->GetTag(mType); // mType: REFCNT++ } @@ -152,6 +152,19 @@ NS_METHOD nsTableRowGroupFrame::Paint(nsIPresContext& aPresContext, return NS_OK; } +PRIntn +nsTableRowGroupFrame::GetSkipSides() const +{ + PRIntn skip = 0; + if (nsnull != mPrevInFlow) { + skip |= 1 << NS_SIDE_TOP; + } + if (nsnull != mNextInFlow) { + skip |= 1 << NS_SIDE_BOTTOM; + } + return skip; +} + // aDirtyRect is in our coordinate system // child rect's are also in our coordinate system /** overloaded method from nsContainerFrame. The difference is that @@ -877,8 +890,7 @@ NS_METHOD nsTableRowGroupFrame::IR_TargetIsMe(nsIPresContext& aPresContext, } else { - rv = IR_UnknownFrameInserted(aPresContext, aDesiredSize, aReflowState, aStatus, - objectFrame, PR_FALSE); + rv = AddFrame(aReflowState.reflowState, objectFrame); } break; @@ -890,8 +902,7 @@ NS_METHOD nsTableRowGroupFrame::IR_TargetIsMe(nsIPresContext& aPresContext, } else { // no optimization to be done for Unknown frame types, so just reuse the Inserted method - rv = IR_UnknownFrameInserted(aPresContext, aDesiredSize, aReflowState, aStatus, - objectFrame, PR_FALSE); + rv = AddFrame(aReflowState.reflowState, objectFrame); } break; @@ -908,8 +919,7 @@ NS_METHOD nsTableRowGroupFrame::IR_TargetIsMe(nsIPresContext& aPresContext, } else { - rv = IR_UnknownFrameRemoved(aPresContext, aDesiredSize, aReflowState, aStatus, - objectFrame); + rv = RemoveFrame(objectFrame); } break; @@ -945,8 +955,7 @@ NS_METHOD nsTableRowGroupFrame::IR_RowInserted(nsIPresContext& aPresContext PRBool aReplace) { if (PR_TRUE==gsDebugIR) printf("\nTRGF IR: IR_RowInserted\n"); - nsresult rv = IR_UnknownFrameInserted(aPresContext, aDesiredSize, aReflowState, - aStatus, (nsIFrame*)aInsertedFrame, aReplace); + nsresult rv = AddFrame(aReflowState.reflowState, (nsIFrame*)aInsertedFrame); if (NS_FAILED(rv)) return rv; @@ -1024,8 +1033,7 @@ NS_METHOD nsTableRowGroupFrame::IR_RowAppended(nsIPresContext& aPresContext { if (PR_TRUE==gsDebugIR) printf("\nTRGF IR: IR_RowAppended\n"); // hook aAppendedFrame into the child list - nsresult rv = IR_UnknownFrameInserted(aPresContext, aDesiredSize, aReflowState, - aStatus, (nsIFrame*)aAppendedFrame, PR_FALSE); + nsresult rv = AddFrame(aReflowState.reflowState, (nsIFrame*)aAppendedFrame); if (NS_FAILED(rv)) return rv; @@ -1083,8 +1091,7 @@ NS_METHOD nsTableRowGroupFrame::IR_RowRemoved(nsIPresContext& aPresContext, nsTableRowFrame * aDeletedFrame) { if (PR_TRUE==gsDebugIR) printf("\nTRGF IR: IR_RowRemoved\n"); - nsresult rv = IR_UnknownFrameRemoved(aPresContext, aDesiredSize, aReflowState, aStatus, - aDeletedFrame); + nsresult rv = RemoveFrame((nsIFrame *)aDeletedFrame); if (NS_SUCCEEDED(rv)) { nsTableFrame *tableFrame=nsnull; @@ -1102,85 +1109,6 @@ NS_METHOD nsTableRowGroupFrame::IR_RowRemoved(nsIPresContext& aPresContext, return rv; } -//XXX: handle aReplace -NS_METHOD nsTableRowGroupFrame::IR_UnknownFrameInserted(nsIPresContext& aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - RowGroupReflowState& aReflowState, - nsReflowStatus& aStatus, - nsIFrame * aInsertedFrame, - PRBool aReplace) -{ - if (PR_TRUE==gsDebugIR) printf("\nTRGF IR: IR_UnknownFrameInserted\n"); - nsIReflowCommand::ReflowType type; - aReflowState.reflowState.reflowCommand->GetType(type); - // we have a generic frame that gets inserted but doesn't effect reflow - // hook it up then ignore it - if (nsIReflowCommand::FrameAppended==type) - { // frameAppended reflow -- find the last child and make aInsertedFrame its next sibling - if (PR_TRUE==gsDebugIR) printf("TRGF IR: FrameAppended adding unknown frame type.\n"); - nsIFrame *lastChild=mFirstChild; - nsIFrame *nextChild=mFirstChild; - while (nsnull!=nextChild) - { - lastChild=nextChild; - nextChild->GetNextSibling(nextChild); - } - if (nsnull==lastChild) - mFirstChild = aInsertedFrame; - else - lastChild->SetNextSibling(aInsertedFrame); - } - else - { // frameInserted reflow -- hook up aInsertedFrame as prevSibling's next sibling, - // and be sure to hook in aInsertedFrame's nextSibling (from prevSibling) - if (PR_TRUE==gsDebugIR) printf("TRGF IR: FrameInserted adding unknown frame type.\n"); - nsIFrame *prevSibling=nsnull; - nsresult rv = aReflowState.reflowState.reflowCommand->GetPrevSiblingFrame(prevSibling); - if (NS_SUCCEEDED(rv) && (nsnull!=prevSibling)) - { - nsIFrame *nextSibling=nsnull; - prevSibling->GetNextSibling(nextSibling); - prevSibling->SetNextSibling(aInsertedFrame); - aInsertedFrame->SetNextSibling(nextSibling); - } - else - { - nsIFrame *nextSibling=mFirstChild; - mFirstChild = aInsertedFrame; - aInsertedFrame->SetNextSibling(nextSibling); - } - } - aStatus = NS_FRAME_COMPLETE; - return NS_OK; -} - -NS_METHOD nsTableRowGroupFrame::IR_UnknownFrameRemoved(nsIPresContext& aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - RowGroupReflowState& aReflowState, - nsReflowStatus& aStatus, - nsIFrame * aRemovedFrame) -{ - if (PR_TRUE==gsDebugIR) printf("\nTRGF IR: IR_UnknownFrameRemoved\n"); - // we have a generic frame that gets removed but doesn't effect reflow - // unhook it then ignore it - if (PR_TRUE==gsDebugIR) printf("TRGF IR: FrameRemoved removing unknown frame type.\n"); - nsIFrame *prevChild=nsnull; - nsIFrame *nextChild=mFirstChild; - while (nextChild!=aRemovedFrame) - { - prevChild=nextChild; - nextChild->GetNextSibling(nextChild); - } - nextChild=nsnull; - aRemovedFrame->GetNextSibling(nextChild); - if (nsnull==prevChild) // objectFrame was first child - mFirstChild = nextChild; - else - prevChild->SetNextSibling(nextChild); - aStatus = NS_FRAME_COMPLETE; - return NS_OK; -} - NS_METHOD nsTableRowGroupFrame::IR_TargetIsChild(nsIPresContext& aPresContext, nsHTMLReflowMetrics& aDesiredSize, RowGroupReflowState& aReflowState, diff --git a/layout/tables/nsTableRowGroupFrame.h b/layout/tables/nsTableRowGroupFrame.h index c254981d5fb..319c5638040 100644 --- a/layout/tables/nsTableRowGroupFrame.h +++ b/layout/tables/nsTableRowGroupFrame.h @@ -19,7 +19,7 @@ #define nsTableRowGroupFrame_h__ #include "nscore.h" -#include "nsContainerFrame.h" +#include "nsHTMLContainerFrame.h" #include "nsIAtom.h" class nsTableRowFrame; @@ -36,7 +36,7 @@ struct RowGroupReflowState; * * @author sclark */ -class nsTableRowGroupFrame : public nsContainerFrame +class nsTableRowGroupFrame : public nsHTMLContainerFrame { public: @@ -80,6 +80,49 @@ public: const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus); + /** returns the type of the mapped row group content in aType. + * caller MUST call release on the returned object if it is not null. + * + * @param aType out param filled with the type of the mapped content, or null if none. + * + * @return NS_OK + */ + NS_IMETHOD GetRowGroupType(nsIAtom *& aType); + + /** set aCount to the number of child rows (not necessarily == number of child frames) */ + NS_METHOD GetRowCount(PRInt32 &aCount); + + NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0, nsIListFilter *aFilter = nsnull) const; + + +protected: + + /** protected constructor. + * @see NewFrame + */ + nsTableRowGroupFrame(nsIContent* aContent, nsIFrame* aParentFrame); + + /** protected destructor */ + ~nsTableRowGroupFrame(); + + /** implement abstract method on nsHTMLContainerFrame */ + virtual PRIntn GetSkipSides() const; + + nscoord GetTopMarginFor(nsIPresContext* aCX, + RowGroupReflowState& aReflowState, + const nsMargin& aKidMargin); + + void PlaceChild( nsIPresContext& aPresContext, + RowGroupReflowState& aReflowState, + nsIFrame* aKidFrame, + const nsRect& aKidRect, + nsSize* aMaxElementSize, + nsSize& aKidMaxElementSize); + + void ShrinkWrapChildren(nsIPresContext* aPresContext, + nsHTMLReflowMetrics& aDesiredSize); + + /** Incremental Reflow attempts to do column balancing with the minimum number of reflow * commands to child elements. This is done by processing the reflow command, * rebalancing column widths (if necessary), then comparing the resulting column widths @@ -121,20 +164,6 @@ public: RowGroupReflowState& aReflowState, nsReflowStatus& aStatus, nsTableRowFrame * aDeletedFrame); - - NS_IMETHOD IR_UnknownFrameInserted(nsIPresContext& aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - RowGroupReflowState& aReflowState, - nsReflowStatus& aStatus, - nsIFrame * aInsertedFrame, - PRBool aReplace); - - NS_IMETHOD IR_UnknownFrameRemoved(nsIPresContext& aPresContext, - nsHTMLReflowMetrics& aDesiredSize, - RowGroupReflowState& aReflowState, - nsReflowStatus& aStatus, - nsIFrame * aDeletedFrame); - NS_IMETHOD DidAppendRow(nsTableRowFrame *aRowFrame); @@ -146,45 +175,6 @@ public: nsIStyleContext* aStyleContext, nsIFrame*& aContinuingFrame); - /** returns the type of the mapped row group content in aType. - * caller MUST call release on the returned object if it is not null. - * - * @param aType out param filled with the type of the mapped content, or null if none. - * - * @return NS_OK - */ - NS_IMETHOD GetRowGroupType(nsIAtom *& aType); - - /** set aCount to the number of child rows (not necessarily == number of child frames) */ - NS_METHOD GetRowCount(PRInt32 &aCount); - - NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0, nsIListFilter *aFilter = nsnull) const; - - -protected: - - /** protected constructor. - * @see NewFrame - */ - nsTableRowGroupFrame(nsIContent* aContent, nsIFrame* aParentFrame); - - /** protected destructor */ - ~nsTableRowGroupFrame(); - - nscoord GetTopMarginFor(nsIPresContext* aCX, - RowGroupReflowState& aReflowState, - const nsMargin& aKidMargin); - - void PlaceChild( nsIPresContext& aPresContext, - RowGroupReflowState& aReflowState, - nsIFrame* aKidFrame, - const nsRect& aKidRect, - nsSize* aMaxElementSize, - nsSize& aKidMaxElementSize); - - void ShrinkWrapChildren(nsIPresContext* aPresContext, - nsHTMLReflowMetrics& aDesiredSize); - nsresult AdjustSiblingsAfterReflow(nsIPresContext& aPresContext, RowGroupReflowState& aReflowState, nsIFrame* aKidFrame,