From 00091b65e387b11418b2f9fe9e766419a155ece2 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 git-svn-id: svn://10.0.0.236/trunk@63049 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/base/nsPresShell.cpp | 3 +-- mozilla/layout/generic/nsBlockFrame.cpp | 4 ++++ mozilla/layout/generic/nsBlockReflowState.cpp | 4 ++++ mozilla/layout/generic/nsBlockReflowState.h | 4 ++++ mozilla/layout/generic/nsViewportFrame.cpp | 6 ++++-- mozilla/layout/html/base/src/nsBlockFrame.cpp | 4 ++++ mozilla/layout/html/base/src/nsBlockReflowState.cpp | 4 ++++ mozilla/layout/html/base/src/nsBlockReflowState.h | 4 ++++ mozilla/layout/html/base/src/nsPresShell.cpp | 3 +-- mozilla/layout/html/base/src/nsViewportFrame.cpp | 6 ++++-- mozilla/layout/html/table/src/nsTableFrame.cpp | 9 ++++++++- mozilla/layout/tables/nsTableFrame.cpp | 9 ++++++++- 12 files changed, 50 insertions(+), 10 deletions(-) diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index f6bca0f4ac8..b8c27cdc2fd 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/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/mozilla/layout/generic/nsBlockFrame.cpp b/mozilla/layout/generic/nsBlockFrame.cpp index 446665af00a..88d661ca993 100644 --- a/mozilla/layout/generic/nsBlockFrame.cpp +++ b/mozilla/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/mozilla/layout/generic/nsBlockReflowState.cpp b/mozilla/layout/generic/nsBlockReflowState.cpp index 446665af00a..88d661ca993 100644 --- a/mozilla/layout/generic/nsBlockReflowState.cpp +++ b/mozilla/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/mozilla/layout/generic/nsBlockReflowState.h b/mozilla/layout/generic/nsBlockReflowState.h index 446665af00a..88d661ca993 100644 --- a/mozilla/layout/generic/nsBlockReflowState.h +++ b/mozilla/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/mozilla/layout/generic/nsViewportFrame.cpp b/mozilla/layout/generic/nsViewportFrame.cpp index 6380be9faa2..2fcd4404107 100644 --- a/mozilla/layout/generic/nsViewportFrame.cpp +++ b/mozilla/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/mozilla/layout/html/base/src/nsBlockFrame.cpp b/mozilla/layout/html/base/src/nsBlockFrame.cpp index 446665af00a..88d661ca993 100644 --- a/mozilla/layout/html/base/src/nsBlockFrame.cpp +++ b/mozilla/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/mozilla/layout/html/base/src/nsBlockReflowState.cpp b/mozilla/layout/html/base/src/nsBlockReflowState.cpp index 446665af00a..88d661ca993 100644 --- a/mozilla/layout/html/base/src/nsBlockReflowState.cpp +++ b/mozilla/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/mozilla/layout/html/base/src/nsBlockReflowState.h b/mozilla/layout/html/base/src/nsBlockReflowState.h index 446665af00a..88d661ca993 100644 --- a/mozilla/layout/html/base/src/nsBlockReflowState.h +++ b/mozilla/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/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp index f6bca0f4ac8..b8c27cdc2fd 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/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/mozilla/layout/html/base/src/nsViewportFrame.cpp b/mozilla/layout/html/base/src/nsViewportFrame.cpp index 6380be9faa2..2fcd4404107 100644 --- a/mozilla/layout/html/base/src/nsViewportFrame.cpp +++ b/mozilla/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/mozilla/layout/html/table/src/nsTableFrame.cpp b/mozilla/layout/html/table/src/nsTableFrame.cpp index c61c1f4ca61..78e3f6c9aa2 100644 --- a/mozilla/layout/html/table/src/nsTableFrame.cpp +++ b/mozilla/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/mozilla/layout/tables/nsTableFrame.cpp b/mozilla/layout/tables/nsTableFrame.cpp index c61c1f4ca61..78e3f6c9aa2 100644 --- a/mozilla/layout/tables/nsTableFrame.cpp +++ b/mozilla/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); }