Bug 1199468 - Create prefs for the smooth scroll timing function shape. r=kats

This commit is contained in:
Markus Stange 2016-01-07 21:09:18 +01:00
parent 7371eb3c6a
commit a5ff2e34ea
3 changed files with 13 additions and 8 deletions

View File

@ -204,6 +204,8 @@ private:
DECL_GFX_PREF(Live, "dom.w3c_touch_events.enabled", TouchEventsEnabled, int32_t, 0);
DECL_GFX_PREF(Live, "general.smoothScroll", SmoothScrollEnabled, bool, true);
DECL_GFX_PREF(Live, "general.smoothScroll.currentVelocityWeighting",
SmoothScrollCurrentVelocityWeighting, float, 0.25);
DECL_GFX_PREF(Live, "general.smoothScroll.durationToIntervalRatio",
SmoothScrollDurationToIntervalRatio, int32_t, 200);
DECL_GFX_PREF(Live, "general.smoothScroll.mouseWheel", WheelSmoothScrollEnabled, bool, true);
@ -211,6 +213,8 @@ private:
WheelSmoothScrollMaxDurationMs, int32_t, 400);
DECL_GFX_PREF(Live, "general.smoothScroll.mouseWheel.durationMinMS",
WheelSmoothScrollMinDurationMs, int32_t, 200);
DECL_GFX_PREF(Live, "general.smoothScroll.stopDecelerationWeighting",
SmoothScrollStopDecelerationWeighting, float, 0.4f);
DECL_GFX_PREF(Once, "gfx.android.rgb16.force", AndroidRGB16Force, bool, false);
#if defined(ANDROID)

View File

@ -4,6 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "AsyncScrollBase.h"
#include "gfxPrefs.h"
using namespace mozilla;
@ -77,26 +78,23 @@ AsyncScrollBase::InitializeHistory(TimeStamp aTime)
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

View File

@ -2127,6 +2127,9 @@ pref("general.smoothScroll.other", true);
// 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