Bug 1920160: Part 1 - Don't force overconstrained margins to ignore end-side margins. r=jwatt,firefox-style-system-reviewers,emilio

Current alignment spec [1] allows the margin-box of an absolutely
positioned elements to be aligned within the inset-reduced absolute
containing box, so just let the overconstrained margin be.

[1]: https://drafts.csswg.org/css-position-3/#abspos-layout

Differential Revision: https://phabricator.services.mozilla.com/D226527
This commit is contained in:
David Shin
2024-11-07 16:33:40 +00:00
parent 2d714730dd
commit 3d33778d3a

View File

@@ -993,17 +993,9 @@ void ReflowInput::ComputeAbsPosInlineAutoMargin(nscoord aAvailMarginSpace,
if (aIsMarginIEndAuto) {
// Just 'margin-right' is 'auto'
aMargin.IEnd(aContainingBlockWM) = aAvailMarginSpace;
} else {
// We're over-constrained so use the direction of the containing
// block to dictate which value to ignore. (And note that the
// spec says to ignore 'left' or 'right' rather than
// 'margin-left' or 'margin-right'.)
// Note that this case is different from the both-'auto' case
// above, where the spec says to ignore
// 'margin-left'/'margin-right'.
// Ignore the specified value for 'right'.
aOffsets.IEnd(aContainingBlockWM) += aAvailMarginSpace;
}
// Else, both margins are non-auto. This margin box would align to the
// inset-reduced containing block, so it's not overconstrained.
}
}
@@ -1029,12 +1021,8 @@ void ReflowInput::ComputeAbsPosBlockAutoMargin(nscoord aAvailMarginSpace,
if (aIsMarginBEndAuto) {
// Just margin-block-end is 'auto'
aMargin.BEnd(aContainingBlockWM) = aAvailMarginSpace;
} else {
// We're over-constrained so ignore the specified value for
// block-end. (And note that the spec says to ignore 'bottom'
// rather than 'margin-bottom'.)
aOffsets.BEnd(aContainingBlockWM) += aAvailMarginSpace;
}
// Else, both margins are non-auto. See comment in the inline version.
}
}