commit 326431509879e00fc49a1040c76e6416ea4866b3
parent 64788e622c1ef22e73a15dee35034ee4364a000e
Author: Jonathan Kew <jkew@mozilla.com>
Date: Mon, 5 Jan 2026 17:56:37 +0000
Bug 2008537 - Use "safe" behavior by default when applying implicit anchor-center alignment. r=layout-anchor-positioning-reviewers,layout-reviewers,emilio,dshin
Differential Revision: https://phabricator.services.mozilla.com/D277892
Diffstat:
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/layout/generic/AbsoluteContainingBlock.cpp b/layout/generic/AbsoluteContainingBlock.cpp
@@ -865,11 +865,13 @@ static nscoord OffsetToAlignedStaticPos(
? aKidReflowInput.mStylePosition->mJustifySelf._0
: aKidReflowInput.mStylePosition->mAlignSelf._0;
if (aNonAutoAlignParams && !safetyBits &&
- rawAlignConst != StyleAlignFlags::AUTO) {
+ (rawAlignConst != StyleAlignFlags::AUTO ||
+ alignConst == StyleAlignFlags::ANCHOR_CENTER)) {
// No `safe` or `unsafe` specified - "in-between" behaviour for relevant
// alignment values: https://drafts.csswg.org/css-position-3/#abspos-layout
// Skip if the raw self alignment for this element is `auto` to preserve
- // legacy behaviour.
+ // legacy behaviour, except in the case where the resolved value is
+ // anchor-center (where "legacy behavior" is not a concern).
// Follows https://drafts.csswg.org/css-align-3/#auto-safety-position
const auto cbSize = aAbsPosCBSize.Size(aAbsPosCBAxis, aAbsPosCBWM);
// IMCB stands for "Inset-Modified Containing Block."