1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 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 "SmoothScrollAnimation.h"
8 #include "ScrollAnimationBezierPhysics.h"
9 #include "mozilla/layers/APZPublicUtils.h"
10 
11 namespace mozilla {
12 namespace layers {
13 
SmoothScrollAnimation(AsyncPanZoomController & aApzc,const nsPoint & aInitialPosition,ScrollOrigin aOrigin)14 SmoothScrollAnimation::SmoothScrollAnimation(AsyncPanZoomController& aApzc,
15                                              const nsPoint& aInitialPosition,
16                                              ScrollOrigin aOrigin)
17     : GenericScrollAnimation(
18           aApzc, aInitialPosition,
19           apz::ComputeBezierAnimationSettingsForOrigin(aOrigin)),
20       mOrigin(aOrigin) {}
21 
AsSmoothScrollAnimation()22 SmoothScrollAnimation* SmoothScrollAnimation::AsSmoothScrollAnimation() {
23   return this;
24 }
25 
GetScrollOrigin() const26 ScrollOrigin SmoothScrollAnimation::GetScrollOrigin() const { return mOrigin; }
27 
GetScrollOriginForAction(KeyboardScrollAction::KeyboardScrollActionType aAction)28 ScrollOrigin SmoothScrollAnimation::GetScrollOriginForAction(
29     KeyboardScrollAction::KeyboardScrollActionType aAction) {
30   switch (aAction) {
31     case KeyboardScrollAction::eScrollCharacter:
32     case KeyboardScrollAction::eScrollLine: {
33       return ScrollOrigin::Lines;
34     }
35     case KeyboardScrollAction::eScrollPage:
36       return ScrollOrigin::Pages;
37     case KeyboardScrollAction::eScrollComplete:
38       return ScrollOrigin::Other;
39     default:
40       MOZ_ASSERT(false, "Unknown keyboard scroll action type");
41       return ScrollOrigin::Other;
42   }
43 }
44 
45 }  // namespace layers
46 }  // namespace mozilla
47