diff --git a/layout/generic/nsFontInflationData.cpp b/layout/generic/nsFontInflationData.cpp index 58ee4c14660a..2b63fdd37583 100644 --- a/layout/generic/nsFontInflationData.cpp +++ b/layout/generic/nsFontInflationData.cpp @@ -38,7 +38,7 @@ nsFontInflationData::FindFontInflationDataFor(const nsIFrame *aFrame) bfc->Properties().Get(FontInflationDataProperty())); } -/* static */ void +/* static */ bool nsFontInflationData::UpdateFontInflationDataWidthFor(const nsHTMLReflowState& aReflowState) { nsIFrame *bfc = aReflowState.frame; @@ -47,12 +47,22 @@ nsFontInflationData::UpdateFontInflationDataWidthFor(const nsHTMLReflowState& aR FrameProperties bfcProps(bfc->Properties()); nsFontInflationData *data = static_cast( bfcProps.Get(FontInflationDataProperty())); - if (!data) { + bool oldInflationEnabled; + nscoord oldNCAWidth; + if (data) { + oldNCAWidth = data->mNCAWidth; + oldInflationEnabled = data->mInflationEnabled; + } else { data = new nsFontInflationData(bfc); bfcProps.Set(FontInflationDataProperty(), data); + oldNCAWidth = -1; + oldInflationEnabled = true; /* not relevant */ } data->UpdateWidth(aReflowState); + + return oldNCAWidth != data->mNCAWidth || + oldInflationEnabled != data->mInflationEnabled; } /* static */ void diff --git a/layout/generic/nsFontInflationData.h b/layout/generic/nsFontInflationData.h index 7e89a369ccb1..b7378d93da92 100644 --- a/layout/generic/nsFontInflationData.h +++ b/layout/generic/nsFontInflationData.h @@ -20,7 +20,9 @@ public: static nsFontInflationData* FindFontInflationDataFor(const nsIFrame *aFrame); - static void + // Returns whether the effective width changed (which requires the + // caller to mark its descendants dirty + static bool UpdateFontInflationDataWidthFor(const nsHTMLReflowState& aReflowState); static void MarkFontInflationDataTextDirty(nsIFrame *aFrame); diff --git a/layout/generic/nsHTMLReflowState.cpp b/layout/generic/nsHTMLReflowState.cpp index d4909c2db9f7..18359a669283 100644 --- a/layout/generic/nsHTMLReflowState.cpp +++ b/layout/generic/nsHTMLReflowState.cpp @@ -305,12 +305,6 @@ nsHTMLReflowState::Init(nsPresContext* aPresContext, "have unconstrained width; this should only result from " "very large sizes, not attempts at intrinsic width " "calculation"); - - if (frame->GetStateBits() & NS_FRAME_FONT_INFLATION_FLOW_ROOT) { - // Create our font inflation data if we don't have it already, and - // give it our current width information. - nsFontInflationData::UpdateFontInflationDataWidthFor(*this); - } } void nsHTMLReflowState::InitCBReflowState() @@ -364,6 +358,20 @@ IsQuirkContainingBlockHeight(const nsHTMLReflowState* rs, nsIAtom* aFrameType) void nsHTMLReflowState::InitResizeFlags(nsPresContext* aPresContext, nsIAtom* aFrameType) { + if (frame->GetStateBits() & NS_FRAME_FONT_INFLATION_FLOW_ROOT) { + // Create our font inflation data if we don't have it already, and + // give it our current width information. + bool dirty = nsFontInflationData::UpdateFontInflationDataWidthFor(*this); + if (dirty) { + // 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); + } + } + mFlags.mHResize = !(frame->GetStateBits() & NS_FRAME_IS_DIRTY) && frame->GetSize().width != mComputedWidth + mComputedBorderPadding.LeftRight();