Bug 1743045 - Respect general.smoothScroll for programmatic scrolls. r=hiro

For programmatic scrolls, we should respect a users general.smoothScroll
preference. If smooth scrolls are disabled, programmatic scrolls with
behavior: "smooth" should be treated as instant programmatic scrolls.

Differential Revision: https://phabricator.services.mozilla.com/D170110
This commit is contained in:
Dan Robertson
2023-02-27 21:09:06 +00:00
parent f65b5e7036
commit a1b0935be4
8 changed files with 214 additions and 64 deletions

View File

@@ -3517,10 +3517,17 @@ static void ScrollToShowRect(nsIScrollableFrame* aFrameAsScrollable,
}
ScrollMode scrollMode = ScrollMode::Instant;
bool autoBehaviorIsSmooth = aFrameAsScrollable->IsSmoothScroll();
bool smoothScroll =
(aScrollFlags & ScrollFlags::ScrollSmooth) ||
((aScrollFlags & ScrollFlags::ScrollSmoothAuto) && autoBehaviorIsSmooth);
// Default to an instant scroll, but if the scroll behavior given is "auto"
// or "smooth", use that as the specified behavior. If the user has disabled
// smooth scrolls, a given mode of "auto" or "smooth" should not result in
// a smooth scroll.
ScrollBehavior behavior = ScrollBehavior::Instant;
if (aScrollFlags & ScrollFlags::ScrollSmooth) {
behavior = ScrollBehavior::Smooth;
} else if (aScrollFlags & ScrollFlags::ScrollSmoothAuto) {
behavior = ScrollBehavior::Auto;
}
bool smoothScroll = aFrameAsScrollable->IsSmoothScroll(behavior);
if (smoothScroll) {
scrollMode = ScrollMode::SmoothMsd;
}