tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 64ca376c6f0b1b588062c64b103878d33b54536b
parent eb408c452f2b4059dd9f9b33e07dcf28242cedbc
Author: Botond Ballo <botond@mozilla.com>
Date:   Wed,  3 Dec 2025 20:04:37 +0000

Bug 1999440 - Rename existing layout.css.scroll-behavior.* prefs to layout.css.scroll-snap.*. r=hiro,layout-reviewers,perftest-reviewers,aglavic

These prefs are no longer used for scroll-behavior if
layout.css.scroll-behavior.same-physics-as-user-input=true,
which will be the default in the future.

They are always used for scroll-snap, so it's more accurate to
name the prefs after scroll-snap.

The patch also updates tests which deliberately tweak these prefs to
control the speed of a scroll animation governed by scroll-behavior
(e.g. to slow it down), to also set
layout.css.scroll-behavior.same-physics-as-user-input=false,
so that the prefs continue to have their intended effect on the test.

Differential Revision: https://phabricator.services.mozilla.com/D272350

Diffstat:
Mgfx/layers/apz/test/mochitest/helper_scroll_snap_resnap_after_async_scroll.html | 2+-
Mgfx/layers/apz/test/mochitest/test_abort_smooth_scroll_by_instant_scroll.html | 7+++++--
Mgfx/layers/apz/test/mochitest/test_group_mainthread.html | 8+++++---
Mgfx/layers/apz/test/mochitest/test_group_scroll_snap.html | 18++++++++++++------
Mlayout/generic/ScrollAnimationMSDPhysics.cpp | 4++--
Mlayout/generic/ScrollContainerFrame.cpp | 8++++----
Mmodules/libpref/init/StaticPrefList.yaml | 4++--
Mtesting/perfdocs/generated/talos.rst | 4++--
Mtesting/talos/talos/test.py | 12++++++++----
Mtesting/talos/talos/unittests/test_config.py | 6++++--
10 files changed, 45 insertions(+), 28 deletions(-)

diff --git a/gfx/layers/apz/test/mochitest/helper_scroll_snap_resnap_after_async_scroll.html b/gfx/layers/apz/test/mochitest/helper_scroll_snap_resnap_after_async_scroll.html @@ -62,7 +62,7 @@ // Now trigger another wheel scroll to escape from the last snap point. transformEndPromise = promiseTransformEnd(); - // With a small `layout.css.scroll-behavior.spring-constant` preference + // With a small `layout.css.scroll-snap.spring-constant` preference // value (it's set in test_group_scroll_snap.html), an async scroll // operation, e.g. a wheel scroll operation, fires multiple scroll events // so that here we wait the first scroll event here by specifying diff --git a/gfx/layers/apz/test/mochitest/test_abort_smooth_scroll_by_instant_scroll.html b/gfx/layers/apz/test/mochitest/test_abort_smooth_scroll_by_instant_scroll.html @@ -16,7 +16,7 @@ async function test() { // Trigger a smooth scroll. document.scrollingElement.scrollTo({ top: 90000, behavior: "smooth" }); // Need to wait for a scroll event here since with the very small - // layout.css.scroll-behavior.spring-constant value it's possible that the + // layout.css.scroll-snap.spring-constant value it's possible that the // scroll position hasn't yet been changed after a promiseApzFlushedRepaints // call. await waitForScrollEvent(window); @@ -41,7 +41,10 @@ SimpleTest.waitForExplicitFinish(); // Use a very small spring constant value for smooth scrolling so that the // smooth scrollling keeps running at least for a few seconds. -pushPrefs([["layout.css.scroll-behavior.spring-constant", 1]]) +pushPrefs([ + ["layout.css.scroll-snap.spring-constant", 1], + // This ensures scrollTo() uses scroll-snap physics settings. + ["layout.css.scroll-behavior.same-physics-as-user-input", false]]) .then(waitUntilApzStable) .then(test) .then(SimpleTest.finish, SimpleTest.finishWithFailure); diff --git a/gfx/layers/apz/test/mochitest/test_group_mainthread.html b/gfx/layers/apz/test/mochitest/test_group_mainthread.html @@ -20,9 +20,11 @@ var subtests = [ {"file": "helper_scroll_anchoring_smooth_scroll_with_set_timeout.html", prefs: [ // Unlike helper_scroll_anchoring_smooth_scroll.html, this test checks that // scroll anchoring __is__ invoked when an async scroll animation triggered - // by mouse wheel is running so the animation needs to keep running for a - // while. - ["layout.css.scroll-behavior.spring-constant", 10] + // by scrollIntoView() is running so the animation needs to keep running for + // a while. + ["layout.css.scroll-snap.spring-constant", 10], + // This ensures scrollIntoView() uses scroll-snap physics settings. + ["layout.css.scroll-behavior.same-physics-as-user-input", false] ]}, {"file": "helper_visualscroll_clamp_restore.html", prefs: [ ["apz.test.logging_enabled", true], diff --git a/gfx/layers/apz/test/mochitest/test_group_scroll_snap.html b/gfx/layers/apz/test/mochitest/test_group_scroll_snap.html @@ -22,28 +22,34 @@ const subtests = [ {"file": "helper_bug1960053_scroll_snap_align_start.html", "prefs": [["apz.test.mac.synth_wheel_input", true]]}, {"file": "helper_scroll_snap_resnap_after_async_scroll.html", - // Specify a small `layout.css.scroll-behavior.spring-constant` value to + // Specify a small `layout.css.scroll-snap.spring-constant` value to // keep the smooth scroll animation running long enough so that we can // trigger a reflow during the animation. - "prefs": [["layout.css.scroll-behavior.spring-constant", 10], + // FIXME: This test uses promiseMoveMouseAndScrollWheelOver(), so even + // with layout.css.scroll-behavior.same-physics-as-user-input=false, + // layout.css.scroll-snap.* prefs have no impact on scroll + // animation speed. + "prefs": [["layout.css.scroll-snap.spring-constant", 10], + ["layout.css.scroll-behavior.same-physics-as-user-input", false], ["apz.test.mac.synth_wheel_input", true]]}, {"file": "helper_scroll_snap_resnap_after_async_scroll.html", "prefs": [["general.smoothScroll", false], ["apz.test.mac.synth_wheel_input", true]]}, {"file": "helper_scroll_snap_resnap_after_async_scrollBy.html", // Same as above helper_scroll_snap_resnap_after_async_scroll.html. - "prefs": [["layout.css.scroll-behavior.spring-constant", 10]]}, + "prefs": [["layout.css.scroll-snap.spring-constant", 10], + ["layout.css.scroll-behavior.same-physics-as-user-input", false]]}, {"file": "helper_scroll_snap_not_resnap_during_panning.html", // Specify a strong spring constant to make scroll snap animation be // effective in a short span of time. - "prefs": [["layout.css.scroll-behavior.spring-constant", 1000]]}, + "prefs": [["layout.css.scroll-snap.spring-constant", 1000]]}, {"file": "helper_scroll_snap_not_resnap_during_scrollbar_dragging.html", // Same as above helper_scroll_snap_not_resnap_during_scrollbar_dragging.html. - "prefs": [["layout.css.scroll-behavior.spring-constant", 1000]]}, + "prefs": [["layout.css.scroll-snap.spring-constant", 1000]]}, {"file": "helper_bug1780701.html"}, {"file": "helper_bug1783936.html", // Shorten the scroll snap animation duration. - "prefs": [["layout.css.scroll-behavior.spring-constant", 1000], + "prefs": [["layout.css.scroll-snap.spring-constant", 1000], // Avoid fling at the end of pan. ["apz.fling_min_velocity_threshold", "10000"], // This test needs mSimilateMomentum flag on headless mode. diff --git a/layout/generic/ScrollAnimationMSDPhysics.cpp b/layout/generic/ScrollAnimationMSDPhysics.cpp @@ -83,7 +83,7 @@ void ScrollAnimationMSDPhysics::ApplyContentShift(const CSSPoint& aShiftDelta) { double ScrollAnimationMSDPhysics::GetDampingRatio() const { if (mAnimationKind == ScrollAnimationKind::SmoothMsd) { - return StaticPrefs::layout_css_scroll_behavior_damping_ratio(); + return StaticPrefs::layout_css_scroll_snap_damping_ratio(); } return 1.0; } @@ -91,7 +91,7 @@ double ScrollAnimationMSDPhysics::GetDampingRatio() const { double ScrollAnimationMSDPhysics::ComputeSpringConstant( const TimeStamp& aTime) { if (mAnimationKind == ScrollAnimationKind::SmoothMsd) { - return StaticPrefs::layout_css_scroll_behavior_spring_constant(); + return StaticPrefs::layout_css_scroll_snap_spring_constant(); } if (!mPreviousEventTime) { diff --git a/layout/generic/ScrollContainerFrame.cpp b/layout/generic/ScrollContainerFrame.cpp @@ -1877,12 +1877,12 @@ class ScrollContainerFrame::AsyncSmoothMSDScroll final ScrollTriggeredByScript aTriggeredByScript) : mXAxisModel(aInitialPosition.x, aInitialDestination.x, aInitialVelocity.width, - StaticPrefs::layout_css_scroll_behavior_spring_constant(), - StaticPrefs::layout_css_scroll_behavior_damping_ratio()), + StaticPrefs::layout_css_scroll_snap_spring_constant(), + StaticPrefs::layout_css_scroll_snap_damping_ratio()), mYAxisModel(aInitialPosition.y, aInitialDestination.y, aInitialVelocity.height, - StaticPrefs::layout_css_scroll_behavior_spring_constant(), - StaticPrefs::layout_css_scroll_behavior_damping_ratio()), + StaticPrefs::layout_css_scroll_snap_spring_constant(), + StaticPrefs::layout_css_scroll_snap_damping_ratio()), mRange(aRange), mStartPosition(aInitialPosition), mLastRefreshTime(aStartTime), diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml @@ -10386,7 +10386,7 @@ #endif mirror: always -- name: layout.css.scroll-behavior.damping-ratio +- name: layout.css.scroll-snap.damping-ratio type: AtomicFloat value: 1.0f mirror: always @@ -10394,7 +10394,7 @@ # Tuning of the smooth scroll motion used by CSSOM-View scroll-behavior. # Spring-constant controls the strength of the simulated MSD # (Mass-Spring-Damper). -- name: layout.css.scroll-behavior.spring-constant +- name: layout.css.scroll-snap.spring-constant type: AtomicFloat value: 250.0f mirror: always diff --git a/testing/perfdocs/generated/talos.rst b/testing/perfdocs/generated/talos.rst @@ -7801,7 +7801,7 @@ For the sample commands found below, note that the capitalization used is import * Slowdown in rasterization of content * Slowdown in composite times * gecko_profile_interval: 2 - * preferences: {'layout.frame_rate': 0, 'docshell.event_starvation_delay_hint': 1, 'dom.send_after_paint_to_content': True, 'apz.paint_skipping.enabled': False, 'layout.css.scroll-behavior.spring-constant': "'10'", 'toolkit.framesRecording.bufferSize': 10000} + * preferences: {'layout.frame_rate': 0, 'docshell.event_starvation_delay_hint': 1, 'dom.send_after_paint_to_content': True, 'apz.paint_skipping.enabled': False, 'layout.css.scroll-snap.spring-constant': "'10'", 'layout.css.scroll-behavior.same-physics-as-user-input': False, 'toolkit.framesRecording.bufferSize': 10000} * tpcycles: 1 * tpmanifest: ${talos}/tests/tp5n/tp5o.manifest * tpmozafterpaint: False @@ -8591,7 +8591,7 @@ For the sample commands found below, note that the capitalization used is import * gecko_profile_interval: 1 * pine: False - * preferences: {'layout.frame_rate': 0, 'docshell.event_starvation_delay_hint': 1, 'dom.send_after_paint_to_content': True, 'apz.paint_skipping.enabled': False, 'layout.css.scroll-behavior.spring-constant': "'10'", 'toolkit.framesRecording.bufferSize': 10000} + * preferences: {'layout.frame_rate': 0, 'docshell.event_starvation_delay_hint': 1, 'dom.send_after_paint_to_content': True, 'apz.paint_skipping.enabled': False, 'layout.css.scroll-snap.spring-constant': "'10'", 'layout.css.scroll-behavior.same-physics-as-user-input': False, 'toolkit.framesRecording.bufferSize': 10000} * timeout: 600 * tpchrome: False * tpcycles: 1 diff --git a/testing/talos/talos/test.py b/testing/talos/talos/test.py @@ -1040,7 +1040,8 @@ class tp5o_scroll(PageloaderTest): "docshell.event_starvation_delay_hint": 1, "dom.send_after_paint_to_content": True, "apz.paint_skipping.enabled": False, - "layout.css.scroll-behavior.spring-constant": "'10'", + "layout.css.scroll-snap.spring-constant": "'10'", + "layout.css.scroll-behavior.same-physics-as-user-input": False, "toolkit.framesRecording.bufferSize": 10000, } filters = filter.ignore_first.prepare(1) + filter.median.prepare() @@ -1058,7 +1059,8 @@ class tp5o_scroll_paint_skip(tp5o_scroll): "docshell.event_starvation_delay_hint": 1, "dom.send_after_paint_to_content": True, "apz.paint_skipping.enabled": True, - "layout.css.scroll-behavior.spring-constant": "'10'", + "layout.css.scroll-snap.spring-constant": "'10'", + "layout.css.scroll-behavior.same-physics-as-user-input": False, "toolkit.framesRecording.bufferSize": 10000, } @@ -1286,7 +1288,8 @@ class tscrollx(PageloaderTest): "docshell.event_starvation_delay_hint": 1, "dom.send_after_paint_to_content": True, "apz.paint_skipping.enabled": False, - "layout.css.scroll-behavior.spring-constant": "'10'", + "layout.css.scroll-snap.spring-constant": "'10'", + "layout.css.scroll-behavior.same-physics-as-user-input": False, "toolkit.framesRecording.bufferSize": 10000, } filters = filter.ignore_first.prepare(5) + filter.median.prepare() @@ -1305,7 +1308,8 @@ class tscrollx_paint_skip(tscrollx): "docshell.event_starvation_delay_hint": 1, "dom.send_after_paint_to_content": True, "apz.paint_skipping.enabled": True, - "layout.css.scroll-behavior.spring-constant": "'10'", + "layout.css.scroll-snap.spring-constant": "'10'", + "layout.css.scroll-behavior.same-physics-as-user-input": False, "toolkit.framesRecording.bufferSize": 10000, } diff --git a/testing/talos/talos/unittests/test_config.py b/testing/talos/talos/unittests/test_config.py @@ -1032,7 +1032,8 @@ class Test_get_config: "layout.frame_rate": 0, "docshell.event_starvation_delay_hint": 1, "dom.send_after_paint_to_content": False, - "layout.css.scroll-behavior.spring-constant": "'10'", + "layout.css.scroll-snap.spring-constant": "'10'", + "layout.css.scroll-behavior.same-physics-as-user-input": False, "toolkit.framesRecording.bufferSize": 10000, } assert test_config["filters"] is not None @@ -1216,7 +1217,8 @@ class Test_get_config: "layout.frame_rate": 0, "docshell.event_starvation_delay_hint": 1, "dom.send_after_paint_to_content": False, - "layout.css.scroll-behavior.spring-constant": "'10'", + "layout.css.scroll-snap.spring-constant": "'10'", + "layout.css.scroll-behavior.same-physics-as-user-input": False, "toolkit.framesRecording.bufferSize": 10000, } assert test_config["filters"] is not None