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/. */
7 #ifndef mozilla_layout_ScrollAnimationPhysics_h_
8 #define mozilla_layout_ScrollAnimationPhysics_h_
10 #include "mozilla/TimeStamp.h"
16 class ScrollAnimationPhysics
{
18 virtual void Update(const TimeStamp
& aTime
, const nsPoint
& aDestination
,
19 const nsSize
& aCurrentVelocity
) = 0;
21 virtual void ApplyContentShift(const CSSPoint
& aShiftDelta
) = 0;
23 // Get the velocity at a point in time in nscoords/sec.
24 virtual nsSize
VelocityAt(const TimeStamp
& aTime
) = 0;
26 // Returns the expected scroll position at a given point in time, in app
27 // units, relative to the scroll frame.
28 virtual nsPoint
PositionAt(const TimeStamp
& aTime
) = 0;
30 virtual bool IsFinished(const TimeStamp
& aTime
) = 0;
32 virtual ~ScrollAnimationPhysics() = default;
35 // Helper for accelerated wheel deltas. This can be called from the main thread
36 // or the APZ Controller thread.
37 static inline double ComputeAcceleratedWheelDelta(double aDelta
,
43 return (aDelta
* aCounter
* double(aFactor
) / 10);
46 static const uint32_t kScrollSeriesTimeoutMs
= 80; // in milliseconds
48 } // namespace mozilla
50 #endif // mozilla_layout_ScrollAnimationPhysics_h_