mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 12:51:06 +00:00
Bug 1931447 - Use MOZ_DEFINE_ENUM_CLASS_WITH_BASE_AND_TOSTRING for some scroll related enums. r=botond
Differential Revision: https://phabricator.services.mozilla.com/D229065
This commit is contained in:
parent
7505e73ed0
commit
713419caca
@ -5,6 +5,7 @@
|
||||
#ifndef mozilla_ScrollTypes_h
|
||||
#define mozilla_ScrollTypes_h
|
||||
|
||||
#include "mozilla/DefineEnum.h"
|
||||
#include "mozilla/TypedEnumBits.h"
|
||||
|
||||
// Types used in main-thread scrolling interfaces such as ScrollContainerFrame.
|
||||
@ -41,7 +42,9 @@ namespace mozilla {
|
||||
* scroll is already in progress, the |SmoothMsd| scroll is interrupted without
|
||||
* first scrolling to the destination.
|
||||
*/
|
||||
enum class ScrollMode { Instant, Smooth, SmoothMsd, Normal };
|
||||
MOZ_DEFINE_ENUM_CLASS_WITH_BASE_AND_TOSTRING(ScrollMode, uint8_t,
|
||||
(Instant, Smooth, SmoothMsd,
|
||||
Normal));
|
||||
|
||||
/**
|
||||
* When scrolling by a relative amount, we can choose various units.
|
||||
|
@ -5,61 +5,65 @@
|
||||
#ifndef mozilla_ScrollOrigin_h_
|
||||
#define mozilla_ScrollOrigin_h_
|
||||
|
||||
#include "mozilla/DefineEnum.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
// A scroll origin is a bit of a combination of "what part of the code caused
|
||||
// this scroll" and "what special properties does this scroll have, in the
|
||||
// context of what caused it". See specific comments below.
|
||||
enum class ScrollOrigin : uint8_t {
|
||||
// This is used as an initial value for the "LastScrollOrigin" property on
|
||||
// scrollable frames. It is not intended to be an actual scroll origin, but
|
||||
// a sentinel value that indicates that there was no "last scroll". It is
|
||||
// used similarly for the "LastSmoothScrollOrigin" property, to indicate
|
||||
// no smooth scroll is in progress.
|
||||
None,
|
||||
MOZ_DEFINE_ENUM_CLASS_WITH_BASE_AND_TOSTRING(
|
||||
ScrollOrigin, uint8_t,
|
||||
(
|
||||
// This is used as an initial value for the "LastScrollOrigin" property
|
||||
// on scrollable frames. It is not intended to be an actual scroll
|
||||
// origin, but a sentinel value that indicates that there was no "last
|
||||
// scroll". It is used similarly for the "LastSmoothScrollOrigin"
|
||||
// property, to indicate no smooth scroll is in progress.
|
||||
None,
|
||||
|
||||
// This is a default value that we use when we don't know of a more specific
|
||||
// value that we can use.
|
||||
NotSpecified,
|
||||
// The scroll came from APZ code.
|
||||
Apz,
|
||||
// The scroll came from an attempt at restoring a scroll position saved in
|
||||
// the bfcache or history.
|
||||
Restore,
|
||||
// The scroll came from a "relative" scroll method like ScrollBy, where the
|
||||
// scroll destination is indicated by a delta from the current position
|
||||
// instead of an absolute value.
|
||||
Relative,
|
||||
// The scroll came from an attempt by the main thread to re-clamp the scroll
|
||||
// position after a reflow.
|
||||
Clamp,
|
||||
// This is a default value that we use when we don't know of a more
|
||||
// specific value that we can use.
|
||||
NotSpecified,
|
||||
// The scroll came from APZ code.
|
||||
Apz,
|
||||
// The scroll came from an attempt at restoring a scroll position saved
|
||||
// in the bfcache or history.
|
||||
Restore,
|
||||
// The scroll came from a "relative" scroll method like ScrollBy, where
|
||||
// the scroll destination is indicated by a delta from the current
|
||||
// position instead of an absolute value.
|
||||
Relative,
|
||||
// The scroll came from an attempt by the main thread to re-clamp the
|
||||
// scroll position after a reflow.
|
||||
Clamp,
|
||||
|
||||
// The following scroll origins also are associated with prefs of the form
|
||||
// general.smoothScroll.<origin>(.*)
|
||||
// e.g. general.smoothScroll.lines indicates whether or not a scroll with
|
||||
// origin Lines will be animated smoothly, and e.g. subprefs like
|
||||
// general.smoothScroll.lines.durationMinMS control some of the animation
|
||||
// timing behavior.
|
||||
// The following scroll origins also are associated with prefs of the
|
||||
// form
|
||||
// general.smoothScroll.<origin>(.*)
|
||||
// e.g. general.smoothScroll.lines indicates whether or not a scroll
|
||||
// with origin Lines will be animated smoothly, and e.g. subprefs like
|
||||
// general.smoothScroll.lines.durationMinMS control some of the
|
||||
// animation timing behavior.
|
||||
|
||||
// The scroll came from some sort of input that's not one of the above or
|
||||
// below values. Generally this means it came from a content-exposed API,
|
||||
// like window.scrollTo, but may also be from other sources that don't need
|
||||
// any particular special handling.
|
||||
Other,
|
||||
// The scroll was originated by pixel-scrolling input device (e.g. precision
|
||||
// mouse wheel).
|
||||
Pixels,
|
||||
// The scroll was originated by a line-scrolling input device (e.g. up/down
|
||||
// keyboard buttons).
|
||||
Lines,
|
||||
// The scroll was originated by a page-scrolling input device (e.g. pgup/
|
||||
// pgdn keyboard buttons).
|
||||
Pages,
|
||||
// The scroll was originated by a mousewheel that scrolls by lines.
|
||||
MouseWheel,
|
||||
// The scroll was originated by moving the scrollbars.
|
||||
Scrollbars,
|
||||
};
|
||||
// The scroll came from some sort of input that's not one of the above
|
||||
// or below values. Generally this means it came from a content-exposed
|
||||
// API, like window.scrollTo, but may also be from other sources that
|
||||
// don't need any particular special handling.
|
||||
Other,
|
||||
// The scroll was originated by pixel-scrolling input device (e.g.
|
||||
// precision mouse wheel).
|
||||
Pixels,
|
||||
// The scroll was originated by a line-scrolling input device (e.g.
|
||||
// up/down keyboard buttons).
|
||||
Lines,
|
||||
// The scroll was originated by a page-scrolling input device (e.g.
|
||||
// pgup/ pgdn keyboard buttons).
|
||||
Pages,
|
||||
// The scroll was originated by a mousewheel that scrolls by lines.
|
||||
MouseWheel,
|
||||
// The scroll was originated by moving the scrollbars.
|
||||
Scrollbars));
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
|
@ -128,10 +128,9 @@ CSSPoint ScrollPositionUpdate::GetDelta() const {
|
||||
|
||||
std::ostream& operator<<(std::ostream& aStream,
|
||||
const ScrollPositionUpdate& aUpdate) {
|
||||
aStream << "{ gen=" << aUpdate.mScrollGeneration
|
||||
<< ", type=" << (int)aUpdate.mType
|
||||
<< ", mode=" << (int)aUpdate.mScrollMode
|
||||
<< ", origin=" << (int)aUpdate.mScrollOrigin
|
||||
aStream << "{ gen=" << aUpdate.mScrollGeneration << ", type=" << aUpdate.mType
|
||||
<< ", mode=" << aUpdate.mScrollMode
|
||||
<< ", origin=" << aUpdate.mScrollOrigin
|
||||
<< ", dst=" << aUpdate.mDestination << ", src=" << aUpdate.mSource
|
||||
<< ", delta=" << aUpdate.mDelta
|
||||
<< ", triggered by script=" << aUpdate.WasTriggeredByScript() << " }";
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <iosfwd>
|
||||
|
||||
#include "nsPoint.h"
|
||||
#include "mozilla/DefineEnum.h"
|
||||
#include "mozilla/ScrollGeneration.h"
|
||||
#include "mozilla/ScrollOrigin.h"
|
||||
#include "mozilla/ScrollSnapTargetId.h"
|
||||
@ -22,19 +23,20 @@ struct ParamTraits;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
enum class ScrollUpdateType {
|
||||
// A scroll update to a specific destination, regardless of the current
|
||||
// scroll position.
|
||||
Absolute,
|
||||
// A scroll update by a specific amount, based off a given starting scroll
|
||||
// position. XXX Fold this into PureRelative, it should be relatively
|
||||
// straightforward after bug 1655733.
|
||||
Relative,
|
||||
// A scroll update by a specific amount, where only the delta is provided.
|
||||
// The delta should be applied to whatever the current scroll position is
|
||||
// on the receiver side.
|
||||
PureRelative,
|
||||
};
|
||||
MOZ_DEFINE_ENUM_CLASS_WITH_BASE_AND_TOSTRING(
|
||||
ScrollUpdateType, uint8_t,
|
||||
(
|
||||
// A scroll update to a specific destination, regardless of the current
|
||||
// scroll position.
|
||||
Absolute,
|
||||
// A scroll update by a specific amount, based off a given starting
|
||||
// scroll position. XXX Fold this into PureRelative, it should be
|
||||
// relatively straightforward after bug 1655733.
|
||||
Relative,
|
||||
// A scroll update by a specific amount, where only the delta is
|
||||
// provided. The delta should be applied to whatever the current scroll
|
||||
// position is on the receiver side.
|
||||
PureRelative));
|
||||
|
||||
enum class ScrollTriggeredByScript : bool { No, Yes };
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user