tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 583HTML 275Markdown 8TOML 41586 Definitions

Fix implementation of SizingMode::ContentSize for Flexbox and Grid algorithms (#576)

d2b2eb08a93c6088e89b14d630cc962d551b084e · by Nico Burns · (2 years ago) · parent 6ca2fd08a · browse the tree at this commit

Semantic delta · 21

src/compute/flexbox.rs

src/compute/grid/mod.rs

tests/generated/bevy_issue_10343_flex.rs

tests/generated/bevy_issue_10343_grid.rs

tests/generated/mod.rs

8 files · +250 −36

diff --git a/src/compute/flexbox.rs b/src/compute/flexbox.rs
index 4ffb9766d..823cd1c1a 100644
--- a/src/compute/flexbox.rs
+++ b/src/compute/flexbox.rs
@@ -32,9 +32,9 @@ impl LayoutAlgorithm for FlexboxAlgorithm {
         known_dimensions: Size<Option<f32>>,
         parent_size: Size<Option<f32>>,
         available_space: Size<AvailableSpace>,
-        _sizing_mode: SizingMode,
+        sizing_mode: SizingMode,
     ) -> SizeAndBaselines {
-        compute(tree, node, known_dimensions, parent_size, available_space, RunMode::PeformLayout)
+        compute(tree, node, known_dimensions, parent_size, available_space, RunMode::PeformLayout, sizing_mode)
     }
 
     fn measure_size(
@@ -43,9 +43,9 @@ impl LayoutAlgorithm for FlexboxAlgorithm {
         known_dimensions: Size<Option<f32>>,
         parent_size: Size<Option<f32>>,
         available_space: Size<AvailableSpace>,
-        _sizing_mode: SizingMode,
+        sizing_mode: SizingMode,
     ) -> Size<f32> {
-        compute(tree, node, known_dimensions, parent_size, available_space, RunMode::ComputeSize).size
+        compute(tree, node, known_dimensions, parent_size, available_space, RunMode::ComputeSize, sizing_mode).size
     }
 }
 
@@ -184,6 +184,7 @@ pub fn compute(
     parent_size: Size<Option<f32>>,
     available_space: Size<AvailableSpace>,
     run_mode: RunMode,
+    sizing_mode: SizingMode,
 ) -> SizeAndBaselines {
     let style = tree.style(node);
 
@@ -191,8 +192,11 @@ pub fn compute(
     let aspect_ratio = style.aspect_ratio;
     let min_size = style.min_size.maybe_resolve(parent_size).maybe_apply_aspect_ratio(aspect_ratio);
     let max_size = style.max_size.maybe_resolve(parent_size).maybe_apply_aspect_ratio(aspect_ratio);
-    let clamped_style_size =
-        style.size.maybe_resolve(parent_size).maybe_apply_aspect_ratio(aspect_ratio).maybe_clamp(min_size, max_size);
+    let clamped_style_size = if sizing_mode == SizingMode::InherentSize {
+        style.size.maybe_resolve(parent_size).maybe_apply_aspect_ratio(aspect_ratio).maybe_clamp(min_size, max_size)
+    } else {
+        Size::NONE
+    };
 
     // If both min and max in a given axis are set and max <= min then this determines the size in that axis
     let min_max_definite_size = min_size.zip_map(max_size, |min, max| match (min, max) {
diff --git a/src/compute/grid/explicit_grid.rs b/src/compute/grid/explicit_grid.rs
index 2b3d773a8..74ca95410 100644
--- a/src/compute/grid/explicit_grid.rs
+++ b/src/compute/grid/explicit_grid.rs
@@ -2,6 +2,7 @@
 //! This mainly consists of evaluating GridAutoTracks
 use super::types::{GridTrack, TrackCounts};
 use crate::axis::AbsoluteAxis;
+use crate::geometry::Size;
 use crate::math::MaybeMath;
 use crate::resolve::ResolveOrZero;
 use crate::style::{GridTrackRepetition, LengthPercentage, NonRepeatedTrackSizingFunction, Style, TrackSizingFunction};
@@ -12,7 +13,11 @@ use crate::sys::{GridTrackVec, Vec};
 use num_traits::float::FloatCore;
 
 /// Compute the number of rows and columns in the explicit grid
-pub(crate) fn compute_explicit_grid_size_in_axis(style: &Style, axis: AbsoluteAxis) -> u16 {
+pub(crate) fn compute_explicit_grid_size_in_axis(
+    style: &Style,
+    preferred_size: Size<Option<f32>>,
+    axis: AbsoluteAxis,
+) -> u16 {
     // Load the grid-template-rows or grid-template-columns definition (depending on the axis)
     let template = style.grid_template_tracks(axis);
 
@@ -88,7 +93,7 @@ pub(crate) fn compute_explicit_grid_size_in_axis(style: &Style, axis: AbsoluteAx
     // Otherwise, if the grid container has a definite min size in the relevant axis:
     //   - then the number of repetitions is the smallest possible positive integer that fulfills that minimum requirement
     // Otherwise, the specified track list repeats only once.
-    let style_size = style.size.get_abs(axis).into_option();
+    let style_size = preferred_size.get_abs(axis);
     let style_min_size = style.min_size.get_abs(axis).into_option();
     let style_max_size = style.max_size.get_abs(axis).into_option();
 
@@ -297,8 +302,9 @@ mod test {
     #[test]
     fn explicit_grid_sizing_no_repeats() {
         let grid_style = (600.0, 600.0, 2, 4).into_grid();
-        let width = compute_explicit_grid_size_in_axis(&grid_style, AbsoluteAxis::Horizontal);
-        let height = compute_explicit_grid_size_in_axis(&grid_style, AbsoluteAxis::Vertical);
+        let preferred_size = grid_style.size.map(|s| s.into_option());
+        let width = compute_explicit_grid_size_in_axis(&grid_style, preferred_size, AbsoluteAxis::Horizontal);
+        let height = compute_explicit_grid_size_in_axis(&grid_style, preferred_size, AbsoluteAxis::Vertical);
         assert_eq!(width, 2);
         assert_eq!(height, 4);
     }
@@ -313,8 +319,9 @@ mod test {
             grid_template_rows: vec![repeat(AutoFill, vec![points(20.0)])],
             ..Default::default()
         };
-        let width = compute_explicit_grid_size_in_axis(&grid_style, AbsoluteAxis::Horizontal);
-        let height = compute_explicit_grid_size_in_axis(&grid_style, AbsoluteAxis::Vertical);
+        let preferred_size = grid_style.size.map(|s| s.into_option());
+        let width = compute_explicit_grid_size_in_axis(&grid_style, preferred_size, AbsoluteAxis::Horizontal);
+        let height = compute_explicit_grid_size_in_axis(&grid_style, preferred_size, AbsoluteAxis::Vertical);
         assert_eq!(width, 3);
         assert_eq!(height, 4);
     }
@@ -329,8 +336,9 @@ mod test {
             grid_template_rows: vec![repeat(AutoFill, vec![points(20.0)])],
             ..Default::default()
         };
-        let width = compute_explicit_grid_size_in_axis(&grid_style, AbsoluteAxis::Horizontal);
-        let height = compute_explicit_grid_size_in_axis(&grid_style, AbsoluteAxis::Vertical);
+        let preferred_size = grid_style.size.map(|s| s.into_option());
+        let width = compute_explicit_grid_size_in_axis(&grid_style, preferred_size, AbsoluteAxis::Horizontal);
+        let height = compute_explicit_grid_size_in_axis(&grid_style, preferred_size, AbsoluteAxis::Vertical);
         assert_eq!(width, 3);
         assert_eq!(height, 4);
     }
@@ -345,8 +353,9 @@ mod test {
             grid_template_rows: vec![repeat(AutoFill, vec![points(20.0)])],
             ..Default::default()
         };
-        let width = compute_explicit_grid_size_in_axis(&grid_style, AbsoluteAxis::Horizontal);
-        let height = compute_explicit_grid_size_in_axis(&grid_style, AbsoluteAxis::Vertical);
+        let preferred_size = grid_style.size.map(|s| s.into_option());
+        let width = compute_explicit_grid_size_in_axis(&grid_style, preferred_size, AbsoluteAxis::Horizontal);
+        let height = compute_explicit_grid_size_in_axis(&grid_style, preferred_size, AbsoluteAxis::Vertical);
         assert_eq!(width, 3);
         assert_eq!(height, 4);
     }
@@ -361,8 +370,9 @@ mod test {
             grid_template_rows: vec![repeat(AutoFill, vec![points(20.0)])],
             ..Default::default()
         };
-        let width = compute_explicit_grid_size_in_axis(&grid_style, AbsoluteAxis::Horizontal);
-        let height = compute_explicit_grid_size_in_axis(&grid_style, AbsoluteAxis::Vertical);
+        let preferred_size = grid_style.size.map(|s| s.into_option());
+        let width = compute_explicit_grid_size_in_axis(&grid_style, preferred_size, AbsoluteAxis::Horizontal);
+        let height = compute_explicit_grid_size_in_axis(&grid_style, preferred_size, AbsoluteAxis::Vertical);
         assert_eq!(width, 4);
         assert_eq!(height, 5);
     }
@@ -377,8 +387,9 @@ mod test {
             grid_template_rows: vec![repeat(AutoFill, vec![points(20.0), points(10.0)])],
             ..Default::default()
         };
-        let width = compute_explicit_grid_size_in_axis(&grid_style, AbsoluteAxis::Horizontal);
-        let height = compute_explicit_grid_size_in_axis(&grid_style, AbsoluteAxis::Vertical);
+        let preferred_size = grid_style.size.map(|s| s.into_option());
+        let width = compute_explicit_grid_size_in_axis(&grid_style, preferred_size, AbsoluteAxis::Horizontal);
+        let height = compute_explicit_grid_size_in_axis(&grid_style, preferred_size, AbsoluteAxis::Vertical);
         assert_eq!(width, 4); // 2 repetitions * 2 repeated tracks = 4 tracks in total
         assert_eq!(height, 6); // 3 repetitions * 2 repeated tracks = 4 tracks in total
     }
@@ -394,8 +405,9 @@ mod test {
             gap: points(20.0),
             ..Default::default()
         };
-        let width = compute_explicit_grid_size_in_axis(&grid_style, AbsoluteAxis::Horizontal);
-        let height = compute_explicit_grid_size_in_axis(&grid_style, AbsoluteAxis::Vertical);
+        let preferred_size = grid_style.size.map(|s| s.into_option());
+        let width = compute_explicit_grid_size_in_axis(&grid_style, preferred_size, AbsoluteAxis::Horizontal);
+        let height = compute_explicit_grid_size_in_axis(&grid_style, preferred_size, AbsoluteAxis::Vertical);
         assert_eq!(width, 2); // 2 tracks + 1 gap
         assert_eq!(height, 3); // 3 tracks + 2 gaps
     }
@@ -410,8 +422,9 @@ mod test {
             gap: points(20.0),
             ..Default::default()
         };
-        let width = compute_explicit_grid_size_in_axis(&grid_style, AbsoluteAxis::Horizontal);
-        let height = compute_explicit_grid_size_in_axis(&grid_style, AbsoluteAxis::Vertical);
+        let preferred_size = grid_style.size.map(|s| s.into_option());
+        let width = compute_explicit_grid_size_in_axis(&grid_style, preferred_size, AbsoluteAxis::Horizontal);
+        let height = compute_explicit_grid_size_in_axis(&grid_style, preferred_size, AbsoluteAxis::Vertical);
         assert_eq!(width, 3);
         assert_eq!(height, 1);
     }
@@ -427,8 +440,9 @@ mod test {
             gap: points(20.0),
             ..Default::default()
         };
-        let width = compute_explicit_grid_size_in_axis(&grid_style, AbsoluteAxis::Horizontal);
-        let height = compute_explicit_grid_size_in_axis(&grid_style, AbsoluteAxis::Vertical);
+        let preferred_size = grid_style.size.map(|s| s.into_option());
+        let width = compute_explicit_grid_size_in_axis(&grid_style, preferred_size, AbsoluteAxis::Horizontal);
+        let height = compute_explicit_grid_size_in_axis(&grid_style, preferred_size, AbsoluteAxis::Vertical);
         assert_eq!(width, 3); // 3 tracks + 2 gaps
         assert_eq!(height, 2); // 2 tracks + 1 gap
     }
@@ -444,8 +458,9 @@ mod test {
             grid_template_rows: vec![repeat(AutoFill, vec![points(20.0)])],
             ..Default::default()
         };
-        let width = compute_explicit_grid_size_in_axis(&grid_style, AbsoluteAxis::Horizontal);
-        let height = compute_explicit_grid_size_in_axis(&grid_style, AbsoluteAxis::Vertical);
+        let preferred_size = grid_style.size.map(|s| s.into_option());
+        let width = compute_explicit_grid_size_in_axis(&grid_style, preferred_size, AbsoluteAxis::Horizontal);
+        let height = compute_explicit_grid_size_in_axis(&grid_style, preferred_size, AbsoluteAxis::Vertical);
         assert_eq!(width, 5); // 40px horizontal padding
         assert_eq!(height, 4); // 20px vertical padding
     }
diff --git a/src/compute/grid/mod.rs b/src/compute/grid/mod.rs
index a1393e26a..e9f8e6f01 100644
--- a/src/compute/grid/mod.rs
+++ b/src/compute/grid/mod.rs
@@ -45,9 +45,9 @@ impl LayoutAlgorithm for CssGridAlgorithm {
         known_dimensions: Size<Option<f32>>,
         parent_size: Size<Option<f32>>,
         available_space: Size<AvailableSpace>,
-        _sizing_mode: SizingMode,
+        sizing_mode: SizingMode,
     ) -> SizeAndBaselines {
-        compute(tree, node, known_dimensions, parent_size, available_space, RunMode::PeformLayout)
+        compute(tree, node, known_dimensions, parent_size, available_space, RunMode::PeformLayout, sizing_mode)
     }
 
     fn measure_size(
@@ -56,9 +56,9 @@ impl LayoutAlgorithm for CssGridAlgorithm {
         known_dimensions: Size<Option<f32>>,
         parent_size: Size<Option<f32>>,
         available_space: Size<AvailableSpace>,
-        _sizing_mode: SizingMode,
+        sizing_mode: SizingMode,
     ) -> Size<f32> {
-        compute(tree, node, known_dimensions, parent_size, available_space, RunMode::ComputeSize).size
+        compute(tree, node, known_dimensions, parent_size, available_space, RunMode::ComputeSize, sizing_mode).size
     }
 }
 
@@ -75,15 +75,22 @@ pub fn compute(
     parent_size: Size<Option<f32>>,
     available_space: Size<AvailableSpace>,
     run_mode: RunMode,
+    sizing_mode: SizingMode,
 ) -> SizeAndBaselines {
     let get_child_styles_iter = |node| tree.children(node).map(|child_node: &Node| tree.style(*child_node));
     let style = tree.style(node).clone();
     let child_styles_iter = get_child_styles_iter(node);
 
+    let preferred_size = if sizing_mode == SizingMode::InherentSize {
+        style.size.maybe_resolve(parent_size).maybe_apply_aspect_ratio(style.aspect_ratio)
+    } else {
+        Size::NONE
+    };
+
     // 1. Resolve the explicit grid
     // Exactly compute the number of rows and columns in the explicit grid.
-    let explicit_col_count = compute_explicit_grid_size_in_axis(&style, AbsoluteAxis::Horizontal);
-    let explicit_row_count = compute_explicit_grid_size_in_axis(&style, AbsoluteAxis::Vertical);
+    let explicit_col_count = compute_explicit_grid_size_in_axis(&style, preferred_size, AbsoluteAxis::Horizontal);
+    let explicit_row_count = compute_explicit_grid_size_in_axis(&style, preferred_size, AbsoluteAxis::Vertical);
 
     // 2. Implicit Grid: Estimate Track Counts
     // Estimate the number of rows and columns in the implicit grid (= the entire grid)
@@ -145,7 +152,7 @@ pub fn compute(
     let aspect_ratio = style.aspect_ratio;
     let min_size = style.min_size.maybe_resolve(parent_size).maybe_apply_aspect_ratio(aspect_ratio);
     let max_size = style.max_size.maybe_resolve(parent_size).maybe_apply_aspect_ratio(aspect_ratio);
-    let size = style.size.maybe_resolve(parent_size).maybe_apply_aspect_ratio(aspect_ratio);
+    let size = preferred_size;
 
     let constrained_available_space = known_dimensions
         .or(size)
@@ -234,7 +241,7 @@ pub fn compute(
     NODE_LOGGER.labelled_debug_log("initial_row_sum", initial_row_sum);
 
     // 6. Compute container size
-    let resolved_style_size = known_dimensions.or(style.size.maybe_resolve(parent_size));
+    let resolved_style_size = known_dimensions.or(preferred_size);
     let container_border_box = Size {
         width: resolved_style_size
             .get(AbstractAxis::Inline)
diff --git a/test_fixtures/bevy_issue_10343_flex.html b/test_fixtures/bevy_issue_10343_flex.html
new file mode 100644
index 000000000..651f21176
--- /dev/null
+++ b/test_fixtures/bevy_issue_10343_flex.html
@@ -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">
+  <title>
+    Test description
+  </title>
+</head>
+<body>
+
+<div id="test-root" style="display: flex; flex-direction: column; justify-content: space-around; width: 100px; height: 100px; background-color: grey;">
+    <div style="display: flex; flex-direction: row; background-color: purple;">
+        <div style="display: flex; width: 200px; height: 200px; margin: 5px; background-color: blue;">
+            <div></div>
+        </div>
+    </div>
+</div>  
+
+</body>
+</html>
\ No newline at end of file
diff --git a/test_fixtures/bevy_issue_10343_grid.html b/test_fixtures/bevy_issue_10343_grid.html
new file mode 100644
index 000000000..5db098625
--- /dev/null
+++ b/test_fixtures/bevy_issue_10343_grid.html
@@ -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">
+  <title>
+    Test description
+  </title>
+</head>
+<body>
+
+<div id="test-root" style="display: flex; flex-direction: column; justify-content: space-around; width: 100px; height: 100px; background-color: grey;">
+    <div style="display: flex; flex-direction: row; background-color: purple;">
+        <div style="display: grid; width: 200px; height: 200px; margin: 5px; background-color: blue;">
+            <div></div>
+        </div>
+    </div>
+</div>  
+
+</body>
+</html>
\ No newline at end of file
diff --git a/tests/generated/bevy_issue_10343_flex.rs b/tests/generated/bevy_issue_10343_flex.rs
new file mode 100644
index 000000000..6c72f1f8b
--- /dev/null
+++ b/tests/generated/bevy_issue_10343_flex.rs
@@ -0,0 +1,72 @@
+#[test]
+fn bevy_issue_10343_flex() {
+    use slotmap::Key;
+    #[allow(unused_imports)]
+    use taffy::{layout::Layout, prelude::*};
+    let mut taffy = taffy::Taffy::new();
+    let node000 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
+    let node00 = taffy
+        .new_with_children(
+            taffy::style::Style {
+                display: taffy::style::Display::Flex,
+                size: taffy::geometry::Size {
+                    width: taffy::style::Dimension::Points(200f32),
+                    height: taffy::style::Dimension::Points(200f32),
+                },
+                margin: taffy::geometry::Rect {
+                    left: taffy::style::LengthPercentageAuto::Points(5f32),
+                    right: taffy::style::LengthPercentageAuto::Points(5f32),
+                    top: taffy::style::LengthPercentageAuto::Points(5f32),
+                    bottom: taffy::style::LengthPercentageAuto::Points(5f32),
+                },
+                ..Default::default()
+            },
+            &[node000],
+        )
+        .unwrap();
+    let node0 = taffy
+        .new_with_children(
+            taffy::style::Style { display: taffy::style::Display::Flex, ..Default::default() },
+            &[node00],
+        )
+        .unwrap();
+    let node = taffy
+        .new_with_children(
+            taffy::style::Style {
+                display: taffy::style::Display::Flex,
+                flex_direction: taffy::style::FlexDirection::Column,
+                justify_content: Some(taffy::style::JustifyContent::SpaceAround),
+                size: taffy::geometry::Size {
+                    width: taffy::style::Dimension::Points(100f32),
+                    height: taffy::style::Dimension::Points(100f32),
+                },
+                ..Default::default()
+            },
+            &[node0],
+        )
+        .unwrap();
+    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
+    println!("\nComputed tree:");
+    taffy::debug::print_tree(&taffy, node);
+    println!();
+    let Layout { size, location, .. } = taffy.layout(node).unwrap();
+    assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width);
+    assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height);
+    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
+    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
+    let Layout { size, location, .. } = taffy.layout(node0).unwrap();
+    assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 100f32, size.width);
+    assert_eq!(size.height, 210f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 210f32, size.height);
+    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x);
+    assert_eq!(location.y, -55f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), -55f32, location.y);
+    let Layout { size, location, .. } = taffy.layout(node00).unwrap();
+    assert_eq!(size.width, 90f32, "width of node {:?}. Expected {}. Actual {}", node00.data(), 90f32, size.width);
+    assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00.data(), 200f32, size.height);
+    assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node00.data(), 5f32, location.x);
+    assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node00.data(), 5f32, location.y);
+    let Layout { size, location, .. } = taffy.layout(node000).unwrap();
+    assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node000.data(), 0f32, size.width);
+    assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node000.data(), 200f32, size.height);
+    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000.data(), 0f32, location.x);
+    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000.data(), 0f32, location.y);
+}
diff --git a/tests/generated/bevy_issue_10343_grid.rs b/tests/generated/bevy_issue_10343_grid.rs
new file mode 100644
index 000000000..9b9d5b810
--- /dev/null
+++ b/tests/generated/bevy_issue_10343_grid.rs
@@ -0,0 +1,72 @@
+#[test]
+fn bevy_issue_10343_grid() {
+    use slotmap::Key;
+    #[allow(unused_imports)]
+    use taffy::{layout::Layout, prelude::*};
+    let mut taffy = taffy::Taffy::new();
+    let node000 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
+    let node00 = taffy
+        .new_with_children(
+            taffy::style::Style {
+                display: taffy::style::Display::Grid,
+                size: taffy::geometry::Size {
+                    width: taffy::style::Dimension::Points(200f32),
+                    height: taffy::style::Dimension::Points(200f32),
+                },
+                margin: taffy::geometry::Rect {
+                    left: taffy::style::LengthPercentageAuto::Points(5f32),
+                    right: taffy::style::LengthPercentageAuto::Points(5f32),
+                    top: taffy::style::LengthPercentageAuto::Points(5f32),
+                    bottom: taffy::style::LengthPercentageAuto::Points(5f32),
+                },
+                ..Default::default()
+            },
+            &[node000],
+        )
+        .unwrap();
+    let node0 = taffy
+        .new_with_children(
+            taffy::style::Style { display: taffy::style::Display::Flex, ..Default::default() },
+            &[node00],
+        )
+        .unwrap();
+    let node = taffy
+        .new_with_children(
+            taffy::style::Style {
+                display: taffy::style::Display::Flex,
+                flex_direction: taffy::style::FlexDirection::Column,
+                justify_content: Some(taffy::style::JustifyContent::SpaceAround),
+                size: taffy::geometry::Size {
+                    width: taffy::style::Dimension::Points(100f32),
+                    height: taffy::style::Dimension::Points(100f32),
+                },
+                ..Default::default()
+            },
+            &[node0],
+        )
+        .unwrap();
+    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
+    println!("\nComputed tree:");
+    taffy::debug::print_tree(&taffy, node);
+    println!();
+    let Layout { size, location, .. } = taffy.layout(node).unwrap();
+    assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width);
+    assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height);
+    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
+    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
+    let Layout { size, location, .. } = taffy.layout(node0).unwrap();
+    assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 100f32, size.width);
+    assert_eq!(size.height, 210f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 210f32, size.height);
+    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x);
+    assert_eq!(location.y, -55f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), -55f32, location.y);
+    let Layout { size, location, .. } = taffy.layout(node00).unwrap();
+    assert_eq!(size.width, 90f32, "width of node {:?}. Expected {}. Actual {}", node00.data(), 90f32, size.width);
+    assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00.data(), 200f32, size.height);
+    assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node00.data(), 5f32, location.x);
+    assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node00.data(), 5f32, location.y);
+    let Layout { size, location, .. } = taffy.layout(node000).unwrap();
+    assert_eq!(size.width, 90f32, "width of node {:?}. Expected {}. Actual {}", node000.data(), 90f32, size.width);
+    assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node000.data(), 200f32, size.height);
+    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000.data(), 0f32, location.x);
+    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000.data(), 0f32, location.y);
+}
diff --git a/tests/generated/mod.rs b/tests/generated/mod.rs
index 49db6907a..c173b30a1 100644
--- a/tests/generated/mod.rs
+++ b/tests/generated/mod.rs
@@ -225,6 +225,8 @@ mod aspect_ratio_flex_row_stretch_fill_height;
 mod aspect_ratio_flex_row_stretch_fill_max_height;
 mod aspect_ratio_flex_row_stretch_fill_max_width;
 mod aspect_ratio_flex_row_stretch_fill_width;
+mod bevy_issue_10343_flex;
+mod bevy_issue_10343_grid;
 mod bevy_issue_7976_3_level;
 mod bevy_issue_7976_4_level;
 mod bevy_issue_7976_reduced;