зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1660933 - Respect wheel migration value. r=botond
This introduces a linear interpolation when computing the wheel animation durations, based on the migration percentage of the user. Initially the migration percentage defaults to 100 (fully migrated) for new users and for existing users who have customized these prefs. The migration percentage defaults to zero for existing users without customizations, so they will still get the old default values of min=200,max=400. Over time we can adjust the migration pref clamping to move that percentage up and migrate those users to get the new values. Differential Revision: https://phabricator.services.mozilla.com/D88163
This commit is contained in:
Родитель
f178e098c9
Коммит
d046d2b406
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include <stdint.h> // for uint32_t
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include "gfxTypes.h"
|
||||
#include "FrameMetrics.h"
|
||||
#include "LayersTypes.h"
|
||||
|
@ -73,6 +74,15 @@ void InitializeGlobalState();
|
|||
const ScreenMargin CalculatePendingDisplayPort(
|
||||
const FrameMetrics& aFrameMetrics, const ParentLayerPoint& aVelocity);
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
} // namespace apz
|
||||
|
||||
} // namespace layers
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "mozilla/layers/APZPublicUtils.h"
|
||||
|
||||
#include "AsyncPanZoomController.h"
|
||||
#include "mozilla/StaticPrefs_general.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
@ -24,6 +25,33 @@ namespace apz {
|
|||
aVelocity);
|
||||
}
|
||||
|
||||
/*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();
|
||||
migration = clamped(migration, 0, 100);
|
||||
|
||||
minMS = ((oldMin * (100 - migration)) + (minMS * migration)) / 100;
|
||||
maxMS = ((oldMax * (100 - migration)) + (maxMS * migration)) / 100;
|
||||
|
||||
return std::make_pair(minMS, maxMS);
|
||||
}
|
||||
|
||||
} // namespace apz
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -5,11 +5,13 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "WheelScrollAnimation.h"
|
||||
#include "ScrollAnimationBezierPhysics.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 {
|
||||
|
@ -33,12 +35,9 @@ static ScrollAnimationBezierPhysicsSettings SettingsForDeltaType(
|
|||
0, maxMS);
|
||||
break;
|
||||
case ScrollWheelInput::SCROLLDELTA_LINE:
|
||||
maxMS =
|
||||
clamped(StaticPrefs::general_smoothScroll_mouseWheel_durationMaxMS(),
|
||||
0, 10000);
|
||||
minMS =
|
||||
clamped(StaticPrefs::general_smoothScroll_mouseWheel_durationMinMS(),
|
||||
0, maxMS);
|
||||
std::tie(minMS, maxMS) = apz::GetMouseWheelAnimationDurations();
|
||||
maxMS = clamped(maxMS, 0, 10000);
|
||||
minMS = clamped(minMS, 0, maxMS);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -78,6 +78,7 @@
|
|||
#include "ViewportFrame.h"
|
||||
#include "mozilla/gfx/gfxVars.h"
|
||||
#include "mozilla/layers/APZCCallbackHelper.h"
|
||||
#include "mozilla/layers/APZPublicUtils.h"
|
||||
#include "mozilla/layers/AxisPhysicsModel.h"
|
||||
#include "mozilla/layers/AxisPhysicsMSDModel.h"
|
||||
#include "mozilla/layers/LayerTransactionChild.h"
|
||||
|
@ -89,6 +90,7 @@
|
|||
#include <algorithm>
|
||||
#include <cstdlib> // for std::abs(int/long)
|
||||
#include <cmath> // for std::abs(float/double)
|
||||
#include <tuple> // for std::tie
|
||||
|
||||
static mozilla::LazyLogModule sApzPaintSkipLog("apz.paintskip");
|
||||
#define PAINT_SKIP_LOG(...) \
|
||||
|
@ -2119,6 +2121,10 @@ ComputeBezierAnimationSettingsForOrigin(ScrollOrigin aOrigin) {
|
|||
minMS = Preferences::GetInt(prefMin.get(), kDefaultMinMS);
|
||||
maxMS = Preferences::GetInt(prefMax.get(), kDefaultMaxMS);
|
||||
|
||||
if (aOrigin == ScrollOrigin::MouseWheel) {
|
||||
std::tie(minMS, maxMS) = layers::apz::GetMouseWheelAnimationDurations();
|
||||
}
|
||||
|
||||
static const int32_t kSmoothScrollMaxAllowedAnimationDurationMS = 10000;
|
||||
maxMS = clamped(maxMS, 0, kSmoothScrollMaxAllowedAnimationDurationMS);
|
||||
minMS = clamped(minMS, 0, maxMS);
|
||||
|
|
Загрузка…
Ссылка в новой задаче