Bug 1713485 - Remove code for completed migration. r=hiro
authorKartikaya Gupta <kats@pancake.staktrace.com>
Mon, 31 May 2021 21:36:36 +0000
changeset 649887 86af980c571026ed06183569d56d3f1153366734
parent 649886 b7e10a54750ff3d079698e4f9f97a959ab76ed65
child 649888 3a9cf4ad9344116ba51ef8d1d7937a9176747090
push id15597
push userffxbld-merge
push dateMon, 12 Jul 2021 12:28:04 +0000
treeherdermozilla-beta@9c0e51e068b6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershiro
bugs1713485
milestone91.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 1713485 - Remove code for completed migration. r=hiro This is essentially dead-code removal. Since the GetNormalizedAppVersion() now always returns 86, the value of the `migration` variable in GetMouseWheelAnimationDurations() is always 100. And thus the function always returns the unmodified minMS and maxMS values stored in the prefs. We can therefore remove the function entirely and just use the pref values directly in the callers. Differential Revision: https://phabricator.services.mozilla.com/D116322
gfx/layers/apz/public/APZPublicUtils.h
gfx/layers/apz/src/APZPublicUtils.cpp
gfx/layers/apz/src/WheelScrollAnimation.cpp
--- a/gfx/layers/apz/public/APZPublicUtils.h
+++ b/gfx/layers/apz/public/APZPublicUtils.h
@@ -56,25 +56,16 @@ const ScreenMargin CalculatePendingDispl
  * The exact details are somewhat arbitrary and tuned by hand.
  * This function is intended to only be used with WebRender, because that is
  * the codepath that wants to use a larger displayport alignment, because
  * moving the displayport is relatively expensive with WebRender.
  */
 gfx::IntSize GetDisplayportAlignmentMultiplier(const ScreenSize& aBaseSize);
 
 /**
- * This computes the min/max values to use for the mousewheel animation
- * duration. Normally this just comes from prefs but we are doing a gradual
- * migration of users from old values to new values so this encapsulates some
- * of that behaviour. Values are in milliseconds, same as the
- * general.smoothScroll.mouseWheel.duration* prefs.
- */
-std::pair<int32_t, int32_t> GetMouseWheelAnimationDurations();
-
-/**
  * Calculate the physics parameters for smooth scroll animations for the
  * given origin, based on pref values.
  */
 ScrollAnimationBezierPhysicsSettings ComputeBezierAnimationSettingsForOrigin(
     ScrollOrigin aOrigin);
 
 }  // namespace apz
 
--- a/gfx/layers/apz/src/APZPublicUtils.cpp
+++ b/gfx/layers/apz/src/APZPublicUtils.cpp
@@ -26,65 +26,16 @@ namespace apz {
       aFrameMetrics, aVelocity, AsyncPanZoomController::ZoomInProgress::No);
 }
 
 /*static*/ gfx::IntSize GetDisplayportAlignmentMultiplier(
     const ScreenSize& aBaseSize) {
   return AsyncPanZoomController::GetDisplayportAlignmentMultiplier(aBaseSize);
 }
 
-static int32_t GetNormalizedAppVersion() {
-  static int32_t sAppVersion = 0;
-  if (sAppVersion == 0) {
-    const char* kVersion = MOZ_STRINGIFY(MOZ_APP_VERSION);
-    long version = strtol(kVersion, nullptr, 10);
-    if (version < 81 || version > 86) {
-      // If the version is garbage or unreasonable, set it to a value that will
-      // complete the migration. This also clamps legitimate values > 86 down to
-      // 86.
-      version = 86;
-    }
-    sAppVersion = static_cast<int32_t>(version);
-  }
-  return sAppVersion;
-}
-
-/*static*/ std::pair<int32_t, int32_t> GetMouseWheelAnimationDurations() {
-  // Special code for migrating users from old values to new values over
-  // a period of time. The old values are defaults prior to bug 1660933, which
-  // we hard-code here. The user's migration percentage is stored in the
-  // migration pref. If the migration percentage is zero, the user gets the old
-  // values, and at a 100 percentage the user gets the new values. Linear
-  // interpolation in between. We can control the speed of migration by
-  // increasing the percentage value over time (e.g. by increasing the min
-  // bound on the clamped migration value). Once it reaches 100 the migration
-  // code can be removed.
-
-  int32_t minMS = StaticPrefs::general_smoothScroll_mouseWheel_durationMinMS();
-  int32_t maxMS = StaticPrefs::general_smoothScroll_mouseWheel_durationMaxMS();
-
-  const int32_t oldMin = 200;
-  const int32_t oldMax = 400;
-
-  int32_t migration =
-      StaticPrefs::general_smoothScroll_mouseWheel_migrationPercent();
-
-  // Increase migration by 25% for each version, starting in version 83.
-  int32_t version = GetNormalizedAppVersion();
-  int32_t minMigrationPercentage = std::max(0, (version - 82) * 25);
-  MOZ_ASSERT(minMigrationPercentage >= 0 && minMigrationPercentage <= 100);
-
-  migration = clamped(migration, minMigrationPercentage, 100);
-
-  minMS = ((oldMin * (100 - migration)) + (minMS * migration)) / 100;
-  maxMS = ((oldMax * (100 - migration)) + (maxMS * migration)) / 100;
-
-  return std::make_pair(minMS, maxMS);
-}
-
 ScrollAnimationBezierPhysicsSettings ComputeBezierAnimationSettingsForOrigin(
     ScrollOrigin aOrigin) {
   int32_t minMS = 0;
   int32_t maxMS = 0;
   bool isOriginSmoothnessEnabled = false;
 
 #define READ_DURATIONS(prefbase)                                              \
   isOriginSmoothnessEnabled = StaticPrefs::general_smoothScroll() &&          \
@@ -112,20 +63,16 @@ ScrollAnimationBezierPhysicsSettings Com
       break;
     default:
       READ_DURATIONS(other)
       break;
   }
 
 #undef READ_DURATIONS
 
-  if (aOrigin == ScrollOrigin::MouseWheel && isOriginSmoothnessEnabled) {
-    std::tie(minMS, maxMS) = GetMouseWheelAnimationDurations();
-  }
-
   if (isOriginSmoothnessEnabled) {
     static const int32_t kSmoothScrollMaxAllowedAnimationDurationMS = 10000;
     maxMS = clamped(maxMS, 0, kSmoothScrollMaxAllowedAnimationDurationMS);
     minMS = clamped(minMS, 0, maxMS);
   }
 
   // Keep the animation duration longer than the average event intervals
   // (to "connect" consecutive scroll animations before the scroll comes to a
--- a/gfx/layers/apz/src/WheelScrollAnimation.cpp
+++ b/gfx/layers/apz/src/WheelScrollAnimation.cpp
@@ -4,17 +4,16 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "WheelScrollAnimation.h"
 
 #include <tuple>
 #include "AsyncPanZoomController.h"
 #include "mozilla/StaticPrefs_general.h"
-#include "mozilla/layers/APZPublicUtils.h"
 #include "nsPoint.h"
 #include "ScrollAnimationBezierPhysics.h"
 
 namespace mozilla {
 namespace layers {
 
 static ScrollAnimationBezierPhysicsSettings SettingsForDeltaType(
     ScrollWheelInput::ScrollDeltaType aDeltaType) {
@@ -30,19 +29,22 @@ static ScrollAnimationBezierPhysicsSetti
       break;
     case ScrollWheelInput::SCROLLDELTA_PIXEL:
       maxMS = clamped(StaticPrefs::general_smoothScroll_pixels_durationMaxMS(),
                       0, 10000);
       minMS = clamped(StaticPrefs::general_smoothScroll_pixels_durationMinMS(),
                       0, maxMS);
       break;
     case ScrollWheelInput::SCROLLDELTA_LINE:
-      std::tie(minMS, maxMS) = apz::GetMouseWheelAnimationDurations();
-      maxMS = clamped(maxMS, 0, 10000);
-      minMS = clamped(minMS, 0, maxMS);
+      maxMS =
+          clamped(StaticPrefs::general_smoothScroll_mouseWheel_durationMaxMS(),
+                  0, 10000);
+      minMS =
+          clamped(StaticPrefs::general_smoothScroll_mouseWheel_durationMinMS(),
+                  0, maxMS);
       break;
   }
 
   // The pref is 100-based int percentage, while mIntervalRatio is 1-based ratio
   double intervalRatio =
       ((double)StaticPrefs::general_smoothScroll_durationToIntervalRatio()) /
       100.0;
   intervalRatio = std::max(1.0, intervalRatio);