tor-browser

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

commit 94b9e3475381144051ccf17b900895817cb50dc9
parent 827aa14e00b3b4003214d95aed3a39876d5ece72
Author: Timothy Nikkel <tnikkel@gmail.com>
Date:   Wed, 26 Nov 2025 13:55:42 +0000

Bug 1988032. Assign the ASR of the anchor to the anchored content. r=hiro,layout-reviewers,layout-anchor-positioning-reviewers,emilio

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

Diffstat:
Mlayout/generic/nsIFrame.cpp | 38++++++++++++++++++++++++++++++++++++--
1 file changed, 36 insertions(+), 2 deletions(-)

diff --git a/layout/generic/nsIFrame.cpp b/layout/generic/nsIFrame.cpp @@ -4421,6 +4421,41 @@ void nsIFrame::BuildDisplayListForChild(nsDisplayListBuilder* aBuilder, if (savedOutOfFlowData) { aBuilder->SetBuildingInvisibleItems(false); + nsIFrame* scrollsWithAnchor = nullptr; + if (aBuilder->IsPaintingToWindow() && + // If we are in view transition capture we get a null asr no matter + // what, so don't bother checking for async scrolling with a CSS anchor + // pos anchor. + !aBuilder->IsInViewTransitionCapture() && + child->IsAbsolutelyPositioned(disp)) { + scrollsWithAnchor = + AnchorPositioningUtils::GetAnchorThatFrameScrollsWith(child); + } + + const ActiveScrolledRoot* asr = + savedOutOfFlowData->mContainingBlockActiveScrolledRoot; + +#ifdef DEBUG + if (aBuilder->IsPaintingToWindow()) { + if (savedOutOfFlowData->mContainingBlockInViewTransitionCapture) { + MOZ_ASSERT(asr == nullptr); + MOZ_ASSERT(aBuilder->IsInViewTransitionCapture()); + } else { + MOZ_ASSERT( + (asr ? asr->mFrame : nullptr) == + nsLayoutUtils::GetASRAncestorFrame(child->GetParent(), aBuilder)); + } + } +#endif + + if (scrollsWithAnchor) { + asr = DisplayPortUtils::ActivateDisplayportOnASRAncestors( + scrollsWithAnchor, child->GetParent(), asr, aBuilder); + + // TODO should we set the scroll parent id too? + // https://github.com/w3c/csswg-drafts/issues/12042 + } + if (aBuilder->IsInViewTransitionCapture()) { if (!savedOutOfFlowData->mContainingBlockInViewTransitionCapture) { clipState.Clear(); @@ -4432,8 +4467,7 @@ void nsIFrame::BuildDisplayListForChild(nsDisplayListBuilder* aBuilder, } else { clipState.SetClipChainForContainingBlockDescendants( savedOutOfFlowData->mContainingBlockClipChain); - asrSetter.SetCurrentActiveScrolledRoot( - savedOutOfFlowData->mContainingBlockActiveScrolledRoot); + asrSetter.SetCurrentActiveScrolledRoot(asr); asrSetter.SetCurrentScrollParentId(savedOutOfFlowData->mScrollParentId); } MOZ_ASSERT(awayFromCommonPath,