Skip to content

Commit 5a4e760

Browse files
cbiesingerCommit Bot
authored andcommitted
[AspectRatio] In abspos, handle transferred min/max
..even if contain-intrinsic-size is specified. [email protected], [email protected] Bug: 1124922 Change-Id: If4c887a3536b65fbeb1c22a8a2e3a66896046ae5 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2423584 Auto-Submit: Christian Biesinger <[email protected]> Reviewed-by: Ian Kilpatrick <[email protected]> Commit-Queue: Christian Biesinger <[email protected]> Cr-Commit-Position: refs/heads/master@{#810105}
1 parent b8e245a commit 5a4e760

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

third_party/blink/renderer/core/layout/ng/ng_absolute_utils.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,15 @@ void ComputeOutOfFlowInlineDimensions(
439439
space, style, border_padding, min_max_sizes, style.LogicalMaxWidth(),
440440
LengthResolvePhase::kLayout);
441441

442+
// This implements the transferred min/max sizes per
443+
// https://drafts.csswg.org/css-sizing-4/#aspect-ratio
444+
if (style.AspectRatio() && dimensions->size.block_size == kIndefiniteSize) {
445+
MinMaxSizes sizes = ComputeMinMaxInlineSizesFromAspectRatio(
446+
space, style, border_padding, LengthResolvePhase::kLayout);
447+
min_inline_size = std::max(sizes.min_size, min_inline_size);
448+
max_inline_size = std::min(sizes.max_size, max_inline_size);
449+
}
450+
442451
bool is_table = style.IsDisplayTableBox();
443452
base::Optional<LayoutUnit> inline_size;
444453
if (!style.LogicalWidth().IsAuto()) {

third_party/blink/renderer/core/layout/ng/ng_absolute_utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ struct NGLogicalStaticPosition;
2121

2222
struct CORE_EXPORT NGLogicalOutOfFlowDimensions {
2323
NGBoxStrut inset;
24-
LogicalSize size;
24+
LogicalSize size = {kIndefiniteSize, kIndefiniteSize};
2525
NGBoxStrut margins;
2626
};
2727

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<title>CSS aspect-ratio: abspos div inline size with max-height and contain-intrinsic-size</title>
3+
<link rel="author" title="Google LLC" href="https://www.google.com/">
4+
<link rel="help" href="https://drafts.csswg.org/css-sizing-4/#aspect-ratio">
5+
<link rel="help" href="https://github.com/w3c/csswg-drafts/issues/5257">
6+
<link rel="match" href="../../reference/ref-filled-green-100px-square.xht" />
7+
<meta name="assert" content="A max-height constraint should be transferred through the aspect-ratio to apply to the inline size">
8+
9+
<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>
10+
11+
<div style="position: relative; height: 100px; position: relative;">
12+
<div style="position: absolute; aspect-ratio: 1/1; max-height: 100%; min-height: 0; contain-intrinsic-size: 500px 500px; contain: size; background: green; color: green;">
13+
</div>
14+
</div>

0 commit comments

Comments
 (0)