From 08d8ed684c3f9fa6fea10686ffdc04397b45eceb Mon Sep 17 00:00:00 2001 From: "dbaron%dbaron.org" Date: Wed, 13 Dec 2006 03:45:28 +0000 Subject: [PATCH] Reflow all of the table structure (although not its descendants) when frame structure within the table is changed. b=363524 r=bernd sr=bzbarsky git-svn-id: svn://10.0.0.236/trunk@216926 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/tables/nsTableFrame.cpp | 9 ++++++++- mozilla/layout/tables/nsTableFrame.h | 6 +++++- mozilla/layout/tables/nsTableRowFrame.cpp | 4 ++++ mozilla/layout/tables/nsTableRowGroupFrame.cpp | 6 +++++- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/mozilla/layout/tables/nsTableFrame.cpp b/mozilla/layout/tables/nsTableFrame.cpp index 2f63429353e..fdf63f51e13 100644 --- a/mozilla/layout/tables/nsTableFrame.cpp +++ b/mozilla/layout/tables/nsTableFrame.cpp @@ -188,6 +188,7 @@ nsTableFrame::nsTableFrame(nsStyleContext* aContext) mBits.mNeedToCalcBCBorders = PR_FALSE; mBits.mIsBorderCollapse = PR_FALSE; mBits.mResizedColumns = PR_FALSE; // only really matters if splitting + mBits.mGeometryDirty = PR_FALSE; } NS_IMPL_ADDREF_INHERITED(nsTableFrame, nsHTMLContainerFrame) @@ -1914,6 +1915,7 @@ NS_METHOD nsTableFrame::Reflow(nsPresContext* aPresContext, !!(GetStateBits() & NS_FRAME_CONTAINS_RELATIVE_HEIGHT); if ((GetStateBits() & (NS_FRAME_IS_DIRTY | NS_FRAME_HAS_DIRTY_CHILDREN)) || aReflowState.ShouldReflowAllKids() || + IsGeometryDirty() || needToInitiateSpecialReflow) { // see if an extra reflow will be necessary in pagination mode when there is a specified table height if (isPaginated && !GetPrevInFlow() && (NS_UNCONSTRAINEDSIZE != aReflowState.availableHeight)) { @@ -2301,6 +2303,7 @@ nsTableFrame::AppendFrames(nsIAtom* aListName, AddStateBits(NS_FRAME_HAS_DIRTY_CHILDREN); GetPresContext()->PresShell()->FrameNeedsReflow(this, nsIPresShell::eTreeChange); + SetGeometryDirty(); return NS_OK; } @@ -2403,6 +2406,7 @@ nsTableFrame::InsertFrames(nsIAtom* aListName, AddStateBits(NS_FRAME_HAS_DIRTY_CHILDREN); GetPresContext()->PresShell()->FrameNeedsReflow(this, nsIPresShell::eTreeChange); + SetGeometryDirty(); #ifdef DEBUG_TABLE_CELLMAP printf("=== TableFrame::InsertFrames\n"); Dump(PR_TRUE, PR_TRUE, PR_TRUE); @@ -2482,6 +2486,7 @@ nsTableFrame::RemoveFrame(nsIAtom* aListName, AddStateBits(NS_FRAME_HAS_DIRTY_CHILDREN); GetPresContext()->PresShell()->FrameNeedsReflow(this, nsIPresShell::eTreeChange); + SetGeometryDirty(); #ifdef DEBUG_TABLE_CELLMAP printf("=== TableFrame::RemoveFrame\n"); Dump(PR_TRUE, PR_TRUE, PR_TRUE); @@ -2954,8 +2959,10 @@ nsTableFrame::ReflowChildren(nsTableReflowState& aReflowState, } } - // We've now propagated the column resize to all the children. + // We've now propagated the column resizes and geometry changes to all + // the children. mBits.mResizedColumns = PR_FALSE; + ClearGeometryDirty(); return rv; } diff --git a/mozilla/layout/tables/nsTableFrame.h b/mozilla/layout/tables/nsTableFrame.h index 2977364169c..7a8cde209c1 100644 --- a/mozilla/layout/tables/nsTableFrame.h +++ b/mozilla/layout/tables/nsTableFrame.h @@ -618,6 +618,10 @@ public: PRBool NeedColSpanExpansion() const; void SetNeedColSpanExpansion(PRBool aValue); + PRBool SetGeometryDirty() { mBits.mGeometryDirty = PR_TRUE; } + PRBool ClearGeometryDirty() { mBits.mGeometryDirty = PR_FALSE; } + PRBool IsGeometryDirty() const { return mBits.mGeometryDirty; } + /** Get the cell map for this table frame. It is not always mCellMap. * Only the firstInFlow has a legit cell map */ @@ -737,12 +741,12 @@ protected: PRUint32 mIsBorderCollapse:1; // border collapsing model vs. separate model PRUint32 mRowInserted:1; PRUint32 mNeedToCalcBCBorders:1; + PRUint32 mGeometryDirty:1; PRUint32 mLeftContBCBorder:8; PRUint32 mNeedToCollapse:1; // rows, cols that have visibility:collapse need to be collapsed PRUint32 mHasZeroColSpans:1; PRUint32 mNeedColSpanExpansion:1; PRBool mResizedColumns:1; // have we resized columns since last reflow? - PRUint32 :8; // unused } mBits; nsTableCellMap* mCellMap; // maintains the relationships between rows, cols, and cells diff --git a/mozilla/layout/tables/nsTableRowFrame.cpp b/mozilla/layout/tables/nsTableRowFrame.cpp index 9e6137af71a..a4c4098a62c 100644 --- a/mozilla/layout/tables/nsTableRowFrame.cpp +++ b/mozilla/layout/tables/nsTableRowFrame.cpp @@ -200,6 +200,7 @@ nsTableRowFrame::AppendFrames(nsIAtom* aListName, AddStateBits(NS_FRAME_HAS_DIRTY_CHILDREN); GetPresContext()->PresShell()->FrameNeedsReflow(this, nsIPresShell::eTreeChange); + tableFrame->SetGeometryDirty(); return NS_OK; } @@ -240,6 +241,7 @@ nsTableRowFrame::InsertFrames(nsIAtom* aListName, AddStateBits(NS_FRAME_HAS_DIRTY_CHILDREN); GetPresContext()->PresShell()->FrameNeedsReflow(this, nsIPresShell::eTreeChange); + tableFrame->SetGeometryDirty(); return NS_OK; } @@ -265,6 +267,7 @@ nsTableRowFrame::RemoveFrame(nsIAtom* aListName, AddStateBits(NS_FRAME_HAS_DIRTY_CHILDREN); GetPresContext()->PresShell()->FrameNeedsReflow(this, nsIPresShell::eTreeChange); + tableFrame->SetGeometryDirty(); } else { NS_ERROR("unexpected frame type"); @@ -843,6 +846,7 @@ nsTableRowFrame::ReflowChildren(nsPresContext* aPresContext, // See if we should only reflow the dirty child frames PRBool doReflowChild = PR_TRUE; if (!aReflowState.ShouldReflowAllKids() && + !aTableFrame.IsGeometryDirty() && !(kidFrame->GetStateBits() & (NS_FRAME_IS_DIRTY | NS_FRAME_HAS_DIRTY_CHILDREN))) { if (!aReflowState.mFlags.mSpecialHeightReflow) diff --git a/mozilla/layout/tables/nsTableRowGroupFrame.cpp b/mozilla/layout/tables/nsTableRowGroupFrame.cpp index 5deda7acb8a..697be8dc906 100644 --- a/mozilla/layout/tables/nsTableRowGroupFrame.cpp +++ b/mozilla/layout/tables/nsTableRowGroupFrame.cpp @@ -372,7 +372,8 @@ nsTableRowGroupFrame::ReflowChildren(nsPresContext* aPresContext, PRBool isPaginated = aPresContext->IsPaginated(); PRBool haveRow = PR_FALSE; - PRBool reflowAllKids = aReflowState.reflowState.ShouldReflowAllKids(); + PRBool reflowAllKids = aReflowState.reflowState.ShouldReflowAllKids() || + tableFrame->IsGeometryDirty(); PRBool needToCalcRowHeights = reflowAllKids; for (nsIFrame* kidFrame = mFrames.FirstChild(); kidFrame; @@ -1349,6 +1350,7 @@ nsTableRowGroupFrame::AppendFrames(nsIAtom* aListName, AddStateBits(NS_FRAME_HAS_DIRTY_CHILDREN); GetPresContext()->PresShell()->FrameNeedsReflow(this, nsIPresShell::eTreeChange); + tableFrame->SetGeometryDirty(); } } @@ -1398,6 +1400,7 @@ nsTableRowGroupFrame::InsertFrames(nsIAtom* aListName, AddStateBits(NS_FRAME_HAS_DIRTY_CHILDREN); GetPresContext()->PresShell()->FrameNeedsReflow(this, nsIPresShell::eTreeChange); + tableFrame->SetGeometryDirty(); } return NS_OK; } @@ -1419,6 +1422,7 @@ nsTableRowGroupFrame::RemoveFrame(nsIAtom* aListName, AddStateBits(NS_FRAME_HAS_DIRTY_CHILDREN); GetPresContext()->PresShell()->FrameNeedsReflow(this, nsIPresShell::eTreeChange); + tableFrame->SetGeometryDirty(); } } mFrames.DestroyFrame(aOldFrame);