diff --git a/src/algo.rs b/src/algo.rs
index 69d06e50a..ae1d1ab2f 100644
--- a/src/algo.rs
+++ b/src/algo.rs
@@ -81,10 +81,14 @@ pub fn compute(root: &style::Node) -> layout::Node {
let result = compute_internal(
root,
- first_pass.size.width
+ first_pass
+ .size
+ .width
.max(root.min_width.resolve(f32::NAN, f32::NAN))
.min(root.max_width.resolve(f32::NAN, f32::NAN)),
- first_pass.size.height
+ first_pass
+ .size
+ .height
.max(root.min_height.resolve(f32::NAN, f32::NAN))
.min(root.max_height.resolve(f32::NAN, f32::NAN)),
f32::NAN,
diff --git a/test_fixtures/justify_content_colunn_max_height_and_margin.html b/test_fixtures/flex_shrink_by_outer_margin_with_max_size.html
similarity index 75%
rename from test_fixtures/justify_content_colunn_max_height_and_margin.html
rename to test_fixtures/flex_shrink_by_outer_margin_with_max_size.html
index b1fb9ceb4..825b1828c 100644
--- a/test_fixtures/justify_content_colunn_max_height_and_margin.html
+++ b/test_fixtures/flex_shrink_by_outer_margin_with_max_size.html
@@ -9,7 +9,7 @@
<head/>
<body>
-<div id="test-root" style="height: 100px; max-height: 80px; justify-content: center; flex-direction: column;">
+<div id="test-root" style="height: 100px; max-height: 80px; flex-direction: column;">
<div style="height: 20px; width: 20px; margin-top: 100px;"></div>
</div>
diff --git a/tests/generated.rs b/tests/generated.rs
index 341e586e7..f2af0e004 100644
--- a/tests/generated.rs
+++ b/tests/generated.rs
@@ -1187,6 +1187,35 @@ mod generated {
assert_eq!(layout.children[1].y, 0.0000);
}
+ #[test]
+ fn flex_shrink_by_outer_margin_with_max_size() {
+ let layout = stretch::compute(&stretch::style::Node {
+ flex_direction: stretch::style::FlexDirection::Column,
+ height: stretch::style::Dimension::Points(100.0000),
+ max_height: stretch::style::Dimension::Points(80.0000),
+ children: vec![stretch::style::Node {
+ width: stretch::style::Dimension::Points(20.0000),
+ height: stretch::style::Dimension::Points(20.0000),
+ margin: stretch::style::Edges {
+ top: stretch::style::Dimension::Points(100.0000),
+ ..Default::default()
+ },
+ ..Default::default()
+ }],
+ ..Default::default()
+ });
+
+ assert_eq!(layout.width, 20.0000);
+ assert_eq!(layout.height, 80.0000);
+ assert_eq!(layout.x, 0.0000);
+ assert_eq!(layout.y, 0.0000);
+
+ assert_eq!(layout.children[0].width, 20.0000);
+ assert_eq!(layout.children[0].height, 0.0000);
+ assert_eq!(layout.children[0].x, 0.0000);
+ assert_eq!(layout.children[0].y, 100.0000);
+ }
+
#[test]
fn absolute_layout_width_height_start_top_end_bottom() {
let layout = stretch::compute(&stretch::style::Node {
@@ -6334,36 +6363,6 @@ mod generated {
assert_eq!(layout.children[3].y, 30.0000);
}
- #[test]
- fn justify_content_colunn_max_height_and_margin() {
- let layout = stretch::compute(&stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- justify_content: stretch::style::JustifyContent::Center,
- height: stretch::style::Dimension::Points(100.0000),
- max_height: stretch::style::Dimension::Points(80.0000),
- children: vec![stretch::style::Node {
- width: stretch::style::Dimension::Points(20.0000),
- height: stretch::style::Dimension::Points(20.0000),
- margin: stretch::style::Edges {
- top: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- });
-
- assert_eq!(layout.width, 20.0000);
- assert_eq!(layout.height, 80.0000);
- assert_eq!(layout.x, 0.0000);
- assert_eq!(layout.y, 0.0000);
-
- assert_eq!(layout.children[0].width, 20.0000);
- assert_eq!(layout.children[0].height, 0.0000);
- assert_eq!(layout.children[0].x, 0.0000);
- assert_eq!(layout.children[0].y, 90.0000);
- }
-
#[test]
fn flex_basis_flex_grow_column() {
let layout = stretch::compute(&stretch::style::Node {