Skip to content

Commit d893a3e

Browse files
authored
Merge pull request #1431 from WebPlatformForEmbedded/pgorszkowski/2.38/css-flexbox-incorrect-layout-with-max-height-and-flex-direction-column-and-justify-content-center
[css-flexbox] incorrect layout with max-height and flex-direction col…
2 parents 3e3b298 + cb045d2 commit d893a3e

3 files changed

Lines changed: 36 additions & 0 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Only red square should be visible
2+
3+
4+
PASS #container 1
5+
A
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<link href="resources/flexbox.css" rel="stylesheet">
3+
<script src="../../resources/testharness.js"></script>
4+
<script src="../../resources/testharnessreport.js"></script>
5+
<script src="../../resources/check-layout-th.js"></script>
6+
<script>
7+
function run() {
8+
checkLayout('#container');
9+
}
10+
</script>
11+
<body onload="run()">
12+
<p>Only red square should be visible</p>
13+
<div id="log"></div>
14+
<div id="container" class="flexbox column" style="max-height: 100px; height: 100px; width: 100px; background: green">
15+
<div class="flexbox column justify-content-center" style="height: 400px; background: red" data-expected-height="100">A</div>
16+
</div>

Source/WebCore/rendering/RenderFlexibleBox.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1587,6 +1587,21 @@ bool RenderFlexibleBox::resolveFlexibleLengths(FlexSign flexSign, Vector<FlexIte
15871587
childSize += LayoutUnit::fromFloatRound(extraSpace);
15881588

15891589
LayoutUnit adjustedChildSize = flexItem.constrainSizeByMinMax(childSize);
1590+
1591+
// Adjust flex item size with the specified container max size.
1592+
auto maximumSize = isHorizontalFlow() ? style().maxWidth() : style().maxHeight();
1593+
const auto minimumSize = isHorizontalFlow() ? style().minWidth() : style().minHeight();
1594+
if (maximumSize.isFixed()) {
1595+
// The fixed min height/width should be considered as maximum size if it is bigger than fixed max height/width.
1596+
if (minimumSize.isFixed() && minimumSize.value() > maximumSize.value())
1597+
maximumSize = minimumSize;
1598+
1599+
// If the size of flex item adjusted to its min/max size is bigger than the maximum size of the container, then
1600+
// we use flext item size calculated before adjusting the min/max size of the flex item.
1601+
if (adjustedChildSize > LayoutUnit { maximumSize.value() })
1602+
adjustedChildSize = std::max(LayoutUnit { }, childSize);
1603+
}
1604+
15901605
ASSERT(adjustedChildSize >= 0);
15911606
flexItem.flexedContentSize = adjustedChildSize;
15921607
usedFreeSpace += adjustedChildSize - flexItem.flexBaseContentSize;

0 commit comments

Comments
 (0)