From eeaae96b5efe0343013443e6f39dfd4fee4c88eb Mon Sep 17 00:00:00 2001 From: "troy@netscape.com" Date: Wed, 15 Mar 2000 15:16:03 +0000 Subject: [PATCH] b=24343 r=karnaze@netscape.com Changes so we properly lay out after changing the font using the pref UI. Block and table code changed to handle eReflowReason_StyleChange --- layout/base/nsPresShell.cpp | 3 +-- layout/generic/nsBlockFrame.cpp | 4 ++++ layout/generic/nsBlockReflowState.cpp | 4 ++++ layout/generic/nsBlockReflowState.h | 4 ++++ layout/generic/nsViewportFrame.cpp | 6 ++++-- layout/html/base/src/nsBlockFrame.cpp | 4 ++++ layout/html/base/src/nsBlockReflowState.cpp | 4 ++++ layout/html/base/src/nsBlockReflowState.h | 4 ++++ layout/html/base/src/nsPresShell.cpp | 3 +-- layout/html/base/src/nsViewportFrame.cpp | 6 ++++-- layout/html/table/src/nsTableFrame.cpp | 9 ++++++++- layout/tables/nsTableFrame.cpp | 9 ++++++++- 12 files changed, 50 insertions(+), 10 deletions(-) diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index f6bca0f4ac84..b8c27cdc2fd8 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -1649,9 +1649,8 @@ PresShell::StyleChangeReflow() nsresult rv=CreateRenderingContext(rootFrame, &rcx); if (NS_FAILED(rv)) return rv; - // XXX We should be using eReflowReason_StyleChange nsHTMLReflowState reflowState(mPresContext, rootFrame, - eReflowReason_Resize, rcx, maxSize); + eReflowReason_StyleChange, rcx, maxSize); nsIView* view; rootFrame->WillReflow(mPresContext); diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp index 446665af00a3..88d661ca9931 100644 --- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -1553,6 +1553,10 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext, } break; + case eReflowReason_StyleChange: + rv = PrepareStyleChangedReflow(state); + break; + case eReflowReason_Resize: default: #ifdef NOISY_REFLOW_REASON diff --git a/layout/generic/nsBlockReflowState.cpp b/layout/generic/nsBlockReflowState.cpp index 446665af00a3..88d661ca9931 100644 --- a/layout/generic/nsBlockReflowState.cpp +++ b/layout/generic/nsBlockReflowState.cpp @@ -1553,6 +1553,10 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext, } break; + case eReflowReason_StyleChange: + rv = PrepareStyleChangedReflow(state); + break; + case eReflowReason_Resize: default: #ifdef NOISY_REFLOW_REASON diff --git a/layout/generic/nsBlockReflowState.h b/layout/generic/nsBlockReflowState.h index 446665af00a3..88d661ca9931 100644 --- a/layout/generic/nsBlockReflowState.h +++ b/layout/generic/nsBlockReflowState.h @@ -1553,6 +1553,10 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext, } break; + case eReflowReason_StyleChange: + rv = PrepareStyleChangedReflow(state); + break; + case eReflowReason_Resize: default: #ifdef NOISY_REFLOW_REASON diff --git a/layout/generic/nsViewportFrame.cpp b/layout/generic/nsViewportFrame.cpp index 6380be9faa20..2fcd44041072 100644 --- a/layout/generic/nsViewportFrame.cpp +++ b/layout/generic/nsViewportFrame.cpp @@ -561,9 +561,11 @@ ViewportFrame::Reflow(nsIPresContext* aPresContext, aDesiredSize.descent = 0; } - // If this is a resize reflow or the initial reflow, then do a repaint + // If this is an initial reflow, resize reflow, or style change reflow + // then do a repaint if ((eReflowReason_Initial == aReflowState.reason) || - (eReflowReason_Resize == aReflowState.reason)) { + (eReflowReason_Resize == aReflowState.reason) || + (eReflowReason_StyleChange == aReflowState.reason)) { nsRect damageRect(0, 0, aDesiredSize.width, aDesiredSize.height); Invalidate(aPresContext, damageRect, PR_FALSE); } diff --git a/layout/html/base/src/nsBlockFrame.cpp b/layout/html/base/src/nsBlockFrame.cpp index 446665af00a3..88d661ca9931 100644 --- a/layout/html/base/src/nsBlockFrame.cpp +++ b/layout/html/base/src/nsBlockFrame.cpp @@ -1553,6 +1553,10 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext, } break; + case eReflowReason_StyleChange: + rv = PrepareStyleChangedReflow(state); + break; + case eReflowReason_Resize: default: #ifdef NOISY_REFLOW_REASON diff --git a/layout/html/base/src/nsBlockReflowState.cpp b/layout/html/base/src/nsBlockReflowState.cpp index 446665af00a3..88d661ca9931 100644 --- a/layout/html/base/src/nsBlockReflowState.cpp +++ b/layout/html/base/src/nsBlockReflowState.cpp @@ -1553,6 +1553,10 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext, } break; + case eReflowReason_StyleChange: + rv = PrepareStyleChangedReflow(state); + break; + case eReflowReason_Resize: default: #ifdef NOISY_REFLOW_REASON diff --git a/layout/html/base/src/nsBlockReflowState.h b/layout/html/base/src/nsBlockReflowState.h index 446665af00a3..88d661ca9931 100644 --- a/layout/html/base/src/nsBlockReflowState.h +++ b/layout/html/base/src/nsBlockReflowState.h @@ -1553,6 +1553,10 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext, } break; + case eReflowReason_StyleChange: + rv = PrepareStyleChangedReflow(state); + break; + case eReflowReason_Resize: default: #ifdef NOISY_REFLOW_REASON diff --git a/layout/html/base/src/nsPresShell.cpp b/layout/html/base/src/nsPresShell.cpp index f6bca0f4ac84..b8c27cdc2fd8 100644 --- a/layout/html/base/src/nsPresShell.cpp +++ b/layout/html/base/src/nsPresShell.cpp @@ -1649,9 +1649,8 @@ PresShell::StyleChangeReflow() nsresult rv=CreateRenderingContext(rootFrame, &rcx); if (NS_FAILED(rv)) return rv; - // XXX We should be using eReflowReason_StyleChange nsHTMLReflowState reflowState(mPresContext, rootFrame, - eReflowReason_Resize, rcx, maxSize); + eReflowReason_StyleChange, rcx, maxSize); nsIView* view; rootFrame->WillReflow(mPresContext); diff --git a/layout/html/base/src/nsViewportFrame.cpp b/layout/html/base/src/nsViewportFrame.cpp index 6380be9faa20..2fcd44041072 100644 --- a/layout/html/base/src/nsViewportFrame.cpp +++ b/layout/html/base/src/nsViewportFrame.cpp @@ -561,9 +561,11 @@ ViewportFrame::Reflow(nsIPresContext* aPresContext, aDesiredSize.descent = 0; } - // If this is a resize reflow or the initial reflow, then do a repaint + // If this is an initial reflow, resize reflow, or style change reflow + // then do a repaint if ((eReflowReason_Initial == aReflowState.reason) || - (eReflowReason_Resize == aReflowState.reason)) { + (eReflowReason_Resize == aReflowState.reason) || + (eReflowReason_StyleChange == aReflowState.reason)) { nsRect damageRect(0, 0, aDesiredSize.width, aDesiredSize.height); Invalidate(aPresContext, damageRect, PR_FALSE); } diff --git a/layout/html/table/src/nsTableFrame.cpp b/layout/html/table/src/nsTableFrame.cpp index c61c1f4ca619..78e3f6c9aa2f 100644 --- a/layout/html/table/src/nsTableFrame.cpp +++ b/layout/html/table/src/nsTableFrame.cpp @@ -1531,14 +1531,21 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext, rv = IncrementalReflow(aPresContext, aDesiredSize, aReflowState, aStatus); } + // If this is a style change reflow, then invalidate the pass 1 cache + if (eReflowReason_StyleChange == aReflowState.reason) { + InvalidateFirstPassCache(); + } + // NeedsReflow and IsFirstPassValid take into account reflow type = Initial_Reflow if (NeedsReflow(aReflowState)) { PRBool needsRecalc = PR_FALSE; if ((NS_UNCONSTRAINEDSIZE == aReflowState.availableWidth) || (PR_FALSE==IsFirstPassValid())) { nsReflowReason reason = aReflowState.reason; - if (eReflowReason_Initial != reason) + if ((eReflowReason_Initial != reason) && + (eReflowReason_StyleChange != reason)) { reason = eReflowReason_Resize; + } if (mBorderCollapser) { mBorderCollapser->ComputeVerticalBorders(aPresContext, 0, -1); } diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index c61c1f4ca619..78e3f6c9aa2f 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -1531,14 +1531,21 @@ NS_METHOD nsTableFrame::Reflow(nsIPresContext* aPresContext, rv = IncrementalReflow(aPresContext, aDesiredSize, aReflowState, aStatus); } + // If this is a style change reflow, then invalidate the pass 1 cache + if (eReflowReason_StyleChange == aReflowState.reason) { + InvalidateFirstPassCache(); + } + // NeedsReflow and IsFirstPassValid take into account reflow type = Initial_Reflow if (NeedsReflow(aReflowState)) { PRBool needsRecalc = PR_FALSE; if ((NS_UNCONSTRAINEDSIZE == aReflowState.availableWidth) || (PR_FALSE==IsFirstPassValid())) { nsReflowReason reason = aReflowState.reason; - if (eReflowReason_Initial != reason) + if ((eReflowReason_Initial != reason) && + (eReflowReason_StyleChange != reason)) { reason = eReflowReason_Resize; + } if (mBorderCollapser) { mBorderCollapser->ComputeVerticalBorders(aPresContext, 0, -1); }