fune/testing/web-platform/tests/css/css-flexbox/flex-minimum-width-flex-items-013.html
David Grogan a8aef429aa Bug 1733091 [wpt PR 30900] - [css-flex] Obey stretch size in replaced items' content size suggestion, a=testonly
Automatic update from web-platform-tests
[css-flex] Obey stretch size in replaced items' content size suggestion

Content size suggestion is just min-content size. The min-content size
of a replaced element is supposed to account for preferred size in the
opposite axis. We were not doing that for content size suggestion when
the opposize axis preferred size came from a flexbox's fixed cross size.

In the example below, Blink now gives the image content size suggestion
100px because 100 = 300*150/50. Before this patch Blink gave it a
content size suggestion equal to its natural width 300px.

<div style="display: flex; height: 50px;">
  <img src="support/300x150-green.png">
</div>

Firefox matches Blink's behavior before this patch. We may have compat
issues.

See https://github.com/w3c/csswg-drafts/issues/6693 for discussion of
this new behavior.

Bug: 1246126
Change-Id: I1d42c7151b9a0da7e001ca89ea1d7fb9187ae235
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3173922
Commit-Queue: David Grogan <dgrogan@chromium.org>
Reviewed-by: Ian Kilpatrick <ikilpatrick@chromium.org>
Cr-Commit-Position: refs/heads/main@{#931259}

--

wpt-commits: 2c83d2e8d545706b565dc6e3dcf77daa77eb5e96
wpt-pr: 30900
2021-10-14 18:34:42 +00:00

34 lines
1.4 KiB
HTML

<!DOCTYPE html>
<title>Flex transferred minimum width</title>
<link rel="author" title="dgrogan@chromium.org" href="mailto:dgrogan@chromium.org" />
<link rel="help" href="https://drafts.csswg.org/css-flexbox/#min-size-auto" />
<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/5663" />
<link rel="match" href="../reference/ref-filled-green-100px-square.xht" />
<meta name="assert" content="content size suggestion of a replaced aspect-ratio item accounts for definition stretched cross size">
<style>
#reference-overlapped-red {
position: absolute;
background-color: red;
width: 100px;
height: 100px;
z-index: -1;
}
</style>
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
<div id="reference-overlapped-red"></div>
<div style="width:100px; height: 50px; background: green;"></div> <!-- This just completes the green square. -->
<div style="display: flex; width: 0px; height: 50px;">
<!--
content size suggestion is 100px because the image has a stretched height of 50px. So min-content size of the image is 300x150/50 = 100.
specified size suggestion is 150px
transferred size suggestion is 100px
transferred size suggestion is ignored because there is a specified size.
So here the content-based minimum size is min(100px, 150px) = 100px
-->
<img src="support/300x150-green.png" style="width: 999px;">
</div>