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_ScrollOrigin_h_
6 #define mozilla_ScrollOrigin_h_
7 
8 namespace mozilla {
9 
10 // A scroll origin is a bit of a combination of "what part of the code caused
11 // this scroll" and "what special properties does this scroll have, in the
12 // context of what caused it". See specific comments below.
13 enum class ScrollOrigin : uint8_t {
14   // This is used as an initial value for the "LastScrollOrigin" property on
15   // scrollable frames. It is not intended to be an actual scroll origin, but
16   // a sentinel value that indicates that there was no "last scroll". It is
17   // used similarly for the "LastSmoothScrollOrigin" property, to indicate
18   // no smooth scroll is in progress.
19   None,
20 
21   // This is a default value that we use when we don't know of a more specific
22   // value that we can use.
23   NotSpecified,
24   // The scroll came from APZ code.
25   Apz,
26   // The scroll came from an attempt at restoring a scroll position saved in
27   // the bfcache or history.
28   Restore,
29   // The scroll came from a "relative" scroll method like ScrollBy, where the
30   // scroll destination is indicated by a delta from the current position
31   // instead of an absolute value.
32   Relative,
33   // The scroll came from an attempt by the main thread to re-clamp the scroll
34   // position after a reflow.
35   Clamp,
36 
37   // The following scroll origins also are associated with prefs of the form
38   //   general.smoothScroll.<origin>(.*)
39   // e.g. general.smoothScroll.lines indicates whether or not a scroll with
40   // origin Lines will be animated smoothly, and e.g. subprefs like
41   // general.smoothScroll.lines.durationMinMS control some of the animation
42   // timing behavior.
43 
44   // The scroll came from some sort of input that's not one of the above or
45   // below values. Generally this means it came from a content-exposed API,
46   // like window.scrollTo, but may also be from other sources that don't need
47   // any particular special handling.
48   Other,
49   // The scroll was originated by pixel-scrolling input device (e.g. precision
50   // mouse wheel).
51   Pixels,
52   // The scroll was originated by a line-scrolling input device (e.g. up/down
53   // keyboard buttons).
54   Lines,
55   // The scroll was originated by a page-scrolling input device (e.g. pgup/
56   // pgdn keyboard buttons).
57   Pages,
58   // The scroll was originated by a mousewheel that scrolls by lines.
59   MouseWheel,
60   // The scroll was originated by moving the scrollbars.
61   Scrollbars,
62 };
63 
64 }  // namespace mozilla
65 
66 #endif  // mozilla_ScrollOrigin_h_
67