diff --git a/gfx/layers/FrameMetrics.h b/gfx/layers/FrameMetrics.h index fb81d7676bf9..fde4176f2a13 100644 --- a/gfx/layers/FrameMetrics.h +++ b/gfx/layers/FrameMetrics.h @@ -862,7 +862,6 @@ struct ScrollMetadata { mForceMousewheelAutodir(false), mForceMousewheelAutodirHonourRoot(false), mIsPaginatedPresentation(false), - mPrefersReducedMotion(false), mOverscrollBehavior() {} bool operator==(const ScrollMetadata& aOther) const { @@ -882,7 +881,6 @@ struct ScrollMetadata { mForceMousewheelAutodirHonourRoot == aOther.mForceMousewheelAutodirHonourRoot && mIsPaginatedPresentation == aOther.mIsPaginatedPresentation && - mPrefersReducedMotion == aOther.mPrefersReducedMotion && mDisregardedDirection == aOther.mDisregardedDirection && mOverscrollBehavior == aOther.mOverscrollBehavior && mScrollUpdates == aOther.mScrollUpdates; @@ -967,9 +965,6 @@ struct ScrollMetadata { } bool IsPaginatedPresentation() const { return mIsPaginatedPresentation; } - void SetPrefersReducedMotion(bool aValue) { mPrefersReducedMotion = aValue; } - bool PrefersReducedMotion() const { return mPrefersReducedMotion; } - bool DidContentGetPainted() const { return mDidContentGetPainted; } private: @@ -1084,10 +1079,6 @@ struct ScrollMetadata { // to different transforms, which constrains the assumptions APZ can make. bool mIsPaginatedPresentation : 1; - // Whether the user has the prefers-reduced-motion system setting - // enabled. - bool mPrefersReducedMotion : 1; - // The disregarded direction means the direction which is disregarded anyway, // even if the scroll frame overflows in that direction and the direction is // specified as scrollable. This could happen in some scenarios, for instance, diff --git a/gfx/layers/apz/public/APZPublicUtils.h b/gfx/layers/apz/public/APZPublicUtils.h index b4ee42915356..6433008b4c55 100644 --- a/gfx/layers/apz/public/APZPublicUtils.h +++ b/gfx/layers/apz/public/APZPublicUtils.h @@ -66,14 +66,13 @@ gfx::IntSize GetDisplayportAlignmentMultiplier(const ScreenSize& aBaseSize); * given origin, based on pref values. */ ScrollAnimationBezierPhysicsSettings ComputeBezierAnimationSettingsForOrigin( - ScrollOrigin aOrigin, bool aSmoothScrollingEnabled); + ScrollOrigin aOrigin); /** * Calculate if the scrolling should be instant or smooth based based on * preferences and the origin */ -ScrollMode GetScrollModeForOrigin(ScrollOrigin origin, - bool aSmoothScrollingEnabled); +ScrollMode GetScrollModeForOrigin(ScrollOrigin origin); } // namespace apz diff --git a/gfx/layers/apz/src/APZInputBridge.cpp b/gfx/layers/apz/src/APZInputBridge.cpp index 2ba6fdf6fda2..bb5b42d2622b 100644 --- a/gfx/layers/apz/src/APZInputBridge.cpp +++ b/gfx/layers/apz/src/APZInputBridge.cpp @@ -22,7 +22,6 @@ #include "mozilla/TouchEvents.h" // for WidgetTouchEvent #include "mozilla/WheelHandlingHelper.h" // for WheelDeltaHorizontalizer, // WheelDeltaAdjustmentStrategy -#include "nsLayoutUtils.h" // for IsSmoothScrollingEnabled namespace mozilla { namespace layers { @@ -229,7 +228,7 @@ APZEventResult APZInputBridge::ReceiveInputEvent( if (Maybe action = ActionForWheelEvent(&wheelEvent)) { ScrollWheelInput::ScrollMode scrollMode = ScrollWheelInput::SCROLLMODE_INSTANT; - if (nsLayoutUtils::IsSmoothScrollingEnabled() && + if (StaticPrefs::general_smoothScroll() && ((wheelEvent.mDeltaMode == dom::WheelEvent_Binding::DOM_DELTA_LINE && StaticPrefs::general_smoothScroll_mouseWheel()) || diff --git a/gfx/layers/apz/src/APZPublicUtils.cpp b/gfx/layers/apz/src/APZPublicUtils.cpp index 4f4dd211694f..6902e0738ce3 100644 --- a/gfx/layers/apz/src/APZPublicUtils.cpp +++ b/gfx/layers/apz/src/APZPublicUtils.cpp @@ -32,13 +32,13 @@ namespace apz { } ScrollAnimationBezierPhysicsSettings ComputeBezierAnimationSettingsForOrigin( - ScrollOrigin aOrigin, bool aSmoothScrollingEnabled) { + ScrollOrigin aOrigin) { int32_t minMS = 0; int32_t maxMS = 0; bool isOriginSmoothnessEnabled = false; #define READ_DURATIONS(prefbase) \ - isOriginSmoothnessEnabled = aSmoothScrollingEnabled && \ + isOriginSmoothnessEnabled = StaticPrefs::general_smoothScroll() && \ StaticPrefs::general_smoothScroll_##prefbase(); \ if (isOriginSmoothnessEnabled) { \ minMS = StaticPrefs::general_smoothScroll_##prefbase##_durationMinMS(); \ @@ -87,9 +87,8 @@ ScrollAnimationBezierPhysicsSettings ComputeBezierAnimationSettingsForOrigin( return ScrollAnimationBezierPhysicsSettings{minMS, maxMS, intervalRatio}; } -ScrollMode GetScrollModeForOrigin(ScrollOrigin origin, - bool aSmoothScrollingEnabled) { - if (!aSmoothScrollingEnabled) return ScrollMode::Instant; +ScrollMode GetScrollModeForOrigin(ScrollOrigin origin) { + if (!StaticPrefs::general_smoothScroll()) return ScrollMode::Instant; switch (origin) { case ScrollOrigin::Lines: return StaticPrefs::general_smoothScroll_lines() ? ScrollMode::Smooth @@ -102,7 +101,8 @@ ScrollMode GetScrollModeForOrigin(ScrollOrigin origin, : ScrollMode::Instant; default: MOZ_ASSERT(false, "Unknown keyboard scroll origin"); - return ScrollMode::Instant; + return StaticPrefs::general_smoothScroll() ? ScrollMode::Smooth + : ScrollMode::Instant; } } diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp index 11945c10ecbd..3d0408cb890d 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -2041,8 +2041,7 @@ nsEventStatus AsyncPanZoomController::OnKeyboard(const KeyboardInput& aEvent) { SmoothScrollAnimation::GetScrollOriginForAction(aEvent.mAction.mType); Maybe snapTarget = MaybeAdjustDestinationForScrollSnapping( aEvent, destination, GetScrollSnapFlagsForKeyboardAction(aEvent.mAction)); - ScrollMode scrollMode = - apz::GetScrollModeForOrigin(scrollOrigin, IsSmoothScrollingEnabled()); + ScrollMode scrollMode = apz::GetScrollModeForOrigin(scrollOrigin); RecordScrollPayload(aEvent.mTimeStamp); // If the scrolling is instant, then scroll immediately to the destination @@ -3555,12 +3554,6 @@ void AsyncPanZoomController::UpdateWithTouchAtDevicePoint( mY.UpdateWithTouchAtDevicePoint(point.y, aEvent.mTimeStamp); } -bool AsyncPanZoomController::IsSmoothScrollingEnabled() const { - RecursiveMutexAutoLock lock(mRecursiveMutex); - return StaticPrefs::general_smoothScroll_DoNotUseDirectly() && - !mScrollMetadata.PrefersReducedMotion(); -} - Maybe AsyncPanZoomController::NotifyScrollSampling() { RecursiveMutexAutoLock lock(mRecursiveMutex); return mSampledState.front().TakeScrollPayload(); @@ -5449,8 +5442,6 @@ void AsyncPanZoomController::NotifyLayersUpdated( aScrollMetadata.GetDisregardedDirection()); mScrollMetadata.SetOverscrollBehavior( aScrollMetadata.GetOverscrollBehavior()); - mScrollMetadata.SetPrefersReducedMotion( - aScrollMetadata.PrefersReducedMotion()); } bool scrollOffsetUpdated = false; diff --git a/gfx/layers/apz/src/AsyncPanZoomController.h b/gfx/layers/apz/src/AsyncPanZoomController.h index 70b602a1032a..5d1ebc74b742 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.h +++ b/gfx/layers/apz/src/AsyncPanZoomController.h @@ -20,7 +20,6 @@ #include "mozilla/RefPtr.h" #include "mozilla/ScrollTypes.h" #include "mozilla/StaticPrefs_apz.h" -#include "mozilla/StaticPrefs_general.h" #include "mozilla/UniquePtr.h" #include "InputData.h" #include "Axis.h" // for Axis, Side, etc. @@ -1137,12 +1136,6 @@ class AsyncPanZoomController { friend class Axis; public: - /** - * Returns true if smooth scrolls are enabled and the user does not - * prefer reduced motion. - */ - bool IsSmoothScrollingEnabled() const; - Maybe NotifyScrollSampling(); /** diff --git a/gfx/layers/apz/src/GenericScrollAnimation.cpp b/gfx/layers/apz/src/GenericScrollAnimation.cpp index e3f240aa2dd7..9320482295bd 100644 --- a/gfx/layers/apz/src/GenericScrollAnimation.cpp +++ b/gfx/layers/apz/src/GenericScrollAnimation.cpp @@ -21,10 +21,10 @@ GenericScrollAnimation::GenericScrollAnimation( AsyncPanZoomController& aApzc, const nsPoint& aInitialPosition, const ScrollAnimationBezierPhysicsSettings& aSettings) : mApzc(aApzc), mFinalDestination(aInitialPosition) { - // ScrollAnimationBezierPhysics (despite its name) handles the case of + // ScrollAnimationBezierPhysics (despite it's name) handles the case of // general.smoothScroll being disabled whereas ScrollAnimationMSDPhysics does // not (ie it scrolls smoothly). - if (aApzc.IsSmoothScrollingEnabled() && + if (StaticPrefs::general_smoothScroll() && StaticPrefs::general_smoothScroll_msdPhysics_enabled()) { mAnimationPhysics = MakeUnique(aInitialPosition); } else { diff --git a/gfx/layers/apz/src/SmoothScrollAnimation.cpp b/gfx/layers/apz/src/SmoothScrollAnimation.cpp index 67422cb2f539..266c027a55d8 100644 --- a/gfx/layers/apz/src/SmoothScrollAnimation.cpp +++ b/gfx/layers/apz/src/SmoothScrollAnimation.cpp @@ -7,7 +7,6 @@ #include "SmoothScrollAnimation.h" #include "ScrollAnimationBezierPhysics.h" #include "mozilla/layers/APZPublicUtils.h" -#include "AsyncPanZoomController.h" namespace mozilla { namespace layers { @@ -15,9 +14,9 @@ namespace layers { SmoothScrollAnimation::SmoothScrollAnimation(AsyncPanZoomController& aApzc, const nsPoint& aInitialPosition, ScrollOrigin aOrigin) - : GenericScrollAnimation(aApzc, aInitialPosition, - apz::ComputeBezierAnimationSettingsForOrigin( - aOrigin, aApzc.IsSmoothScrollingEnabled())), + : GenericScrollAnimation( + aApzc, aInitialPosition, + apz::ComputeBezierAnimationSettingsForOrigin(aOrigin)), mOrigin(aOrigin) {} SmoothScrollAnimation* SmoothScrollAnimation::AsSmoothScrollAnimation() { diff --git a/gfx/layers/apz/test/mochitest/helper_programmatic_scroll_behavior.html b/gfx/layers/apz/test/mochitest/helper_programmatic_scroll_behavior.html index c9f3693edeeb..721ce7e53814 100644 --- a/gfx/layers/apz/test/mochitest/helper_programmatic_scroll_behavior.html +++ b/gfx/layers/apz/test/mochitest/helper_programmatic_scroll_behavior.html @@ -62,12 +62,10 @@ async function test() { await scrollendPromise; - // If general.smoothScroll is set and the user does not prefer reduced motion, - // the behavior of the scroll should be "smooth". If general.smoothScroll is - // disabled, we should respect it and the scrolls should instant regardless of - // the specified behavior. - if (SpecialPowers.getBoolPref("general.smoothScroll") && - SpecialPowers.getIntPref("ui.prefersReducedMotion") == 0) { + // If general.smoothScroll is set, the behavior of the scroll should be + // "smooth". If general.smoothScroll is disabled, we should respect it and + // the scrolls should instant regardless of the specified behavior. + if (SpecialPowers.getBoolPref("general.smoothScroll")) { info("final enabled scroll count: " + scrollCount); ok(scrollCount > 1, "The programmatic scroll should create more than one scroll event"); } else { diff --git a/gfx/layers/apz/test/mochitest/test_group_programmatic_scroll_behavior.html b/gfx/layers/apz/test/mochitest/test_group_programmatic_scroll_behavior.html index e1a4ae588ae5..13bdb4efc41f 100644 --- a/gfx/layers/apz/test/mochitest/test_group_programmatic_scroll_behavior.html +++ b/gfx/layers/apz/test/mochitest/test_group_programmatic_scroll_behavior.html @@ -9,20 +9,19 @@