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 "WheelScrollAnimation.h"
8 :
9 : #include "AsyncPanZoomController.h"
10 : #include "gfxPrefs.h"
11 : #include "nsPoint.h"
12 :
13 : namespace mozilla {
14 : namespace layers {
15 :
16 0 : WheelScrollAnimation::WheelScrollAnimation(AsyncPanZoomController& aApzc,
17 : const nsPoint& aInitialPosition,
18 0 : ScrollWheelInput::ScrollDeltaType aDeltaType)
19 0 : : GenericScrollAnimation(aApzc, aInitialPosition)
20 : {
21 0 : mForceVerticalOverscroll = !mApzc.mScrollMetadata.AllowVerticalScrollWithWheel();
22 :
23 0 : switch (aDeltaType) {
24 : case ScrollWheelInput::SCROLLDELTA_PAGE:
25 0 : mOriginMaxMS = clamped(gfxPrefs::PageSmoothScrollMaxDurationMs(), 0, 10000);
26 0 : mOriginMinMS = clamped(gfxPrefs::PageSmoothScrollMinDurationMs(), 0, mOriginMaxMS);
27 0 : break;
28 : case ScrollWheelInput::SCROLLDELTA_PIXEL:
29 0 : mOriginMaxMS = clamped(gfxPrefs::PixelSmoothScrollMaxDurationMs(), 0, 10000);
30 0 : mOriginMinMS = clamped(gfxPrefs::PixelSmoothScrollMinDurationMs(), 0, mOriginMaxMS);
31 0 : break;
32 : case ScrollWheelInput::SCROLLDELTA_LINE:
33 0 : mOriginMaxMS = clamped(gfxPrefs::WheelSmoothScrollMaxDurationMs(), 0, 10000);
34 0 : mOriginMinMS = clamped(gfxPrefs::WheelSmoothScrollMinDurationMs(), 0, mOriginMaxMS);
35 0 : break;
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
|