Bug 705446: Disable font inflation for preformatted text. [r=dbaron]
authorScott Johnson <sjohnson@mozilla.com>
Fri, 02 Mar 2012 11:25:33 -0600
changeset 91035 e4006a8627b6b3981663689577629d8c748bb75a
parent 91034 a3b1c010b101260cb007702d656f3b45b26828e1
child 91036 68b1f715d7c9d2a71b823f1b5f563a81882cdf72
push id783
push userlsblakk@mozilla.com
push dateTue, 24 Apr 2012 17:33:42 +0000
treeherdermozilla-beta@11faed19f136 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs705446
milestone13.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 705446: Disable font inflation for preformatted text. [r=dbaron]
layout/base/nsLayoutUtils.cpp
layout/base/tests/font-inflation/preformatted-text-ref.html
layout/base/tests/font-inflation/preformatted-text.html
layout/base/tests/test_font_inflation_reftests.html
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -4729,19 +4729,23 @@ ShouldInflateFontsForContainer(const nsI
 {
   // We only want to inflate fonts for text that is in a place
   // with room to expand.  The question is what the best heuristic for
   // that is...
   // For now, we're going to use NS_FRAME_IN_CONSTRAINED_HEIGHT, which
   // 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
 nsLayoutUtils::InflationMinFontSizeFor(const nsIFrame *aFrame,
                                        WidthDetermination aWidthDetermination)
 {
 #ifdef DEBUG
   if (aWidthDetermination == eNotInReflow) {
new file mode 100644
--- /dev/null
+++ b/layout/base/tests/font-inflation/preformatted-text-ref.html
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html>
+
+<!--
+This text is in a preformatted block, and should therefore not be inflated with the fix for bug 705446.
+-->
+<html>
+  <head>
+    <style>
+      pre { font-size: 12px; line-height: 1.0;}
+    </style>
+    <body>
+      <div>
+        <pre>
+             <div class="line" id="line1"><span style="color: red">Firefox</span> is quite neat</div>
+             <div class="line" id="line2">It browses the web fluidly</div>
+             <div class="line" id="line3">With no cares at all</div>
+        </pre>
+      </div>
+    </body>
+  </head>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/base/tests/font-inflation/preformatted-text.html
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html>
+
+<!--
+This text is in a preformatted block, and should therefore not be inflated with the fix for bug 705446.
+-->
+<html>
+  <head>
+    <style>
+      pre { font-size: 12px; line-height: 1.0;}
+    </style>
+    <body>
+      <div>
+        <pre>
+             <div class="line" id="line1"><span style="color: red">Firefox</span> is quite neat</div>
+             <div class="line" id="line2">It browses the web fluidly</div>
+             <div class="line" id="line3">With no cares at all</div>
+        </pre>
+      </div>
+    </body>
+  </head>
+</html>
--- a/layout/base/tests/test_font_inflation_reftests.html
+++ b/layout/base/tests/test_font_inflation_reftests.html
@@ -60,16 +60,17 @@ var gTests = [
   "== select-combobox-2.html select-combobox-2-ref.html",
   "!= select-combobox-2.html select-combobox-2.html",
   "!= input-checkbox.html input-checkbox.html",
   "!= input-radio.html input-radio.html",
   "== disable-fontinfl-on-mobile.html disable-fontinfl-on-mobile-ref.html",
   "== 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
 // we can say the tests are done.
 var gDelayCount = 0;
 function AddFinishDependency()
   { ++gDelayCount; }
 function RemoveFinishDependency()