From d138bc14e10cb05e03dadd231da3ed3e148966b5 Mon Sep 17 00:00:00 2001 From: troy Date: Thu, 2 Jul 1998 20:35:23 +0000 Subject: [PATCH] Moved code that resized the table row cells from the row group frame to the row frame. It's now handled as part of the DidReflow() post- processing code --- layout/html/table/src/nsTableFrame.cpp | 5 ++ layout/html/table/src/nsTableRowFrame.cpp | 36 ++++++++++++ layout/html/table/src/nsTableRowFrame.h | 3 + .../html/table/src/nsTableRowGroupFrame.cpp | 58 +------------------ layout/html/table/src/nsTableRowGroupFrame.h | 7 --- layout/tables/nsTableFrame.cpp | 5 ++ layout/tables/nsTableRowFrame.cpp | 36 ++++++++++++ layout/tables/nsTableRowFrame.h | 3 + layout/tables/nsTableRowGroupFrame.cpp | 58 +------------------ layout/tables/nsTableRowGroupFrame.h | 7 --- 10 files changed, 94 insertions(+), 124 deletions(-) diff --git a/layout/html/table/src/nsTableFrame.cpp b/layout/html/table/src/nsTableFrame.cpp index b7c15a646511..bc9e906f7f67 100644 --- a/layout/html/table/src/nsTableFrame.cpp +++ b/layout/html/table/src/nsTableFrame.cpp @@ -398,6 +398,11 @@ PRInt32 nsTableFrame::GetRowCount () // return the rows spanned by aCell starting at aRowIndex // note that this is different from just the rowspan of aCell // (that would be GetEffectiveRowSpan (indexOfRowThatContains_aCell, aCell) +// +// XXX This code should be in the table row group frame instead, and it +// should clip rows spans so they don't extend past a row group rather than +// clip to the table itself. Before that can happen the code that builds the +// cell map needs to take row groups into account PRInt32 nsTableFrame::GetEffectiveRowSpan (PRInt32 aRowIndex, nsTableCellFrame *aCell) { NS_PRECONDITION (nsnull!=aCell, "bad cell arg"); diff --git a/layout/html/table/src/nsTableRowFrame.cpp b/layout/html/table/src/nsTableRowFrame.cpp index 1a1192f96aa8..cc6d9cf69972 100644 --- a/layout/html/table/src/nsTableRowFrame.cpp +++ b/layout/html/table/src/nsTableRowFrame.cpp @@ -105,6 +105,42 @@ nsTableRowFrame::~nsTableRowFrame() { } +/** + * Post-reflow hook. This is where the table row does its post-processing + */ +NS_METHOD +nsTableRowFrame::DidReflow(nsIPresContext& aPresContext, + nsDidReflowStatus aStatus) +{ + if (NS_FRAME_REFLOW_FINISHED == aStatus) { + // Resize and re-align the cell frames based on our row height + nscoord cellHeight = mRect.height - mCellMaxTopMargin - mCellMaxBottomMargin; + nsTableCellFrame *cellFrame = (nsTableCellFrame*)mFirstChild; + nsTableFrame* tableFrame; + mContentParent->GetContentParent((nsIFrame*&)tableFrame); + while (nsnull != cellFrame) + { + PRInt32 rowSpan = tableFrame->GetEffectiveRowSpan(mRowIndex, cellFrame); + if (1==rowSpan) + { + // resize the cell's height + nsSize cellFrameSize; + cellFrame->GetSize(cellFrameSize); + cellFrame->SizeTo(cellFrameSize.width, cellHeight); + + // realign cell content based on the new height + cellFrame->VerticallyAlignChild(&aPresContext); + } + + // Get the next cell + cellFrame->GetNextSibling((nsIFrame*&)cellFrame); + } + } + + // Let our base class do the usual work + return nsContainerFrame::DidReflow(aPresContext, aStatus); +} + void nsTableRowFrame::ResetMaxChildHeight() { mTallestCell=0; diff --git a/layout/html/table/src/nsTableRowFrame.h b/layout/html/table/src/nsTableRowFrame.h index 366240eadaeb..4c1a14bc2683 100644 --- a/layout/html/table/src/nsTableRowFrame.h +++ b/layout/html/table/src/nsTableRowFrame.h @@ -94,6 +94,9 @@ public: const nsReflowState& aReflowState, nsReflowStatus& aStatus); + NS_IMETHOD DidReflow(nsIPresContext& aPresContext, + nsDidReflowStatus aStatus); + /** @see nsContainerFrame::CreateContinuingFrame */ NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext, nsIFrame* aParent, diff --git a/layout/html/table/src/nsTableRowGroupFrame.cpp b/layout/html/table/src/nsTableRowGroupFrame.cpp index b6660bc6b9c3..c5e0640c39d0 100644 --- a/layout/html/table/src/nsTableRowGroupFrame.cpp +++ b/layout/html/table/src/nsTableRowGroupFrame.cpp @@ -827,55 +827,6 @@ nsTableRowGroupFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext, return result; } -/** - * Called by ShrinkWrapChildren() to set the height of a table row. Resizes - * the table row, each of the row's table cells, and then realigns the cell - * content based on the new height - */ -void nsTableRowGroupFrame::SetRowHeight(nsIPresContext* aPresContext, - nsIFrame* aRowFrame, - PRInt32 aRowIndex, - nscoord aRowHeight, - nscoord aMaxCellHeight, - PRBool& aHasRowSpanningCell) -{ - // initialize out parameter - aHasRowSpanningCell = PR_FALSE; - - // set the row's height - nsSize rowFrameSize; - aRowFrame->GetSize(rowFrameSize); - aRowFrame->SizeTo(rowFrameSize.width, aRowHeight); - - // resize all the cells based on the max cell height - // XXX It would be better to just inform the row of the new size and have - // it resize and re-align its cells... - nsTableCellFrame *cellFrame; - aRowFrame->FirstChild((nsIFrame*&)cellFrame); - while (nsnull != cellFrame) - { - PRInt32 rowSpan = ((nsTableFrame*)mGeometricParent)->GetEffectiveRowSpan(aRowIndex, - cellFrame); - if (1==rowSpan) - { - // resize the cell's height - nsSize cellFrameSize; - cellFrame->GetSize(cellFrameSize); - cellFrame->SizeTo(cellFrameSize.width, aMaxCellHeight); - - // realign cell content based on the new height - cellFrame->VerticallyAlignChild(aPresContext); - } - else - { - aHasRowSpanningCell = PR_TRUE; - } - - // Get the next cell - cellFrame->GetNextSibling((nsIFrame*&)cellFrame); - } -} - /** */ void nsTableRowGroupFrame::ShrinkWrapChildren(nsIPresContext* aPresContext, @@ -909,12 +860,9 @@ void nsTableRowGroupFrame::ShrinkWrapChildren(nsIPresContext* aPresContext, rowHeights[rowIndex] = maxRowHeight; // resize the row - PRBool hasRowSpanningCell; - SetRowHeight(aPresContext, rowFrame, rowIndex, maxRowHeight, maxCellHeight, - hasRowSpanningCell); - if (hasRowSpanningCell) { - atLeastOneRowSpanningCell = PR_TRUE; - } + nsSize rowFrameSize; + rowFrame->GetSize(rowFrameSize); + rowFrame->SizeTo(rowFrameSize.width, maxRowHeight); // Update the running row group height rowGroupHeight += maxRowHeight; diff --git a/layout/html/table/src/nsTableRowGroupFrame.h b/layout/html/table/src/nsTableRowGroupFrame.h index f2c6bc3a6629..58169324c20d 100644 --- a/layout/html/table/src/nsTableRowGroupFrame.h +++ b/layout/html/table/src/nsTableRowGroupFrame.h @@ -123,13 +123,6 @@ protected: nsReflowMetrics& aDesiredSize, nsSize* aMaxElementSize); - void SetRowHeight(nsIPresContext* aPresContext, - nsIFrame* aRowFrame, - PRInt32 aRowIndex, - nscoord aRowHeight, - nscoord aMaxCellHeight, - PRBool& aHasRowSpanningCell); - /** * Reflow the frames we've already created * diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index b7c15a646511..bc9e906f7f67 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -398,6 +398,11 @@ PRInt32 nsTableFrame::GetRowCount () // return the rows spanned by aCell starting at aRowIndex // note that this is different from just the rowspan of aCell // (that would be GetEffectiveRowSpan (indexOfRowThatContains_aCell, aCell) +// +// XXX This code should be in the table row group frame instead, and it +// should clip rows spans so they don't extend past a row group rather than +// clip to the table itself. Before that can happen the code that builds the +// cell map needs to take row groups into account PRInt32 nsTableFrame::GetEffectiveRowSpan (PRInt32 aRowIndex, nsTableCellFrame *aCell) { NS_PRECONDITION (nsnull!=aCell, "bad cell arg"); diff --git a/layout/tables/nsTableRowFrame.cpp b/layout/tables/nsTableRowFrame.cpp index 1a1192f96aa8..cc6d9cf69972 100644 --- a/layout/tables/nsTableRowFrame.cpp +++ b/layout/tables/nsTableRowFrame.cpp @@ -105,6 +105,42 @@ nsTableRowFrame::~nsTableRowFrame() { } +/** + * Post-reflow hook. This is where the table row does its post-processing + */ +NS_METHOD +nsTableRowFrame::DidReflow(nsIPresContext& aPresContext, + nsDidReflowStatus aStatus) +{ + if (NS_FRAME_REFLOW_FINISHED == aStatus) { + // Resize and re-align the cell frames based on our row height + nscoord cellHeight = mRect.height - mCellMaxTopMargin - mCellMaxBottomMargin; + nsTableCellFrame *cellFrame = (nsTableCellFrame*)mFirstChild; + nsTableFrame* tableFrame; + mContentParent->GetContentParent((nsIFrame*&)tableFrame); + while (nsnull != cellFrame) + { + PRInt32 rowSpan = tableFrame->GetEffectiveRowSpan(mRowIndex, cellFrame); + if (1==rowSpan) + { + // resize the cell's height + nsSize cellFrameSize; + cellFrame->GetSize(cellFrameSize); + cellFrame->SizeTo(cellFrameSize.width, cellHeight); + + // realign cell content based on the new height + cellFrame->VerticallyAlignChild(&aPresContext); + } + + // Get the next cell + cellFrame->GetNextSibling((nsIFrame*&)cellFrame); + } + } + + // Let our base class do the usual work + return nsContainerFrame::DidReflow(aPresContext, aStatus); +} + void nsTableRowFrame::ResetMaxChildHeight() { mTallestCell=0; diff --git a/layout/tables/nsTableRowFrame.h b/layout/tables/nsTableRowFrame.h index 366240eadaeb..4c1a14bc2683 100644 --- a/layout/tables/nsTableRowFrame.h +++ b/layout/tables/nsTableRowFrame.h @@ -94,6 +94,9 @@ public: const nsReflowState& aReflowState, nsReflowStatus& aStatus); + NS_IMETHOD DidReflow(nsIPresContext& aPresContext, + nsDidReflowStatus aStatus); + /** @see nsContainerFrame::CreateContinuingFrame */ NS_IMETHOD CreateContinuingFrame(nsIPresContext* aPresContext, nsIFrame* aParent, diff --git a/layout/tables/nsTableRowGroupFrame.cpp b/layout/tables/nsTableRowGroupFrame.cpp index b6660bc6b9c3..c5e0640c39d0 100644 --- a/layout/tables/nsTableRowGroupFrame.cpp +++ b/layout/tables/nsTableRowGroupFrame.cpp @@ -827,55 +827,6 @@ nsTableRowGroupFrame::ReflowUnmappedChildren(nsIPresContext* aPresContext, return result; } -/** - * Called by ShrinkWrapChildren() to set the height of a table row. Resizes - * the table row, each of the row's table cells, and then realigns the cell - * content based on the new height - */ -void nsTableRowGroupFrame::SetRowHeight(nsIPresContext* aPresContext, - nsIFrame* aRowFrame, - PRInt32 aRowIndex, - nscoord aRowHeight, - nscoord aMaxCellHeight, - PRBool& aHasRowSpanningCell) -{ - // initialize out parameter - aHasRowSpanningCell = PR_FALSE; - - // set the row's height - nsSize rowFrameSize; - aRowFrame->GetSize(rowFrameSize); - aRowFrame->SizeTo(rowFrameSize.width, aRowHeight); - - // resize all the cells based on the max cell height - // XXX It would be better to just inform the row of the new size and have - // it resize and re-align its cells... - nsTableCellFrame *cellFrame; - aRowFrame->FirstChild((nsIFrame*&)cellFrame); - while (nsnull != cellFrame) - { - PRInt32 rowSpan = ((nsTableFrame*)mGeometricParent)->GetEffectiveRowSpan(aRowIndex, - cellFrame); - if (1==rowSpan) - { - // resize the cell's height - nsSize cellFrameSize; - cellFrame->GetSize(cellFrameSize); - cellFrame->SizeTo(cellFrameSize.width, aMaxCellHeight); - - // realign cell content based on the new height - cellFrame->VerticallyAlignChild(aPresContext); - } - else - { - aHasRowSpanningCell = PR_TRUE; - } - - // Get the next cell - cellFrame->GetNextSibling((nsIFrame*&)cellFrame); - } -} - /** */ void nsTableRowGroupFrame::ShrinkWrapChildren(nsIPresContext* aPresContext, @@ -909,12 +860,9 @@ void nsTableRowGroupFrame::ShrinkWrapChildren(nsIPresContext* aPresContext, rowHeights[rowIndex] = maxRowHeight; // resize the row - PRBool hasRowSpanningCell; - SetRowHeight(aPresContext, rowFrame, rowIndex, maxRowHeight, maxCellHeight, - hasRowSpanningCell); - if (hasRowSpanningCell) { - atLeastOneRowSpanningCell = PR_TRUE; - } + nsSize rowFrameSize; + rowFrame->GetSize(rowFrameSize); + rowFrame->SizeTo(rowFrameSize.width, maxRowHeight); // Update the running row group height rowGroupHeight += maxRowHeight; diff --git a/layout/tables/nsTableRowGroupFrame.h b/layout/tables/nsTableRowGroupFrame.h index f2c6bc3a6629..58169324c20d 100644 --- a/layout/tables/nsTableRowGroupFrame.h +++ b/layout/tables/nsTableRowGroupFrame.h @@ -123,13 +123,6 @@ protected: nsReflowMetrics& aDesiredSize, nsSize* aMaxElementSize); - void SetRowHeight(nsIPresContext* aPresContext, - nsIFrame* aRowFrame, - PRInt32 aRowIndex, - nscoord aRowHeight, - nscoord aMaxCellHeight, - PRBool& aHasRowSpanningCell); - /** * Reflow the frames we've already created *