diff --git a/layout/generic/nsTextFrame.h b/layout/generic/nsTextFrame.h index df6030c998af..0cf3da50ed5d 100644 --- a/layout/generic/nsTextFrame.h +++ b/layout/generic/nsTextFrame.h @@ -182,6 +182,7 @@ public: #endif float GetFontSizeInflation() const; + bool IsCurrentFontInflation(float aInflation) const; bool HasFontSizeInflation() const { return (GetStateBits() & TEXT_HAS_FONT_INFLATION) != 0; } diff --git a/layout/generic/nsTextFrameThebes.cpp b/layout/generic/nsTextFrameThebes.cpp index e524fcd08257..67704bd85f0c 100644 --- a/layout/generic/nsTextFrameThebes.cpp +++ b/layout/generic/nsTextFrameThebes.cpp @@ -6710,6 +6710,10 @@ nsTextFrame::AddInlineMinWidthForFlow(nsRenderingContext *aRenderingContext, } } +bool nsTextFrame::IsCurrentFontInflation(float aInflation) const { + return fabsf(aInflation - GetFontSizeInflation()) < 1e-6; +} + // XXX Need to do something here to avoid incremental reflow bugs due to // first-line and first-letter changing min-width /* virtual */ void @@ -6719,7 +6723,7 @@ nsTextFrame::AddInlineMinWidth(nsRenderingContext *aRenderingContext, float inflation = nsLayoutUtils::FontSizeInflationFor(this); TextRunType trtype = (inflation == 1.0f) ? eNotInflated : eInflated; - if (trtype == eInflated && inflation != GetFontSizeInflation()) { + if (trtype == eInflated && !IsCurrentFontInflation(inflation)) { // FIXME: Ideally, if we already have a text run, we'd move it to be // the uninflated text run. ClearTextRun(nsnull, nsTextFrame::eInflated); @@ -6855,7 +6859,7 @@ nsTextFrame::AddInlinePrefWidth(nsRenderingContext *aRenderingContext, float inflation = nsLayoutUtils::FontSizeInflationFor(this); TextRunType trtype = (inflation == 1.0f) ? eNotInflated : eInflated; - if (trtype == eInflated && inflation != GetFontSizeInflation()) { + if (trtype == eInflated && !IsCurrentFontInflation(inflation)) { // FIXME: Ideally, if we already have a text run, we'd move it to be // the uninflated text run. ClearTextRun(nsnull, nsTextFrame::eInflated); @@ -7395,7 +7399,7 @@ nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth, float fontSizeInflation = nsLayoutUtils::FontSizeInflationFor(this); - if (fontSizeInflation != GetFontSizeInflation()) { + if (!IsCurrentFontInflation(fontSizeInflation)) { // FIXME: Ideally, if we already have a text run, we'd move it to be // the uninflated text run. ClearTextRun(nsnull, nsTextFrame::eInflated); @@ -7405,7 +7409,7 @@ nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth, EnsureTextRun(nsTextFrame::eInflated, ctx, lineContainer, aLineLayout.GetLine(), &flowEndInTextRun); - NS_ABORT_IF_FALSE(GetFontSizeInflation() == fontSizeInflation, + NS_ABORT_IF_FALSE(IsCurrentFontInflation(fontSizeInflation), "EnsureTextRun should have set font size inflation"); if (mTextRun && iter.GetOriginalEnd() < offset + length) {