commit 81f86c8b2f7e9ac0b65eeb9e066176a35843a78a
parent 11aa87560528683e19d203586ca6fc6fac68c8e8
Author: Jonathan Kew <jkew@mozilla.com>
Date: Tue, 30 Dec 2025 19:10:22 +0000
Bug 2006959 - Even if there's no anchor-positioning cache, we need to save and potentially restore the target's firstTryNormalPosition. r=layout-anchor-positioning-reviewers,layout-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D277619
Diffstat:
2 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/layout/generic/AbsoluteContainingBlock.cpp b/layout/generic/AbsoluteContainingBlock.cpp
@@ -1634,6 +1634,10 @@ void AbsoluteContainingBlock::ReflowAbsoluteFrame(
aKidFrame->DidReflow(aPresContext, &kidReflowInput);
[&]() {
+ const auto position = aKidFrame->GetPosition();
+ if (!firstTryNormalPosition) {
+ firstTryNormalPosition = Some(position);
+ }
if (!aAnchorPosResolutionCache) {
return;
}
@@ -1653,12 +1657,8 @@ void AbsoluteContainingBlock::ReflowAbsoluteFrame(
aAnchorPosResolutionCache->mDefaultAnchorCache);
}();
// Apply the hypothetical scroll offset.
- const auto position = aKidFrame->GetPosition();
// Set initial scroll position. TODO(dshin, bug 1987962): Need
// additional work for remembered scroll offset here.
- if (!firstTryNormalPosition) {
- firstTryNormalPosition = Some(position);
- }
aKidFrame->SetProperty(nsIFrame::NormalPositionProperty(), position);
if (offset != nsPoint{}) {
aKidFrame->SetPosition(position - offset);
@@ -1728,14 +1728,13 @@ void AbsoluteContainingBlock::ReflowAbsoluteFrame(
}
}
- // Try with the next fallback.
+ // Try with the next fallback.
aKidFrame->AddStateBits(NS_FRAME_IS_DIRTY);
aStatus.Reset();
} while (true);
[&]() {
- if (!isOverflowingCB || !aAnchorPosResolutionCache ||
- !firstTryNormalPosition) {
+ if (!isOverflowingCB || !firstTryNormalPosition) {
return;
}
// We gave up applying fallbacks. Recover previous values, if changed, and
@@ -1749,9 +1748,11 @@ void AbsoluteContainingBlock::ReflowAbsoluteFrame(
aKidFrame->SetProperty(nsIFrame::NormalPositionProperty(),
normalPosition);
}
- const auto position =
- normalPosition -
- aAnchorPosResolutionCache->mReferenceData->mDefaultScrollShift;
+ auto position = normalPosition;
+ if (aAnchorPosResolutionCache) {
+ position -=
+ aAnchorPosResolutionCache->mReferenceData->mDefaultScrollShift;
+ }
const auto oldPosition = aKidFrame->GetPosition();
if (position == oldPosition) {
return;
diff --git a/testing/web-platform/meta/css/css-anchor-position/try-tactic-back-to-base.html.ini b/testing/web-platform/meta/css/css-anchor-position/try-tactic-back-to-base.html.ini
@@ -1,3 +0,0 @@
-[try-tactic-back-to-base.html]
- [Should use base values when nothing fits]
- expected: FAIL