Backed out 2 changesets (bug 1753565) for causing bc failures in browser_proton_moreTools_panel.js CLOSED TREE

Backed out changeset 817b0cf1e4e0 (bug 1753565)
Backed out changeset 947534ff1319 (bug 1753565)
This commit is contained in:
Cristian Tuns 2023-04-18 02:03:20 -04:00
parent 5b6634089f
commit f65f34399a
21 changed files with 48 additions and 117 deletions

View file

@ -862,7 +862,6 @@ struct ScrollMetadata {
mForceMousewheelAutodir(false), mForceMousewheelAutodir(false),
mForceMousewheelAutodirHonourRoot(false), mForceMousewheelAutodirHonourRoot(false),
mIsPaginatedPresentation(false), mIsPaginatedPresentation(false),
mPrefersReducedMotion(false),
mOverscrollBehavior() {} mOverscrollBehavior() {}
bool operator==(const ScrollMetadata& aOther) const { bool operator==(const ScrollMetadata& aOther) const {
@ -882,7 +881,6 @@ struct ScrollMetadata {
mForceMousewheelAutodirHonourRoot == mForceMousewheelAutodirHonourRoot ==
aOther.mForceMousewheelAutodirHonourRoot && aOther.mForceMousewheelAutodirHonourRoot &&
mIsPaginatedPresentation == aOther.mIsPaginatedPresentation && mIsPaginatedPresentation == aOther.mIsPaginatedPresentation &&
mPrefersReducedMotion == aOther.mPrefersReducedMotion &&
mDisregardedDirection == aOther.mDisregardedDirection && mDisregardedDirection == aOther.mDisregardedDirection &&
mOverscrollBehavior == aOther.mOverscrollBehavior && mOverscrollBehavior == aOther.mOverscrollBehavior &&
mScrollUpdates == aOther.mScrollUpdates; mScrollUpdates == aOther.mScrollUpdates;
@ -967,9 +965,6 @@ struct ScrollMetadata {
} }
bool IsPaginatedPresentation() const { return mIsPaginatedPresentation; } bool IsPaginatedPresentation() const { return mIsPaginatedPresentation; }
void SetPrefersReducedMotion(bool aValue) { mPrefersReducedMotion = aValue; }
bool PrefersReducedMotion() const { return mPrefersReducedMotion; }
bool DidContentGetPainted() const { return mDidContentGetPainted; } bool DidContentGetPainted() const { return mDidContentGetPainted; }
private: private:
@ -1084,10 +1079,6 @@ struct ScrollMetadata {
// to different transforms, which constrains the assumptions APZ can make. // to different transforms, which constrains the assumptions APZ can make.
bool mIsPaginatedPresentation : 1; 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, // The disregarded direction means the direction which is disregarded anyway,
// even if the scroll frame overflows in that direction and the direction is // even if the scroll frame overflows in that direction and the direction is
// specified as scrollable. This could happen in some scenarios, for instance, // specified as scrollable. This could happen in some scenarios, for instance,

View file

@ -66,14 +66,13 @@ gfx::IntSize GetDisplayportAlignmentMultiplier(const ScreenSize& aBaseSize);
* given origin, based on pref values. * given origin, based on pref values.
*/ */
ScrollAnimationBezierPhysicsSettings ComputeBezierAnimationSettingsForOrigin( ScrollAnimationBezierPhysicsSettings ComputeBezierAnimationSettingsForOrigin(
ScrollOrigin aOrigin, bool aSmoothScrollingEnabled); ScrollOrigin aOrigin);
/** /**
* Calculate if the scrolling should be instant or smooth based based on * Calculate if the scrolling should be instant or smooth based based on
* preferences and the origin * preferences and the origin
*/ */
ScrollMode GetScrollModeForOrigin(ScrollOrigin origin, ScrollMode GetScrollModeForOrigin(ScrollOrigin origin);
bool aSmoothScrollingEnabled);
} // namespace apz } // namespace apz

View file

@ -22,7 +22,6 @@
#include "mozilla/TouchEvents.h" // for WidgetTouchEvent #include "mozilla/TouchEvents.h" // for WidgetTouchEvent
#include "mozilla/WheelHandlingHelper.h" // for WheelDeltaHorizontalizer, #include "mozilla/WheelHandlingHelper.h" // for WheelDeltaHorizontalizer,
// WheelDeltaAdjustmentStrategy // WheelDeltaAdjustmentStrategy
#include "nsLayoutUtils.h" // for IsSmoothScrollingEnabled
namespace mozilla { namespace mozilla {
namespace layers { namespace layers {
@ -229,7 +228,7 @@ APZEventResult APZInputBridge::ReceiveInputEvent(
if (Maybe<APZWheelAction> action = ActionForWheelEvent(&wheelEvent)) { if (Maybe<APZWheelAction> action = ActionForWheelEvent(&wheelEvent)) {
ScrollWheelInput::ScrollMode scrollMode = ScrollWheelInput::ScrollMode scrollMode =
ScrollWheelInput::SCROLLMODE_INSTANT; ScrollWheelInput::SCROLLMODE_INSTANT;
if (nsLayoutUtils::IsSmoothScrollingEnabled() && if (StaticPrefs::general_smoothScroll() &&
((wheelEvent.mDeltaMode == ((wheelEvent.mDeltaMode ==
dom::WheelEvent_Binding::DOM_DELTA_LINE && dom::WheelEvent_Binding::DOM_DELTA_LINE &&
StaticPrefs::general_smoothScroll_mouseWheel()) || StaticPrefs::general_smoothScroll_mouseWheel()) ||

View file

@ -32,13 +32,13 @@ namespace apz {
} }
ScrollAnimationBezierPhysicsSettings ComputeBezierAnimationSettingsForOrigin( ScrollAnimationBezierPhysicsSettings ComputeBezierAnimationSettingsForOrigin(
ScrollOrigin aOrigin, bool aSmoothScrollingEnabled) { ScrollOrigin aOrigin) {
int32_t minMS = 0; int32_t minMS = 0;
int32_t maxMS = 0; int32_t maxMS = 0;
bool isOriginSmoothnessEnabled = false; bool isOriginSmoothnessEnabled = false;
#define READ_DURATIONS(prefbase) \ #define READ_DURATIONS(prefbase) \
isOriginSmoothnessEnabled = aSmoothScrollingEnabled && \ isOriginSmoothnessEnabled = StaticPrefs::general_smoothScroll() && \
StaticPrefs::general_smoothScroll_##prefbase(); \ StaticPrefs::general_smoothScroll_##prefbase(); \
if (isOriginSmoothnessEnabled) { \ if (isOriginSmoothnessEnabled) { \
minMS = StaticPrefs::general_smoothScroll_##prefbase##_durationMinMS(); \ minMS = StaticPrefs::general_smoothScroll_##prefbase##_durationMinMS(); \
@ -87,9 +87,8 @@ ScrollAnimationBezierPhysicsSettings ComputeBezierAnimationSettingsForOrigin(
return ScrollAnimationBezierPhysicsSettings{minMS, maxMS, intervalRatio}; return ScrollAnimationBezierPhysicsSettings{minMS, maxMS, intervalRatio};
} }
ScrollMode GetScrollModeForOrigin(ScrollOrigin origin, ScrollMode GetScrollModeForOrigin(ScrollOrigin origin) {
bool aSmoothScrollingEnabled) { if (!StaticPrefs::general_smoothScroll()) return ScrollMode::Instant;
if (!aSmoothScrollingEnabled) return ScrollMode::Instant;
switch (origin) { switch (origin) {
case ScrollOrigin::Lines: case ScrollOrigin::Lines:
return StaticPrefs::general_smoothScroll_lines() ? ScrollMode::Smooth return StaticPrefs::general_smoothScroll_lines() ? ScrollMode::Smooth
@ -102,7 +101,8 @@ ScrollMode GetScrollModeForOrigin(ScrollOrigin origin,
: ScrollMode::Instant; : ScrollMode::Instant;
default: default:
MOZ_ASSERT(false, "Unknown keyboard scroll origin"); MOZ_ASSERT(false, "Unknown keyboard scroll origin");
return ScrollMode::Instant; return StaticPrefs::general_smoothScroll() ? ScrollMode::Smooth
: ScrollMode::Instant;
} }
} }

View file

@ -2041,8 +2041,7 @@ nsEventStatus AsyncPanZoomController::OnKeyboard(const KeyboardInput& aEvent) {
SmoothScrollAnimation::GetScrollOriginForAction(aEvent.mAction.mType); SmoothScrollAnimation::GetScrollOriginForAction(aEvent.mAction.mType);
Maybe<CSSSnapTarget> snapTarget = MaybeAdjustDestinationForScrollSnapping( Maybe<CSSSnapTarget> snapTarget = MaybeAdjustDestinationForScrollSnapping(
aEvent, destination, GetScrollSnapFlagsForKeyboardAction(aEvent.mAction)); aEvent, destination, GetScrollSnapFlagsForKeyboardAction(aEvent.mAction));
ScrollMode scrollMode = ScrollMode scrollMode = apz::GetScrollModeForOrigin(scrollOrigin);
apz::GetScrollModeForOrigin(scrollOrigin, IsSmoothScrollingEnabled());
RecordScrollPayload(aEvent.mTimeStamp); RecordScrollPayload(aEvent.mTimeStamp);
// If the scrolling is instant, then scroll immediately to the destination // If the scrolling is instant, then scroll immediately to the destination
@ -3555,12 +3554,6 @@ void AsyncPanZoomController::UpdateWithTouchAtDevicePoint(
mY.UpdateWithTouchAtDevicePoint(point.y, aEvent.mTimeStamp); mY.UpdateWithTouchAtDevicePoint(point.y, aEvent.mTimeStamp);
} }
bool AsyncPanZoomController::IsSmoothScrollingEnabled() const {
RecursiveMutexAutoLock lock(mRecursiveMutex);
return StaticPrefs::general_smoothScroll_DoNotUseDirectly() &&
!mScrollMetadata.PrefersReducedMotion();
}
Maybe<CompositionPayload> AsyncPanZoomController::NotifyScrollSampling() { Maybe<CompositionPayload> AsyncPanZoomController::NotifyScrollSampling() {
RecursiveMutexAutoLock lock(mRecursiveMutex); RecursiveMutexAutoLock lock(mRecursiveMutex);
return mSampledState.front().TakeScrollPayload(); return mSampledState.front().TakeScrollPayload();
@ -5449,8 +5442,6 @@ void AsyncPanZoomController::NotifyLayersUpdated(
aScrollMetadata.GetDisregardedDirection()); aScrollMetadata.GetDisregardedDirection());
mScrollMetadata.SetOverscrollBehavior( mScrollMetadata.SetOverscrollBehavior(
aScrollMetadata.GetOverscrollBehavior()); aScrollMetadata.GetOverscrollBehavior());
mScrollMetadata.SetPrefersReducedMotion(
aScrollMetadata.PrefersReducedMotion());
} }
bool scrollOffsetUpdated = false; bool scrollOffsetUpdated = false;

View file

@ -20,7 +20,6 @@
#include "mozilla/RefPtr.h" #include "mozilla/RefPtr.h"
#include "mozilla/ScrollTypes.h" #include "mozilla/ScrollTypes.h"
#include "mozilla/StaticPrefs_apz.h" #include "mozilla/StaticPrefs_apz.h"
#include "mozilla/StaticPrefs_general.h"
#include "mozilla/UniquePtr.h" #include "mozilla/UniquePtr.h"
#include "InputData.h" #include "InputData.h"
#include "Axis.h" // for Axis, Side, etc. #include "Axis.h" // for Axis, Side, etc.
@ -1137,12 +1136,6 @@ class AsyncPanZoomController {
friend class Axis; friend class Axis;
public: public:
/**
* Returns true if smooth scrolls are enabled and the user does not
* prefer reduced motion.
*/
bool IsSmoothScrollingEnabled() const;
Maybe<CompositionPayload> NotifyScrollSampling(); Maybe<CompositionPayload> NotifyScrollSampling();
/** /**

View file

@ -21,10 +21,10 @@ GenericScrollAnimation::GenericScrollAnimation(
AsyncPanZoomController& aApzc, const nsPoint& aInitialPosition, AsyncPanZoomController& aApzc, const nsPoint& aInitialPosition,
const ScrollAnimationBezierPhysicsSettings& aSettings) const ScrollAnimationBezierPhysicsSettings& aSettings)
: mApzc(aApzc), mFinalDestination(aInitialPosition) { : 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 // general.smoothScroll being disabled whereas ScrollAnimationMSDPhysics does
// not (ie it scrolls smoothly). // not (ie it scrolls smoothly).
if (aApzc.IsSmoothScrollingEnabled() && if (StaticPrefs::general_smoothScroll() &&
StaticPrefs::general_smoothScroll_msdPhysics_enabled()) { StaticPrefs::general_smoothScroll_msdPhysics_enabled()) {
mAnimationPhysics = MakeUnique<ScrollAnimationMSDPhysics>(aInitialPosition); mAnimationPhysics = MakeUnique<ScrollAnimationMSDPhysics>(aInitialPosition);
} else { } else {

View file

@ -7,7 +7,6 @@
#include "SmoothScrollAnimation.h" #include "SmoothScrollAnimation.h"
#include "ScrollAnimationBezierPhysics.h" #include "ScrollAnimationBezierPhysics.h"
#include "mozilla/layers/APZPublicUtils.h" #include "mozilla/layers/APZPublicUtils.h"
#include "AsyncPanZoomController.h"
namespace mozilla { namespace mozilla {
namespace layers { namespace layers {
@ -15,9 +14,9 @@ namespace layers {
SmoothScrollAnimation::SmoothScrollAnimation(AsyncPanZoomController& aApzc, SmoothScrollAnimation::SmoothScrollAnimation(AsyncPanZoomController& aApzc,
const nsPoint& aInitialPosition, const nsPoint& aInitialPosition,
ScrollOrigin aOrigin) ScrollOrigin aOrigin)
: GenericScrollAnimation(aApzc, aInitialPosition, : GenericScrollAnimation(
apz::ComputeBezierAnimationSettingsForOrigin( aApzc, aInitialPosition,
aOrigin, aApzc.IsSmoothScrollingEnabled())), apz::ComputeBezierAnimationSettingsForOrigin(aOrigin)),
mOrigin(aOrigin) {} mOrigin(aOrigin) {}
SmoothScrollAnimation* SmoothScrollAnimation::AsSmoothScrollAnimation() { SmoothScrollAnimation* SmoothScrollAnimation::AsSmoothScrollAnimation() {

View file

@ -62,12 +62,10 @@ async function test() {
await scrollendPromise; await scrollendPromise;
// If general.smoothScroll is set and the user does not prefer reduced motion, // If general.smoothScroll is set, the behavior of the scroll should be
// the behavior of the scroll should be "smooth". If general.smoothScroll is // "smooth". If general.smoothScroll is disabled, we should respect it and
// disabled, we should respect it and the scrolls should instant regardless of // the scrolls should instant regardless of the specified behavior.
// the specified behavior. if (SpecialPowers.getBoolPref("general.smoothScroll")) {
if (SpecialPowers.getBoolPref("general.smoothScroll") &&
SpecialPowers.getIntPref("ui.prefersReducedMotion") == 0) {
info("final enabled scroll count: " + scrollCount); info("final enabled scroll count: " + scrollCount);
ok(scrollCount > 1, "The programmatic scroll should create more than one scroll event"); ok(scrollCount > 1, "The programmatic scroll should create more than one scroll event");
} else { } else {

View file

@ -9,20 +9,19 @@
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript"> <script type="application/javascript">
let preferenceSets = [ let smoothScrollEnabled = [["general.smoothScroll", true]];
[["general.smoothScroll", true], ["ui.prefersReducedMotion", 0]], let smoothScrollDisabled = [["general.smoothScroll", false]];
[["general.smoothScroll", false], ["ui.prefersReducedMotion", 0]],
[["general.smoothScroll", true], ["ui.prefersReducedMotion", 1]],
];
let subtests = preferenceSets.flatMap((prefs) => { var subtests = [
return [ {"file": "helper_programmatic_scroll_behavior.html?action=scrollIntoView", "prefs": smoothScrollEnabled},
{"file": "helper_programmatic_scroll_behavior.html?action=scrollIntoView", "prefs": prefs}, {"file": "helper_programmatic_scroll_behavior.html?action=scrollIntoView", "prefs": smoothScrollDisabled},
{"file": "helper_programmatic_scroll_behavior.html?action=scrollBy", "prefs": prefs}, {"file": "helper_programmatic_scroll_behavior.html?action=scrollBy", "prefs": smoothScrollEnabled},
{"file": "helper_programmatic_scroll_behavior.html?action=scrollTo", "prefs": prefs}, {"file": "helper_programmatic_scroll_behavior.html?action=scrollBy", "prefs": smoothScrollDisabled},
{"file": "helper_programmatic_scroll_behavior.html?action=scroll", "prefs": prefs}, {"file": "helper_programmatic_scroll_behavior.html?action=scrollTo", "prefs": smoothScrollEnabled},
]; {"file": "helper_programmatic_scroll_behavior.html?action=scrollTo", "prefs": smoothScrollDisabled},
}); {"file": "helper_programmatic_scroll_behavior.html?action=scroll", "prefs": smoothScrollEnabled},
{"file": "helper_programmatic_scroll_behavior.html?action=scroll", "prefs": smoothScrollDisabled},
];
if (isApzEnabled()) { if (isApzEnabled()) {
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();

View file

@ -10,8 +10,6 @@
var basePrefs = [ var basePrefs = [
["apz.test.mac.synth_wheel_input", true], ["apz.test.mac.synth_wheel_input", true],
["general.smoothScroll", true],
["ui.prefersReducedMotion", 0],
]; ];
var scrollendDisabledPrefs = [ var scrollendDisabledPrefs = [
@ -25,8 +23,8 @@ var prefs = [
]; ];
var smoothScrollDisabled = [ var smoothScrollDisabled = [
["apz.test.mac.synth_wheel_input", true], ...basePrefs,
["general.smoothScroll", false], ["general.smoothScroll", true],
]; ];
var subtests = [ var subtests = [

View file

@ -571,7 +571,6 @@ struct ParamTraits<mozilla::layers::ScrollMetadata>
WriteParam(aWriter, aParam.mForceMousewheelAutodir); WriteParam(aWriter, aParam.mForceMousewheelAutodir);
WriteParam(aWriter, aParam.mForceMousewheelAutodirHonourRoot); WriteParam(aWriter, aParam.mForceMousewheelAutodirHonourRoot);
WriteParam(aWriter, aParam.mIsPaginatedPresentation); WriteParam(aWriter, aParam.mIsPaginatedPresentation);
WriteParam(aWriter, aParam.mPrefersReducedMotion);
WriteParam(aWriter, aParam.mDisregardedDirection); WriteParam(aWriter, aParam.mDisregardedDirection);
WriteParam(aWriter, aParam.mOverscrollBehavior); WriteParam(aWriter, aParam.mOverscrollBehavior);
WriteParam(aWriter, aParam.mScrollUpdates); WriteParam(aWriter, aParam.mScrollUpdates);
@ -615,8 +614,6 @@ struct ParamTraits<mozilla::layers::ScrollMetadata>
&paramType::SetForceMousewheelAutodirHonourRoot) && &paramType::SetForceMousewheelAutodirHonourRoot) &&
ReadBoolForBitfield(aReader, aResult, ReadBoolForBitfield(aReader, aResult,
&paramType::SetIsPaginatedPresentation) && &paramType::SetIsPaginatedPresentation) &&
ReadBoolForBitfield(aReader, aResult,
&paramType::SetPrefersReducedMotion) &&
ReadParam(aReader, &aResult->mDisregardedDirection) && ReadParam(aReader, &aResult->mDisregardedDirection) &&
ReadParam(aReader, &aResult->mOverscrollBehavior) && ReadParam(aReader, &aResult->mOverscrollBehavior) &&
ReadParam(aReader, &aResult->mScrollUpdates); ReadParam(aReader, &aResult->mScrollUpdates);

View file

@ -2367,8 +2367,7 @@ NS_IMETHODIMP
PresShell::ScrollPage(bool aForward) { PresShell::ScrollPage(bool aForward) {
nsIScrollableFrame* scrollFrame = nsIScrollableFrame* scrollFrame =
GetScrollableFrameToScroll(VerticalScrollDirection); GetScrollableFrameToScroll(VerticalScrollDirection);
ScrollMode scrollMode = apz::GetScrollModeForOrigin( ScrollMode scrollMode = apz::GetScrollModeForOrigin(ScrollOrigin::Pages);
ScrollOrigin::Pages, nsLayoutUtils::IsSmoothScrollingEnabled());
if (scrollFrame) { if (scrollFrame) {
scrollFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1), ScrollUnit::PAGES, scrollFrame->ScrollBy(nsIntPoint(0, aForward ? 1 : -1), ScrollUnit::PAGES,
scrollMode, nullptr, scrollMode, nullptr,
@ -2384,8 +2383,7 @@ NS_IMETHODIMP
PresShell::ScrollLine(bool aForward) { PresShell::ScrollLine(bool aForward) {
nsIScrollableFrame* scrollFrame = nsIScrollableFrame* scrollFrame =
GetScrollableFrameToScroll(VerticalScrollDirection); GetScrollableFrameToScroll(VerticalScrollDirection);
ScrollMode scrollMode = apz::GetScrollModeForOrigin( ScrollMode scrollMode = apz::GetScrollModeForOrigin(ScrollOrigin::Lines);
ScrollOrigin::Lines, nsLayoutUtils::IsSmoothScrollingEnabled());
if (scrollFrame) { if (scrollFrame) {
nsRect scrollPort = scrollFrame->GetScrollPortRect(); nsRect scrollPort = scrollFrame->GetScrollPortRect();
nsSize lineSize = scrollFrame->GetLineScrollAmount(); nsSize lineSize = scrollFrame->GetLineScrollAmount();
@ -2405,8 +2403,7 @@ NS_IMETHODIMP
PresShell::ScrollCharacter(bool aRight) { PresShell::ScrollCharacter(bool aRight) {
nsIScrollableFrame* scrollFrame = nsIScrollableFrame* scrollFrame =
GetScrollableFrameToScroll(HorizontalScrollDirection); GetScrollableFrameToScroll(HorizontalScrollDirection);
ScrollMode scrollMode = apz::GetScrollModeForOrigin( ScrollMode scrollMode = apz::GetScrollModeForOrigin(ScrollOrigin::Lines);
ScrollOrigin::Lines, nsLayoutUtils::IsSmoothScrollingEnabled());
if (scrollFrame) { if (scrollFrame) {
int32_t h = StaticPrefs::toolkit_scrollbox_horizontalScrollDistance(); int32_t h = StaticPrefs::toolkit_scrollbox_horizontalScrollDistance();
scrollFrame->ScrollBy( scrollFrame->ScrollBy(
@ -2421,8 +2418,7 @@ NS_IMETHODIMP
PresShell::CompleteScroll(bool aForward) { PresShell::CompleteScroll(bool aForward) {
nsIScrollableFrame* scrollFrame = nsIScrollableFrame* scrollFrame =
GetScrollableFrameToScroll(VerticalScrollDirection); GetScrollableFrameToScroll(VerticalScrollDirection);
ScrollMode scrollMode = apz::GetScrollModeForOrigin( ScrollMode scrollMode = apz::GetScrollModeForOrigin(ScrollOrigin::Other);
ScrollOrigin::Other, nsLayoutUtils::IsSmoothScrollingEnabled());
if (scrollFrame) { if (scrollFrame) {
scrollFrame->ScrollBy( scrollFrame->ScrollBy(
nsIntPoint(0, aForward ? 1 : -1), ScrollUnit::WHOLE, scrollMode, nsIntPoint(0, aForward ? 1 : -1), ScrollUnit::WHOLE, scrollMode,

View file

@ -85,7 +85,6 @@
#include "mozilla/StaticPrefs_apz.h" #include "mozilla/StaticPrefs_apz.h"
#include "mozilla/StaticPrefs_dom.h" #include "mozilla/StaticPrefs_dom.h"
#include "mozilla/StaticPrefs_font.h" #include "mozilla/StaticPrefs_font.h"
#include "mozilla/StaticPrefs_general.h"
#include "mozilla/StaticPrefs_gfx.h" #include "mozilla/StaticPrefs_gfx.h"
#include "mozilla/StaticPrefs_image.h" #include "mozilla/StaticPrefs_image.h"
#include "mozilla/StaticPrefs_layers.h" #include "mozilla/StaticPrefs_layers.h"
@ -7770,16 +7769,6 @@ size_t nsLayoutUtils::SizeOfTextRunsForFrames(nsIFrame* aFrame,
return total; return total;
} }
bool nsLayoutUtils::PrefersReducedMotion() {
MOZ_ASSERT(NS_IsMainThread());
return LookAndFeel::GetInt(LookAndFeel::IntID::PrefersReducedMotion, 0) == 1;
}
bool nsLayoutUtils::IsSmoothScrollingEnabled() {
return StaticPrefs::general_smoothScroll_DoNotUseDirectly() &&
!PrefersReducedMotion();
}
/* static */ /* static */
void nsLayoutUtils::Initialize() { void nsLayoutUtils::Initialize() {
nsComputedDOMStyle::RegisterPrefChangeCallbacks(); nsComputedDOMStyle::RegisterPrefChangeCallbacks();
@ -9008,7 +8997,6 @@ ScrollMetadata nsLayoutUtils::ComputeScrollMetadata(
metadata.SetIsPaginatedPresentation(presContext->Type() != metadata.SetIsPaginatedPresentation(presContext->Type() !=
nsPresContext::eContext_Galley); nsPresContext::eContext_Galley);
metadata.SetPrefersReducedMotion(PrefersReducedMotion());
return metadata; return metadata;
} }

View file

@ -3039,21 +3039,6 @@ class nsLayoutUtils {
**/ **/
static nsIFrame* GetNearestOverflowClipFrame(nsIFrame* aFrame); static nsIFrame* GetNearestOverflowClipFrame(nsIFrame* aFrame);
/**
* Returns true if the user's preferences and system settings allow for smooth
* scrolling.
*
* Note: Must only be called on the main thread.
*/
static bool IsSmoothScrollingEnabled();
/**
* Returns true if the user's system settings prefer reduced motion.
*
* Note: Must only be called on the main thread.
*/
static bool PrefersReducedMotion();
private: private:
/** /**
* Helper function for LogTestDataForPaint(). * Helper function for LogTestDataForPaint().

View file

@ -2222,8 +2222,7 @@ void nsHTMLScrollFrame::AsyncScroll::InitSmoothScroll(
MakeUnique<ScrollAnimationMSDPhysics>(aInitialPosition); MakeUnique<ScrollAnimationMSDPhysics>(aInitialPosition);
} else { } else {
ScrollAnimationBezierPhysicsSettings settings = ScrollAnimationBezierPhysicsSettings settings =
layers::apz::ComputeBezierAnimationSettingsForOrigin( layers::apz::ComputeBezierAnimationSettingsForOrigin(mOrigin);
mOrigin, nsLayoutUtils::IsSmoothScrollingEnabled());
mAnimationPhysics = mAnimationPhysics =
MakeUnique<ScrollAnimationBezierPhysics>(aInitialPosition, settings); MakeUnique<ScrollAnimationBezierPhysics>(aInitialPosition, settings);
} }
@ -2235,6 +2234,11 @@ void nsHTMLScrollFrame::AsyncScroll::InitSmoothScroll(
mAnimationPhysics->Update(aTime, aDestination, aCurrentVelocity); mAnimationPhysics->Update(aTime, aDestination, aCurrentVelocity);
} }
/* static */
bool nsHTMLScrollFrame::IsSmoothScrollingEnabled() {
return StaticPrefs::general_smoothScroll();
}
/* /*
* Callback function from AsyncSmoothMSDScroll, used in * Callback function from AsyncSmoothMSDScroll, used in
* nsHTMLScrollFrame::ScrollTo * nsHTMLScrollFrame::ScrollTo
@ -2556,8 +2560,7 @@ void nsHTMLScrollFrame::ScrollToWithOrigin(nsPoint aScrollPosition,
mAsyncScroll->SetRefreshObserver(this); mAsyncScroll->SetRefreshObserver(this);
} }
const bool isSmoothScroll = const bool isSmoothScroll = aParams.IsSmooth() && IsSmoothScrollingEnabled();
aParams.IsSmooth() && nsLayoutUtils::IsSmoothScrollingEnabled();
if (isSmoothScroll) { if (isSmoothScroll) {
mAsyncScroll->InitSmoothScroll(now, GetScrollPosition(), mDestination, mAsyncScroll->InitSmoothScroll(now, GetScrollPosition(), mDestination,
aParams.mOrigin, range, currentVelocity); aParams.mOrigin, range, currentVelocity);
@ -7913,7 +7916,7 @@ bool nsHTMLScrollFrame::IsSmoothScroll(dom::ScrollBehavior aBehavior) const {
// smooth scrolls. A requested smooth scroll when smooth scrolling is // smooth scrolls. A requested smooth scroll when smooth scrolling is
// disabled should be equivalent to an instant scroll. // disabled should be equivalent to an instant scroll.
if (aBehavior == dom::ScrollBehavior::Instant || if (aBehavior == dom::ScrollBehavior::Instant ||
!nsLayoutUtils::IsSmoothScrollingEnabled()) { !nsHTMLScrollFrame::IsSmoothScrollingEnabled()) {
return false; return false;
} }

View file

@ -538,6 +538,8 @@ class nsHTMLScrollFrame : public nsContainerFrame,
void PostScrolledAreaEvent(); void PostScrolledAreaEvent();
MOZ_CAN_RUN_SCRIPT void FireScrolledAreaEvent(); MOZ_CAN_RUN_SCRIPT void FireScrolledAreaEvent();
static bool IsSmoothScrollingEnabled();
/** /**
* @note This method might destroy the frame, pres shell and other objects. * @note This method might destroy the frame, pres shell and other objects.
*/ */

View file

@ -5442,7 +5442,6 @@
type: RelaxedAtomicBool type: RelaxedAtomicBool
value: true value: true
mirror: always mirror: always
do_not_use_directly: true
# This pref and general.smoothScroll.stopDecelerationWeighting determine # This pref and general.smoothScroll.stopDecelerationWeighting determine
# the timing function. # the timing function.

View file

@ -13,6 +13,3 @@ user_pref("javascript.options.asyncstack_capture_debuggee_only", false);
// is suppressed, synthetic click events and co. go to the old page, which can // is suppressed, synthetic click events and co. go to the old page, which can
// be confusing for tests that send click events before the first paint. // be confusing for tests that send click events before the first paint.
user_pref("nglayout.initialpaint.unsuppress_with_no_background", true); user_pref("nglayout.initialpaint.unsuppress_with_no_background", true);
// Disable prefers-reduced-motion to ensure that smooth scrolls can be tested.
user_pref("ui.prefersReducedMotion", 0);

View file

@ -81,5 +81,3 @@ user_pref("layout.css.font-loading-api.workers.enabled", true);
user_pref("remote.experimental.enabled", true); user_pref("remote.experimental.enabled", true);
// Disable always partitioning storage with the Storage Access API // Disable always partitioning storage with the Storage Access API
user_pref("privacy.partition.always_partition_third_party_non_cookie_storage", false); user_pref("privacy.partition.always_partition_third_party_non_cookie_storage", false);
// Disable prefers-reduced-motion to ensure that smooth scrolls can be tested.
user_pref("ui.prefersReducedMotion", 0);

View file

@ -3189,8 +3189,7 @@ static gfx::IntPoint GetIntegerDeltaForEvent(NSEvent* aEvent) {
geckoChildDeathGrip->DispatchAPZWheelInputEvent(wheelEvent); geckoChildDeathGrip->DispatchAPZWheelInputEvent(wheelEvent);
} else { } else {
ScrollWheelInput::ScrollMode scrollMode = ScrollWheelInput::SCROLLMODE_INSTANT; ScrollWheelInput::ScrollMode scrollMode = ScrollWheelInput::SCROLLMODE_INSTANT;
if (nsLayoutUtils::IsSmoothScrollingEnabled() && if (StaticPrefs::general_smoothScroll() && StaticPrefs::general_smoothScroll_mouseWheel()) {
StaticPrefs::general_smoothScroll_mouseWheel()) {
scrollMode = ScrollWheelInput::SCROLLMODE_SMOOTH; scrollMode = ScrollWheelInput::SCROLLMODE_SMOOTH;
} }
ScrollWheelInput wheelEvent(eventTimeStamp, modifiers, scrollMode, ScrollWheelInput wheelEvent(eventTimeStamp, modifiers, scrollMode,