Backed out changeset b71c8c052463 (bug 1943846) for causing mass failures. CLOSED...
[gecko.git] / layout / base / ScrollTypes.h
blob5db29d0962cb21d4eb84422996355190b3ce31b3
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/. */
5 #ifndef mozilla_ScrollTypes_h
6 #define mozilla_ScrollTypes_h
8 #include "mozilla/DefineEnum.h"
9 #include "mozilla/TypedEnumBits.h"
11 // Types used in main-thread scrolling interfaces such as ScrollContainerFrame.
13 namespace mozilla {
15 /**
16 * Scroll modes for main-thread scroll operations. These are mostly used
17 * by ScrollContainerFrame methods.
19 * When a scroll operation is requested, we ask for instant, smooth,
20 * smooth msd, or normal scrolling.
22 * |Smooth| scrolls have a symmetrical acceleration and deceleration curve
23 * modeled with a set of splines that guarantee that the destination will be
24 * reached over a fixed time interval. |Smooth| will only be smooth if smooth
25 * scrolling is actually enabled. This behavior is utilized by keyboard and
26 * mouse wheel scrolling events.
28 * |SmoothMsd| implements a physically based model that approximates the
29 * behavior of a mass-spring-damper system. |SmoothMsd| scrolls have a
30 * non-symmetrical acceleration and deceleration curve, can potentially
31 * overshoot the destination on intermediate frames, and complete over a
32 * variable time interval. |SmoothMsd| will only be smooth if cssom-view
33 * smooth-scrolling is enabled.
35 * |Instant| is always synchronous, |Normal| can be asynchronous.
37 * If an |Instant| scroll request happens while a |Smooth| or async scroll is
38 * already in progress, the async scroll is interrupted and we instantly
39 * scroll to the destination.
41 * If an |Instant| or |Smooth| scroll request happens while a |SmoothMsd|
42 * scroll is already in progress, the |SmoothMsd| scroll is interrupted without
43 * first scrolling to the destination.
45 MOZ_DEFINE_ENUM_CLASS_WITH_BASE_AND_TOSTRING(ScrollMode, uint8_t,
46 (Instant, Smooth, SmoothMsd,
47 Normal));
49 /**
50 * When scrolling by a relative amount, we can choose various units.
52 enum class ScrollUnit { DEVICE_PIXELS, LINES, PAGES, WHOLE };
54 /**
55 * Representing whether there's an on-going animation in APZC and it was
56 * triggered by script or by user input.
58 enum class APZScrollAnimationType {
59 No, // No animation.
60 TriggeredByScript, // Animation triggered by script.
61 TriggeredByUserInput // Animation triggered by user input.
64 enum class ScrollSnapFlags : uint8_t {
65 Disabled = 0,
66 // https://drafts.csswg.org/css-scroll-snap/#intended-end-position
67 IntendedEndPosition = 1 << 0,
68 // https://drafts.csswg.org/css-scroll-snap/#intended-direction
69 IntendedDirection = 1 << 1
72 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(ScrollSnapFlags);
74 } // namespace mozilla
76 #endif // mozilla_ScrollTypes_h