commit e7619a7efccc6f2ca258a9f3cdf4cc1d8741ede4
parent 537725a5c4aaa5e36df125f308024c54b1eb6fda
Author: Timothy Nikkel <tnikkel@gmail.com>
Date: Wed, 26 Nov 2025 13:04:52 +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:
2 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/layout/base/DisplayPortUtils.cpp b/layout/base/DisplayPortUtils.cpp
@@ -834,9 +834,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
@@ -1325,6 +1325,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;
@@ -2620,6 +2622,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;