commit c85f102c6f7713484396721c12b3afc215de097f
parent 8e441104183c1c26db3c8e1e20eed613e306846b
Author: David Shin <dshin@mozilla.com>
Date: Fri, 7 Nov 2025 17:57:08 +0000
Bug 1996832: Use inset modified containing block for abspos frame overflow check. r=layout-anchor-positioning-reviewers,layout-reviewers,emilio
Differential Revision: https://phabricator.services.mozilla.com/D271233
Diffstat:
1 file changed, 28 insertions(+), 12 deletions(-)
diff --git a/layout/generic/AbsoluteContainingBlock.cpp b/layout/generic/AbsoluteContainingBlock.cpp
@@ -1119,7 +1119,7 @@ void AbsoluteContainingBlock::ReflowAbsoluteFrame(
AutoFallbackStyleSetter fallback(aKidFrame, currentFallbackStyle,
aAnchorPosResolutionCache,
firstTryIndex == currentFallbackIndex);
- const auto cb = [&]() {
+ auto cb = [&]() {
if (isGrid) {
// TODO(emilio): how does position-area interact with grid?
const auto border = aDelegatingFrame->GetUsedBorder();
@@ -1303,24 +1303,29 @@ void AbsoluteContainingBlock::ReflowAbsoluteFrame(
AnchorPosResolutionParams::From(aKidFrame,
aAnchorPosResolutionCache),
&cbSize);
- const bool iInsetAuto =
+ const bool iStartInsetAuto =
stylePos
->GetAnchorResolvedInset(LogicalSide::IStart, outerWM,
anchorResolutionParams)
- ->IsAuto() ||
+ ->IsAuto();
+ const bool iEndInsetAuto =
stylePos
->GetAnchorResolvedInset(LogicalSide::IEnd, outerWM,
anchorResolutionParams)
->IsAuto();
- const bool bInsetAuto =
+ const bool iInsetAuto = iStartInsetAuto || iEndInsetAuto;
+
+ const bool bStartInsetAuto =
stylePos
->GetAnchorResolvedInset(LogicalSide::BStart, outerWM,
anchorResolutionParams)
- ->IsAuto() ||
+ ->IsAuto();
+ const bool bEndInsetAuto =
stylePos
->GetAnchorResolvedInset(LogicalSide::BEnd, outerWM,
anchorResolutionParams)
->IsAuto();
+ const bool bInsetAuto = bStartInsetAuto || bEndInsetAuto;
const LogicalSize kidMarginBox{
outerWM, margin.IStartEnd(outerWM) + kidSize.ISize(outerWM),
margin.BStartEnd(outerWM) + kidSize.BSize(outerWM)};
@@ -1380,6 +1385,16 @@ void AbsoluteContainingBlock::ReflowAbsoluteFrame(
aKidFrame->SetRect(r);
+ // For the purpose of computing the inset-modified containing block,
+ // `auto` is considered the same as 0.
+ // https://drafts.csswg.org/css-position-3/#resolving-insets
+ LogicalMargin insetModification{
+ outerWM, bStartInsetAuto ? 0 : offsets.BStart(outerWM),
+ iEndInsetAuto ? 0 : offsets.IEnd(outerWM),
+ bEndInsetAuto ? 0 : offsets.BEnd(outerWM),
+ iStartInsetAuto ? 0 : offsets.IStart(outerWM)};
+ cb.mRect.Deflate(insetModification.GetPhysicalMargin(outerWM));
+
nsView* view = aKidFrame->GetView();
if (view) {
// Size and position the view and set its opacity, visibility, content
@@ -1431,13 +1446,14 @@ void AbsoluteContainingBlock::ReflowAbsoluteFrame(
}();
const auto fits = aStatus.IsComplete() && [&]() {
- auto overflowCheckRect = cb.mRect;
- if (aAnchorPosResolutionCache && cb.mAnchorShiftInfo) {
- overflowCheckRect =
- GrowOverflowCheckRect(overflowCheckRect, aKidFrame->GetNormalRect(),
- cb.mAnchorShiftInfo->mResolvedArea);
- aAnchorPosResolutionCache->mReferenceData->mContainingBlockRect =
- overflowCheckRect;
+ const auto overflowCheckRect = cb.mRect;
+ if (aAnchorPosResolutionCache) {
+ if (cb.mAnchorShiftInfo) {
+ aAnchorPosResolutionCache->mReferenceData->mContainingBlockRect =
+ GrowOverflowCheckRect(overflowCheckRect,
+ aKidFrame->GetNormalRect(),
+ cb.mAnchorShiftInfo->mResolvedArea);
+ }
return AnchorPositioningUtils::FitsInContainingBlock(
AnchorPositioningUtils::ContainingBlockInfo::ExplicitCBFrameSize(
aOriginalContainingBlockRect),