fix: single-line flex-container should clamp the line's cross-size (#638)
* fix: single-line flex-container should clamp the line's cross-size
* Format fixtures
* Add max-height test
* Fix single-line and add tests
---------
Co-authored-by: Nico Burns <nico@nicoburns.com>
aad4f024eaed6abb769426720eac588c9e7bd301 · por RomChung · (hace 2 años) · padre d43dd24ad · ver el árbol en este commit
Delta semántico · 17
tests/generated/flex/align_items_center_with_height_with_padding_border_with_wrap.rs
tests/generated/flex/align_items_center_with_max_height_percentage_with_align_content_flex_start.rs
tests/generated/flex/align_items_center_with_max_height_with_align_content_flex_start.rs
tests/generated/flex/align_items_center_with_max_height_with_padding_border.rs
tests/generated/flex/align_items_center_with_min_height_percentage_with_align_content_flex_start.rs
tests/generated/flex/align_items_center_with_min_height_with_align_content_flex_start.rs
tests/generated/flex/align_items_center_with_min_height_with_align_content_flex_start_with_wrap.rs
tests/generated/flex/align_items_center_with_min_height_with_padding_border.rs
tests/generated/flex/mod.rs
diff --git a/src/compute/flexbox.rs b/src/compute/flexbox.rs
index 4af14ae1e..143a1dea3 100644
--- a/src/compute/flexbox.rs
+++ b/src/compute/flexbox.rs
@@ -1396,6 +1396,16 @@ fn calculate_cross_size(flex_lines: &mut [FlexLine], node_size: Size<Option<f32>
})
.fold(0.0, |acc, x| acc.max(x));
}
+ // If the flex container is single-line, then clamp the line’s cross-size to be within the container’s computed min and max cross sizes.
+ if !constants.is_wrap {
+ let cross_axis_padding_border = constants.content_box_inset.cross_axis_sum(constants.dir);
+ let cross_min_size = constants.min_size.cross(constants.dir);
+ let cross_max_size = constants.max_size.cross(constants.dir);
+ flex_lines[0].cross_size = flex_lines[0].cross_size.maybe_clamp(
+ cross_min_size.maybe_sub(cross_axis_padding_border),
+ cross_max_size.maybe_sub(cross_axis_padding_border),
+ );
+ }
}
}
diff --git a/test_fixtures/flex/align_items_center_with_height_with_padding_border_with_wrap.html b/test_fixtures/flex/align_items_center_with_height_with_padding_border_with_wrap.html
new file mode 100644
index 000000000..9986068e0
--- /dev/null
+++ b/test_fixtures/flex/align_items_center_with_height_with_padding_border_with_wrap.html
@@ -0,0 +1,23 @@
+<!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>
+ Test description
+ </title>
+</head>
+<body>
+<div id="test-root">
+ <div style="display: flex; width: 100px; height: 100px; align-items: center; align-content: flex-start; flex-wrap: wrap;">
+ <div style="height: 10px; width: 10px;"></div>
+ <div style="height: 20px; width: 10px;"></div>
+ </div>
+ <div style="display: flex; width: 100px; height: 100px; align-items: center; flex-wrap: wrap;">
+ <div style="height: 10px; width: 10px;"></div>
+ <div style="height: 20px; width: 10px;"></div>
+ </div>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/test_fixtures/flex/align_items_center_with_max_height_percentage_with_align_content_flex_start.html b/test_fixtures/flex/align_items_center_with_max_height_percentage_with_align_content_flex_start.html
new file mode 100644
index 000000000..3db92c396
--- /dev/null
+++ b/test_fixtures/flex/align_items_center_with_max_height_percentage_with_align_content_flex_start.html
@@ -0,0 +1,20 @@
+<!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>
+ Test description
+ </title>
+</head>
+<body>
+
+<div id="test-root" style="width: 100px; height: 100px;">
+ <div style="display: flex; width: 100px; height: 100px; max-height: 50%; align-items: center; align-content: flex-start;">
+ <div style="height: 10px; width: 10px;"></div>
+ <div style="height: 20px; width: 10px;"></div>
+ </div>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/test_fixtures/flex/align_items_center_with_max_height_with_align_content_flex_start.html b/test_fixtures/flex/align_items_center_with_max_height_with_align_content_flex_start.html
new file mode 100644
index 000000000..6a375513b
--- /dev/null
+++ b/test_fixtures/flex/align_items_center_with_max_height_with_align_content_flex_start.html
@@ -0,0 +1,18 @@
+<!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>
+ Test description
+ </title>
+</head>
+<body>
+
+<div id="test-root" style="width: 100px; max-height: 100px; align-items: center; align-content: flex-start;">
+ <div style="height: 50px; width: 10px;"></div>
+ <div style="height: 150px; width: 10px;"></div>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/test_fixtures/flex/align_items_center_with_max_height_with_padding_border.html b/test_fixtures/flex/align_items_center_with_max_height_with_padding_border.html
new file mode 100644
index 000000000..73f6f09c2
--- /dev/null
+++ b/test_fixtures/flex/align_items_center_with_max_height_with_padding_border.html
@@ -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>
+ Test description
+ </title>
+</head>
+<body>
+<div id="test-root" style="display: block;">
+ <div style="display: flex; width: 100px; max-height: 100px; align-items: center; align-content: flex-start; padding: 10px; border-width: 10px;">
+ <div style="height: 10px; width: 10px;"></div>
+ <div style="height: 150px; width: 10px;"></div>
+ </div>
+ <div style="display: flex; width: 100px; max-height: 100px; align-items: center; align-content: flex-start; padding: 10px; border-width: 10px; flex-wrap: wrap;">
+ <div style="height: 10px; width: 10px;"></div>
+ <div style="height: 150px; width: 10px;"></div>
+ </div>
+</div>
+
+
+</body>
+</html>
\ No newline at end of file
diff --git a/test_fixtures/flex/align_items_center_with_min_height_percentage_with_align_content_flex_start.html b/test_fixtures/flex/align_items_center_with_min_height_percentage_with_align_content_flex_start.html
new file mode 100644
index 000000000..cc2662bef
--- /dev/null
+++ b/test_fixtures/flex/align_items_center_with_min_height_percentage_with_align_content_flex_start.html
@@ -0,0 +1,20 @@
+<!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>
+ Test description
+ </title>
+</head>
+<body>
+
+<div id="test-root" style="width: 100px; height: 100px;">
+ <div style="display: flex; width: 100px; min-height: 100%; align-items: center; align-content: flex-start;">
+ <div style="height: 10px; width: 10px;"></div>
+ <div style="height: 20px; width: 10px;"></div>
+ </div>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/test_fixtures/flex/align_items_center_with_min_height_with_align_content_flex_start.html b/test_fixtures/flex/align_items_center_with_min_height_with_align_content_flex_start.html
new file mode 100644
index 000000000..9f92eec24
--- /dev/null
+++ b/test_fixtures/flex/align_items_center_with_min_height_with_align_content_flex_start.html
@@ -0,0 +1,18 @@
+<!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>
+ Test description
+ </title>
+</head>
+<body>
+
+<div id="test-root" style="width: 100px; min-height: 100px; align-items: center; align-content: flex-start;">
+ <div style="height: 10px; width: 10px;"></div>
+ <div style="height: 20px; width: 10px;"></div>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/test_fixtures/flex/align_items_center_with_min_height_with_align_content_flex_start_with_wrap.html b/test_fixtures/flex/align_items_center_with_min_height_with_align_content_flex_start_with_wrap.html
new file mode 100644
index 000000000..a6e90fcb4
--- /dev/null
+++ b/test_fixtures/flex/align_items_center_with_min_height_with_align_content_flex_start_with_wrap.html
@@ -0,0 +1,31 @@
+<!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>
+ Test description
+ </title>
+</head>
+<body>
+<div id="test-root">
+ <div style="display: flex; width: 100px; min-height: 100px; align-items: center; align-content: flex-start; flex-wrap: wrap;">
+ <div style="height: 10px; width: 10px;"></div>
+ <div style="height: 20px; width: 10px;"></div>
+ </div>
+ <div style="display: flex; width: 100px; min-height: 100px; align-items: center; flex-wrap: wrap;">
+ <div style="height: 10px; width: 10px;"></div>
+ <div style="height: 20px; width: 10px;"></div>
+ </div>
+ <div style="display: flex; width: 100px; min-height: 100px; align-items: center; flex-wrap: no-wrap;">
+ <div style="height: 10px; width: 10px;"></div>
+ <div style="height: 20px; width: 10px;"></div>
+ </div>
+ <div style="display: flex; width: 100px; min-height: 100px; align-items: center; align-content: flex-start; flex-wrap: no-wrap;">
+ <div style="height: 10px; width: 10px;"></div>
+ <div style="height: 20px; width: 10px;"></div>
+ </div>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/test_fixtures/flex/align_items_center_with_min_height_with_padding_border.html b/test_fixtures/flex/align_items_center_with_min_height_with_padding_border.html
new file mode 100644
index 000000000..a29e52dbe
--- /dev/null
+++ b/test_fixtures/flex/align_items_center_with_min_height_with_padding_border.html
@@ -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>
+ Test description
+ </title>
+</head>
+<body>
+<div id="test-root">
+ <div style="display: flex; width: 100px; min-height: 100px; align-items: center; align-content: flex-start; padding: 8px; border-width: 7px;">
+ <div style="height: 10px; width: 10px;"></div>
+ <div style="height: 20px; width: 10px;"></div>
+ </div>
+ <div style="display: flex; width: 100px; min-height: 100px; align-items: center; align-content: flex-start; padding: 8px; border-width: 7px; flex-wrap: wrap;">
+ <div style="height: 10px; width: 10px;"></div>
+ <div style="height: 20px; width: 10px;"></div>
+ </div>
+</div>
+
+
+</body>
+</html>
\ No newline at end of file
diff --git a/tests/generated/flex/align_items_center_with_height_with_padding_border_with_wrap.rs b/tests/generated/flex/align_items_center_with_height_with_padding_border_with_wrap.rs
new file mode 100644
index 000000000..16c86a0c3
--- /dev/null
+++ b/tests/generated/flex/align_items_center_with_height_with_padding_border_with_wrap.rs
@@ -0,0 +1,246 @@
+#[test]
+fn align_items_center_with_height_with_padding_border_with_wrap() {
+ #[allow(unused_imports)]
+ use taffy::{prelude::*, tree::Layout, TaffyTree};
+ let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::new();
+ let node00 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Length(10f32),
+ height: taffy::style::Dimension::Length(10f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node01 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Length(10f32),
+ height: taffy::style::Dimension::Length(20f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node0 = taffy
+ .new_with_children(
+ taffy::style::Style {
+ display: taffy::style::Display::Flex,
+ flex_wrap: taffy::style::FlexWrap::Wrap,
+ align_items: Some(taffy::style::AlignItems::Center),
+ align_content: Some(taffy::style::AlignContent::FlexStart),
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Length(100f32),
+ height: taffy::style::Dimension::Length(100f32),
+ },
+ ..Default::default()
+ },
+ &[node00, node01],
+ )
+ .unwrap();
+ let node10 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Length(10f32),
+ height: taffy::style::Dimension::Length(10f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node11 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Length(10f32),
+ height: taffy::style::Dimension::Length(20f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node1 = taffy
+ .new_with_children(
+ taffy::style::Style {
+ display: taffy::style::Display::Flex,
+ flex_wrap: taffy::style::FlexWrap::Wrap,
+ align_items: Some(taffy::style::AlignItems::Center),
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Length(100f32),
+ height: taffy::style::Dimension::Length(100f32),
+ },
+ ..Default::default()
+ },
+ &[node10, node11],
+ )
+ .unwrap();
+ let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0, node1]).unwrap();
+ taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
+ println!("\nComputed tree:");
+ taffy.print_tree(node);
+ println!();
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
+ assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width);
+ assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node,
+ 0f32,
+ layout.scroll_height()
+ );
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
+ assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width);
+ assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node0,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node0,
+ 0f32,
+ layout.scroll_height()
+ );
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node00).unwrap();
+ assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node00, 10f32, size.width);
+ assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x);
+ assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node00, 5f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node00,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node00,
+ 0f32,
+ layout.scroll_height()
+ );
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node01).unwrap();
+ assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node01, 10f32, size.width);
+ assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height);
+ assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node01, 10f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node01,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node01,
+ 0f32,
+ layout.scroll_height()
+ );
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node1).unwrap();
+ assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width);
+ assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height);
+ assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node1, 100f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node1,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node1,
+ 0f32,
+ layout.scroll_height()
+ );
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node10).unwrap();
+ assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node10, 10f32, size.width);
+ assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x);
+ assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node10, 45f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node10,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node10,
+ 0f32,
+ layout.scroll_height()
+ );
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node11).unwrap();
+ assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node11, 10f32, size.width);
+ assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node11, 20f32, size.height);
+ assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node11, 10f32, location.x);
+ assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node11, 40f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node11,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node11,
+ 0f32,
+ layout.scroll_height()
+ );
+}
diff --git a/tests/generated/flex/align_items_center_with_max_height_percentage_with_align_content_flex_start.rs b/tests/generated/flex/align_items_center_with_max_height_percentage_with_align_content_flex_start.rs
new file mode 100644
index 000000000..38ff0789a
--- /dev/null
+++ b/tests/generated/flex/align_items_center_with_max_height_percentage_with_align_content_flex_start.rs
@@ -0,0 +1,152 @@
+#[test]
+fn align_items_center_with_max_height_percentage_with_align_content_flex_start() {
+ #[allow(unused_imports)]
+ use taffy::{prelude::*, tree::Layout, TaffyTree};
+ let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::new();
+ let node00 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Length(10f32),
+ height: taffy::style::Dimension::Length(10f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node01 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Length(10f32),
+ height: taffy::style::Dimension::Length(20f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node0 = taffy
+ .new_with_children(
+ taffy::style::Style {
+ display: taffy::style::Display::Flex,
+ align_items: Some(taffy::style::AlignItems::Center),
+ align_content: Some(taffy::style::AlignContent::FlexStart),
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Length(100f32),
+ height: taffy::style::Dimension::Length(100f32),
+ },
+ max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.5f32) },
+ ..Default::default()
+ },
+ &[node00, node01],
+ )
+ .unwrap();
+ let node = taffy
+ .new_with_children(
+ taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Length(100f32),
+ height: taffy::style::Dimension::Length(100f32),
+ },
+ ..Default::default()
+ },
+ &[node0],
+ )
+ .unwrap();
+ taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
+ println!("\nComputed tree:");
+ taffy.print_tree(node);
+ println!();
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
+ assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
+ assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node,
+ 0f32,
+ layout.scroll_height()
+ );
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
+ assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width);
+ assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node0,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node0,
+ 0f32,
+ layout.scroll_height()
+ );
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node00).unwrap();
+ assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node00, 10f32, size.width);
+ assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x);
+ assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node00, 20f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node00,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node00,
+ 0f32,
+ layout.scroll_height()
+ );
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node01).unwrap();
+ assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node01, 10f32, size.width);
+ assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height);
+ assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node01, 10f32, location.x);
+ assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node01, 15f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node01,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node01,
+ 0f32,
+ layout.scroll_height()
+ );
+}
diff --git a/tests/generated/flex/align_items_center_with_max_height_with_align_content_flex_start.rs b/tests/generated/flex/align_items_center_with_max_height_with_align_content_flex_start.rs
new file mode 100644
index 000000000..bd4b57832
--- /dev/null
+++ b/tests/generated/flex/align_items_center_with_max_height_with_align_content_flex_start.rs
@@ -0,0 +1,112 @@
+#[test]
+fn align_items_center_with_max_height_with_align_content_flex_start() {
+ #[allow(unused_imports)]
+ use taffy::{prelude::*, tree::Layout, TaffyTree};
+ let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::new();
+ let node0 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Length(10f32),
+ height: taffy::style::Dimension::Length(50f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node1 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Length(10f32),
+ height: taffy::style::Dimension::Length(150f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node = taffy
+ .new_with_children(
+ taffy::style::Style {
+ align_items: Some(taffy::style::AlignItems::Center),
+ align_content: Some(taffy::style::AlignContent::FlexStart),
+ size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() },
+ max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) },
+ ..Default::default()
+ },
+ &[node0, node1],
+ )
+ .unwrap();
+ taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
+ println!("\nComputed tree:");
+ taffy.print_tree(node);
+ println!();
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
+ assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
+ assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 25f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node,
+ 25f32,
+ layout.scroll_height()
+ );
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
+ assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width);
+ assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
+ assert_eq!(location.y, 25f32, "y of node {:?}. Expected {}. Actual {}", node0, 25f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node0,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node0,
+ 0f32,
+ layout.scroll_height()
+ );
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node1).unwrap();
+ assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width);
+ assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node1, 150f32, size.height);
+ assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node1, 10f32, location.x);
+ assert_eq!(location.y, -25f32, "y of node {:?}. Expected {}. Actual {}", node1, -25f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node1,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node1,
+ 0f32,
+ layout.scroll_height()
+ );
+}
diff --git a/tests/generated/flex/align_items_center_with_max_height_with_padding_border.rs b/tests/generated/flex/align_items_center_with_max_height_with_padding_border.rs
new file mode 100644
index 000000000..45b8462ff
--- /dev/null
+++ b/tests/generated/flex/align_items_center_with_max_height_with_padding_border.rs
@@ -0,0 +1,271 @@
+#[test]
+fn align_items_center_with_max_height_with_padding_border() {
+ #[allow(unused_imports)]
+ use taffy::{prelude::*, tree::Layout, TaffyTree};
+ let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::new();
+ let node00 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Length(10f32),
+ height: taffy::style::Dimension::Length(10f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node01 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Length(10f32),
+ height: taffy::style::Dimension::Length(150f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node0 = taffy
+ .new_with_children(
+ taffy::style::Style {
+ display: taffy::style::Display::Flex,
+ align_items: Some(taffy::style::AlignItems::Center),
+ align_content: Some(taffy::style::AlignContent::FlexStart),
+ size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() },
+ max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) },
+ padding: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Length(10f32),
+ right: taffy::style::LengthPercentage::Length(10f32),
+ top: taffy::style::LengthPercentage::Length(10f32),
+ bottom: taffy::style::LengthPercentage::Length(10f32),
+ },
+ border: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Length(10f32),
+ right: taffy::style::LengthPercentage::Length(10f32),
+ top: taffy::style::LengthPercentage::Length(10f32),
+ bottom: taffy::style::LengthPercentage::Length(10f32),
+ },
+ ..Default::default()
+ },
+ &[node00, node01],
+ )
+ .unwrap();
+ let node10 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Length(10f32),
+ height: taffy::style::Dimension::Length(10f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node11 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Length(10f32),
+ height: taffy::style::Dimension::Length(150f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node1 = taffy
+ .new_with_children(
+ taffy::style::Style {
+ display: taffy::style::Display::Flex,
+ flex_wrap: taffy::style::FlexWrap::Wrap,
+ align_items: Some(taffy::style::AlignItems::Center),
+ align_content: Some(taffy::style::AlignContent::FlexStart),
+ size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() },
+ max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) },
+ padding: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Length(10f32),
+ right: taffy::style::LengthPercentage::Length(10f32),
+ top: taffy::style::LengthPercentage::Length(10f32),
+ bottom: taffy::style::LengthPercentage::Length(10f32),
+ },
+ border: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Length(10f32),
+ right: taffy::style::LengthPercentage::Length(10f32),
+ top: taffy::style::LengthPercentage::Length(10f32),
+ bottom: taffy::style::LengthPercentage::Length(10f32),
+ },
+ ..Default::default()
+ },
+ &[node10, node11],
+ )
+ .unwrap();
+ let node = taffy
+ .new_with_children(
+ taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() },
+ &[node0, node1],
+ )
+ .unwrap();
+ taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
+ println!("\nComputed tree:");
+ taffy.print_tree(node);
+ println!();
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
+ assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
+ assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 70f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node,
+ 70f32,
+ layout.scroll_height()
+ );
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
+ assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width);
+ assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node0,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 35f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node0,
+ 35f32,
+ layout.scroll_height()
+ );
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node00).unwrap();
+ assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node00, 10f32, size.width);
+ assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height);
+ assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x);
+ assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node00, 45f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node00,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node00,
+ 0f32,
+ layout.scroll_height()
+ );
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node01).unwrap();
+ assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node01, 10f32, size.width);
+ assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node01, 150f32, size.height);
+ assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node01, 30f32, location.x);
+ assert_eq!(location.y, -25f32, "y of node {:?}. Expected {}. Actual {}", node01, -25f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node01,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node01,
+ 0f32,
+ layout.scroll_height()
+ );
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node1).unwrap();
+ assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width);
+ assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x);
+ assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node1, 100f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node1,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 80f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node1,
+ 80f32,
+ layout.scroll_height()
+ );
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node10).unwrap();
+ assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node10, 10f32, size.width);
+ assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height);
+ assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node10, 20f32, location.x);
+ assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node10, 90f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node10,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node10,
+ 0f32,
+ layout.scroll_height()
+ );
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node11).unwrap();
+ assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node11, 10f32, size.width);
+ assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node11, 150f32, size.height);
+ assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node11, 30f32, location.x);
+ assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node11, 20f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node11,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node11,
+ 0f32,
+ layout.scroll_height()
+ );
+}
diff --git a/tests/generated/flex/align_items_center_with_min_height_percentage_with_align_content_flex_start.rs b/tests/generated/flex/align_items_center_with_min_height_percentage_with_align_content_flex_start.rs
new file mode 100644
index 000000000..eee102cbb
--- /dev/null
+++ b/tests/generated/flex/align_items_center_with_min_height_percentage_with_align_content_flex_start.rs
@@ -0,0 +1,149 @@
+#[test]
+fn align_items_center_with_min_height_percentage_with_align_content_flex_start() {
+ #[allow(unused_imports)]
+ use taffy::{prelude::*, tree::Layout, TaffyTree};
+ let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::new();
+ let node00 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Length(10f32),
+ height: taffy::style::Dimension::Length(10f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node01 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Length(10f32),
+ height: taffy::style::Dimension::Length(20f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node0 = taffy
+ .new_with_children(
+ taffy::style::Style {
+ display: taffy::style::Display::Flex,
+ align_items: Some(taffy::style::AlignItems::Center),
+ align_content: Some(taffy::style::AlignContent::FlexStart),
+ size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() },
+ min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(1f32) },
+ ..Default::default()
+ },
+ &[node00, node01],
+ )
+ .unwrap();
+ let node = taffy
+ .new_with_children(
+ taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Length(100f32),
+ height: taffy::style::Dimension::Length(100f32),
+ },
+ ..Default::default()
+ },
+ &[node0],
+ )
+ .unwrap();
+ taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
+ println!("\nComputed tree:");
+ taffy.print_tree(node);
+ println!();
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
+ assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
+ assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node,
+ 0f32,
+ layout.scroll_height()
+ );
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
+ assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width);
+ assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node0,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node0,
+ 0f32,
+ layout.scroll_height()
+ );
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node00).unwrap();
+ assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node00, 10f32, size.width);
+ assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x);
+ assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node00, 45f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node00,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node00,
+ 0f32,
+ layout.scroll_height()
+ );
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node01).unwrap();
+ assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node01, 10f32, size.width);
+ assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height);
+ assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node01, 10f32, location.x);
+ assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node01, 40f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node01,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node01,
+ 0f32,
+ layout.scroll_height()
+ );
+}
diff --git a/tests/generated/flex/align_items_center_with_min_height_with_align_content_flex_start.rs b/tests/generated/flex/align_items_center_with_min_height_with_align_content_flex_start.rs
new file mode 100644
index 000000000..1f05d063b
--- /dev/null
+++ b/tests/generated/flex/align_items_center_with_min_height_with_align_content_flex_start.rs
@@ -0,0 +1,112 @@
+#[test]
+fn align_items_center_with_min_height_with_align_content_flex_start() {
+ #[allow(unused_imports)]
+ use taffy::{prelude::*, tree::Layout, TaffyTree};
+ let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::new();
+ let node0 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Length(10f32),
+ height: taffy::style::Dimension::Length(10f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node1 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Length(10f32),
+ height: taffy::style::Dimension::Length(20f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node = taffy
+ .new_with_children(
+ taffy::style::Style {
+ align_items: Some(taffy::style::AlignItems::Center),
+ align_content: Some(taffy::style::AlignContent::FlexStart),
+ size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() },
+ min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) },
+ ..Default::default()
+ },
+ &[node0, node1],
+ )
+ .unwrap();
+ taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
+ println!("\nComputed tree:");
+ taffy.print_tree(node);
+ println!();
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
+ assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
+ assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node,
+ 0f32,
+ layout.scroll_height()
+ );
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
+ assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width);
+ assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
+ assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node0, 45f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node0,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node0,
+ 0f32,
+ layout.scroll_height()
+ );
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node1).unwrap();
+ assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1, 10f32, size.width);
+ assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height);
+ assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node1, 10f32, location.x);
+ assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1, 40f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node1,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node1,
+ 0f32,
+ layout.scroll_height()
+ );
+}
diff --git a/tests/generated/flex/align_items_center_with_min_height_with_align_content_flex_start_with_wrap.rs b/tests/generated/flex/align_items_center_with_min_height_with_align_content_flex_start_with_wrap.rs
new file mode 100644
index 000000000..8330af0d6
--- /dev/null
+++ b/tests/generated/flex/align_items_center_with_min_height_with_align_content_flex_start_with_wrap.rs
@@ -0,0 +1,448 @@
+#[test]
+fn align_items_center_with_min_height_with_align_content_flex_start_with_wrap() {
+ #[allow(unused_imports)]
+ use taffy::{prelude::*, tree::Layout, TaffyTree};
+ let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::new();
+ let node00 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Length(10f32),
+ height: taffy::style::Dimension::Length(10f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node01 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Length(10f32),
+ height: taffy::style::Dimension::Length(20f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node0 = taffy
+ .new_with_children(
+ taffy::style::Style {
+ display: taffy::style::Display::Flex,
+ flex_wrap: taffy::style::FlexWrap::Wrap,
+ align_items: Some(taffy::style::AlignItems::Center),
+ align_content: Some(taffy::style::AlignContent::FlexStart),
+ size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() },
+ min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) },
+ ..Default::default()
+ },
+ &[node00, node01],
+ )
+ .unwrap();
+ let node10 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Length(10f32),
+ height: taffy::style::Dimension::Length(10f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node11 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Length(10f32),
+ height: taffy::style::Dimension::Length(20f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node1 = taffy
+ .new_with_children(
+ taffy::style::Style {
+ display: taffy::style::Display::Flex,
+ flex_wrap: taffy::style::FlexWrap::Wrap,
+ align_items: Some(taffy::style::AlignItems::Center),
+ size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() },
+ min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) },
+ ..Default::default()
+ },
+ &[node10, node11],
+ )
+ .unwrap();
+ let node20 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Length(10f32),
+ height: taffy::style::Dimension::Length(10f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node21 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Length(10f32),
+ height: taffy::style::Dimension::Length(20f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node2 = taffy
+ .new_with_children(
+ taffy::style::Style {
+ display: taffy::style::Display::Flex,
+ align_items: Some(taffy::style::AlignItems::Center),
+ size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() },
+ min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) },
+ ..Default::default()
+ },
+ &[node20, node21],
+ )
+ .unwrap();
+ let node30 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Length(10f32),
+ height: taffy::style::Dimension::Length(10f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node31 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Length(10f32),
+ height: taffy::style::Dimension::Length(20f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node3 = taffy
+ .new_with_children(
+ taffy::style::Style {
+ display: taffy::style::Display::Flex,
+ align_items: Some(taffy::style::AlignItems::Center),
+ align_content: Some(taffy::style::AlignContent::FlexStart),
+ size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() },
+ min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) },
+ ..Default::default()
+ },
+ &[node30, node31],
+ )
+ .unwrap();
+ let node =
+ taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0, node1, node2, node3]).unwrap();
+ taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
+ println!("\nComputed tree:");
+ taffy.print_tree(node);
+ println!();
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
+ assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node, 400f32, size.width);
+ assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node,
+ 0f32,
+ layout.scroll_height()
+ );
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
+ assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width);
+ assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node0,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node0,
+ 0f32,
+ layout.scroll_height()
+ );
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node00).unwrap();
+ assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node00, 10f32, size.width);
+ assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x);
+ assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node00, 5f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node00,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node00,
+ 0f32,
+ layout.scroll_height()
+ );
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node01).unwrap();
+ assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node01, 10f32, size.width);
+ assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height);
+ assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node01, 10f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node01,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node01,
+ 0f32,
+ layout.scroll_height()
+ );
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node1).unwrap();
+ assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width);
+ assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height);
+ assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node1, 100f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node1,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node1,
+ 0f32,
+ layout.scroll_height()
+ );
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node10).unwrap();
+ assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node10, 10f32, size.width);
+ assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x);
+ assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node10, 45f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node10,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node10,
+ 0f32,
+ layout.scroll_height()
+ );
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node11).unwrap();
+ assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node11, 10f32, size.width);
+ assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node11, 20f32, size.height);
+ assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node11, 10f32, location.x);
+ assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node11, 40f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node11,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node11,
+ 0f32,
+ layout.scroll_height()
+ );
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node2).unwrap();
+ assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width);
+ assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node2, 100f32, size.height);
+ assert_eq!(location.x, 200f32, "x of node {:?}. Expected {}. Actual {}", node2, 200f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node2,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node2,
+ 0f32,
+ layout.scroll_height()
+ );
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node20).unwrap();
+ assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node20, 10f32, size.width);
+ assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20, 10f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node20, 0f32, location.x);
+ assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node20, 45f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node20,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node20,
+ 0f32,
+ layout.scroll_height()
+ );
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node21).unwrap();
+ assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node21, 10f32, size.width);
+ assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node21, 20f32, size.height);
+ assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node21, 10f32, location.x);
+ assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node21, 40f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node21,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node21,
+ 0f32,
+ layout.scroll_height()
+ );
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node3).unwrap();
+ assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node3, 100f32, size.width);
+ assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node3, 100f32, size.height);
+ assert_eq!(location.x, 300f32, "x of node {:?}. Expected {}. Actual {}", node3, 300f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node3,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node3,
+ 0f32,
+ layout.scroll_height()
+ );
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node30).unwrap();
+ assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node30, 10f32, size.width);
+ assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node30, 10f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node30, 0f32, location.x);
+ assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node30, 45f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node30,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node30,
+ 0f32,
+ layout.scroll_height()
+ );
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node31).unwrap();
+ assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node31, 10f32, size.width);
+ assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node31, 20f32, size.height);
+ assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node31, 10f32, location.x);
+ assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node31, 40f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node31,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node31,
+ 0f32,
+ layout.scroll_height()
+ );
+}
diff --git a/tests/generated/flex/align_items_center_with_min_height_with_padding_border.rs b/tests/generated/flex/align_items_center_with_min_height_with_padding_border.rs
new file mode 100644
index 000000000..9fc6966a3
--- /dev/null
+++ b/tests/generated/flex/align_items_center_with_min_height_with_padding_border.rs
@@ -0,0 +1,266 @@
+#[test]
+fn align_items_center_with_min_height_with_padding_border() {
+ #[allow(unused_imports)]
+ use taffy::{prelude::*, tree::Layout, TaffyTree};
+ let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::new();
+ let node00 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Length(10f32),
+ height: taffy::style::Dimension::Length(10f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node01 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Length(10f32),
+ height: taffy::style::Dimension::Length(20f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node0 = taffy
+ .new_with_children(
+ taffy::style::Style {
+ display: taffy::style::Display::Flex,
+ align_items: Some(taffy::style::AlignItems::Center),
+ align_content: Some(taffy::style::AlignContent::FlexStart),
+ size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() },
+ min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) },
+ padding: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Length(8f32),
+ right: taffy::style::LengthPercentage::Length(8f32),
+ top: taffy::style::LengthPercentage::Length(8f32),
+ bottom: taffy::style::LengthPercentage::Length(8f32),
+ },
+ border: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Length(7f32),
+ right: taffy::style::LengthPercentage::Length(7f32),
+ top: taffy::style::LengthPercentage::Length(7f32),
+ bottom: taffy::style::LengthPercentage::Length(7f32),
+ },
+ ..Default::default()
+ },
+ &[node00, node01],
+ )
+ .unwrap();
+ let node10 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Length(10f32),
+ height: taffy::style::Dimension::Length(10f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node11 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Length(10f32),
+ height: taffy::style::Dimension::Length(20f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node1 = taffy
+ .new_with_children(
+ taffy::style::Style {
+ display: taffy::style::Display::Flex,
+ flex_wrap: taffy::style::FlexWrap::Wrap,
+ align_items: Some(taffy::style::AlignItems::Center),
+ align_content: Some(taffy::style::AlignContent::FlexStart),
+ size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() },
+ min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) },
+ padding: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Length(8f32),
+ right: taffy::style::LengthPercentage::Length(8f32),
+ top: taffy::style::LengthPercentage::Length(8f32),
+ bottom: taffy::style::LengthPercentage::Length(8f32),
+ },
+ border: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Length(7f32),
+ right: taffy::style::LengthPercentage::Length(7f32),
+ top: taffy::style::LengthPercentage::Length(7f32),
+ bottom: taffy::style::LengthPercentage::Length(7f32),
+ },
+ ..Default::default()
+ },
+ &[node10, node11],
+ )
+ .unwrap();
+ let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0, node1]).unwrap();
+ taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
+ println!("\nComputed tree:");
+ taffy.print_tree(node);
+ println!();
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
+ assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width);
+ assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node,
+ 0f32,
+ layout.scroll_height()
+ );
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
+ assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width);
+ assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node0,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node0,
+ 0f32,
+ layout.scroll_height()
+ );
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node00).unwrap();
+ assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node00, 10f32, size.width);
+ assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height);
+ assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node00, 15f32, location.x);
+ assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node00, 45f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node00,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node00,
+ 0f32,
+ layout.scroll_height()
+ );
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node01).unwrap();
+ assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node01, 10f32, size.width);
+ assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height);
+ assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node01, 25f32, location.x);
+ assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node01, 40f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node01,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node01,
+ 0f32,
+ layout.scroll_height()
+ );
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node1).unwrap();
+ assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width);
+ assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height);
+ assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node1, 100f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node1,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node1,
+ 0f32,
+ layout.scroll_height()
+ );
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node10).unwrap();
+ assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node10, 10f32, size.width);
+ assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height);
+ assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node10, 15f32, location.x);
+ assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node10, 20f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node10,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node10,
+ 0f32,
+ layout.scroll_height()
+ );
+ #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
+ let layout @ Layout { size, location, .. } = taffy.layout(node11).unwrap();
+ assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node11, 10f32, size.width);
+ assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node11, 20f32, size.height);
+ assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node11, 25f32, location.x);
+ assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node11, 15f32, location.y);
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_width(),
+ 0f32,
+ "scroll_width of node {:?}. Expected {}. Actual {}",
+ node11,
+ 0f32,
+ layout.scroll_width()
+ );
+ #[cfg(feature = "content_size")]
+ assert_eq!(
+ layout.scroll_height(),
+ 0f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node11,
+ 0f32,
+ layout.scroll_height()
+ );
+}
diff --git a/tests/generated/flex/mod.rs b/tests/generated/flex/mod.rs
index c3873c3ca..6e427742d 100644
--- a/tests/generated/flex/mod.rs
+++ b/tests/generated/flex/mod.rs
@@ -126,6 +126,14 @@ mod align_items_center_justify_content_center;
mod align_items_center_min_max_with_padding;
mod align_items_center_with_child_margin;
mod align_items_center_with_child_top;
+mod align_items_center_with_height_with_padding_border_with_wrap;
+mod align_items_center_with_max_height_percentage_with_align_content_flex_start;
+mod align_items_center_with_max_height_with_align_content_flex_start;
+mod align_items_center_with_max_height_with_padding_border;
+mod align_items_center_with_min_height_percentage_with_align_content_flex_start;
+mod align_items_center_with_min_height_with_align_content_flex_start;
+mod align_items_center_with_min_height_with_align_content_flex_start_with_wrap;
+mod align_items_center_with_min_height_with_padding_border;
mod align_items_flex_end;
mod align_items_flex_end_child_with_margin_bigger_than_parent;
mod align_items_flex_end_child_without_margin_bigger_than_parent;