diff --git a/gfx/layers/apz/src/APZInputBridge.cpp b/gfx/layers/apz/src/APZInputBridge.cpp index 42b6f44d8e4a..21631045f872 100644 --- a/gfx/layers/apz/src/APZInputBridge.cpp +++ b/gfx/layers/apz/src/APZInputBridge.cpp @@ -10,6 +10,7 @@ #include "InputData.h" // for MouseInput, etc #include "InputBlockState.h" // for InputBlockState #include "OverscrollHandoffState.h" // for OverscrollHandoffState +#include "nsLayoutUtils.h" // for IsSmoothScrollingEnabled #include "mozilla/EventForwards.h" #include "mozilla/dom/WheelEventBinding.h" // for WheelEvent constants #include "mozilla/EventStateManager.h" // for EventStateManager @@ -331,7 +332,7 @@ APZEventResult APZInputBridge::ReceiveInputEvent( if (Maybe action = ActionForWheelEvent(&wheelEvent)) { ScrollWheelInput::ScrollMode scrollMode = ScrollWheelInput::SCROLLMODE_INSTANT; - if (StaticPrefs::general_smoothScroll() && + if (nsLayoutUtils::IsSmoothScrollingEnabled() && ((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 6902e0738ce3..d0f002e0255f 100644 --- a/gfx/layers/apz/src/APZPublicUtils.cpp +++ b/gfx/layers/apz/src/APZPublicUtils.cpp @@ -7,6 +7,7 @@ #include "mozilla/layers/APZPublicUtils.h" #include "AsyncPanZoomController.h" +#include "nsLayoutUtils.h" #include "mozilla/HelperMacros.h" #include "mozilla/StaticPrefs_general.h" @@ -36,9 +37,10 @@ ScrollAnimationBezierPhysicsSettings ComputeBezierAnimationSettingsForOrigin( int32_t minMS = 0; int32_t maxMS = 0; bool isOriginSmoothnessEnabled = false; + bool isGeneralSmoothnessEnabled = nsLayoutUtils::IsSmoothScrollingEnabled(); #define READ_DURATIONS(prefbase) \ - isOriginSmoothnessEnabled = StaticPrefs::general_smoothScroll() && \ + isOriginSmoothnessEnabled = isGeneralSmoothnessEnabled && \ StaticPrefs::general_smoothScroll_##prefbase(); \ if (isOriginSmoothnessEnabled) { \ minMS = StaticPrefs::general_smoothScroll_##prefbase##_durationMinMS(); \ @@ -88,7 +90,8 @@ ScrollAnimationBezierPhysicsSettings ComputeBezierAnimationSettingsForOrigin( } ScrollMode GetScrollModeForOrigin(ScrollOrigin origin) { - if (!StaticPrefs::general_smoothScroll()) return ScrollMode::Instant; + bool isSmoothScrollingEnabled = nsLayoutUtils::IsSmoothScrollingEnabled(); + if (!isSmoothScrollingEnabled) return ScrollMode::Instant; switch (origin) { case ScrollOrigin::Lines: return StaticPrefs::general_smoothScroll_lines() ? ScrollMode::Smooth @@ -101,8 +104,8 @@ ScrollMode GetScrollModeForOrigin(ScrollOrigin origin) { : ScrollMode::Instant; default: MOZ_ASSERT(false, "Unknown keyboard scroll origin"); - return StaticPrefs::general_smoothScroll() ? ScrollMode::Smooth - : ScrollMode::Instant; + return isSmoothScrollingEnabled ? ScrollMode::Smooth + : ScrollMode::Instant; } } diff --git a/gfx/layers/apz/src/GenericScrollAnimation.cpp b/gfx/layers/apz/src/GenericScrollAnimation.cpp index 62f19fab35e4..ae4c4371c3de 100644 --- a/gfx/layers/apz/src/GenericScrollAnimation.cpp +++ b/gfx/layers/apz/src/GenericScrollAnimation.cpp @@ -8,6 +8,7 @@ #include "AsyncPanZoomController.h" #include "FrameMetrics.h" +#include "nsLayoutUtils.h" #include "mozilla/layers/APZPublicUtils.h" #include "nsPoint.h" #include "ScrollAnimationPhysics.h" @@ -28,7 +29,7 @@ GenericScrollAnimation::GenericScrollAnimation(AsyncPanZoomController& aApzc, // ScrollAnimationBezierPhysics (despite its name) handles the case of // general.smoothScroll being disabled whereas ScrollAnimationMSDPhysics does // not (ie it scrolls smoothly). - if (StaticPrefs::general_smoothScroll() && + if (nsLayoutUtils::IsSmoothScrollingEnabled() && StaticPrefs::general_smoothScroll_msdPhysics_enabled()) { mAnimationPhysics = MakeUnique(aInitialPosition); } else { diff --git a/gfx/layers/apz/src/WheelScrollAnimation.cpp b/gfx/layers/apz/src/WheelScrollAnimation.cpp index ddc88615de46..cd59eca642fa 100644 --- a/gfx/layers/apz/src/WheelScrollAnimation.cpp +++ b/gfx/layers/apz/src/WheelScrollAnimation.cpp @@ -8,6 +8,7 @@ #include #include "AsyncPanZoomController.h" +#include "nsLayoutUtils.h" #include "mozilla/StaticPrefs_general.h" #include "mozilla/layers/APZPublicUtils.h" #include "nsPoint.h" @@ -35,7 +36,7 @@ WheelScrollAnimation::WheelScrollAnimation( ScrollWheelInput::ScrollDeltaType aDeltaType) : GenericScrollAnimation(aApzc, aInitialPosition, OriginForDeltaType(aDeltaType)) { - MOZ_ASSERT(StaticPrefs::general_smoothScroll(), + MOZ_ASSERT(nsLayoutUtils::IsSmoothScrollingEnabled(), "We shouldn't be creating a WheelScrollAnimation if smooth " "scrolling is disabled"); mDirectionForcedToOverscroll = diff --git a/layout/xul/nsSliderFrame.cpp b/layout/xul/nsSliderFrame.cpp index bff2647ed352..7f5620cbece4 100644 --- a/layout/xul/nsSliderFrame.cpp +++ b/layout/xul/nsSliderFrame.cpp @@ -1540,7 +1540,7 @@ void nsSliderFrame::PageScroll(bool aClickAndHold) { mCurrentClickHoldDestination = Some(pos); sf->ScrollTo(pos, - StaticPrefs::general_smoothScroll() && + nsLayoutUtils::IsSmoothScrollingEnabled() && StaticPrefs::general_smoothScroll_pages() ? ScrollMode::Smooth : ScrollMode::Instant, diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm index 062105ce7cc6..017499dc7f8a 100644 --- a/widget/cocoa/nsChildView.mm +++ b/widget/cocoa/nsChildView.mm @@ -3295,7 +3295,7 @@ static gfx::IntPoint GetIntegerDeltaForEvent(NSEvent* aEvent) { } else { ScrollWheelInput::ScrollMode scrollMode = ScrollWheelInput::SCROLLMODE_INSTANT; - if (StaticPrefs::general_smoothScroll() && + if (nsLayoutUtils::IsSmoothScrollingEnabled() && StaticPrefs::general_smoothScroll_mouseWheel()) { scrollMode = ScrollWheelInput::SCROLLMODE_SMOOTH; }