diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index db594605273..5a89f12c8dd 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -4765,14 +4765,6 @@ nsLayoutUtils::FontSizeInflationInner(const nsIFrame *aFrame, return (1.0f / ratio) + (1.0f / 3.0f); } -static inline bool -InflationDataSaysEnabled(const nsIFrame *aFrame) -{ - nsFontInflationData *data = - nsFontInflationData::FindFontInflationDataFor(aFrame); - return data && data->InflationEnabled(); -} - static bool ShouldInflateFontsForContainer(const nsIFrame *aFrame) { @@ -4789,55 +4781,35 @@ ShouldInflateFontsForContainer(const nsIFrame *aFrame) !(aFrame->GetStateBits() & NS_FRAME_IN_CONSTRAINED_HEIGHT) && // We also want to disable font inflation for containers that have // preformatted text. - styleText->WhiteSpaceCanWrap() && - InflationDataSaysEnabled(aFrame); + styleText->WhiteSpaceCanWrap(); } nscoord nsLayoutUtils::InflationMinFontSizeFor(const nsIFrame *aFrame, WidthDetermination aWidthDetermination) { -#ifdef DEBUG - if (aWidthDetermination == eNotInReflow) { - // Check that neither this frame nor any of its ancestors are - // currently being reflowed. - // It's ok for box frames (but not arbitrary ancestors of box frames) - // since they set their size before reflow. - if (!(aFrame->IsBoxFrame() && IsContainerForFontSizeInflation(aFrame))) { - for (const nsIFrame *f = aFrame; f; f = f->GetParent()) { - NS_ABORT_IF_FALSE(!(f->GetStateBits() & NS_FRAME_IN_REFLOW), - "must call nsHTMLReflowState& version during reflow"); - } - } - // It's ok if frames are dirty, or even if they've never been - // reflowed, since they will be eventually and then we'll get the - // right size. - } -#endif - nsPresContext *presContext = aFrame->PresContext(); if (!FontSizeInflationEnabled(presContext) || presContext->mInflationDisabledForShrinkWrap) { return 0; } - if (aWidthDetermination == eInReflow) { - nsIFrame *container = presContext->mCurrentInflationContainer; - if (!container || !ShouldInflateFontsForContainer(container)) { - return 0; - } - return MinimumFontSizeFor(presContext, - presContext->mCurrentInflationContainerWidth); - } - for (const nsIFrame *f = aFrame; f; f = f->GetParent()) { if (IsContainerForFontSizeInflation(f)) { if (!ShouldInflateFontsForContainer(f)) { return 0; } + nsFontInflationData *data = + nsFontInflationData::FindFontInflationDataFor(aFrame); + // FIXME: The need to null-check here is sort of a bug, and might + // lead to incorrect results. + if (!data || !data->InflationEnabled()) { + return 0; + } + return MinimumFontSizeFor(aFrame->PresContext(), - f->GetContentRect().width); + data->EffectiveWidth()); } } @@ -4850,24 +4822,6 @@ float nsLayoutUtils::FontSizeInflationFor(const nsIFrame *aFrame, WidthDetermination aWidthDetermination) { -#ifdef DEBUG - if (aWidthDetermination == eNotInReflow) { - // Check that neither this frame nor any of its ancestors are - // currently being reflowed. - // It's ok for box frames (but not arbitrary ancestors of box frames) - // since they set their size before reflow. - if (!(aFrame->IsBoxFrame() && IsContainerForFontSizeInflation(aFrame))) { - for (const nsIFrame *f = aFrame; f; f = f->GetParent()) { - NS_ABORT_IF_FALSE(!(f->GetStateBits() & NS_FRAME_IN_REFLOW), - "must call nsHTMLReflowState& version during reflow"); - } - } - // It's ok if frames are dirty, or even if they've never been - // reflowed, since they will be eventually and then we'll get the - // right size. - } -#endif - if (!FontSizeInflationEnabled(aFrame->PresContext())) { return 1.0; } diff --git a/layout/reftests/font-inflation/reftest.list b/layout/reftests/font-inflation/reftest.list index 4976dc7530d..12ba5350007 100644 --- a/layout/reftests/font-inflation/reftest.list +++ b/layout/reftests/font-inflation/reftest.list @@ -92,3 +92,5 @@ fuzzy-if(gtk2Widget,1,8) test-pref(font.size.inflation.emPerLine,15) test-pref(f fuzzy-if(gtk2Widget,1,8) test-pref(font.size.inflation.emPerLine,15) test-pref(font.size.inflation.lineThreshold,100) == threshold-select-combobox-contents-under-2.html threshold-select-combobox-contents-under-2.html fuzzy-if(gtk2Widget,1,8) test-pref(font.size.inflation.emPerLine,15) test-pref(font.size.inflation.lineThreshold,100) == threshold-select-combobox-contents-at-1.html threshold-select-combobox-contents-at-1-ref.html fuzzy-if(gtk2Widget,1,8) test-pref(font.size.inflation.emPerLine,15) test-pref(font.size.inflation.lineThreshold,100) == threshold-select-combobox-contents-at-2.html threshold-select-combobox-contents-at-2-ref.html + +test-pref(font.size.inflation.emPerLine,15) test-pref(font.size.inflation.lineThreshold,0) == relevant-width-1.html relevant-width-1-ref.html diff --git a/layout/reftests/font-inflation/relevant-width-1-ref.html b/layout/reftests/font-inflation/relevant-width-1-ref.html new file mode 100644 index 00000000000..90b67e1b6ad --- /dev/null +++ b/layout/reftests/font-inflation/relevant-width-1-ref.html @@ -0,0 +1,9 @@ + + +
+ Text in middle. +
Text in inner.
+
diff --git a/layout/reftests/font-inflation/relevant-width-1.html b/layout/reftests/font-inflation/relevant-width-1.html new file mode 100644 index 00000000000..814917786d8 --- /dev/null +++ b/layout/reftests/font-inflation/relevant-width-1.html @@ -0,0 +1,16 @@ + + + +
+
+ Text in middle. +
Text in inner.
+
+