From 4d84af3591820e8c16d2abc00c8943689d8b4acf Mon Sep 17 00:00:00 2001 From: "L. David Baron" Date: Wed, 23 Nov 2011 18:48:23 -0800 Subject: [PATCH] When font size inflation is enabled, horizontal resizes of blocks must cause a full dirty reflow. (Bug 627842, patch 5) r=bzbarsky This change is sufficient because the places that set mHResize to true other than InitResizeFlags and nsFrame::BoxReflow aren't a problem because they're in table code whose goal is to force the reflow to propagate down to the cell, and once we reach the cell we'll hit the code we've added here. --- layout/generic/nsFrame.cpp | 10 +++++++++- layout/generic/nsHTMLReflowState.cpp | 25 +++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index b125e98a3371..8651b1dffa64 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -7568,8 +7568,16 @@ nsFrame::BoxReflow(nsBoxLayoutState& aState, // mLastSize before calling Reflow and then switching it back, but // However, mLastSize can also be the size passed to BoxReflow by // RefreshSizeCache, so that doesn't really make sense. - if (metrics->mLastSize.width != aWidth) + if (metrics->mLastSize.width != aWidth) { reflowState.mFlags.mHResize = true; + + // When font size inflation is enabled, a horizontal resize + // requires a full reflow. See nsHTMLReflowState::InitResizeFlags + // for more details. + if (nsLayoutUtils::FontSizeInflationEnabled(aPresContext)) { + AddStateBits(NS_FRAME_IS_DIRTY); + } + } if (metrics->mLastSize.height != aHeight) reflowState.mFlags.mVResize = true; diff --git a/layout/generic/nsHTMLReflowState.cpp b/layout/generic/nsHTMLReflowState.cpp index a1d5b79a7c49..63bc722097cc 100644 --- a/layout/generic/nsHTMLReflowState.cpp +++ b/layout/generic/nsHTMLReflowState.cpp @@ -365,6 +365,31 @@ nsHTMLReflowState::InitResizeFlags(nsPresContext* aPresContext, nsIAtom* aFrameT mFlags.mHResize = !(frame->GetStateBits() & NS_FRAME_IS_DIRTY) && frame->GetSize().width != mComputedWidth + mComputedBorderPadding.LeftRight(); + if (mFlags.mHResize && + nsLayoutUtils::FontSizeInflationEnabled(aPresContext)) { + // When font size inflation is enabled, the change in the width of a + // block (or anything that returns true in + // IsContainerForFontSizeInflation) needs to cause a dirty reflow + // since it changes the size of text, line-heights, etc. This is + // relatively similar to a classic case of style change reflow, + // except that because inflation doesn't affect the intrinsic sizing + // codepath, there's no need to invalidate intrinsic sizes. + // + // Note that this makes horizontal resizing a good bit more + // expensive. However, font size inflation is targeted at a set of + // devices (zoom-and-pan devices) where the main use case for + // horizontal resizing needing to be efficient (window resizing) is + // not present. It does still increase the cost of dynamic changes + // caused by script where a style or content change in one place + // causes a resize in another (e.g., rebalancing a table). + + // FIXME: This isn't so great for the cases where + // nsHTMLReflowState::SetComputedWith is called, if the first time + // we go through InitResizeFlags we set mHResize to true, and then + // the second time we'd set it to false even without the + // NS_FRAME_IS_DIRTY bit already set. + frame->AddStateBits(NS_FRAME_IS_DIRTY); + } // XXX Should we really need to null check mCBReflowState? (We do for // at least nsBoxFrame).