Bug 1573268 - Convert zoom.maxPercent and zoom.minPercent to static prefs. r=njn
authorKristen Wright <kwright@mozilla.com>
Wed, 14 Aug 2019 18:29:55 +0000
changeset 488022 eb90a1fef7e9be5ee97b5fe44f5551eabf3ffea4
parent 488021 2bfed8cd65e8b70ea4ac2352af88aaafe1cf5814
child 488023 b7bef0d94937b477989e9775ad981d84577ef97b
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 zoom.maxPercent and zoom.minPercent to static prefs. r=njn Converts zoom.maxPercent and zoom.minPercent to static prefs, which creates a new "zoom" category on StaticPrefList.yaml. Differential Revision: https://phabricator.services.mozilla.com/D41835
dom/events/EventStateManager.cpp
layout/base/nsLayoutUtils.cpp
layout/base/nsLayoutUtils.h
layout/base/nsPresContext.cpp
mobile/android/app/mobile.js
modules/libpref/init/StaticPrefList.yaml
modules/libpref/init/all.js
modules/libpref/moz.build
--- a/dom/events/EventStateManager.cpp
+++ b/dom/events/EventStateManager.cpp
@@ -27,16 +27,17 @@
 #include "mozilla/dom/BrowserChild.h"
 #include "mozilla/dom/BrowserParent.h"
 #include "mozilla/dom/UIEvent.h"
 #include "mozilla/dom/UIEventBinding.h"
 #include "mozilla/dom/WheelEventBinding.h"
 #include "mozilla/StaticPrefs_dom.h"
 #include "mozilla/StaticPrefs_layout.h"
 #include "mozilla/StaticPrefs_ui.h"
+#include "mozilla/StaticPrefs_zoom.h"
 
 #include "ContentEventHandler.h"
 #include "IMEContentObserver.h"
 #include "WheelHandlingHelper.h"
 #include "RemoteDragStartData.h"
 
 #include "nsCommandParams.h"
 #include "nsCOMPtr.h"
@@ -2122,18 +2123,18 @@ nsresult EventStateManager::GetContentVi
 
 nsresult EventStateManager::ChangeTextSize(int32_t change) {
   nsCOMPtr<nsIContentViewer> cv;
   nsresult rv = GetContentViewer(getter_AddRefs(cv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (cv) {
     float textzoom;
-    float zoomMin = ((float)Preferences::GetInt("zoom.minPercent", 50)) / 100;
-    float zoomMax = ((float)Preferences::GetInt("zoom.maxPercent", 300)) / 100;
+    float zoomMin = ((float)StaticPrefs::zoom_minPercent()) / 100;
+    float zoomMax = ((float)StaticPrefs::zoom_maxPercent()) / 100;
     cv->GetTextZoom(&textzoom);
     textzoom += ((float)change) / 10;
     if (textzoom < zoomMin)
       textzoom = zoomMin;
     else if (textzoom > zoomMax)
       textzoom = zoomMax;
     cv->SetTextZoom(textzoom);
   }
@@ -2143,18 +2144,18 @@ nsresult EventStateManager::ChangeTextSi
 
 nsresult EventStateManager::ChangeFullZoom(int32_t change) {
   nsCOMPtr<nsIContentViewer> cv;
   nsresult rv = GetContentViewer(getter_AddRefs(cv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (cv) {
     float fullzoom;
-    float zoomMin = ((float)Preferences::GetInt("zoom.minPercent", 50)) / 100;
-    float zoomMax = ((float)Preferences::GetInt("zoom.maxPercent", 300)) / 100;
+    float zoomMin = ((float)StaticPrefs::zoom_minPercent()) / 100;
+    float zoomMax = ((float)StaticPrefs::zoom_maxPercent()) / 100;
     cv->GetFullZoom(&fullzoom);
     fullzoom += ((float)change) / 10;
     if (fullzoom < zoomMin)
       fullzoom = zoomMin;
     else if (fullzoom > zoomMax)
       fullzoom = zoomMax;
     cv->SetFullZoom(fullzoom);
   }
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -179,20 +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::sZoomMaxPercent;
-/* static */
-uint32_t nsLayoutUtils::sZoomMinPercent;
-/* static */
 bool nsLayoutUtils::sInvalidationDebuggingIsEnabled;
 /* static */
 bool nsLayoutUtils::sInterruptibleReflowEnabled;
 /* static */
 bool nsLayoutUtils::sSVGTransformBoxEnabled;
 /* static */
 uint32_t nsLayoutUtils::sIdlePeriodDeadlineLimit;
 /* static */
@@ -7966,18 +7962,16 @@ size_t nsLayoutUtils::SizeOfTextRunsForF
       total += SizeOfTextRunsForFrames(e.get(), aMallocSizeOf, clear);
     }
   }
   return total;
 }
 
 /* static */
 void nsLayoutUtils::Initialize() {
-  Preferences::AddUintVarCache(&sZoomMaxPercent, "zoom.maxPercent", 300);
-  Preferences::AddUintVarCache(&sZoomMinPercent, "zoom.minPercent", 30);
   Preferences::AddBoolVarCache(&sInvalidationDebuggingIsEnabled,
                                "nglayout.debug.invalidation");
   Preferences::AddBoolVarCache(&sInterruptibleReflowEnabled,
                                "layout.interruptible-reflow.enabled");
   Preferences::AddBoolVarCache(&sSVGTransformBoxEnabled,
                                "svg.transform-box.enabled");
   Preferences::AddUintVarCache(&sIdlePeriodDeadlineLimit,
                                "layout.idle_period.time_limit",
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -2440,20 +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);
 
-  static float MaxZoom() { return sZoomMaxPercent / 100.0f; }
-
-  static float MinZoom() { return sZoomMinPercent / 100.0f; }
-
   static bool SVGTransformBoxEnabled() { return sSVGTransformBoxEnabled; }
 
   static uint32_t IdlePeriodDeadlineLimit() { return sIdlePeriodDeadlineLimit; }
 
   static uint32_t QuiescentFramesBeforeIdlePeriod() {
     return sQuiescentFramesBeforeIdlePeriod;
   }
 
@@ -2998,18 +2994,16 @@ class nsLayoutUtils {
 
   /**
    * Generate the motion path transform result.
    **/
   static mozilla::Maybe<mozilla::MotionPathData> ResolveMotionPath(
       const nsIFrame* aFrame);
 
  private:
-  static uint32_t sZoomMaxPercent;
-  static uint32_t sZoomMinPercent;
   static bool sInvalidationDebuggingIsEnabled;
   static bool sInterruptibleReflowEnabled;
   static bool sSVGTransformBoxEnabled;
   static uint32_t sIdlePeriodDeadlineLimit;
   static uint32_t sQuiescentFramesBeforeIdlePeriod;
 
   /**
    * Helper function for LogTestDataForPaint().
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -71,16 +71,17 @@
 #include "nsFrameLoader.h"
 #include "nsContentUtils.h"
 #include "nsPIWindowRoot.h"
 #include "mozilla/Preferences.h"
 #include "gfxTextRun.h"
 #include "nsFontFaceUtils.h"
 #include "nsLayoutStylesheetCache.h"
 #include "mozilla/ServoBindings.h"
+#include "mozilla/StaticPrefs_zoom.h"
 #include "mozilla/StyleSheet.h"
 #include "mozilla/StyleSheetInlines.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/dom/Performance.h"
 #include "mozilla/dom/PerformanceTiming.h"
 #include "mozilla/layers/APZThreadUtils.h"
 
 // Needed for Start/Stop of Image Animation
@@ -914,18 +915,18 @@ void nsPresContext::SetImageAnimationMod
     }
   }
 
   mImageAnimationMode = aMode;
 }
 
 void nsPresContext::UpdateEffectiveTextZoom() {
   float newZoom = mSystemFontScale * mTextZoom;
-  float minZoom = nsLayoutUtils::MinZoom();
-  float maxZoom = nsLayoutUtils::MaxZoom();
+  float minZoom = StaticPrefs::zoom_minPercent() / 100.0f;
+  float maxZoom = StaticPrefs::zoom_maxPercent() / 100.0f;
 
   if (newZoom < minZoom) {
     newZoom = minZoom;
   } else if (newZoom > maxZoom) {
     newZoom = maxZoom;
   }
 
   mEffectiveTextZoom = newZoom;
--- a/mobile/android/app/mobile.js
+++ b/mobile/android/app/mobile.js
@@ -36,19 +36,16 @@ pref("browser.tabs.expireTime", 900);
 // test harness code to be zombified.
 pref("browser.tabs.disableBackgroundZombification", false);
 
 // Control whether tab content should try to load from disk cache when network
 // is offline.
 // Controlled by Switchboard experiment "offline-cache".
 pref("browser.tabs.useCache", false);
 
-// From libpref/src/init/all.js, extended to allow a slightly wider zoom range.
-pref("zoom.minPercent", 20);
-pref("zoom.maxPercent", 400);
 pref("toolkit.zoomManager.zoomValues", ".2,.3,.5,.67,.8,.9,1,1.1,1.2,1.33,1.5,1.7,2,2.4,3,4");
 
 // Mobile will use faster, less durable mode.
 pref("toolkit.storage.synchronous", 0);
 
 // Android needs concurrent access to the same database from multiple processes,
 // thus we can't use exclusive locking on it.
 pref("storage.multiProcessAccess.enabled", true);
--- a/modules/libpref/init/StaticPrefList.yaml
+++ b/modules/libpref/init/StaticPrefList.yaml
@@ -6657,12 +6657,33 @@
   type: bool
 #ifdef MOZ_WIDGET_GTK
   value: false
 #else
   value: true
 #endif
   mirror: always
 
+#---------------------------------------------------------------------------
+# Prefs starting with "zoom."
+#---------------------------------------------------------------------------
+
+- name: zoom.maxPercent
+  type: uint32_t
+#ifdef ANDROID
+  value: 400
+#else
+  value: 300
+#endif
+  mirror: always
+
+- name: zoom.minPercent
+  type: uint32_t
+#ifdef ANDROID
+  value: 20
+#else
+  value: 30
+#endif
+  mirror: always
 
 #---------------------------------------------------------------------------
 # End of prefs
 #---------------------------------------------------------------------------
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -4426,18 +4426,16 @@ pref("browser.formfill.agedWeight",     
 pref("browser.formfill.bucketSize",       1);
 pref("browser.formfill.maxTimeGroupings", 25);
 pref("browser.formfill.timeGroupingSize", 604800);
 pref("browser.formfill.boundaryWeight",   25);
 pref("browser.formfill.prefixWeight",     5);
 
 // Zoom prefs
 pref("browser.zoom.full", false);
-pref("zoom.minPercent", 30);
-pref("zoom.maxPercent", 300);
 pref("toolkit.zoomManager.zoomValues", ".3,.5,.67,.8,.9,1,1.1,1.2,1.33,1.5,1.7,2,2.4,3");
 
 //
 // Image-related prefs
 //
 
 // The maximum size (in kB) that the aggregate frames of an animation can use
 // before it starts to discard already displayed frames and redecode them as
--- a/modules/libpref/moz.build
+++ b/modules/libpref/moz.build
@@ -71,16 +71,17 @@ pref_groups = [
     'test',
     'threads',
     'toolkit',
     'ui',
     'view_source',
     'webgl',
     'widget',
     'xul',
+    'zoom',
 ]
 if CONFIG['OS_TARGET'] == 'Android':
     pref_groups += [
         'consoleservice'
     ]
 if CONFIG['FUZZING']:
     pref_groups += [
         'fuzzing'