1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 
5 #ifndef mozilla_ScrollTypes_h
6 #define mozilla_ScrollTypes_h
7 
8 // Types used in main-thread scrolling interfaces such as nsIScrollableFrame.
9 
10 namespace mozilla {
11 
12 /**
13  * Scroll modes for main-thread scroll operations. These are mostly used
14  * by nsIScrollableFrame methods.
15  *
16  * When a scroll operation is requested, we ask for instant, smooth,
17  * smooth msd, or normal scrolling.
18  *
19  * |eSmooth| scrolls have a symmetrical acceleration and deceleration curve
20  * modeled with a set of splines that guarantee that the destination will be
21  * reached over a fixed time interval.  |eSmooth| will only be smooth if smooth
22  * scrolling is actually enabled.  This behavior is utilized by keyboard and
23  * mouse wheel scrolling events.
24  *
25  * |eSmoothMsd| implements a physically based model that approximates the
26  * behavior of a mass-spring-damper system.  |eSmoothMsd| scrolls have a
27  * non-symmetrical acceleration and deceleration curve, can potentially
28  * overshoot the destination on intermediate frames, and complete over a
29  * variable time interval.  |eSmoothMsd| will only be smooth if cssom-view
30  * smooth-scrolling is enabled.
31  *
32  * |eInstant| is always synchronous, |eNormal| can be asynchronous.
33  *
34  * If an |eInstant| scroll request happens while a |eSmooth| or async scroll is
35  * already in progress, the async scroll is interrupted and we instantly
36  * scroll to the destination.
37  *
38  * If an |eInstant| or |eSmooth| scroll request happens while a |eSmoothMsd|
39  * scroll is already in progress, the |eSmoothMsd| scroll is interrupted without
40  * first scrolling to the destination.
41  */
42 enum class ScrollMode { Instant, Smooth, SmoothMsd, Normal };
43 
44 /**
45  * When scrolling by a relative amount, we can choose various units.
46  */
47 enum class ScrollUnit { DEVICE_PIXELS, LINES, PAGES, WHOLE };
48 
49 }  // namespace mozilla
50 
51 #endif  // mozilla_ScrollTypes_h
52