Commit c4a20ff4 authored by Christian Biesinger's avatar Christian Biesinger Committed by Commit Bot

[AspectRatio] Correctly compute flex line length

Because flexbox passes in LayoutUnit::Max(), ng_length_utils used
that as the minimum block size, so effectively we ignored the
aspect ratio.

The test was incorrect. See also https://github.com/w3c/csswg-drafts/issues/5406

R=ikilpatrick@chromium.org, mstensho@chromium.org

Bug: 1083010, 1045668
Change-Id: I2ed30cb6d9539ea82ac5c22b34c45770fa9a60a8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2479802
Auto-Submit: Christian Biesinger <cbiesinger@chromium.org>
Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Christian Biesinger <cbiesinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#818452}
parent 25647916
...@@ -1300,6 +1300,7 @@ LayoutUnit LayoutBox::ConstrainLogicalHeightByMinMax( ...@@ -1300,6 +1300,7 @@ LayoutUnit LayoutBox::ConstrainLogicalHeightByMinMax(
if (logical_min_height.IsAuto() && if (logical_min_height.IsAuto() &&
ShouldComputeLogicalHeightFromAspectRatio() && ShouldComputeLogicalHeightFromAspectRatio() &&
intrinsic_content_height != kIndefiniteSize && intrinsic_content_height != kIndefiniteSize &&
intrinsic_content_height != LayoutUnit::Max() &&
StyleRef().OverflowBlockDirection() == EOverflow::kVisible) { StyleRef().OverflowBlockDirection() == EOverflow::kVisible) {
logical_min_height = Length::Fixed(intrinsic_content_height); logical_min_height = Length::Fixed(intrinsic_content_height);
} }
......
...@@ -594,10 +594,15 @@ LayoutUnit ComputeBlockSizeForFragmentInternal( ...@@ -594,10 +594,15 @@ LayoutUnit ComputeBlockSizeForFragmentInternal(
style.BoxSizing(), *inline_size); style.BoxSizing(), *inline_size);
// Apply the automatic minimum size for aspect ratio: // Apply the automatic minimum size for aspect ratio:
// https://drafts.csswg.org/css-sizing-4/#aspect-ratio-minimum // https://drafts.csswg.org/css-sizing-4/#aspect-ratio-minimum
// We also check for LayoutUnit::Max() because flexbox uses that as a
// "placeholder" to compute the flex line length while still respecting
// max-block-size.
if (style.LogicalMinHeight().IsAuto() && if (style.LogicalMinHeight().IsAuto() &&
style.OverflowBlockDirection() == EOverflow::kVisible && style.OverflowBlockDirection() == EOverflow::kVisible &&
intrinsic_size != kIndefiniteSize) intrinsic_size != kIndefiniteSize &&
intrinsic_size != LayoutUnit::Max()) {
min_max.min_size = intrinsic_size; min_max.min_size = intrinsic_size;
}
} else if (extent == kIndefiniteSize) { } else if (extent == kIndefiniteSize) {
DCHECK_EQ(intrinsic_size, kIndefiniteSize); DCHECK_EQ(intrinsic_size, kIndefiniteSize);
return extent; return extent;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> <p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
<div style="display: flex; flex-direction: column; flex-wrap: wrap; width: 200px; aspect-ratio: 4/1;"> <div style="display: flex; flex-direction: column; flex-wrap: wrap; width: 100px; aspect-ratio: 1/1;">
<div style="background: green; width: 100px; height: 50px;"></div> <div style="background: green; width: 50px; height: 100px;"></div>
<div style="background: green; width: 100px; height: 50px;"></div> <div style="background: green; width: 50px; height: 100px;"></div>
</div> </div>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment