tor-browser

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

commit f24cbbb7a2d1c2fe21276360d3f2aa1eb92c6834
parent 0aec81c009fd130661ddd22885d63fd192a4623b
Author: Timothy Nikkel <tnikkel@gmail.com>
Date:   Wed, 26 Nov 2025 13:55:42 +0000

Bug 1988032. Add a pref to control async scroll of CSS anchor positioned content. r=layout-reviewers,hiro

This gives an easy way to disable in case of issues and allows toggling for testing purposes (to narrow down if a potential issue is async or main thread scrolling related).

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

Diffstat:
Mlayout/base/AnchorPositioningUtils.cpp | 4++++
Mlayout/generic/ScrollContainerFrame.cpp | 3++-
Mmodules/libpref/init/StaticPrefList.yaml | 6++++++
3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/layout/base/AnchorPositioningUtils.cpp b/layout/base/AnchorPositioningUtils.cpp @@ -9,6 +9,7 @@ #include "ScrollContainerFrame.h" #include "mozilla/Maybe.h" #include "mozilla/PresShell.h" +#include "mozilla/StaticPrefs_apz.h" #include "mozilla/dom/Document.h" #include "mozilla/dom/Element.h" #include "nsCanvasFrame.h" @@ -876,6 +877,9 @@ bool AnchorPositioningUtils::FitsInContainingBlock( nsIFrame* AnchorPositioningUtils::GetAnchorThatFrameScrollsWith( nsIFrame* aFrame) { + if (!StaticPrefs::apz_async_scroll_css_anchor_pos_AtStartup()) { + return nullptr; + } mozilla::PhysicalAxes axes = aFrame->GetAnchorPosCompensatingForScroll(); // TODO for now we return the anchor if we are compensating in either axis. // This is not fully spec compliant, bug 1988034 tracks this. diff --git a/layout/generic/ScrollContainerFrame.cpp b/layout/generic/ScrollContainerFrame.cpp @@ -4340,7 +4340,8 @@ nsRect ScrollContainerFrame::RestrictToRootDisplayPort( FissionAutostart()) { return true; } - return aFrame->PresShell()->GetRootPresShell()->HasSeenAnchorPos(); + return StaticPrefs::apz_async_scroll_css_anchor_pos_AtStartup() && + aFrame->PresShell()->GetRootPresShell()->HasSeenAnchorPos(); } bool ScrollContainerFrame::DecideScrollableLayerEnsureDisplayport( diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml @@ -953,6 +953,12 @@ value: false mirror: always +# Whether to async scroll CSS anchor pos. +- name: apz.async_scroll_css_anchor_pos + type: bool + value: true + mirror: once + #--------------------------------------------------------------------------- # Prefs starting with "beacon." #---------------------------------------------------------------------------