From 5be9b0763abb003b5c3e57b0eac6cde554670292 Mon Sep 17 00:00:00 2001 From: Scott Johnson Date: Fri, 2 Mar 2012 11:25:33 -0600 Subject: [PATCH] Bug 705446: Disable font inflation for preformatted text. [r=dbaron] --- layout/base/nsLayoutUtils.cpp | 10 ++++++--- .../font-inflation/preformatted-text-ref.html | 22 +++++++++++++++++++ .../font-inflation/preformatted-text.html | 22 +++++++++++++++++++ .../tests/test_font_inflation_reftests.html | 1 + 4 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 layout/base/tests/font-inflation/preformatted-text-ref.html create mode 100644 layout/base/tests/font-inflation/preformatted-text.html diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 5b50bba3eca..068b8c20aac 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -4734,9 +4734,13 @@ ShouldInflateFontsForContainer(const nsIFrame *aFrame) // indicates whether the frame is inside something with a constrained // height (propagating down the tree), but the propagation stops when // we hit overflow-y: scroll or auto. - return aFrame->GetStyleText()->mTextSizeAdjust != - NS_STYLE_TEXT_SIZE_ADJUST_NONE && - !(aFrame->GetStateBits() & NS_FRAME_IN_CONSTRAINED_HEIGHT); + const nsStyleText* styleText = aFrame->GetStyleText(); + + return styleText->mTextSizeAdjust != NS_STYLE_TEXT_SIZE_ADJUST_NONE && + !(aFrame->GetStateBits() & NS_FRAME_IN_CONSTRAINED_HEIGHT) && + // We also want to disable font inflation for containers that have + // preformatted text. + styleText->WhiteSpaceCanWrap(); } nscoord diff --git a/layout/base/tests/font-inflation/preformatted-text-ref.html b/layout/base/tests/font-inflation/preformatted-text-ref.html new file mode 100644 index 00000000000..0a847a80664 --- /dev/null +++ b/layout/base/tests/font-inflation/preformatted-text-ref.html @@ -0,0 +1,22 @@ + + + + + + + + +
+
+             
Firefox is quite neat
+
It browses the web fluidly
+
With no cares at all
+
+
+ + + diff --git a/layout/base/tests/font-inflation/preformatted-text.html b/layout/base/tests/font-inflation/preformatted-text.html new file mode 100644 index 00000000000..0a847a80664 --- /dev/null +++ b/layout/base/tests/font-inflation/preformatted-text.html @@ -0,0 +1,22 @@ + + + + + + + + +
+
+             
Firefox is quite neat
+
It browses the web fluidly
+
With no cares at all
+
+
+ + + diff --git a/layout/base/tests/test_font_inflation_reftests.html b/layout/base/tests/test_font_inflation_reftests.html index 1031c320847..e1e3e029018 100644 --- a/layout/base/tests/test_font_inflation_reftests.html +++ b/layout/base/tests/test_font_inflation_reftests.html @@ -65,6 +65,7 @@ var gTests = [ "== disable-fontinfl-on-mobile-2.html disable-fontinfl-on-mobile-ref.html", "== disable-fontinfl-on-mobile-3.html disable-fontinfl-on-mobile-ref.html", "== disable-fontinfl-on-mobile-4.html disable-fontinfl-on-mobile-ref.html", + "== preformatted-text.html preformatted-text-ref.html", ]; // Maintain a reference count of how many things we're waiting for until