Bug 1573268 - Convert 3 font.size.inflation.* prefs to static prefs. r=njn
authorkriswright <kwright@mozilla.com>
Tue, 13 Aug 2019 18:19:33 +0000
changeset 488113 cd573e89e3a8a1cca6fcd7c2d4bb931d4d744b1a
parent 488112 5028fca248cc75f4a6ef91456da84d8093a9380a
child 488114 266c9ff0255fa11cf9cd7cde786e56b6fcfc64f1
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 3 font.size.inflation.* prefs to static prefs. r=njn Converts font.size.inflation.minTwips, font.size.inflation.emPerLine, and font.size.inflation.mappingIntercept to static prefs and removes their associated functions from nsLayoutUtils. There are associated member variables in PresShell, but since documentation specified that these variables are set specifically to prevent changes to the cache from being read until page reload, I made the decision to leave these and set them to the static prefs. Differential Revision: https://phabricator.services.mozilla.com/D41656
layout/base/PresShell.cpp
layout/base/nsLayoutUtils.cpp
layout/base/nsLayoutUtils.h
mobile/android/app/mobile.js
modules/libpref/init/StaticPrefList.yaml
modules/libpref/init/all.js
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -24,16 +24,17 @@
 #include "mozilla/Logging.h"
 #include "mozilla/MouseEvents.h"
 #include "mozilla/PerfStats.h"
 #include "mozilla/PresShellInlines.h"
 #include "mozilla/RangeUtils.h"
 #include "mozilla/Sprintf.h"
 #include "mozilla/StaticPrefs_apz.h"
 #include "mozilla/StaticPrefs_dom.h"
+#include "mozilla/StaticPrefs_font.h"
 #include "mozilla/StaticPrefs_layout.h"
 #include "mozilla/TextEvents.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/TouchEvents.h"
 #include "mozilla/UniquePtr.h"
 #include "mozilla/Unused.h"
 #include <algorithm>
 
@@ -1027,18 +1028,18 @@ void PresShell::Init(Document* aDocument
   for (DocumentTimeline* timeline : mDocument->Timelines()) {
     timeline->NotifyRefreshDriverCreated(GetPresContext()->RefreshDriver());
   }
 
   // Get our activeness from the docShell.
   QueryIsActive();
 
   // Setup our font inflation preferences.
-  mFontSizeInflationEmPerLine = nsLayoutUtils::FontSizeInflationEmPerLine();
-  mFontSizeInflationMinTwips = nsLayoutUtils::FontSizeInflationMinTwips();
+  mFontSizeInflationEmPerLine = StaticPrefs::font_size_inflation_emPerLine();
+  mFontSizeInflationMinTwips = StaticPrefs::font_size_inflation_minTwips();
   mFontSizeInflationLineThreshold =
       nsLayoutUtils::FontSizeInflationLineThreshold();
   mFontSizeInflationForceEnabled =
       nsLayoutUtils::FontSizeInflationForceEnabled();
   mFontSizeInflationDisabledInMasterProcess =
       nsLayoutUtils::FontSizeInflationDisabledInMasterProcess();
   // We'll compute the font size inflation state in Initialize(), when we know
   // the document type.
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -179,24 +179,18 @@ 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::sFontSizeInflationEmPerLine;
-/* static */
-uint32_t nsLayoutUtils::sFontSizeInflationMinTwips;
-/* static */
 uint32_t nsLayoutUtils::sFontSizeInflationLineThreshold;
 /* static */
-int32_t nsLayoutUtils::sFontSizeInflationMappingIntercept;
-/* static */
 bool nsLayoutUtils::sFontSizeInflationForceEnabled;
 /* static */
 bool nsLayoutUtils::sFontSizeInflationDisabledInMasterProcess;
 /* static */
 uint32_t nsLayoutUtils::sSystemFontScale;
 /* static */
 uint32_t nsLayoutUtils::sZoomMaxPercent;
 /* static */
@@ -7980,24 +7974,18 @@ size_t nsLayoutUtils::SizeOfTextRunsForF
       total += SizeOfTextRunsForFrames(e.get(), aMallocSizeOf, clear);
     }
   }
   return total;
 }
 
 /* static */
 void nsLayoutUtils::Initialize() {
-  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");
   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);
@@ -8239,17 +8227,17 @@ float nsLayoutUtils::FontSizeInflationIn
       const auto& stylePosBSize = f->StylePosition()->BSize(wm);
       if (!stylePosISize.IsAuto() ||
           !stylePosBSize.BehavesLikeInitialValueOnBlockAxis()) {
         return 1.0;
       }
     }
   }
 
-  int32_t interceptParam = nsLayoutUtils::FontSizeInflationMappingIntercept();
+  int32_t interceptParam = StaticPrefs::font_size_inflation_mappingIntercept();
   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) {
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -2441,32 +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.emPerLine" in
-   * modules/libpref/src/init/all.js .
-   */
-  static uint32_t FontSizeInflationEmPerLine() {
-    return sFontSizeInflationEmPerLine;
-  }
-
-  /**
-   * See comment above "font.size.inflation.minTwips" in
-   * modules/libpref/src/init/all.js .
-   */
-  static uint32_t FontSizeInflationMinTwips() {
-    return sFontSizeInflationMinTwips;
-  }
-
-  /**
    * See comment above "font.size.inflation.lineThreshold" in
    * modules/libpref/src/init/all.js .
    */
   static uint32_t FontSizeInflationLineThreshold() {
     return sFontSizeInflationLineThreshold;
   }
 
   static bool FontSizeInflationForceEnabled() {
@@ -2491,24 +2475,16 @@ class nsLayoutUtils {
 
   static uint32_t IdlePeriodDeadlineLimit() { return sIdlePeriodDeadlineLimit; }
 
   static uint32_t QuiescentFramesBeforeIdlePeriod() {
     return sQuiescentFramesBeforeIdlePeriod;
   }
 
   /**
-   * See comment above "font.size.inflation.mappingIntercept" in
-   * modules/libpref/src/init/all.js .
-   */
-  static int32_t FontSizeInflationMappingIntercept() {
-    return sFontSizeInflationMappingIntercept;
-  }
-
-  /**
    * Returns true if the nglayout.debug.invalidation pref is set to true.
    * Note that sInvalidationDebuggingIsEnabled is declared outside this function
    * to allow it to be accessed an manipulated from breakpoint conditions.
    */
   static bool InvalidationDebuggingIsEnabled() {
     return sInvalidationDebuggingIsEnabled ||
            getenv("MOZ_DUMP_INVALIDATION") != 0;
   }
@@ -3044,20 +3020,17 @@ class nsLayoutUtils {
 
   /**
    * Generate the motion path transform result.
    **/
   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 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/mobile/android/app/mobile.js
+++ b/mobile/android/app/mobile.js
@@ -341,18 +341,16 @@ pref("dom.max_script_run_time", 20);
 
 // Absolute path to the devtools unix domain socket file used
 // to communicate with a usb cable via adb forward.
 pref("devtools.debugger.unix-domain-socket", "@ANDROID_PACKAGE_NAME@/firefox-debugger-socket");
 
 pref("devtools.remote.usb.enabled", false);
 pref("devtools.remote.wifi.enabled", false);
 
-pref("font.size.inflation.minTwips", 0);
-
 // When true, zooming will be enabled on all sites, even ones that declare user-scalable=no.
 pref("browser.ui.zoom.force-user-scalable", false);
 
 // With the typical screen sizes on mobile devices, we want to wrap page sources by default.
 pref("view_source.wrap_long_lines", true);
 
 
 pref("ui.touch.radius.enabled", false);
--- a/modules/libpref/init/StaticPrefList.yaml
+++ b/modules/libpref/init/StaticPrefList.yaml
@@ -2527,16 +2527,63 @@
   type: bool
   value: false
   mirror: always
 
 #---------------------------------------------------------------------------
 # Prefs starting with "font."
 #---------------------------------------------------------------------------
 
+# A value greater than zero enables font size inflation for
+# pan-and-zoom UIs, so that the fonts in a block are at least the size
+# that, if a block's width is scaled to match the device's width, the
+# fonts in the block are big enough that at most the pref value ems of
+# text fit in *the width of the device*.
+#
+# When both this pref and the next are set, the larger inflation is used.
+- name: font.size.inflation.emPerLine
+  type: uint32_t
+  value: 0
+  mirror: always
+
+# A value greater than zero enables font size inflation for
+# pan-and-zoom UIs, so that if a block's width is scaled to match the
+# device's width, the fonts in a block are at least the given font size.
+# The value given is in twips, i.e., 1/20 of a point, or 1/1440 of an inch.
+#
+# When both this pref and the previous are set, the larger inflation is used.
+- name: font.size.inflation.minTwips
+  type: uint32_t
+  value: 0
+  mirror: always
+
+# Defines the font size inflation mapping intercept parameter.
+#
+# Font size inflation computes a minimum font size, m, based on
+# other preferences (see font.size.inflation.minTwips and
+# font.size.inflation.emPerLine, above) and the width of the
+# frame in which the text resides. Using this minimum, a specified
+# font size, s, is mapped to an inflated font size, i, using an
+# equation that varies depending on the value of the font size
+# inflation mapping intercept parameter, P.
+#
+# If the intercept parameter is negative, then the following mapping
+# function is used:
+#
+# i = m + s
+#
+# 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.
+- name: font.size.inflation.mappingIntercept
+  type: int32_t
+  value: 1
+  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
@@ -3353,38 +3353,16 @@ pref("font.size.monospace.zh-TW", 16);
 // mathml.css sets font-size to "inherit" and font-family to "serif" so only
 // font.name.*.x-math and font.minimum-size.x-math are really relevant.
 pref("font.default.x-math", "serif");
 pref("font.minimum-size.x-math", 0);
 pref("font.size.variable.x-math", 16);
 pref("font.size.monospace.x-math", 13);
 
 /*
- * A value greater than zero enables font size inflation for
- * pan-and-zoom UIs, so that the fonts in a block are at least the size
- * that, if a block's width is scaled to match the device's width, the
- * fonts in the block are big enough that at most the pref value ems of
- * text fit in *the width of the device*.
- *
- * When both this pref and the next are set, the larger inflation is
- * used.
- */
-pref("font.size.inflation.emPerLine", 0);
-/*
- * A value greater than zero enables font size inflation for
- * pan-and-zoom UIs, so that if a block's width is scaled to match the
- * device's width, the fonts in a block are at least the font size
- * given.  The value given is in twips, i.e., 1/20 of a point, or 1/1440
- * of an inch.
- *
- * When both this pref and the previous are set, the larger inflation is
- * used.
- */
-pref("font.size.inflation.minTwips", 0);
-/*
  * In products with multi-mode pan-and-zoom and non-pan-and-zoom UIs,
  * this pref forces font inflation to always be enabled in all modes.
  * That is, any heuristics used to detect pan-and-zoom
  * vs. non-pan-and-zoom modes are disabled and all content is treated
  * as pan-and-zoom mode wrt font inflation.
  *
  * This pref has no effect if font inflation is not enabled through
  * either of the prefs above.  It has no meaning in single-mode UIs.
@@ -3418,39 +3396,16 @@ pref("font.size.inflation.disabledInMast
  * 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);
 
-/*
- * Defines the font size inflation mapping intercept parameter.
- *
- * Font size inflation computes a minimum font size, m, based on
- * other preferences (see font.size.inflation.minTwips and
- * font.size.inflation.emPerLine, above) and the width of the
- * frame in which the text resides. Using this minimum, a specified
- * font size, s, is mapped to an inflated font size, i, using an
- * equation that varies depending on the value of the font size
- * inflation mapping intercept parameter, P:
- *
- * If the intercept parameter is negative, then the following mapping
- * function is used:
- *
- * i = m + s
- *
- * 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 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.