Bug 1199468 - Create prefs for the smooth scroll timing function shape. r?kats
--- a/gfx/thebes/gfxPrefs.h
+++ b/gfx/thebes/gfxPrefs.h
@@ -206,16 +206,20 @@ private:
DECL_GFX_PREF(Live, "general.smoothScroll", SmoothScrollEnabled, bool, true);
DECL_GFX_PREF(Live, "general.smoothScroll.durationToIntervalRatio",
SmoothScrollDurationToIntervalRatio, int32_t, 200);
DECL_GFX_PREF(Live, "general.smoothScroll.mouseWheel", WheelSmoothScrollEnabled, bool, true);
DECL_GFX_PREF(Live, "general.smoothScroll.mouseWheel.durationMaxMS",
WheelSmoothScrollMaxDurationMs, int32_t, 400);
DECL_GFX_PREF(Live, "general.smoothScroll.mouseWheel.durationMinMS",
WheelSmoothScrollMinDurationMs, int32_t, 200);
+ DECL_GFX_PREF(Live, "general.smoothScroll.currentVelocityWeighting",
+ SmoothScrollCurrentVelocityWeighting, float, 0.25);
+ DECL_GFX_PREF(Live, "general.smoothScroll.stopDecelerationWeighting",
+ SmoothScrollStopDecelerationWeighting, float, 0.4);
DECL_GFX_PREF(Once, "gfx.android.rgb16.force", AndroidRGB16Force, bool, false);
#if defined(ANDROID)
DECL_GFX_PREF(Once, "gfx.apitrace.enabled", UseApitrace, bool, false);
#endif
#if defined(RELEASE_BUILD)
// "Skip" means this is locked to the default value in beta and release.
DECL_GFX_PREF(Skip, "gfx.blocklist.all", BlocklistAll, int32_t, 0);
--- a/layout/generic/AsyncScrollBase.cpp
+++ b/layout/generic/AsyncScrollBase.cpp
@@ -1,14 +1,15 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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 "AsyncScrollBase.h"
+#include "gfxPrefs.h"
using namespace mozilla;
AsyncScrollBase::AsyncScrollBase(nsPoint aStartPos)
: mIsFirstIteration(true)
, mStartPos(aStartPos)
{
}
@@ -72,36 +73,33 @@ AsyncScrollBase::InitializeHistory(TimeS
// Longest relevant interval (which results in maximum duration)
TimeDuration maxDelta = TimeDuration::FromMilliseconds(mOriginMaxMS / mIntervalRatio);
mPrevEventTime[0] = aTime - maxDelta;
mPrevEventTime[1] = mPrevEventTime[0] - maxDelta;
mPrevEventTime[2] = mPrevEventTime[1] - maxDelta;
}
-const double kCurrentVelocityWeighting = 0.25;
-const double kStopDecelerationWeighting = 0.4;
-
void
AsyncScrollBase::InitTimingFunction(nsSMILKeySpline& aTimingFunction,
nscoord aCurrentPos,
nscoord aCurrentVelocity,
nscoord aDestination)
{
- if (aDestination == aCurrentPos || kCurrentVelocityWeighting == 0) {
- aTimingFunction.Init(0, 0, 1 - kStopDecelerationWeighting, 1);
+ if (aDestination == aCurrentPos || gfxPrefs::SmoothScrollCurrentVelocityWeighting() == 0) {
+ aTimingFunction.Init(0, 0, 1 - gfxPrefs::SmoothScrollStopDecelerationWeighting(), 1);
return;
}
const TimeDuration oneSecond = TimeDuration::FromSeconds(1);
double slope = aCurrentVelocity * (mDuration / oneSecond) / (aDestination - aCurrentPos);
double normalization = sqrt(1.0 + slope * slope);
- double dt = 1.0 / normalization * kCurrentVelocityWeighting;
- double dxy = slope / normalization * kCurrentVelocityWeighting;
- aTimingFunction.Init(dt, dxy, 1 - kStopDecelerationWeighting, 1);
+ double dt = 1.0 / normalization * gfxPrefs::SmoothScrollCurrentVelocityWeighting();
+ double dxy = slope / normalization * gfxPrefs::SmoothScrollCurrentVelocityWeighting();
+ aTimingFunction.Init(dt, dxy, 1 - gfxPrefs::SmoothScrollStopDecelerationWeighting(), 1);
}
nsPoint
AsyncScrollBase::PositionAt(TimeStamp aTime) const
{
double progressX = mTimingFunctionX.GetSplineValue(ProgressAt(aTime));
double progressY = mTimingFunctionY.GetSplineValue(ProgressAt(aTime));
return nsPoint(NSToCoordRound((1 - progressX) * mStartPos.x + progressX * mDestination.x),
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -2122,16 +2122,19 @@ pref("general.smoothScroll.pages", true)
pref("general.smoothScroll.scrollbars", true);
pref("general.smoothScroll.other", true);
// To connect consecutive scroll events into a continuous flow, the animation's duration
// should be longer than scroll events intervals (or else the scroll will stop
// before the next event arrives - we're guessing next interval by averaging recent
// intervals).
// This defines how longer is the duration compared to events interval (percentage)
pref("general.smoothScroll.durationToIntervalRatio", 200);
+// These two prefs determine the timing function.
+pref("general.smoothScroll.currentVelocityWeighting", "0.25");
+pref("general.smoothScroll.stopDecelerationWeighting", "0.4");
pref("profile.confirm_automigration",true);
// profile.migration_behavior determines how the profiles root is set
// 0 - use NS_APP_USER_PROFILES_ROOT_DIR
// 1 - create one based on the NS4.x profile root
// 2 - use, if not empty, profile.migration_directory otherwise same as 0
pref("profile.migration_behavior",0);
pref("profile.migration_directory", "");