Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flexbox: Fix flooring hypothetical_main_size by computed min size #689

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions src/compute/flexbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -744,14 +744,6 @@ fn determine_flex_base_size(
child.flex_basis - child.padding.main_axis_sum(constants.dir) - child.border.main_axis_sum(constants.dir);

let padding_border_axes_sums = (child.padding + child.border).sum_axes().map(Some);
let hypothetical_inner_min_main =
child.min_size.main(constants.dir).maybe_max(padding_border_axes_sums.main(constants.dir));
let hypothetical_inner_size =
child.flex_basis.maybe_clamp(hypothetical_inner_min_main, child.max_size.main(constants.dir));
let hypothetical_outer_size = hypothetical_inner_size + child.margin.main_axis_sum(constants.dir);

child.hypothetical_inner_size.set_main(constants.dir, hypothetical_inner_size);
child.hypothetical_outer_size.set_main(constants.dir, hypothetical_outer_size);

// Note that it is important that the `parent_size` parameter in the main axis is not set for this
// function call as it used for resolving percentages, and percentage size in an axis should not contribute
Expand Down Expand Up @@ -784,6 +776,15 @@ fn determine_flex_base_size(
min_content_main_size.maybe_min(child.size.main(dir)).maybe_min(child.max_size.main(dir));
clamped_min_content_size.maybe_max(padding_border_axes_sums.main(dir))
});

let hypothetical_inner_min_main =
child.resolved_minimum_main_size.maybe_max(padding_border_axes_sums.main(constants.dir));
let hypothetical_inner_size =
child.flex_basis.maybe_clamp(Some(hypothetical_inner_min_main), child.max_size.main(constants.dir));
let hypothetical_outer_size = hypothetical_inner_size + child.margin.main_axis_sum(constants.dir);

child.hypothetical_inner_size.set_main(constants.dir, hypothetical_inner_size);
child.hypothetical_outer_size.set_main(constants.dir, hypothetical_outer_size);
}
}

Expand Down
21 changes: 21 additions & 0 deletions test_fixtures/flex/flex_grow_0_min_size.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script src="../../scripts/gentest/test_helper.js"></script>
<link rel="stylesheet" type="text/css" href="../../scripts/gentest/test_base_style.css">
<meta name="wpt-test-port" value="css/css-flexbox/flexbox_flex-0-0-0.html" />
<title>
Test description
</title>
</head>
<body>

<div id="test-root" style="display: flex; flex-direction: row; height: 100px; width: 400px; background: blue; border: 1px solid black;">
<div style="flex-shrink: 0; flex-grow: 0; flex-basis: 0%;">one</div>
<div style="flex-shrink: 0; flex-grow: 0; flex-basis: 0%;">two</div>
<div style="flex-shrink: 0; flex-grow: 0; flex-basis: 0%;">three</div>
<div style="flex-shrink: 0; flex-grow: 0; flex-basis: 0%;">four</div>
</div>

</body>
</html>
Loading