Bug 1573268 - Convert font.size.inflation.lineThreshold to a static pref. r=njn
authorkriswright <kwright@mozilla.com>
Tue, 13 Aug 2019 18:23:54 +0000
changeset 488019 266c9ff0255fa11cf9cd7cde786e56b6fcfc64f1
parent 488018 cd573e89e3a8a1cca6fcd7c2d4bb931d4d744b1a
child 488020 c84c8016d09e25b921dff654a271bbe630f7f4eb
push id36434
push usercbrindusan@mozilla.com
push dateThu, 15 Aug 2019 09:44:30 +0000
treeherdermozilla-central@144fbfb409b7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs1573268
milestone70.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 1573268 - Convert font.size.inflation.lineThreshold to a static pref. r=njn Converts font.size.inflation.lineThreshold varcache pref to a static pref. Like previous revisions, this retains the member variable in PresShell. Differential Revision: https://phabricator.services.mozilla.com/D41662
layout/base/PresShell.cpp
layout/base/nsLayoutUtils.cpp
layout/base/nsLayoutUtils.h
layout/generic/nsFontInflationData.cpp
modules/libpref/init/StaticPrefList.yaml
modules/libpref/init/all.js
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -1031,17 +1031,17 @@ void PresShell::Init(Document* aDocument
 
   // Get our activeness from the docShell.
   QueryIsActive();
 
   // Setup our font inflation preferences.
   mFontSizeInflationEmPerLine = StaticPrefs::font_size_inflation_emPerLine();
   mFontSizeInflationMinTwips = StaticPrefs::font_size_inflation_minTwips();
   mFontSizeInflationLineThreshold =
-      nsLayoutUtils::FontSizeInflationLineThreshold();
+      StaticPrefs::font_size_inflation_lineThreshold();
   mFontSizeInflationForceEnabled =
       nsLayoutUtils::FontSizeInflationForceEnabled();
   mFontSizeInflationDisabledInMasterProcess =
       nsLayoutUtils::FontSizeInflationDisabledInMasterProcess();
   // We'll compute the font size inflation state in Initialize(), when we know
   // the document type.
 
   mTouchManager.Init(this, mDocument);
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -179,18 +179,16 @@ using mozilla::dom::HTMLMediaElement_Bin
 // TODO: remove, see bug 598468.
 bool nsLayoutUtils::gPreventAssertInCompareTreePosition = false;
 #endif  // DEBUG
 
 typedef ScrollableLayerGuid::ViewID ViewID;
 typedef nsStyleTransformMatrix::TransformReferenceBox TransformReferenceBox;
 
 /* static */
-uint32_t nsLayoutUtils::sFontSizeInflationLineThreshold;
-/* static */
 bool nsLayoutUtils::sFontSizeInflationForceEnabled;
 /* static */
 bool nsLayoutUtils::sFontSizeInflationDisabledInMasterProcess;
 /* static */
 uint32_t nsLayoutUtils::sSystemFontScale;
 /* static */
 uint32_t nsLayoutUtils::sZoomMaxPercent;
 /* static */
@@ -7974,18 +7972,16 @@ size_t nsLayoutUtils::SizeOfTextRunsForF
       total += SizeOfTextRunsForFrames(e.get(), aMallocSizeOf, clear);
     }
   }
   return total;
 }
 
 /* static */
 void nsLayoutUtils::Initialize() {
-  Preferences::AddUintVarCache(&sFontSizeInflationLineThreshold,
-                               "font.size.inflation.lineThreshold");
   Preferences::AddBoolVarCache(&sFontSizeInflationForceEnabled,
                                "font.size.inflation.forceEnabled");
   Preferences::AddBoolVarCache(&sFontSizeInflationDisabledInMasterProcess,
                                "font.size.inflation.disabledInMasterProcess");
   Preferences::AddUintVarCache(&sSystemFontScale, "font.size.systemFontScale",
                                100);
   Preferences::AddUintVarCache(&sZoomMaxPercent, "zoom.maxPercent", 300);
   Preferences::AddUintVarCache(&sZoomMinPercent, "zoom.minPercent", 30);
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -2440,24 +2440,16 @@ class nsLayoutUtils {
    * aMinFontSize must be the result of one of the
    *   InflationMinFontSizeFor methods above.
    */
   static float FontSizeInflationInner(const nsIFrame* aFrame,
                                       nscoord aMinFontSize);
 
   static bool FontSizeInflationEnabled(nsPresContext* aPresContext);
 
-  /**
-   * See comment above "font.size.inflation.lineThreshold" in
-   * modules/libpref/src/init/all.js .
-   */
-  static uint32_t FontSizeInflationLineThreshold() {
-    return sFontSizeInflationLineThreshold;
-  }
-
   static bool FontSizeInflationForceEnabled() {
     return sFontSizeInflationForceEnabled;
   }
 
   static bool FontSizeInflationDisabledInMasterProcess() {
     return sFontSizeInflationDisabledInMasterProcess;
   }
 
@@ -3020,17 +3012,16 @@ class nsLayoutUtils {
 
   /**
    * Generate the motion path transform result.
    **/
   static mozilla::Maybe<mozilla::MotionPathData> ResolveMotionPath(
       const nsIFrame* aFrame);
 
  private:
-  static uint32_t sFontSizeInflationLineThreshold;
   static bool sFontSizeInflationForceEnabled;
   static bool sFontSizeInflationDisabledInMasterProcess;
   static uint32_t sSystemFontScale;
   static uint32_t sZoomMaxPercent;
   static uint32_t sZoomMinPercent;
   static bool sInvalidationDebuggingIsEnabled;
   static bool sInterruptibleReflowEnabled;
   static bool sSVGTransformBoxEnabled;
--- a/layout/generic/nsFontInflationData.cpp
+++ b/layout/generic/nsFontInflationData.cpp
@@ -189,17 +189,17 @@ void nsFontInflationData::UpdateISize(co
       firstInflatableDescendant, lastInflatableDescendant, bfc);
   while (!nca->IsContainerForFontSizeInflation()) {
     nca = nca->GetParent()->FirstInFlow();
   }
 
   nscoord newNCAISize = ComputeDescendantISize(aReflowInput, nca);
 
   // See comment above "font.size.inflation.lineThreshold" in
-  // modules/libpref/src/init/all.js .
+  // modules/libpref/src/init/StaticPrefList.yaml .
   PresShell* presShell = bfc->PresShell();
   uint32_t lineThreshold = presShell->FontSizeInflationLineThreshold();
   nscoord newTextThreshold = (newNCAISize * lineThreshold) / 100;
 
   if (mTextThreshold <= mTextAmount && mTextAmount < newTextThreshold) {
     // Because we truncate our scan when we hit sufficient text, we now
     // need to rescan.
     mTextDirty = true;
--- a/modules/libpref/init/StaticPrefList.yaml
+++ b/modules/libpref/init/StaticPrefList.yaml
@@ -2574,16 +2574,40 @@
 # is a function such that its graph meets the graph of i = s at the
 # point where both i and s are (1 + P/2) * m for values of s that are
 # large enough. This means that when s=0, i is always equal to m.
 - name: font.size.inflation.mappingIntercept
   type: int32_t
   value: 1
   mirror: always
 
+# Since the goal of font size inflation is to avoid having to
+# repeatedly scroll side to side to read a block of text, and there are
+# a number of page layouts where a relatively small chunk of text is
+# better off not being inflated according to the same algorithm we use
+# for larger chunks of text, we want a threshold for an amount of text
+# that triggers font size inflation.  This preference controls that
+# threshold.
+#
+# It controls the threshold used within an *approximation* of the
+# number of lines of text we use.  In particular, if we assume that
+# each character (collapsing collapsible whitespace) has a width the
+# same as the em-size of the font (when, normally, it's actually quite
+# a bit smaller on average), this preference gives the percentage of a
+# number of lines of text we'd need to trigger inflation.  This means
+# that a percentage of 100 means that we'd need a number of characters
+# (we know the font size and the width) equivalent to one line of
+# square text (which is actually a lot less than a real line of text).
+#
+# A value of 0 means there's no character length threshold.
+- name: font.size.inflation.lineThreshold
+  type: uint32_t
+  value: 400
+  mirror: always
+
 # This controls the percentage that fonts will be inflated, if font
 # size inflation is enabled. Essentially, if we have a specified font
 # size, s, and an inflated font size, i, this specifies that the ratio
 # i/s * 100 should never exceed the value of this preference. In order
 # for this preference to have any effect, its value must be greater
 # than 100, since font inflation can never decrease the ratio i/s.
 - name: font.size.inflation.maxRatio
   type: uint32_t
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -3373,38 +3373,16 @@ pref("font.size.inflation.forceEnabled",
  * this pref disables font inflation in master-process contexts where
  * existing heuristics can't be used determine enabled-ness.
  *
  * This pref has no effect if font inflation is not enabled through
  * either of the prefs above.  The "forceEnabled" pref above overrides
  * this pref.
  */
 pref("font.size.inflation.disabledInMasterProcess", false);
-/*
- * Since the goal of font size inflation is to avoid having to
- * repeatedly scroll side to side to read a block of text, and there are
- * a number of page layouts where a relatively small chunk of text is
- * better of not being inflated according to the same algorithm we use
- * for larger chunks of text, we want a threshold for an amount of text
- * that triggers font size inflation.  This preference controls that
- * threshold.
- *
- * It controls the threshold used within an *approximation* of the
- * number of lines of text we use.  In particular, if we assume that
- * each character (collapsing collapsible whitespace) has a width the
- * same as the em-size of the font (when, normally, it's actually quite
- * a bit smaller on average), this preference gives the percentage of a
- * number of lines of text we'd need to trigger inflation.  This means
- * that a percentage of 100 means that we'd need a number of characters
- * (we know the font size and the width) equivalent to one line of
- * square text (which is actually a lot less than a real line of text).
- *
- * A value of 0 means there's no character length threshold.
- */
-pref("font.size.inflation.lineThreshold", 400);
 
 /**
  * This setting corresponds to a global text zoom setting affecting
  * all content that is not already subject to font size inflation.
  * It is interpreted as a percentage value that is applied on top
  * of the document's current text zoom setting.
  *
  * The resulting total zoom factor (text zoom * system font scale)