Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set sw=2 ts=8 et tw=80 : */
3 : /* This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this
5 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #include "KeyboardScrollAnimation.h"
8 :
9 : #include "gfxPrefs.h"
10 :
11 : namespace mozilla {
12 : namespace layers {
13 :
14 0 : KeyboardScrollAnimation::KeyboardScrollAnimation(AsyncPanZoomController& aApzc,
15 : const nsPoint& aInitialPosition,
16 0 : KeyboardScrollAction::KeyboardScrollActionType aType)
17 0 : : GenericScrollAnimation(aApzc, aInitialPosition)
18 : {
19 0 : switch (aType) {
20 : case KeyboardScrollAction::eScrollCharacter:
21 : case KeyboardScrollAction::eScrollLine: {
22 0 : mOriginMaxMS = clamped(gfxPrefs::LineSmoothScrollMaxDurationMs(), 0, 10000);
23 0 : mOriginMinMS = clamped(gfxPrefs::LineSmoothScrollMinDurationMs(), 0, mOriginMaxMS);
24 0 : break;
25 : }
26 : case KeyboardScrollAction::eScrollPage: {
27 0 : mOriginMaxMS = clamped(gfxPrefs::PageSmoothScrollMaxDurationMs(), 0, 10000);
28 0 : mOriginMinMS = clamped(gfxPrefs::PageSmoothScrollMinDurationMs(), 0, mOriginMaxMS);
29 0 : break;
30 : }
31 : case KeyboardScrollAction::eScrollComplete: {
32 0 : mOriginMaxMS = clamped(gfxPrefs::OtherSmoothScrollMaxDurationMs(), 0, 10000);
33 0 : mOriginMinMS = clamped(gfxPrefs::OtherSmoothScrollMinDurationMs(), 0, mOriginMaxMS);
34 0 : break;
35 : }
36 : }
37 :
38 : // The pref is 100-based int percentage, while mIntervalRatio is 1-based ratio
39 0 : mIntervalRatio = ((double)gfxPrefs::SmoothScrollDurationToIntervalRatio()) / 100.0;
40 0 : mIntervalRatio = std::max(1.0, mIntervalRatio);
41 0 : }
42 :
43 : } // namespace layers
44 : } // namespace mozilla
|