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

Prevent percentages contributing to min-content sizes #388

Merged
merged 2 commits into from
Mar 10, 2023
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
5 changes: 4 additions & 1 deletion src/compute/flexbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -706,11 +706,14 @@ fn determine_flex_base_size(
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 is not set for this function call
// as it used to resolve percentages against, and percentage size should not contribute to a
// min-content contribution. See https://drafts.csswg.org/css-sizing-3/#min-percentage-contribution
let min_content_size = GenericAlgorithm::measure_size(
tree,
child.node,
Size::NONE,
constants.node_inner_size,
Size::NONE,
Size::MIN_CONTENT,
SizingMode::ContentSize,
);
Expand Down
24 changes: 24 additions & 0 deletions test_fixtures/bevy_issue_8017.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!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">
<title>
Bevy #8017
</title>
</head>
<body>

<div id="test-root" style="display: flex; flex-direction: column; gap: 8px;width: 400px;height:400px;padding: 8px;">
<div style="display: flex; gap: 8px; width: 100%; height: 50%;">
<div style="width: 100%; height: 100%;"></div>
<div style="width: 100%; height: 100%;"></div>
</div>
<div style="display: flex; gap: 8px; width: 100%; height: 50%;">
<div style="width: 100%; height: 100%;"></div>
<div style="width: 100%; height: 100%;"></div>
</div>
</div>

</body>
</html>
22 changes: 22 additions & 0 deletions test_fixtures/bevy_issue_8017_reduced.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!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">
<title>
Bevy #8017
</title>
</head>
<body>

<div id="test-root" style="flex-direction: column;width: 200px;height:400px;gap: 8px;">
<div style="height: 50%;">
<div></div>
</div>
<div style="height: 50%;">
<div></div>
</div>
</div>

</body>
</html>
140 changes: 140 additions & 0 deletions tests/generated/bevy_issue_8017.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

73 changes: 73 additions & 0 deletions tests/generated/bevy_issue_8017_reduced.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions tests/generated/mod.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.