Bug 1905463 - Cap aspect-ratio's automatic minimum size by the maximum size. r=layout-reviewers,emilio

See https://drafts.csswg.org/css-sizing-4/#aspect-ratio-minimum

The flex container and grid container have already considered max sizes clamping
when computing their sizes. Therefore, `flex-aspect-ratio-043.html`,
`flex-aspect-ratio-044.html`, and `grid-aspect-ratio-042.html` already pass on
the current Nightly without this patch.

- `flex-aspect-ratio-043.html` and `flex-aspect-ratio-044.html` are adapted from
  `flex-aspect-ratio-040.html` and `flex-aspect-ratio-041.html`.
- `grid-aspect-ratio-042.html` is adapted from `grid-aspect-ratio-039.html`.
- `fieldset-element-002.html` is adapted from `fieldset-element-001.html`.

Differential Revision: https://phabricator.services.mozilla.com/D215296
This commit is contained in:
Ting-Yu Lin
2024-07-01 21:26:25 +00:00
parent ad3a7fd625
commit 21d81e2fbe
9 changed files with 152 additions and 8 deletions

View File

@@ -2207,6 +2207,13 @@ nscoord nsBlockFrame::ComputeFinalSize(const ReflowInput& aReflowInput,
finalSize.BSize(wm) =
std::max(finalSize.BSize(wm),
contentBSizeWithBStartBP + borderPadding.BEnd(wm));
// The size should be capped by its maximum block size.
if (aReflowInput.ComputedMaxBSize() != NS_UNCONSTRAINEDSIZE) {
finalSize.BSize(wm) =
std::min(finalSize.BSize(wm), aReflowInput.ComputedMaxBSize() +
borderPadding.BStartEnd(wm));
}
}
// Don't carry out a block-end margin when our BSize is fixed.