tor-browser

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

commit 3a7c8be81f6eec6d001dc73656783fd8ec68e561
parent 0793c4b404d9a35dbe3e3fd664f79c4eaf413490
Author: Timothy Nikkel <tnikkel@gmail.com>
Date:   Wed, 26 Nov 2025 13:55:41 +0000

Bug 1988030. Adjust DisplayPortUtils::OneStepInAsyncScrollableAncestorChain to be CSS anchor pos aware. r=hiro,layout-reviewers,layout-anchor-positioning-reviewers,emilio

We want to assign the ASR of the anchor to the anchored content. That means we are changing the ASR chain so we need to adjust the functions that walk the async scrollable ancestors chain. In this patch we adjust DisplayPortUtils::OneStepInAsyncScrollableAncestorChain.

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

Diffstat:
Mlayout/base/DisplayPortUtils.cpp | 10++++++++++
Mlayout/base/nsLayoutUtils.cpp | 4++++
2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/layout/base/DisplayPortUtils.cpp b/layout/base/DisplayPortUtils.cpp @@ -25,6 +25,7 @@ #include "nsLayoutUtils.h" #include "nsPlaceholderFrame.h" #include "nsSubDocumentFrame.h" +#include "AnchorPositioningUtils.h" namespace mozilla { @@ -834,9 +835,18 @@ bool DisplayPortUtils::MaybeCreateDisplayPort( nsIFrame* DisplayPortUtils::OneStepInAsyncScrollableAncestorChain( nsIFrame* aFrame) { + // This mirrors one iteration of GetNearestScrollableOrOverflowClipFrame in + // nsLayoutUtils.cpp as called by + // nsLayoutUtils::GetAsyncScrollableAncestorFrame. They should be kept in + // sync. See that function for comments about the structure of this code. if (aFrame->IsMenuPopupFrame()) { return nullptr; } + nsIFrame* anchor = nullptr; + while ((anchor = + AnchorPositioningUtils::GetAnchorThatFrameScrollsWith(aFrame))) { + aFrame = anchor; + } if (aFrame->StyleDisplay()->mPosition == StylePositionProperty::Fixed && nsLayoutUtils::IsReallyFixedPos(aFrame)) { if (nsIFrame* root = aFrame->PresShell()->GetRootScrollContainerFrame()) { diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp @@ -1326,6 +1326,8 @@ static nsIFrame* GetNearestScrollableOrOverflowClipFrame( : nsLayoutUtils::GetCrossDocParentFrameInProcess(aFrame); }; + // This should be kept in sync with + // DisplayPortUtils::OneStepInAsyncScrollableAncestorChain. for (nsIFrame* f = aFrame; f; f = GetNextFrame(f)) { if (aClipFrameCheck && aClipFrameCheck(f)) { return f; @@ -2621,6 +2623,8 @@ FrameMetrics nsLayoutUtils::CalculateBasicFrameMetrics( ScrollContainerFrame* nsLayoutUtils::GetAsyncScrollableAncestorFrame( nsIFrame* aTarget) { + // This should be kept in sync with + // DisplayPortUtils::OneStepInAsyncScrollableAncestorChain. uint32_t flags = nsLayoutUtils::SCROLLABLE_ALWAYS_MATCH_ROOT | nsLayoutUtils::SCROLLABLE_ONLY_ASYNC_SCROLLABLE | nsLayoutUtils::SCROLLABLE_FIXEDPOS_FINDS_ROOT;