Bug 1573268 - Convert font.size.inflation.maxRatio to static pref. r=njn
authorkriswright <kwright@mozilla.com>
Tue, 13 Aug 2019 00:07:32 +0000
changeset 488112 5028fca248cc75f4a6ef91456da84d8093a9380a
parent 488111 43cbfaf3e97eb0aa5a503d6f19492d67ba5ba86c
child 488113 cd573e89e3a8a1cca6fcd7c2d4bb931d4d744b1a
push id113900
push usercbrindusan@mozilla.com
push dateThu, 15 Aug 2019 09:53:50 +0000
treeherdermozilla-inbound@0db07ff50ab5 [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.maxRatio to static pref. r=njn Creates the new 'font' category in StaticPrefList.yaml and adds font.size.inflation.maxRatio to the category. Removes the old static uint in nsLayoutUtils and the function that returns it. Differential Revision: https://phabricator.services.mozilla.com/D41654
layout/base/nsLayoutUtils.cpp
layout/base/nsLayoutUtils.h
modules/libpref/init/StaticPrefList.yaml
modules/libpref/init/all.js
modules/libpref/moz.build
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -21,16 +21,17 @@
 #include "mozilla/Likely.h"
 #include "mozilla/Maybe.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/PerfStats.h"
 #include "mozilla/PresShell.h"
 #include "mozilla/ServoStyleSetInlines.h"
 #include "mozilla/StaticPrefs_apz.h"
 #include "mozilla/StaticPrefs_dom.h"
+#include "mozilla/StaticPrefs_font.h"
 #include "mozilla/StaticPrefs_gfx.h"
 #include "mozilla/StaticPrefs_layers.h"
 #include "mozilla/StaticPrefs_layout.h"
 #include "mozilla/Unused.h"
 #include "nsCharTraits.h"
 #include "mozilla/dom/BrowserChild.h"
 #include "mozilla/dom/Document.h"
 #include "mozilla/dom/DocumentInlines.h"
@@ -186,18 +187,16 @@ typedef nsStyleTransformMatrix::Transfor
 uint32_t nsLayoutUtils::sFontSizeInflationEmPerLine;
 /* static */
 uint32_t nsLayoutUtils::sFontSizeInflationMinTwips;
 /* static */
 uint32_t nsLayoutUtils::sFontSizeInflationLineThreshold;
 /* static */
 int32_t nsLayoutUtils::sFontSizeInflationMappingIntercept;
 /* static */
-uint32_t nsLayoutUtils::sFontSizeInflationMaxRatio;
-/* static */
 bool nsLayoutUtils::sFontSizeInflationForceEnabled;
 /* static */
 bool nsLayoutUtils::sFontSizeInflationDisabledInMasterProcess;
 /* static */
 uint32_t nsLayoutUtils::sSystemFontScale;
 /* static */
 uint32_t nsLayoutUtils::sZoomMaxPercent;
 /* static */
@@ -7981,18 +7980,16 @@ size_t nsLayoutUtils::SizeOfTextRunsForF
       total += SizeOfTextRunsForFrames(e.get(), aMallocSizeOf, clear);
     }
   }
   return total;
 }
 
 /* static */
 void nsLayoutUtils::Initialize() {
-  Preferences::AddUintVarCache(&sFontSizeInflationMaxRatio,
-                               "font.size.inflation.maxRatio");
   Preferences::AddUintVarCache(&sFontSizeInflationEmPerLine,
                                "font.size.inflation.emPerLine");
   Preferences::AddUintVarCache(&sFontSizeInflationMinTwips,
                                "font.size.inflation.minTwips");
   Preferences::AddUintVarCache(&sFontSizeInflationLineThreshold,
                                "font.size.inflation.lineThreshold");
   Preferences::AddIntVarCache(&sFontSizeInflationMappingIntercept,
                               "font.size.inflation.mappingIntercept");
@@ -8243,17 +8240,17 @@ float nsLayoutUtils::FontSizeInflationIn
       if (!stylePosISize.IsAuto() ||
           !stylePosBSize.BehavesLikeInitialValueOnBlockAxis()) {
         return 1.0;
       }
     }
   }
 
   int32_t interceptParam = nsLayoutUtils::FontSizeInflationMappingIntercept();
-  float maxRatio = (float)nsLayoutUtils::FontSizeInflationMaxRatio() / 100.0f;
+  float maxRatio = (float)StaticPrefs::font_size_inflation_maxRatio() / 100.0f;
 
   float ratio = float(styleFontSize) / float(aMinFontSize);
   float inflationRatio;
 
   // Given a minimum inflated font size m, a specified font size s, we want to
   // find the inflated font size i and then return the ratio of i to s (i/s).
   if (interceptParam >= 0) {
     // Since the mapping intercept parameter P is greater than zero, we use it
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -2441,24 +2441,16 @@ class nsLayoutUtils {
    *   InflationMinFontSizeFor methods above.
    */
   static float FontSizeInflationInner(const nsIFrame* aFrame,
                                       nscoord aMinFontSize);
 
   static bool FontSizeInflationEnabled(nsPresContext* aPresContext);
 
   /**
-   * See comment above "font.size.inflation.maxRatio" in
-   * modules/libpref/src/init/all.js .
-   */
-  static uint32_t FontSizeInflationMaxRatio() {
-    return sFontSizeInflationMaxRatio;
-  }
-
-  /**
    * See comment above "font.size.inflation.emPerLine" in
    * modules/libpref/src/init/all.js .
    */
   static uint32_t FontSizeInflationEmPerLine() {
     return sFontSizeInflationEmPerLine;
   }
 
   /**
@@ -3056,17 +3048,16 @@ class nsLayoutUtils {
   static mozilla::Maybe<mozilla::MotionPathData> ResolveMotionPath(
       const nsIFrame* aFrame);
 
  private:
   static uint32_t sFontSizeInflationEmPerLine;
   static uint32_t sFontSizeInflationMinTwips;
   static uint32_t sFontSizeInflationLineThreshold;
   static int32_t sFontSizeInflationMappingIntercept;
-  static uint32_t sFontSizeInflationMaxRatio;
   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/modules/libpref/init/StaticPrefList.yaml
+++ b/modules/libpref/init/StaticPrefList.yaml
@@ -2524,16 +2524,31 @@
 # This pref has no effect within fission windows, it only controls the
 # behaviour within non-fission windows.
 - name: fission.preserve_browsing_contexts
   type: bool
   value: false
   mirror: always
 
 #---------------------------------------------------------------------------
+# Prefs starting with "font."
+#---------------------------------------------------------------------------
+
+# 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
+  value: 0
+  mirror: always
+
+#---------------------------------------------------------------------------
 # Prefs starting with "full-screen-api."
 #---------------------------------------------------------------------------
 
 - name: full-screen-api.enabled
   type: bool
   value: false
   mirror: always
 
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -3441,28 +3441,16 @@ pref("font.size.inflation.lineThreshold"
  *
  * If the intercept parameter is non-negative, then the mapping function
  * 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.
  */
 pref("font.size.inflation.mappingIntercept", 1);
 
-/*
- * 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.
- */
-pref("font.size.inflation.maxRatio", 0);
-
 /**
  * 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)
  * will be limited by zoom.minPercent and maxPercent.
--- a/modules/libpref/moz.build
+++ b/modules/libpref/moz.build
@@ -35,16 +35,17 @@ pref_groups = [
     'clipboard',
     'content',
     'device',
     'devtools',
     'dom',
     'editor',
     'extensions',
     'fission',
+    'font',
     'full_screen_api',
     'general',
     'geo',
     'gfx',
     'gl',
     'html5',
     'idle_period',
     'image',