commit eb408c452f2b4059dd9f9b33e07dcf28242cedbc
parent d18702226672e73e35fef6e3da3dc112c2f8901f
Author: Botond Ballo <botond@mozilla.com>
Date: Wed, 3 Dec 2025 20:04:37 +0000
Bug 1999440 - Add a layout.css.scroll-behavior.same-physics-as-user-input pref. r=hiro,layout-reviewers
When enabled, programmatic smooth scrolls governed by scroll-behavior
use the same physics as scroll animations triggered by user input
(specified by ScrollMode::Smooth), rather than the physics used for
scroll snapping (specified by ScrollMode::SmoothMsd).
Differential Revision: https://phabricator.services.mozilla.com/D272349
Diffstat:
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/layout/generic/ScrollContainerFrame.cpp b/layout/generic/ScrollContainerFrame.cpp
@@ -7831,8 +7831,13 @@ bool ScrollContainerFrame::IsSmoothScroll(dom::ScrollBehavior aBehavior) const {
ScrollMode ScrollContainerFrame::ScrollModeForScrollBehavior(
dom::ScrollBehavior aBehavior) const {
- return IsSmoothScroll(aBehavior) ? ScrollMode::SmoothMsd
- : ScrollMode::Instant;
+ if (!IsSmoothScroll(aBehavior)) {
+ return ScrollMode::Instant;
+ }
+
+ return StaticPrefs::layout_css_scroll_behavior_same_physics_as_user_input()
+ ? ScrollMode::Smooth
+ : ScrollMode::SmoothMsd;
}
nsTArray<ScrollPositionUpdate> ScrollContainerFrame::GetScrollUpdates() const {
diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml
@@ -10399,6 +10399,14 @@
value: 250.0f
mirror: always
+# If enabled, CSSOM-View scroll-behavior uses the same physics as
+# scroll animations for user input (mousewheel or keyboard), rather
+# than the snappier-feeling scroll snap physics.
+- name: layout.css.scroll-behavior.same-physics-as-user-input
+ type: bool
+ value: false
+ mirror: always
+
# Whether the scroll-driven animations generated by CSS is enabled. This
# also include animation-timeline property.
- name: layout.css.scroll-driven-animations.enabled