ScrollTypes.h (2884B)
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 #include "mozilla/DefineEnum.h" 9 #include "mozilla/TypedEnumBits.h" 10 11 // Types used in main-thread scrolling interfaces such as ScrollContainerFrame. 12 13 namespace mozilla { 14 15 /** 16 * Scroll modes for main-thread scroll operations. These are mostly used 17 * by ScrollContainerFrame methods. 18 * 19 * When a scroll operation is requested, we ask for instant, smooth, 20 * smooth msd, or normal scrolling. 21 * 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. 27 * 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. 34 * 35 * |Instant| is always synchronous, |Normal| can be asynchronous. 36 * 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. 40 * 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. 44 */ 45 MOZ_DEFINE_ENUM_CLASS_WITH_BASE_AND_TOSTRING(ScrollMode, uint8_t, 46 (Instant, Smooth, SmoothMsd, 47 Normal)); 48 49 /** 50 * When scrolling by a relative amount, we can choose various units. 51 */ 52 enum class ScrollUnit { DEVICE_PIXELS, LINES, PAGES, WHOLE }; 53 54 /** 55 * Representing whether there's an on-going animation in APZC and it was 56 * triggered by script or by user input. 57 */ 58 enum class APZScrollAnimationType { 59 No, // No animation. 60 TriggeredByScript, // Animation triggered by script. 61 TriggeredByUserInput // Animation triggered by user input. 62 }; 63 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 70 }; 71 72 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(ScrollSnapFlags); 73 74 } // namespace mozilla 75 76 #endif // mozilla_ScrollTypes_h