Use the font inflation data to disable font inflation for small pieces of text. (Bug 706193, patch 4) r=roc
authorL. David Baron <dbaron@dbaron.org>
Mon, 16 Apr 2012 15:32:12 -0700
changeset 95106 0c18caf33991da536864054f0dbaa7037332eab3
parent 95105 9cf58850cf26befc69b189d831ae6d8e5bff8a7d
child 95107 e44a95efa5f098cfd5f41d68371a407427f7c7ef
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs706193
milestone14.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
Use the font inflation data to disable font inflation for small pieces of text. (Bug 706193, patch 4) r=roc This merely hooks up the computation done in the previous patches for this bug to the decision on whether to do font size inflation.
layout/base/nsLayoutUtils.cpp
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -99,16 +99,17 @@
 #include "mozilla/arm.h"
 #include "mozilla/dom/Element.h"
 #include "nsCanvasFrame.h"
 #include "gfxDrawable.h"
 #include "gfxUtils.h"
 #include "nsDataHashtable.h"
 #include "nsTextFrame.h"
 #include "nsFontFaceList.h"
+#include "nsFontInflationData.h"
 
 #include "nsSVGUtils.h"
 #include "nsSVGIntegrationUtils.h"
 #include "nsSVGForeignObjectFrame.h"
 #include "nsSVGOuterSVGFrame.h"
 
 #include "mozilla/Preferences.h"
 
@@ -4707,33 +4708,42 @@ nsLayoutUtils::FontSizeInflationInner(co
 
   // To scale 0-1.5 times min to instead be 1-1.5 times min, we want
   // to the desired multiple of min to be 1 + (ratio/3) (where ratio
   // is our input's multiple of min).  The scaling needed to produce
   // that is that divided by |ratio|, or:
   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)
 {
   // 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.
   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();
+         styleText->WhiteSpaceCanWrap() &&
+         InflationDataSaysEnabled(aFrame);
 }
 
 nscoord
 nsLayoutUtils::InflationMinFontSizeFor(const nsIFrame *aFrame,
                                        WidthDetermination aWidthDetermination)
 {
 #ifdef DEBUG
   if (aWidthDetermination == eNotInReflow) {