Bug 1753565 - Disable smooth scrolls if prefers-reduced-motion. r=botond

If the user has the prefers-reduced-motion system setting enabled, do
not enable smooth scrolls.

Differential Revision: https://phabricator.services.mozilla.com/D172446
This commit is contained in:
Dan Robertson
2023-04-18 04:11:10 +00:00
parent 82c846d592
commit a1fd34dcbc
18 changed files with 108 additions and 46 deletions

View File

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