From 6f183845ad294a300cabf6e4716c2f6d1c61d78a Mon Sep 17 00:00:00 2001 From: "bmlk%gmx.de" Date: Sun, 9 Nov 2003 11:35:52 +0000 Subject: [PATCH] issue style change reflow also at the table caption when there is a style change reflow that is targeted at the inner table frame. This is currently necessary due to bizarre style contetxt relationsship between inner and outer table frame, bug 222846 r/sr=bzbarsky --- layout/html/table/src/nsTableOuterFrame.cpp | 24 +++++++++++++++++---- layout/html/table/src/nsTableOuterFrame.h | 5 +++-- layout/tables/nsTableOuterFrame.cpp | 24 +++++++++++++++++---- layout/tables/nsTableOuterFrame.h | 5 +++-- 4 files changed, 46 insertions(+), 12 deletions(-) diff --git a/layout/html/table/src/nsTableOuterFrame.cpp b/layout/html/table/src/nsTableOuterFrame.cpp index acdbd22df929..d93157b3a2b4 100644 --- a/layout/html/table/src/nsTableOuterFrame.cpp +++ b/layout/html/table/src/nsTableOuterFrame.cpp @@ -552,7 +552,7 @@ GetContainingBlockSize(const nsHTMLReflowState& aOuterRS) void nsTableOuterFrame::InvalidateDamage(nsIPresContext* aPresContext, PRUint8 aCaptionSide, - nsSize& aOuterSize, + const nsSize& aOuterSize, PRBool aInnerChanged, PRBool aCaptionChanged, nsRect* aOldOverflowArea) @@ -1258,7 +1258,8 @@ nsTableOuterFrame::OuterReflowChild(nsIPresContext* aPresContext, nsMargin& aMarginNoAuto, nsMargin& aPadding, nsReflowReason aReflowReason, - nsReflowStatus& aStatus) + nsReflowStatus& aStatus, + PRBool* aNeedToReflowCaption) { if (!aPresContext) ABORT1(NS_ERROR_NULL_POINTER); aMargin = aPadding = nsMargin(0,0,0,0); @@ -1318,6 +1319,16 @@ nsTableOuterFrame::OuterReflowChild(nsIPresContext* aPresContext, aAvailWidth = aOuterRS.availableWidth; } } + // see if we need to reflow the caption in addition + if (aNeedToReflowCaption && !*aNeedToReflowCaption && + mInnerTableFrame == aChildFrame) { + nsHTMLReflowCommand* command = childRS.path->mReflowCommand; + if (command) { + nsReflowType type; + command->GetType(type); + *aNeedToReflowCaption = eReflowType_StyleChanged == type; + } + } // use the current position as a best guess for placement nsPoint childPt = aChildFrame->GetPosition(); @@ -1676,9 +1687,14 @@ nsTableOuterFrame::IR_InnerTableReflow(nsIPresContext* aPresContext, &capMin, innerMargin, innerPadding); nsresult rv = OuterReflowChild(aPresContext, mInnerTableFrame, aOuterRS, innerMet, availWidth, innerSize, innerMargin, innerMarginNoAuto, innerPadding, - reflowReason, aStatus); + reflowReason, aStatus, &reflowCaption); if (NS_FAILED(rv)) return rv; - + + if (eReflowReason_StyleChange != reflowReason && reflowCaption) { + // inner table frame was target for a style change reflow issue a style + // change reflow for the caption too. + reflowReason = eReflowReason_StyleChange; + } nsPoint innerOrigin(0,0); nsMargin captionMargin(0,0,0,0); nsMargin captionMarginNoAuto(0,0,0,0); diff --git a/layout/html/table/src/nsTableOuterFrame.h b/layout/html/table/src/nsTableOuterFrame.h index 7bad67c2129d..f043904537da 100644 --- a/layout/html/table/src/nsTableOuterFrame.h +++ b/layout/html/table/src/nsTableOuterFrame.h @@ -377,7 +377,8 @@ protected: nsMargin& aMarginNoAuto, nsMargin& aPadding, nsReflowReason aReflowReason, - nsReflowStatus& aStatus); + nsReflowStatus& aStatus, + PRBool* aNeedToReflowCaption = nsnull); // Set the reflow metrics, aInnerMarginNoAuto is aInnerMargin, but with // auto margins set to 0 @@ -394,7 +395,7 @@ protected: void InvalidateDamage(nsIPresContext* aPresContext, PRUint8 aCaptionSide, - nsSize& aOuterSize, + const nsSize& aOuterSize, PRBool aInnerChanged, PRBool aCaptionChanged, nsRect* aOldOverflowArea); diff --git a/layout/tables/nsTableOuterFrame.cpp b/layout/tables/nsTableOuterFrame.cpp index acdbd22df929..d93157b3a2b4 100644 --- a/layout/tables/nsTableOuterFrame.cpp +++ b/layout/tables/nsTableOuterFrame.cpp @@ -552,7 +552,7 @@ GetContainingBlockSize(const nsHTMLReflowState& aOuterRS) void nsTableOuterFrame::InvalidateDamage(nsIPresContext* aPresContext, PRUint8 aCaptionSide, - nsSize& aOuterSize, + const nsSize& aOuterSize, PRBool aInnerChanged, PRBool aCaptionChanged, nsRect* aOldOverflowArea) @@ -1258,7 +1258,8 @@ nsTableOuterFrame::OuterReflowChild(nsIPresContext* aPresContext, nsMargin& aMarginNoAuto, nsMargin& aPadding, nsReflowReason aReflowReason, - nsReflowStatus& aStatus) + nsReflowStatus& aStatus, + PRBool* aNeedToReflowCaption) { if (!aPresContext) ABORT1(NS_ERROR_NULL_POINTER); aMargin = aPadding = nsMargin(0,0,0,0); @@ -1318,6 +1319,16 @@ nsTableOuterFrame::OuterReflowChild(nsIPresContext* aPresContext, aAvailWidth = aOuterRS.availableWidth; } } + // see if we need to reflow the caption in addition + if (aNeedToReflowCaption && !*aNeedToReflowCaption && + mInnerTableFrame == aChildFrame) { + nsHTMLReflowCommand* command = childRS.path->mReflowCommand; + if (command) { + nsReflowType type; + command->GetType(type); + *aNeedToReflowCaption = eReflowType_StyleChanged == type; + } + } // use the current position as a best guess for placement nsPoint childPt = aChildFrame->GetPosition(); @@ -1676,9 +1687,14 @@ nsTableOuterFrame::IR_InnerTableReflow(nsIPresContext* aPresContext, &capMin, innerMargin, innerPadding); nsresult rv = OuterReflowChild(aPresContext, mInnerTableFrame, aOuterRS, innerMet, availWidth, innerSize, innerMargin, innerMarginNoAuto, innerPadding, - reflowReason, aStatus); + reflowReason, aStatus, &reflowCaption); if (NS_FAILED(rv)) return rv; - + + if (eReflowReason_StyleChange != reflowReason && reflowCaption) { + // inner table frame was target for a style change reflow issue a style + // change reflow for the caption too. + reflowReason = eReflowReason_StyleChange; + } nsPoint innerOrigin(0,0); nsMargin captionMargin(0,0,0,0); nsMargin captionMarginNoAuto(0,0,0,0); diff --git a/layout/tables/nsTableOuterFrame.h b/layout/tables/nsTableOuterFrame.h index 7bad67c2129d..f043904537da 100644 --- a/layout/tables/nsTableOuterFrame.h +++ b/layout/tables/nsTableOuterFrame.h @@ -377,7 +377,8 @@ protected: nsMargin& aMarginNoAuto, nsMargin& aPadding, nsReflowReason aReflowReason, - nsReflowStatus& aStatus); + nsReflowStatus& aStatus, + PRBool* aNeedToReflowCaption = nsnull); // Set the reflow metrics, aInnerMarginNoAuto is aInnerMargin, but with // auto margins set to 0 @@ -394,7 +395,7 @@ protected: void InvalidateDamage(nsIPresContext* aPresContext, PRUint8 aCaptionSide, - nsSize& aOuterSize, + const nsSize& aOuterSize, PRBool aInnerChanged, PRBool aCaptionChanged, nsRect* aOldOverflowArea);