Bug 1602088 - Move nsIScrollableFrame::ScrollUnit to namespace scope. r=botond
authorKousuke Takaki <u7693@protonmail.com>
Thu, 30 Jan 2020 09:13:19 +0000
changeset 512141 4ba3576a07615d1dadedf55d3cbdb9bee0df8a33
parent 512140 1343555236b2ea97b1786c0635973f64c21c3213
child 512142 36440af6bb5a480223db693863b49dc1a6f3fdb7
push id106212
push usercsabou@mozilla.com
push dateThu, 30 Jan 2020 13:03:26 +0000
treeherderautoland@36440af6bb5a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1602088
milestone74.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1602088 - Move nsIScrollableFrame::ScrollUnit to namespace scope. r=botond Differential Revision: https://phabricator.services.mozilla.com/D61140
dom/base/nsGlobalWindowInner.cpp
dom/events/EventStateManager.cpp
dom/html/TextControlState.cpp
gfx/layers/apz/src/AsyncPanZoomController.cpp
gfx/layers/apz/src/AsyncPanZoomController.h
gfx/layers/apz/src/KeyboardScrollAction.cpp
gfx/layers/apz/src/KeyboardScrollAction.h
layout/base/PresShell.cpp
layout/base/ScrollTypes.h
layout/generic/ScrollSnap.cpp
layout/generic/ScrollSnap.h
layout/generic/nsFrameSelection.cpp
layout/generic/nsGfxScrollFrame.cpp
layout/generic/nsGfxScrollFrame.h
layout/generic/nsIScrollableFrame.h
widget/InputData.cpp
widget/InputData.h
--- a/dom/base/nsGlobalWindowInner.cpp
+++ b/dom/base/nsGlobalWindowInner.cpp
@@ -3654,35 +3654,33 @@ void nsGlobalWindowInner::ScrollByLines(
   if (sf) {
     // It seems like it would make more sense for ScrollByLines to use
     // SMOOTH mode, but tests seem to depend on the synchronous behaviour.
     // Perhaps Web content does too.
     ScrollMode scrollMode = sf->IsSmoothScroll(aOptions.mBehavior)
                                 ? ScrollMode::SmoothMsd
                                 : ScrollMode::Instant;
 
-    sf->ScrollBy(nsIntPoint(0, numLines), nsIScrollableFrame::LINES,
-                 scrollMode);
+    sf->ScrollBy(nsIntPoint(0, numLines), ScrollUnit::LINES, scrollMode);
   }
 }
 
 void nsGlobalWindowInner::ScrollByPages(int32_t numPages,
                                         const ScrollOptions& aOptions) {
   FlushPendingNotifications(FlushType::Layout);
   nsIScrollableFrame* sf = GetScrollFrame();
   if (sf) {
     // It seems like it would make more sense for ScrollByPages to use
     // SMOOTH mode, but tests seem to depend on the synchronous behaviour.
     // Perhaps Web content does too.
     ScrollMode scrollMode = sf->IsSmoothScroll(aOptions.mBehavior)
                                 ? ScrollMode::SmoothMsd
                                 : ScrollMode::Instant;
 
-    sf->ScrollBy(nsIntPoint(0, numPages), nsIScrollableFrame::PAGES,
-                 scrollMode);
+    sf->ScrollBy(nsIntPoint(0, numPages), ScrollUnit::PAGES, scrollMode);
   }
 }
 
 void nsGlobalWindowInner::MozScrollSnap() {
   FlushPendingNotifications(FlushType::Layout);
   nsIScrollableFrame* sf = GetScrollFrame();
   if (sf) {
     sf->ScrollSnap();
--- a/dom/events/EventStateManager.cpp
+++ b/dom/events/EventStateManager.cpp
@@ -2851,18 +2851,18 @@ void EventStateManager::DoScrollText(nsI
   }
 
   nsIScrollableFrame::ScrollMomentum momentum =
       aEvent->mIsMomentum ? nsIScrollableFrame::SYNTHESIZED_MOMENTUM_EVENT
                           : nsIScrollableFrame::NOT_MOMENTUM;
 
   nsIntPoint overflow;
   aScrollableFrame->ScrollBy(actualDevPixelScrollAmount,
-                             nsIScrollableFrame::DEVICE_PIXELS, mode, &overflow,
-                             origin, momentum, snapMode);
+                             ScrollUnit::DEVICE_PIXELS, mode, &overflow, origin,
+                             momentum, snapMode);
 
   if (!scrollFrameWeak.IsAlive()) {
     // If the scroll causes changing the layout, we can think that the event
     // has been completely consumed by the content.  Then, users probably don't
     // want additional action.
     aEvent->mOverflowDeltaX = aEvent->mOverflowDeltaY = 0;
   } else if (isDeltaModePixel) {
     aEvent->mOverflowDeltaX = overflow.x;
@@ -5869,26 +5869,26 @@ nsresult EventStateManager::DoContentCom
 
 nsresult EventStateManager::DoContentCommandScrollEvent(
     WidgetContentCommandEvent* aEvent) {
   NS_ENSURE_TRUE(mPresContext, NS_ERROR_NOT_AVAILABLE);
   PresShell* presShell = mPresContext->GetPresShell();
   NS_ENSURE_TRUE(presShell, NS_ERROR_NOT_AVAILABLE);
   NS_ENSURE_TRUE(aEvent->mScroll.mAmount != 0, NS_ERROR_INVALID_ARG);
 
-  nsIScrollableFrame::ScrollUnit scrollUnit;
+  ScrollUnit scrollUnit;
   switch (aEvent->mScroll.mUnit) {
     case WidgetContentCommandEvent::eCmdScrollUnit_Line:
-      scrollUnit = nsIScrollableFrame::LINES;
+      scrollUnit = ScrollUnit::LINES;
       break;
     case WidgetContentCommandEvent::eCmdScrollUnit_Page:
-      scrollUnit = nsIScrollableFrame::PAGES;
+      scrollUnit = ScrollUnit::PAGES;
       break;
     case WidgetContentCommandEvent::eCmdScrollUnit_Whole:
-      scrollUnit = nsIScrollableFrame::WHOLE;
+      scrollUnit = ScrollUnit::WHOLE;
       break;
     default:
       return NS_ERROR_INVALID_ARG;
   }
 
   aEvent->mSucceeded = true;
 
   nsIScrollableFrame* sf =
--- a/dom/html/TextControlState.cpp
+++ b/dom/html/TextControlState.cpp
@@ -40,16 +40,17 @@
 #include "mozilla/dom/Text.h"
 #include "mozilla/StaticPrefs_dom.h"
 #include "nsFrameSelection.h"
 #include "mozilla/ErrorResult.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/ShortcutKeys.h"
 #include "mozilla/KeyEventHandler.h"
 #include "mozilla/dom/KeyboardEvent.h"
+#include "mozilla/ScrollTypes.h"
 
 namespace mozilla {
 
 using namespace dom;
 
 /*****************************************************************************
  * TextControlElement
  *****************************************************************************/
@@ -680,18 +681,18 @@ TextInputSelectionController::PageMove(b
           nsISelectionController::SCROLL_FOR_CARET_MOVE);
 }
 
 NS_IMETHODIMP
 TextInputSelectionController::CompleteScroll(bool aForward) {
   if (!mScrollFrame) {
     return NS_ERROR_NOT_INITIALIZED;
   }
-  mScrollFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1),
-                         nsIScrollableFrame::WHOLE, ScrollMode::Instant);
+  mScrollFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1), ScrollUnit::WHOLE,
+                         ScrollMode::Instant);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 TextInputSelectionController::CompleteMove(bool aForward, bool aExtend) {
   if (NS_WARN_IF(!mFrameSelection)) {
     return NS_ERROR_NULL_POINTER;
   }
@@ -728,38 +729,38 @@ TextInputSelectionController::CompleteMo
   return CompleteScroll(aForward);
 }
 
 NS_IMETHODIMP
 TextInputSelectionController::ScrollPage(bool aForward) {
   if (!mScrollFrame) {
     return NS_ERROR_NOT_INITIALIZED;
   }
-  mScrollFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1),
-                         nsIScrollableFrame::PAGES, ScrollMode::Smooth);
+  mScrollFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1), ScrollUnit::PAGES,
+                         ScrollMode::Smooth);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 TextInputSelectionController::ScrollLine(bool aForward) {
   if (!mScrollFrame) {
     return NS_ERROR_NOT_INITIALIZED;
   }
-  mScrollFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1),
-                         nsIScrollableFrame::LINES, ScrollMode::Smooth);
+  mScrollFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1), ScrollUnit::LINES,
+                         ScrollMode::Smooth);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 TextInputSelectionController::ScrollCharacter(bool aRight) {
   if (!mScrollFrame) {
     return NS_ERROR_NOT_INITIALIZED;
   }
-  mScrollFrame->ScrollBy(nsIntPoint(aRight ? 1 : -1, 0),
-                         nsIScrollableFrame::LINES, ScrollMode::Smooth);
+  mScrollFrame->ScrollBy(nsIntPoint(aRight ? 1 : -1, 0), ScrollUnit::LINES,
+                         ScrollMode::Smooth);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 TextInputSelectionController::SelectAll() {
   if (!mFrameSelection) {
     return NS_ERROR_NULL_POINTER;
   }
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -40,16 +40,17 @@
 #include "mozilla/ClearOnShutdown.h"    // for ClearOnShutdown
 #include "mozilla/ComputedTimingFunction.h"  // for ComputedTimingFunction
 #include "mozilla/EventForwards.h"           // for nsEventStatus_*
 #include "mozilla/EventStateManager.h"       // for EventStateManager
 #include "mozilla/MouseEvents.h"             // for WidgetWheelEvent
 #include "mozilla/Preferences.h"             // for Preferences
 #include "mozilla/RecursiveMutex.h"          // for RecursiveMutexAutoLock, etc
 #include "mozilla/RefPtr.h"                  // for RefPtr
+#include "mozilla/ScrollTypes.h"
 #include "mozilla/StaticPrefs_apz.h"
 #include "mozilla/StaticPrefs_general.h"
 #include "mozilla/StaticPrefs_gfx.h"
 #include "mozilla/StaticPrefs_mousewheel.h"
 #include "mozilla/StaticPrefs_layers.h"
 #include "mozilla/StaticPrefs_layout.h"
 #include "mozilla/StaticPrefs_slider.h"
 #include "mozilla/StaticPrefs_test.h"
@@ -5285,17 +5286,17 @@ void AsyncPanZoomController::SetTestAsyn
 
 void AsyncPanZoomController::SetTestAsyncZoom(
     const LayerToParentLayerScale& aZoom) {
   mTestAsyncZoom = aZoom;
   ScheduleComposite();
 }
 
 Maybe<CSSPoint> AsyncPanZoomController::FindSnapPointNear(
-    const CSSPoint& aDestination, nsIScrollableFrame::ScrollUnit aUnit) {
+    const CSSPoint& aDestination, ScrollUnit aUnit) {
   mRecursiveMutex.AssertCurrentThreadIn();
   APZC_LOG("%p scroll snapping near %s\n", this,
            Stringify(aDestination).c_str());
   CSSRect scrollRange = Metrics().CalculateScrollRange();
   if (Maybe<nsPoint> snapPoint = ScrollSnapUtils::GetSnapPointForDestination(
           mScrollMetadata.GetSnapInfo(), aUnit,
           CSSRect::ToAppUnits(scrollRange),
           CSSPoint::ToAppUnits(Metrics().GetScrollOffset()),
@@ -5307,17 +5308,17 @@ Maybe<CSSPoint> AsyncPanZoomController::
     // nsGfxScrollFrame::ScrollTo()).
     return Some(scrollRange.ClampPoint(cssSnapPoint));
   }
   return Nothing();
 }
 
 void AsyncPanZoomController::ScrollSnapNear(const CSSPoint& aDestination) {
   if (Maybe<CSSPoint> snapPoint =
-          FindSnapPointNear(aDestination, nsIScrollableFrame::DEVICE_PIXELS)) {
+          FindSnapPointNear(aDestination, ScrollUnit::DEVICE_PIXELS)) {
     if (*snapPoint != Metrics().GetScrollOffset()) {
       APZC_LOG("%p smooth scrolling to snap point %s\n", this,
                Stringify(*snapPoint).c_str());
       SmoothScrollTo(*snapPoint);
     }
   }
 }
 
@@ -5346,34 +5347,33 @@ void AsyncPanZoomController::ScrollSnapT
   bool flingWillOverscroll =
       IsOverscrolled() && ((velocity.x * mX.GetOverscroll() >= 0) ||
                            (velocity.y * mY.GetOverscroll() >= 0));
   if (flingWillOverscroll) {
     return;
   }
 
   CSSPoint startPosition = Metrics().GetScrollOffset();
-  if (MaybeAdjustDeltaForScrollSnapping(nsIScrollableFrame::LINES,
-                                        predictedDelta, startPosition)) {
+  if (MaybeAdjustDeltaForScrollSnapping(ScrollUnit::LINES, predictedDelta,
+                                        startPosition)) {
     APZC_LOG(
         "%p fling snapping.  friction: %f velocity: %f, %f "
         "predictedDelta: %f, %f position: %f, %f "
         "snapDestination: %f, %f\n",
         this, friction, velocity.x, velocity.y, (float)predictedDelta.x,
         (float)predictedDelta.y, (float)Metrics().GetScrollOffset().x,
         (float)Metrics().GetScrollOffset().y, (float)startPosition.x,
         (float)startPosition.y);
 
     SmoothScrollTo(startPosition);
   }
 }
 
 bool AsyncPanZoomController::MaybeAdjustDeltaForScrollSnapping(
-    nsIScrollableFrame::ScrollUnit aUnit, ParentLayerPoint& aDelta,
-    CSSPoint& aStartPosition) {
+    ScrollUnit aUnit, ParentLayerPoint& aDelta, CSSPoint& aStartPosition) {
   RecursiveMutexAutoLock lock(mRecursiveMutex);
   CSSToParentLayerScale2D zoom = Metrics().GetZoom();
   CSSPoint destination = Metrics().CalculateScrollRange().ClampPoint(
       aStartPosition + (aDelta / zoom));
 
   if (Maybe<CSSPoint> snapPoint = FindSnapPointNear(destination, aUnit)) {
     aDelta = (*snapPoint - aStartPosition) * zoom;
     aStartPosition = *snapPoint;
@@ -5394,18 +5394,17 @@ bool AsyncPanZoomController::MaybeAdjust
   return MaybeAdjustDeltaForScrollSnapping(
       ScrollWheelInput::ScrollUnitForDeltaType(aEvent.mDeltaType), aDelta,
       aStartPosition);
 }
 
 bool AsyncPanZoomController::MaybeAdjustDestinationForScrollSnapping(
     const KeyboardInput& aEvent, CSSPoint& aDestination) {
   RecursiveMutexAutoLock lock(mRecursiveMutex);
-  nsIScrollableFrame::ScrollUnit unit =
-      KeyboardScrollAction::GetScrollUnit(aEvent.mAction.mType);
+  ScrollUnit unit = KeyboardScrollAction::GetScrollUnit(aEvent.mAction.mType);
 
   if (Maybe<CSSPoint> snapPoint = FindSnapPointNear(aDestination, unit)) {
     aDestination = *snapPoint;
     return true;
   }
   return false;
 }
 
--- a/gfx/layers/apz/src/AsyncPanZoomController.h
+++ b/gfx/layers/apz/src/AsyncPanZoomController.h
@@ -12,26 +12,26 @@
 #include "mozilla/layers/RepaintRequest.h"
 #include "mozilla/layers/ZoomConstraints.h"
 #include "mozilla/Atomics.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/EventForwards.h"
 #include "mozilla/Monitor.h"
 #include "mozilla/RecursiveMutex.h"
 #include "mozilla/RefPtr.h"
+#include "mozilla/ScrollTypes.h"
 #include "mozilla/StaticPrefs_apz.h"
 #include "mozilla/UniquePtr.h"
 #include "InputData.h"
 #include "Axis.h"  // for Axis, Side, etc.
 #include "InputQueue.h"
 #include "APZUtils.h"
 #include "Layers.h"  // for Layer::ScrollDirection
 #include "LayersTypes.h"
 #include "mozilla/gfx/Matrix.h"
-#include "nsIScrollableFrame.h"
 #include "nsRegion.h"
 #include "nsTArray.h"
 #include "PotentialCheckerboardDurationTracker.h"
 #include "RecentEventsBuffer.h"  // for RecentEventsBuffer
 
 #include "base/message_loop.h"
 
 namespace mozilla {
@@ -1676,17 +1676,17 @@ class AsyncPanZoomController {
   // If moving |aStartPosition| by |aDelta| should trigger scroll snapping,
   // adjust |aDelta| to reflect the snapping (that is, make it a delta that will
   // take us to the desired snap point). The delta is interpreted as being
   // relative to |aStartPosition|, and if a target snap point is found,
   // |aStartPosition| is also updated, to the value of the snap point.
   // |aUnit| affects the snapping behaviour (see ScrollSnapUtils::
   // GetSnapPointForDestination).
   // Returns true iff. a target snap point was found.
-  bool MaybeAdjustDeltaForScrollSnapping(nsIScrollableFrame::ScrollUnit aUnit,
+  bool MaybeAdjustDeltaForScrollSnapping(ScrollUnit aUnit,
                                          ParentLayerPoint& aDelta,
                                          CSSPoint& aStartPosition);
 
   // A wrapper function of MaybeAdjustDeltaForScrollSnapping for
   // ScrollWheelInput.
   bool MaybeAdjustDeltaForScrollSnappingOnWheelInput(
       const ScrollWheelInput& aEvent, ParentLayerPoint& aDelta,
       CSSPoint& aStartPosition);
@@ -1705,15 +1705,15 @@ class AsyncPanZoomController {
   void ScrollSnapNear(const CSSPoint& aDestination);
 
   // Find a snap point near |aDestination| that we should snap to.
   // Returns the snap point if one was found, or an empty Maybe otherwise.
   // |aUnit| affects the snapping behaviour (see ScrollSnapUtils::
   // GetSnapPointForDestination). It should generally be determined by the
   // type of event that's triggering the scroll.
   Maybe<CSSPoint> FindSnapPointNear(const CSSPoint& aDestination,
-                                    nsIScrollableFrame::ScrollUnit aUnit);
+                                    ScrollUnit aUnit);
 };
 
 }  // namespace layers
 }  // namespace mozilla
 
 #endif  // mozilla_layers_PanZoomController_h
--- a/gfx/layers/apz/src/KeyboardScrollAction.cpp
+++ b/gfx/layers/apz/src/KeyboardScrollAction.cpp
@@ -4,31 +4,31 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/layers/KeyboardScrollAction.h"
 
 namespace mozilla {
 namespace layers {
 
-/* static */ nsIScrollableFrame::ScrollUnit KeyboardScrollAction::GetScrollUnit(
+/* static */ ScrollUnit KeyboardScrollAction::GetScrollUnit(
     KeyboardScrollAction::KeyboardScrollActionType aDeltaType) {
   switch (aDeltaType) {
     case KeyboardScrollAction::eScrollCharacter:
-      return nsIScrollableFrame::LINES;
+      return ScrollUnit::LINES;
     case KeyboardScrollAction::eScrollLine:
-      return nsIScrollableFrame::LINES;
+      return ScrollUnit::LINES;
     case KeyboardScrollAction::eScrollPage:
-      return nsIScrollableFrame::PAGES;
+      return ScrollUnit::PAGES;
     case KeyboardScrollAction::eScrollComplete:
-      return nsIScrollableFrame::WHOLE;
+      return ScrollUnit::WHOLE;
   }
 
   // Silence an overzealous warning
-  return nsIScrollableFrame::WHOLE;
+  return ScrollUnit::WHOLE;
 }
 
 KeyboardScrollAction::KeyboardScrollAction()
     : mType(KeyboardScrollAction::eScrollCharacter), mForward(false) {}
 
 KeyboardScrollAction::KeyboardScrollAction(KeyboardScrollActionType aType,
                                            bool aForward)
     : mType(aType), mForward(aForward) {}
--- a/gfx/layers/apz/src/KeyboardScrollAction.h
+++ b/gfx/layers/apz/src/KeyboardScrollAction.h
@@ -2,18 +2,18 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_layers_KeyboardScrollAction_h
 #define mozilla_layers_KeyboardScrollAction_h
 
+#include "mozilla/ScrollTypes.h"
 #include "mozilla/DefineEnum.h"  // for MOZ_DEFINE_ENUM
-#include "nsIScrollableFrame.h"  // for nsIScrollableFrame::ScrollUnit
 
 namespace mozilla {
 namespace layers {
 
 /**
  * This class represents a scrolling action to be performed on a scrollable
  * layer.
  */
@@ -24,18 +24,17 @@ struct KeyboardScrollAction final {
     KeyboardScrollActionType, uint8_t, (
       eScrollCharacter,
       eScrollLine,
       eScrollPage,
       eScrollComplete
   ));
   // clang-format on
 
-  static nsIScrollableFrame::ScrollUnit GetScrollUnit(
-      KeyboardScrollActionType aDeltaType);
+  static ScrollUnit GetScrollUnit(KeyboardScrollActionType aDeltaType);
 
   KeyboardScrollAction();
   KeyboardScrollAction(KeyboardScrollActionType aType, bool aForward);
 
   // The type of scroll to perform for this action
   KeyboardScrollActionType mType;
   // Whether to scroll forward or backward along the axis of this action type
   bool mForward;
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -181,16 +181,17 @@
 #include "nsSubDocumentFrame.h"
 #include "nsQueryObject.h"
 #include "mozilla/GlobalStyleSheetCache.h"
 #include "mozilla/layers/InputAPZContext.h"
 #include "mozilla/layers/FocusTarget.h"
 #include "mozilla/layers/WebRenderLayerManager.h"
 #include "mozilla/layers/WebRenderUserData.h"
 #include "mozilla/layout/ScrollAnchorContainer.h"
+#include "mozilla/ScrollTypes.h"
 #include "mozilla/ServoBindings.h"
 #include "mozilla/ServoStyleSet.h"
 #include "mozilla/StyleSheet.h"
 #include "mozilla/StyleSheetInlines.h"
 #include "mozilla/dom/ImageTracker.h"
 #include "nsIDocShellTreeOwner.h"
 #include "nsClassHashtable.h"
 #include "nsHashKeys.h"
@@ -2246,64 +2247,64 @@ PresShell::PageMove(bool aForward, bool 
       aForward, aExtend, frame, nsFrameSelection::SelectionIntoView::IfChanged);
 }
 
 NS_IMETHODIMP
 PresShell::ScrollPage(bool aForward) {
   nsIScrollableFrame* scrollFrame =
       GetScrollableFrameToScroll(ScrollableDirection::Vertical);
   if (scrollFrame) {
-    scrollFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1),
-                          nsIScrollableFrame::PAGES, ScrollMode::Smooth,
-                          nullptr, nullptr, nsIScrollableFrame::NOT_MOMENTUM,
+    scrollFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1), ScrollUnit::PAGES,
+                          ScrollMode::Smooth, nullptr, nullptr,
+                          nsIScrollableFrame::NOT_MOMENTUM,
                           nsIScrollableFrame::ENABLE_SNAP);
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PresShell::ScrollLine(bool aForward) {
   nsIScrollableFrame* scrollFrame =
       GetScrollableFrameToScroll(ScrollableDirection::Vertical);
   if (scrollFrame) {
     int32_t lineCount =
         Preferences::GetInt("toolkit.scrollbox.verticalScrollDistance",
                             NS_DEFAULT_VERTICAL_SCROLL_DISTANCE);
     scrollFrame->ScrollBy(nsIntPoint(0, aForward ? lineCount : -lineCount),
-                          nsIScrollableFrame::LINES, ScrollMode::Smooth,
-                          nullptr, nullptr, nsIScrollableFrame::NOT_MOMENTUM,
+                          ScrollUnit::LINES, ScrollMode::Smooth, nullptr,
+                          nullptr, nsIScrollableFrame::NOT_MOMENTUM,
                           nsIScrollableFrame::ENABLE_SNAP);
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PresShell::ScrollCharacter(bool aRight) {
   nsIScrollableFrame* scrollFrame =
       GetScrollableFrameToScroll(ScrollableDirection::Horizontal);
   if (scrollFrame) {
     int32_t h =
         Preferences::GetInt("toolkit.scrollbox.horizontalScrollDistance",
                             NS_DEFAULT_HORIZONTAL_SCROLL_DISTANCE);
-    scrollFrame->ScrollBy(nsIntPoint(aRight ? h : -h, 0),
-                          nsIScrollableFrame::LINES, ScrollMode::Smooth,
-                          nullptr, nullptr, nsIScrollableFrame::NOT_MOMENTUM,
+    scrollFrame->ScrollBy(nsIntPoint(aRight ? h : -h, 0), ScrollUnit::LINES,
+                          ScrollMode::Smooth, nullptr, nullptr,
+                          nsIScrollableFrame::NOT_MOMENTUM,
                           nsIScrollableFrame::ENABLE_SNAP);
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PresShell::CompleteScroll(bool aForward) {
   nsIScrollableFrame* scrollFrame =
       GetScrollableFrameToScroll(ScrollableDirection::Vertical);
   if (scrollFrame) {
-    scrollFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1),
-                          nsIScrollableFrame::WHOLE, ScrollMode::Smooth,
-                          nullptr, nullptr, nsIScrollableFrame::NOT_MOMENTUM,
+    scrollFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1), ScrollUnit::WHOLE,
+                          ScrollMode::Smooth, nullptr, nullptr,
+                          nsIScrollableFrame::NOT_MOMENTUM,
                           nsIScrollableFrame::ENABLE_SNAP);
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PresShell::CompleteMove(bool aForward, bool aExtend) {
   // Beware! This may flush notifications via synchronous
--- a/layout/base/ScrollTypes.h
+++ b/layout/base/ScrollTypes.h
@@ -36,11 +36,16 @@ namespace mozilla {
  * scroll to the destination.
  *
  * If an |eInstant| or |eSmooth| scroll request happens while a |eSmoothMsd|
  * scroll is already in progress, the |eSmoothMsd| scroll is interrupted without
  * first scrolling to the destination.
  */
 enum class ScrollMode { Instant, Smooth, SmoothMsd, Normal };
 
+/**
+ * When scrolling by a relative amount, we can choose various units.
+ */
+enum class ScrollUnit { DEVICE_PIXELS, LINES, PAGES, WHOLE };
+
 }  // namespace mozilla
 
 #endif  // mozilla_ScrollTypes_h
--- a/layout/generic/ScrollSnap.cpp
+++ b/layout/generic/ScrollSnap.cpp
@@ -18,18 +18,18 @@ namespace mozilla {
 using layers::ScrollSnapInfo;
 
 /**
  * Keeps track of the current best edge to snap to. The criteria for
  * adding an edge depends on the scrolling unit.
  */
 class CalcSnapPoints final {
  public:
-  CalcSnapPoints(nsIScrollableFrame::ScrollUnit aUnit,
-                 const nsPoint& aDestination, const nsPoint& aStartPos);
+  CalcSnapPoints(ScrollUnit aUnit, const nsPoint& aDestination,
+                 const nsPoint& aStartPos);
   void AddHorizontalEdge(nscoord aEdge);
   void AddVerticalEdge(nscoord aEdge);
   void AddEdge(nscoord aEdge, nscoord aDestination, nscoord aStartPos,
                nscoord aScrollingDirection, nscoord* aBestEdge,
                nscoord* aSecondBestEdge, bool* aEdgeFound);
   void AddEdgeInterval(nscoord aInterval, nscoord aMinPos, nscoord aMaxPos,
                        nscoord aOffset, nscoord aDestination, nscoord aStartPos,
                        nscoord aScrollingDirection, nscoord* aBestEdge,
@@ -38,32 +38,31 @@ class CalcSnapPoints final {
   nscoord XDistanceBetweenBestAndSecondEdge() const {
     return std::abs(mBestEdge.x - mSecondBestEdge.x);
   }
   nscoord YDistanceBetweenBestAndSecondEdge() const {
     return std::abs(mBestEdge.y - mSecondBestEdge.y);
   }
 
  protected:
-  nsIScrollableFrame::ScrollUnit mUnit;
+  ScrollUnit mUnit;
   nsPoint mDestination;  // gives the position after scrolling but before
                          // snapping
   nsPoint mStartPos;     // gives the position before scrolling
   nsIntPoint mScrollingDirection;  // always -1, 0, or 1
   nsPoint mBestEdge;  // keeps track of the position of the current best edge
   nsPoint mSecondBestEdge;    // keeps track of the position of the current
                               // second best edge
   bool mHorizontalEdgeFound;  // true if mBestEdge.x is storing a valid
                               // horizontal edge
   bool mVerticalEdgeFound;    // true if mBestEdge.y is storing a valid vertical
                               // edge
 };
 
-CalcSnapPoints::CalcSnapPoints(nsIScrollableFrame::ScrollUnit aUnit,
-                               const nsPoint& aDestination,
+CalcSnapPoints::CalcSnapPoints(ScrollUnit aUnit, const nsPoint& aDestination,
                                const nsPoint& aStartPos) {
   mUnit = aUnit;
   mDestination = aDestination;
   mStartPos = aStartPos;
 
   nsPoint direction = aDestination - aStartPos;
   mScrollingDirection = nsIntPoint(0, 0);
   if (direction.x < 0) {
@@ -98,34 +97,34 @@ void CalcSnapPoints::AddVerticalEdge(nsc
   AddEdge(aEdge, mDestination.x, mStartPos.x, mScrollingDirection.x,
           &mBestEdge.x, &mSecondBestEdge.x, &mVerticalEdgeFound);
 }
 
 void CalcSnapPoints::AddEdge(nscoord aEdge, nscoord aDestination,
                              nscoord aStartPos, nscoord aScrollingDirection,
                              nscoord* aBestEdge, nscoord* aSecondBestEdge,
                              bool* aEdgeFound) {
-  // nsIScrollableFrame::DEVICE_PIXELS indicates that we are releasing a drag
+  // ScrollUnit::DEVICE_PIXELS indicates that we are releasing a drag
   // gesture or any other user input event that sets an absolute scroll
   // position.  In this case, scroll snapping is expected to travel in any
   // direction.  Otherwise, we will restrict the direction of the scroll
   // snapping movement based on aScrollingDirection.
-  if (mUnit != nsIScrollableFrame::DEVICE_PIXELS) {
+  if (mUnit != ScrollUnit::DEVICE_PIXELS) {
     // Unless DEVICE_PIXELS, we only want to snap to points ahead of the
     // direction we are scrolling
     if (aScrollingDirection == 0) {
       // The scroll direction is neutral - will not hit a snap point.
       return;
     }
-    // nsIScrollableFrame::WHOLE indicates that we are navigating to "home" or
+    // ScrollUnit::WHOLE indicates that we are navigating to "home" or
     // "end".  In this case, we will always select the first or last snap point
     // regardless of the direction of the scroll.  Otherwise, we will select
     // scroll snapping points only in the direction specified by
     // aScrollingDirection.
-    if (mUnit != nsIScrollableFrame::WHOLE) {
+    if (mUnit != ScrollUnit::WHOLE) {
       // Direction of the edge from the current position (before scrolling) in
       // the direction of scrolling
       nscoord direction = (aEdge - aStartPos) * aScrollingDirection;
       if (direction <= 0) {
         // The edge is not in the direction we are scrolling, skip it.
         return;
       }
     }
@@ -146,22 +145,21 @@ void CalcSnapPoints::AddEdge(nscoord aEd
     if (aIsCloserThanBest) {
       *aSecondBestEdge = *aBestEdge;
       *aBestEdge = aEdge;
     } else if (aIsCloserThanSecond) {
       *aSecondBestEdge = aEdge;
     }
   };
 
-  if (mUnit == nsIScrollableFrame::DEVICE_PIXELS ||
-      mUnit == nsIScrollableFrame::LINES) {
+  if (mUnit == ScrollUnit::DEVICE_PIXELS || mUnit == ScrollUnit::LINES) {
     nscoord distance = std::abs(aEdge - aDestination);
     updateBestEdges(distance < std::abs(*aBestEdge - aDestination),
                     distance < std::abs(*aSecondBestEdge - aDestination));
-  } else if (mUnit == nsIScrollableFrame::PAGES) {
+  } else if (mUnit == ScrollUnit::PAGES) {
     // distance to the edge from the scrolling destination in the direction of
     // scrolling
     nscoord overshoot = (aEdge - aDestination) * aScrollingDirection;
     // distance to the current best edge from the scrolling destination in the
     // direction of scrolling
     nscoord curOvershoot = (*aBestEdge - aDestination) * aScrollingDirection;
 
     nscoord secondOvershoot =
@@ -173,17 +171,17 @@ void CalcSnapPoints::AddEdge(nscoord aEd
       updateBestEdges(overshoot > curOvershoot || curOvershoot >= 0,
                       overshoot > secondOvershoot || secondOvershoot >= 0);
     }
     // if there are no edges between the current position and the scrolling
     // destination the closest edge beyond the destination is used
     if (overshoot > 0) {
       updateBestEdges(overshoot < curOvershoot, overshoot < secondOvershoot);
     }
-  } else if (mUnit == nsIScrollableFrame::WHOLE) {
+  } else if (mUnit == ScrollUnit::WHOLE) {
     // the edge closest to the top/bottom/left/right is used, depending on
     // scrolling direction
     if (aScrollingDirection > 0) {
       updateBestEdges(aEdge > *aBestEdge, aEdge > *aSecondBestEdge);
     } else if (aScrollingDirection < 0) {
       updateBestEdges(aEdge < *aBestEdge, aEdge < *aSecondBestEdge);
     }
   } else {
@@ -235,17 +233,17 @@ static void ProcessSnapPositions(CalcSna
     aCalcSnapPoints.AddVerticalEdge(position);
   }
   for (auto position : aSnapInfo.mSnapPositionY) {
     aCalcSnapPoints.AddHorizontalEdge(position);
   }
 }
 
 Maybe<nsPoint> ScrollSnapUtils::GetSnapPointForDestination(
-    const ScrollSnapInfo& aSnapInfo, nsIScrollableFrame::ScrollUnit aUnit,
+    const ScrollSnapInfo& aSnapInfo, ScrollUnit aUnit,
     const nsRect& aScrollRange, const nsPoint& aStartPos,
     const nsPoint& aDestination) {
   if (aSnapInfo.mScrollSnapStrictnessY == StyleScrollSnapStrictness::None &&
       aSnapInfo.mScrollSnapStrictnessX == StyleScrollSnapStrictness::None) {
     return Nothing();
   }
 
   if (!aSnapInfo.HasSnapPositions()) {
--- a/layout/generic/ScrollSnap.h
+++ b/layout/generic/ScrollSnap.h
@@ -2,18 +2,18 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_layout_ScrollSnap_h_
 #define mozilla_layout_ScrollSnap_h_
 
+#include "mozilla/ScrollTypes.h"
 #include "mozilla/Maybe.h"
-#include "nsIScrollableFrame.h"
 
 namespace mozilla {
 
 namespace layers {
 struct ScrollSnapInfo;
 }
 
 struct ScrollSnapUtils {
@@ -27,16 +27,16 @@ struct ScrollSnapUtils {
    * If a suitable snap point could be found, it is returned. Otherwise, an
    * empty Maybe is returned.
    * IMPORTANT NOTE: This function is designed to be called both on and off
    *                 the main thread. If modifying its implementation, be sure
    *                 not to touch main-thread-only data structures without
    *                 appropriate locking.
    */
   static mozilla::Maybe<nsPoint> GetSnapPointForDestination(
-      const layers::ScrollSnapInfo& aSnapInfo,
-      nsIScrollableFrame::ScrollUnit aUnit, const nsRect& aScrollRange,
-      const nsPoint& aStartPos, const nsPoint& aDestination);
+      const layers::ScrollSnapInfo& aSnapInfo, ScrollUnit aUnit,
+      const nsRect& aScrollRange, const nsPoint& aStartPos,
+      const nsPoint& aDestination);
 };
 
 }  // namespace mozilla
 
 #endif  // mozilla_layout_ScrollSnap_h_
--- a/layout/generic/nsFrameSelection.cpp
+++ b/layout/generic/nsFrameSelection.cpp
@@ -11,16 +11,17 @@
 #include "nsFrameSelection.h"
 
 #include "mozilla/Attributes.h"
 #include "mozilla/AutoRestore.h"
 #include "mozilla/BasePrincipal.h"
 #include "mozilla/EventStates.h"
 #include "mozilla/HTMLEditor.h"
 #include "mozilla/PresShell.h"
+#include "mozilla/ScrollTypes.h"
 #include "mozilla/StaticPrefs_dom.h"
 
 #include "nsCOMPtr.h"
 #include "nsDebug.h"
 #include "nsString.h"
 #include "nsISelectionListener.h"
 #include "nsContentCID.h"
 #include "nsDeviceContext.h"
@@ -1760,17 +1761,17 @@ nsresult nsFrameSelection::PageMove(bool
     // pending smooth scroll.  Therefore, if we used smooth scroll in such
     // case, ScrollSelectionIntoView would scroll to show caret instead of
     // page scroll of an element outside selection limiter.
     ScrollMode scrollMode = doScrollSelectionIntoView && !selectionChanged &&
                                     scrolledFrame != frameToClick
                                 ? ScrollMode::Instant
                                 : ScrollMode::Smooth;
     scrollableFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1),
-                              nsIScrollableFrame::PAGES, scrollMode);
+                              ScrollUnit::PAGES, scrollMode);
   }
 
   // Finally, scroll selection into view if requested.
   if (!doScrollSelectionIntoView) {
     return NS_OK;
   }
   return ScrollSelectionIntoView(
       SelectionType::eNormal, nsISelectionController::SELECTION_FOCUS_REGION,
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -1443,25 +1443,25 @@ static nsRect GetOnePixelRangeAroundPoin
     allowedRange.height = halfPixel * 2 - 1;
   }
   return allowedRange;
 }
 
 void ScrollFrameHelper::ScrollByPage(
     nsScrollbarFrame* aScrollbar, int32_t aDirection,
     nsIScrollbarMediator::ScrollSnapMode aSnap) {
-  ScrollByUnit(aScrollbar, ScrollMode::Smooth, aDirection,
-               nsIScrollableFrame::PAGES, aSnap);
+  ScrollByUnit(aScrollbar, ScrollMode::Smooth, aDirection, ScrollUnit::PAGES,
+               aSnap);
 }
 
 void ScrollFrameHelper::ScrollByWhole(
     nsScrollbarFrame* aScrollbar, int32_t aDirection,
     nsIScrollbarMediator::ScrollSnapMode aSnap) {
-  ScrollByUnit(aScrollbar, ScrollMode::Instant, aDirection,
-               nsIScrollableFrame::WHOLE, aSnap);
+  ScrollByUnit(aScrollbar, ScrollMode::Instant, aDirection, ScrollUnit::WHOLE,
+               aSnap);
 }
 
 void ScrollFrameHelper::ScrollByLine(
     nsScrollbarFrame* aScrollbar, int32_t aDirection,
     nsIScrollbarMediator::ScrollSnapMode aSnap) {
   bool isHorizontal = aScrollbar->IsXULHorizontal();
   nsIntPoint delta;
   if (isHorizontal) {
@@ -1486,17 +1486,17 @@ void ScrollFrameHelper::ScrollByLine(
       // than an entire page.  Scroll by one page instead to maintain
       // context.
       ScrollByPage(aScrollbar, aDirection);
       return;
     }
   }
 
   nsIntPoint overflow;
-  ScrollBy(delta, nsIScrollableFrame::LINES, ScrollMode::Smooth, &overflow,
+  ScrollBy(delta, ScrollUnit::LINES, ScrollMode::Smooth, &overflow,
            nsGkAtoms::other, nsIScrollableFrame::NOT_MOMENTUM, aSnap);
 }
 
 void ScrollFrameHelper::RepeatButtonScroll(nsScrollbarFrame* aScrollbar) {
   aScrollbar->MoveToNewPosition();
 }
 
 void ScrollFrameHelper::ThumbMoved(nsScrollbarFrame* aScrollbar,
@@ -1529,18 +1529,17 @@ void ScrollFrameHelper::ScrollbarRelease
 
   // Perform scroll snapping, if needed.  Scrollbar movement uses the same
   // smooth scrolling animation as keyboard scrolling.
   ScrollSnap(mDestination, ScrollMode::Smooth);
 }
 
 void ScrollFrameHelper::ScrollByUnit(
     nsScrollbarFrame* aScrollbar, ScrollMode aMode, int32_t aDirection,
-    nsIScrollableFrame::ScrollUnit aUnit,
-    nsIScrollbarMediator::ScrollSnapMode aSnap) {
+    ScrollUnit aUnit, nsIScrollbarMediator::ScrollSnapMode aSnap) {
   MOZ_ASSERT(aScrollbar != nullptr);
   bool isHorizontal = aScrollbar->IsXULHorizontal();
   nsIntPoint delta;
   if (isHorizontal) {
     delta.x = aDirection;
   } else {
     delta.y = aDirection;
   }
@@ -2284,17 +2283,17 @@ void ScrollFrameHelper::ScrollToWithOrig
   if (aOrigin != nsGkAtoms::restore) {
     // If we're doing a non-restore scroll, we don't want to later
     // override it by restoring our saved scroll position.
     mRestorePos.x = mRestorePos.y = -1;
   }
 
   bool willSnap = false;
   if (aSnap == nsIScrollableFrame::ENABLE_SNAP) {
-    willSnap = GetSnapPointForDestination(nsIScrollableFrame::DEVICE_PIXELS,
+    willSnap = GetSnapPointForDestination(ScrollUnit::DEVICE_PIXELS,
                                           mDestination, aScrollPosition);
   }
 
   nsRect scrollRange = GetLayoutScrollRange();
   mDestination = scrollRange.ClampPoint(aScrollPosition);
   if (mDestination != aScrollPosition && aOrigin == nsGkAtoms::restore &&
       GetPageLoadingState() != LoadingState::Loading) {
     // If we're doing a restore but the scroll position is clamped, promote
@@ -4190,18 +4189,17 @@ static void CalcRangeForScrollBy(int32_t
     return;
   }
   *aLower = aPos - NSToCoordRound(aMultiplier *
                                   (aDelta > 0 ? aNegTolerance : aPosTolerance));
   *aUpper = aPos + NSToCoordRound(aMultiplier *
                                   (aDelta > 0 ? aPosTolerance : aNegTolerance));
 }
 
-void ScrollFrameHelper::ScrollBy(nsIntPoint aDelta,
-                                 nsIScrollableFrame::ScrollUnit aUnit,
+void ScrollFrameHelper::ScrollBy(nsIntPoint aDelta, ScrollUnit aUnit,
                                  ScrollMode aMode, nsIntPoint* aOverflow,
                                  nsAtom* aOrigin,
                                  nsIScrollableFrame::ScrollMomentum aMomentum,
                                  nsIScrollbarMediator::ScrollSnapMode aSnap) {
   // When a smooth scroll is being processed on a frame, mouse wheel and
   // trackpad momentum scroll event updates must notcancel the SMOOTH or
   // SMOOTH_MSD scroll animations, enabling Javascript that depends on them to
   // be responsive without forcing the user to wait for the fling animations to
@@ -4227,44 +4225,44 @@ void ScrollFrameHelper::ScrollBy(nsIntPo
   nsSize deltaMultiplier;
   float negativeTolerance;
   float positiveTolerance;
   if (!aOrigin) {
     aOrigin = nsGkAtoms::other;
   }
   bool isGenericOrigin = (aOrigin == nsGkAtoms::other);
   switch (aUnit) {
-    case nsIScrollableFrame::DEVICE_PIXELS: {
+    case ScrollUnit::DEVICE_PIXELS: {
       nscoord appUnitsPerDevPixel =
           mOuter->PresContext()->AppUnitsPerDevPixel();
       deltaMultiplier = nsSize(appUnitsPerDevPixel, appUnitsPerDevPixel);
       if (isGenericOrigin) {
         aOrigin = nsGkAtoms::pixels;
       }
       negativeTolerance = positiveTolerance = 0.5f;
       break;
     }
-    case nsIScrollableFrame::LINES: {
+    case ScrollUnit::LINES: {
       deltaMultiplier = GetLineScrollAmount();
       if (isGenericOrigin) {
         aOrigin = nsGkAtoms::lines;
       }
       negativeTolerance = positiveTolerance = 0.1f;
       break;
     }
-    case nsIScrollableFrame::PAGES: {
+    case ScrollUnit::PAGES: {
       deltaMultiplier = GetPageScrollAmount();
       if (isGenericOrigin) {
         aOrigin = nsGkAtoms::pages;
       }
       negativeTolerance = 0.05f;
       positiveTolerance = 0;
       break;
     }
-    case nsIScrollableFrame::WHOLE: {
+    case ScrollUnit::WHOLE: {
       nsPoint pos = GetScrollPosition();
       AdjustForWholeDelta(aDelta.x, &pos.x);
       AdjustForWholeDelta(aDelta.y, &pos.y);
       if (aSnap == nsIScrollableFrame::ENABLE_SNAP) {
         GetSnapPointForDestination(aUnit, mDestination, pos);
       }
       ScrollTo(pos, aMode, nsGkAtoms::other);
       // 'this' might be destroyed here
@@ -4283,22 +4281,22 @@ void ScrollFrameHelper::ScrollBy(nsIntPo
 
   if (aSnap == nsIScrollableFrame::ENABLE_SNAP) {
     if (NeedsScrollSnap()) {
       nscoord appUnitsPerDevPixel =
           mOuter->PresContext()->AppUnitsPerDevPixel();
       deltaMultiplier = nsSize(appUnitsPerDevPixel, appUnitsPerDevPixel);
       negativeTolerance = 0.1f;
       positiveTolerance = 0;
-      nsIScrollableFrame::ScrollUnit snapUnit = aUnit;
+      ScrollUnit snapUnit = aUnit;
       if (aOrigin == nsGkAtoms::mouseWheel) {
         // When using a clicky scroll wheel, snap point selection works the same
         // as keyboard up/down/left/right navigation, but with varying amounts
         // of scroll delta.
-        snapUnit = nsIScrollableFrame::LINES;
+        snapUnit = ScrollUnit::LINES;
       }
       GetSnapPointForDestination(snapUnit, mDestination, newPos);
     }
   }
 
   // Calculate desired range values.
   nscoord rangeLowerX, rangeUpperX, rangeLowerY, rangeUpperY;
   CalcRangeForScrollBy(aDelta.x, newPos.x, negativeTolerance, positiveTolerance,
@@ -4316,17 +4314,17 @@ void ScrollFrameHelper::ScrollBy(nsIntPo
   if (aOverflow) {
     nsPoint clampAmount = newPos - mDestination;
     float appUnitsPerDevPixel = mOuter->PresContext()->AppUnitsPerDevPixel();
     *aOverflow =
         nsIntPoint(NSAppUnitsToIntPixels(clampAmount.x, appUnitsPerDevPixel),
                    NSAppUnitsToIntPixels(clampAmount.y, appUnitsPerDevPixel));
   }
 
-  if (aUnit == nsIScrollableFrame::DEVICE_PIXELS &&
+  if (aUnit == ScrollUnit::DEVICE_PIXELS &&
       !nsLayoutUtils::AsyncPanZoomEnabled(mOuter)) {
     // When APZ is disabled, we must track the velocity
     // on the main thread; otherwise, the APZC will manage this.
     mVelocityQueue.Sample(GetScrollPosition());
   }
 }
 
 void ScrollFrameHelper::ScrollByCSSPixels(
@@ -4390,17 +4388,17 @@ void ScrollFrameHelper::ScrollSnap(Scrol
   ScrollSnap(destinationPos, aMode);
 }
 
 void ScrollFrameHelper::ScrollSnap(const nsPoint& aDestination,
                                    ScrollMode aMode) {
   nsRect scrollRange = GetLayoutScrollRange();
   nsPoint pos = GetScrollPosition();
   nsPoint snapDestination = scrollRange.ClampPoint(aDestination);
-  if (GetSnapPointForDestination(nsIScrollableFrame::DEVICE_PIXELS, pos,
+  if (GetSnapPointForDestination(ScrollUnit::DEVICE_PIXELS, pos,
                                  snapDestination)) {
     ScrollTo(snapDestination, aMode, nsGkAtoms::other);
   }
 }
 
 nsSize ScrollFrameHelper::GetLineScrollAmount() const {
   RefPtr<nsFontMetrics> fm =
       nsLayoutUtils::GetInflatedFontMetricsForFrame(mOuter);
@@ -6972,19 +6970,19 @@ layers::ScrollSnapInfo ScrollFrameHelper
 }
 
 layers::ScrollSnapInfo ScrollFrameHelper::GetScrollSnapInfo(
     const Maybe<nsPoint>& aDestination) const {
   // TODO(botond): Should we cache it?
   return ComputeScrollSnapInfo(aDestination);
 }
 
-bool ScrollFrameHelper::GetSnapPointForDestination(
-    nsIScrollableFrame::ScrollUnit aUnit, nsPoint aStartPos,
-    nsPoint& aDestination) {
+bool ScrollFrameHelper::GetSnapPointForDestination(ScrollUnit aUnit,
+                                                   nsPoint aStartPos,
+                                                   nsPoint& aDestination) {
   Maybe<nsPoint> snapPoint = ScrollSnapUtils::GetSnapPointForDestination(
       GetScrollSnapInfo(Some(aDestination)), aUnit, GetLayoutScrollRange(),
       aStartPos, aDestination);
   if (snapPoint) {
     aDestination = snapPoint.ref();
     return true;
   }
   return false;
--- a/layout/generic/nsGfxScrollFrame.h
+++ b/layout/generic/nsGfxScrollFrame.h
@@ -19,16 +19,17 @@
 #include "nsThreadUtils.h"
 #include "nsIReflowCallback.h"
 #include "nsBoxLayoutState.h"
 #include "nsQueryFrame.h"
 #include "nsRefreshDriver.h"
 #include "nsExpirationTracker.h"
 #include "TextOverflow.h"
 #include "ScrollVelocityQueue.h"
+#include "mozilla/ScrollTypes.h"
 #include "mozilla/PresState.h"
 #include "mozilla/layout/ScrollAnchorContainer.h"
 
 class nsPresContext;
 class nsIContent;
 class nsAtom;
 class nsIScrollPositionListener;
 
@@ -244,19 +245,18 @@ class ScrollFrameHelper : public nsIRefl
    * @note This method might destroy the frame, pres shell and other objects.
    */
   void ScrollToImpl(nsPoint aScrollPosition, const nsRect& aRange,
                     nsAtom* aOrigin = nullptr);
   void ScrollVisual();
   /**
    * @note This method might destroy the frame, pres shell and other objects.
    */
-  void ScrollBy(nsIntPoint aDelta, nsIScrollableFrame::ScrollUnit aUnit,
-                ScrollMode aMode, nsIntPoint* aOverflow,
-                nsAtom* aOrigin = nullptr,
+  void ScrollBy(nsIntPoint aDelta, mozilla::ScrollUnit aUnit, ScrollMode aMode,
+                nsIntPoint* aOverflow, nsAtom* aOrigin = nullptr,
                 nsIScrollableFrame::ScrollMomentum aMomentum =
                     nsIScrollableFrame::NOT_MOMENTUM,
                 nsIScrollbarMediator::ScrollSnapMode aSnap =
                     nsIScrollbarMediator::DISABLE_SNAP);
   void ScrollByCSSPixels(const CSSIntPoint& aDelta,
                          ScrollMode aMode = ScrollMode::Instant,
                          nsAtom* aOrigin = nullptr,
                          nsIScrollbarMediator::ScrollSnapMode aSnap =
@@ -273,18 +273,18 @@ class ScrollFrameHelper : public nsIRefl
   /**
    * GetSnapPointForDestination determines which point to snap to after
    * scrolling. aStartPos gives the position before scrolling and aDestination
    * gives the position after scrolling, with no snapping. Behaviour is
    * dependent on the value of aUnit.
    * Returns true if a suitable snap point could be found and aDestination has
    * been updated to a valid snapping position.
    */
-  bool GetSnapPointForDestination(nsIScrollableFrame::ScrollUnit aUnit,
-                                  nsPoint aStartPos, nsPoint& aDestination);
+  bool GetSnapPointForDestination(mozilla::ScrollUnit aUnit, nsPoint aStartPos,
+                                  nsPoint& aDestination);
 
   nsMargin GetScrollPadding() const;
 
   nsSize GetLineScrollAmount() const;
   nsSize GetPageScrollAmount() const;
 
   mozilla::UniquePtr<mozilla::PresState> SaveState() const;
   void RestoreState(mozilla::PresState* aState);
@@ -480,17 +480,17 @@ class ScrollFrameHelper : public nsIRefl
   void ScrollByLine(nsScrollbarFrame* aScrollbar, int32_t aDirection,
                     nsIScrollbarMediator::ScrollSnapMode aSnap =
                         nsIScrollbarMediator::DISABLE_SNAP);
   void RepeatButtonScroll(nsScrollbarFrame* aScrollbar);
   void ThumbMoved(nsScrollbarFrame* aScrollbar, nscoord aOldPos,
                   nscoord aNewPos);
   void ScrollbarReleased(nsScrollbarFrame* aScrollbar);
   void ScrollByUnit(nsScrollbarFrame* aScrollbar, ScrollMode aMode,
-                    int32_t aDirection, nsIScrollableFrame::ScrollUnit aUnit,
+                    int32_t aDirection, mozilla::ScrollUnit aUnit,
                     nsIScrollbarMediator::ScrollSnapMode aSnap =
                         nsIScrollbarMediator::DISABLE_SNAP);
   bool ShouldSuppressScrollbarRepaints() const {
     return mSuppressScrollbarRepaints;
   }
 
   bool DragScroll(WidgetEvent* aEvent);
 
@@ -947,17 +947,17 @@ class nsHTMLScrollFrame : public nsConta
    * @note This method might destroy the frame, pres shell and other objects.
    */
   CSSIntPoint GetScrollPositionCSSPixels() final {
     return mHelper.GetScrollPositionCSSPixels();
   }
   /**
    * @note This method might destroy the frame, pres shell and other objects.
    */
-  void ScrollBy(nsIntPoint aDelta, ScrollUnit aUnit, ScrollMode aMode,
+  void ScrollBy(nsIntPoint aDelta, mozilla::ScrollUnit aUnit, ScrollMode aMode,
                 nsIntPoint* aOverflow, nsAtom* aOrigin = nullptr,
                 nsIScrollableFrame::ScrollMomentum aMomentum =
                     nsIScrollableFrame::NOT_MOMENTUM,
                 nsIScrollbarMediator::ScrollSnapMode aSnap =
                     nsIScrollbarMediator::DISABLE_SNAP) final {
     mHelper.ScrollBy(aDelta, aUnit, aMode, aOverflow, aOrigin, aMomentum,
                      aSnap);
   }
@@ -1411,17 +1411,17 @@ class nsXULScrollFrame final : public ns
     mHelper.ScrollToCSSPixelsApproximate(aScrollPosition, aOrigin);
   }
   CSSIntPoint GetScrollPositionCSSPixels() final {
     return mHelper.GetScrollPositionCSSPixels();
   }
   /**
    * @note This method might destroy the frame, pres shell and other objects.
    */
-  void ScrollBy(nsIntPoint aDelta, ScrollUnit aUnit, ScrollMode aMode,
+  void ScrollBy(nsIntPoint aDelta, mozilla::ScrollUnit aUnit, ScrollMode aMode,
                 nsIntPoint* aOverflow, nsAtom* aOrigin = nullptr,
                 nsIScrollableFrame::ScrollMomentum aMomentum =
                     nsIScrollableFrame::NOT_MOMENTUM,
                 nsIScrollbarMediator::ScrollSnapMode aSnap =
                     nsIScrollbarMediator::DISABLE_SNAP) final {
     mHelper.ScrollBy(aDelta, aUnit, aMode, aOverflow, aOrigin, aMomentum,
                      aSnap);
   }
--- a/layout/generic/nsIScrollableFrame.h
+++ b/layout/generic/nsIScrollableFrame.h
@@ -278,31 +278,27 @@ class nsIScrollableFrame : public nsIScr
       const mozilla::CSSPoint& aScrollPosition, nsAtom* aOrigin = nullptr) = 0;
 
   /**
    * Returns the scroll position in integer CSS pixels, rounded to the nearest
    * pixel.
    */
   virtual CSSIntPoint GetScrollPositionCSSPixels() = 0;
   /**
-   * When scrolling by a relative amount, we can choose various units.
-   */
-  enum ScrollUnit { DEVICE_PIXELS, LINES, PAGES, WHOLE };
-  /**
    * @note This method might destroy the frame, pres shell and other objects.
    * Modifies the current scroll position by aDelta units given by aUnit,
    * clamping it to GetScrollRange. If WHOLE is specified as the unit,
    * content is scrolled all the way in the direction(s) given by aDelta.
    * @param aOverflow if non-null, returns the amount that scrolling
    * was clamped by in each direction (how far we moved the scroll position
    * to bring it back into the legal range). This is never negative. The
    * values are in device pixels.
    */
-  virtual void ScrollBy(nsIntPoint aDelta, ScrollUnit aUnit, ScrollMode aMode,
-                        nsIntPoint* aOverflow = nullptr,
+  virtual void ScrollBy(nsIntPoint aDelta, mozilla::ScrollUnit aUnit,
+                        ScrollMode aMode, nsIntPoint* aOverflow = nullptr,
                         nsAtom* aOrigin = nullptr,
                         ScrollMomentum aMomentum = NOT_MOMENTUM,
                         nsIScrollbarMediator::ScrollSnapMode aSnap =
                             nsIScrollbarMediator::DISABLE_SNAP) = 0;
 
   /**
    * FIXME: Drop |aSnap| argument once after we finished the migration to the
    * Scroll Snap Module v1. We should alway use ENABLE_SNAP.
--- a/widget/InputData.cpp
+++ b/widget/InputData.cpp
@@ -680,29 +680,29 @@ uint32_t ScrollWheelInput::DeltaModeForD
     case ScrollWheelInput::SCROLLDELTA_PAGE:
       return WheelEvent_Binding::DOM_DELTA_PAGE;
     case ScrollWheelInput::SCROLLDELTA_PIXEL:
     default:
       return WheelEvent_Binding::DOM_DELTA_PIXEL;
   }
 }
 
-nsIScrollableFrame::ScrollUnit ScrollWheelInput::ScrollUnitForDeltaType(
+ScrollUnit ScrollWheelInput::ScrollUnitForDeltaType(
     ScrollDeltaType aDeltaType) {
   switch (aDeltaType) {
     case SCROLLDELTA_LINE:
-      return nsIScrollableFrame::LINES;
+      return ScrollUnit::LINES;
     case SCROLLDELTA_PAGE:
-      return nsIScrollableFrame::PAGES;
+      return ScrollUnit::PAGES;
     case SCROLLDELTA_PIXEL:
-      return nsIScrollableFrame::DEVICE_PIXELS;
+      return ScrollUnit::DEVICE_PIXELS;
     default:
       MOZ_CRASH();
   }
-  return nsIScrollableFrame::LINES;
+  return ScrollUnit::LINES;
 }
 
 WidgetWheelEvent ScrollWheelInput::ToWidgetWheelEvent(
     nsIWidget* aWidget) const {
   WidgetWheelEvent wheelEvent(true, eWheel, aWidget);
   wheelEvent.mModifiers = this->modifiers;
   wheelEvent.mTime = mTime;
   wheelEvent.mTimeStamp = mTimeStamp;
--- a/widget/InputData.h
+++ b/widget/InputData.h
@@ -2,20 +2,20 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef InputData_h__
 #define InputData_h__
 
 #include "nsDebug.h"
-#include "nsIScrollableFrame.h"
 #include "nsPoint.h"
 #include "nsTArray.h"
 #include "Units.h"
+#include "mozilla/ScrollTypes.h"
 #include "mozilla/DefineEnum.h"
 #include "mozilla/EventForwards.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/WheelHandlingHelper.h"  // for WheelDeltaAdjustmentStrategy
 #include "mozilla/gfx/MatrixFwd.h"
 #include "mozilla/layers/APZUtils.h"
 #include "mozilla/layers/KeyboardScrollAction.h"
 
@@ -581,18 +581,17 @@ class ScrollWheelInput : public InputDat
                    ScrollMode aScrollMode, ScrollDeltaType aDeltaType,
                    const ScreenPoint& aOrigin, double aDeltaX, double aDeltaY,
                    bool aAllowToOverrideSystemScrollSpeed,
                    WheelDeltaAdjustmentStrategy aWheelDeltaAdjustmentStrategy);
   explicit ScrollWheelInput(const WidgetWheelEvent& aEvent);
 
   static ScrollDeltaType DeltaTypeForDeltaMode(uint32_t aDeltaMode);
   static uint32_t DeltaModeForDeltaType(ScrollDeltaType aDeltaType);
-  static nsIScrollableFrame::ScrollUnit ScrollUnitForDeltaType(
-      ScrollDeltaType aDeltaType);
+  static mozilla::ScrollUnit ScrollUnitForDeltaType(ScrollDeltaType aDeltaType);
 
   WidgetWheelEvent ToWidgetWheelEvent(nsIWidget* aWidget) const;
   bool TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform);
 
   bool IsCustomizedByUserPrefs() const;
 
   // The following two functions are for auto-dir scrolling. For detailed
   // information on auto-dir, @see mozilla::WheelDeltaAdjustmentStrategy