Bug 1772305 - Allow auto margins of abspos boxes to be negative if both in-axis insets are non-auto. r=emilio

Currently, when an inset is large enough that auto margins would distribute a
negative value, we always clamp it to zero. This works for scenarios where
at least one of the insets in the relevant axis was auto, since the spec
resolves the auto margin to be zero in this case. However, the spec does not
disallow a negative auto margin value when both insets are non-auto.

Differential Revision: https://phabricator.services.mozilla.com/D170931
This commit is contained in:
David Shin 2023-02-27 14:01:26 +00:00
Родитель ba10a84cbb
Коммит 2be6246f15
3 изменённых файлов: 8 добавлений и 12 удалений

Просмотреть файл

@ -672,14 +672,14 @@ void nsAbsoluteContainingBlock::ResolveAutoMarginsAfterLayout(
LogicalMargin offsetsInWM = aOffsets.ConvertTo(wm, outerWM);
// No need to substract border sizes because aKidSize has it included
// already
nscoord availMarginSpace = aLogicalCBSize->BSize(wm) - kidSizeInWM.BSize(wm) -
offsetsInWM.BStartEnd(wm) -
marginInWM.BStartEnd(wm);
if (availMarginSpace < 0) {
availMarginSpace = 0;
}
// already. Also, if any offset is auto, the auto margin resolves to zero.
// https://drafts.csswg.org/css-position-3/#abspos-margins
const bool autoOffset = offsetsInWM.BEnd(wm) == NS_AUTOOFFSET ||
offsetsInWM.BStart(wm) == NS_AUTOOFFSET;
nscoord availMarginSpace =
autoOffset ? 0
: aLogicalCBSize->BSize(wm) - kidSizeInWM.BSize(wm) -
offsetsInWM.BStartEnd(wm) - marginInWM.BStartEnd(wm);
const auto& styleMargin = aKidReflowInput.mStyleMargin;
if (wm.IsOrthogonalTo(outerWM)) {

Просмотреть файл

@ -1,2 +0,0 @@
[fit-content-block-size-abspos.html]
expected: FAIL

Просмотреть файл

@ -1,2 +0,0 @@
[fit-content-block-size-fixedpos.html]
expected: FAIL