Fix intrinsic size of scroll containers that have a small explicit flex-basis (#728)
* Add tests to for issue 696
* Flexbox: prevent content size from affecting intrinsic main size if an
item is a scroll container
* Format fixtures
* Fix clippy lints
9f1d71c97e0852760580b7d7bb30f503baa6a988 · by Nico Burns · 2024-10-22T08:30:18Z (2 years ago) · parent 343203d51 · browse the tree at this commit
Semantic delta · 17
tests/generated/flex/mod.rs
tests/generated/flex/taffy_issue_696.rs
tests/generated/flex/taffy_issue_696_flex_basis_20.rs
tests/generated/flex/taffy_issue_696_min_height.rs
tests/generated/flex/taffy_issue_696_no_flex_basis.rs
tests/generated/flex/taffy_issue_696_overflow_hidden.rs
diff --git a/src/compute/flexbox.rs b/src/compute/flexbox.rs
index bf8bf360b..9f1fcc1f4 100644
--- a/src/compute/flexbox.rs
+++ b/src/compute/flexbox.rs
@@ -97,6 +97,13 @@ struct FlexItem {
offset_cross: f32,
}
+impl FlexItem {
+ /// Returns true if the item is a <https://www.w3.org/TR/css-overflow-3/#scroll-container>
+ fn is_scroll_container(&self) -> bool {
+ self.overflow.x.is_scroll_container() | self.overflow.y.is_scroll_container()
+ }
+}
+
/// A line of [`FlexItem`] used for intermediate computation
struct FlexLine<'a> {
/// The slice of items to iterate over during computation of this line
@@ -975,8 +982,12 @@ fn determine_container_main_size(
pref.min(max).max(min) + item.margin.main_axis_sum(constants.dir)
}
(min, _, max) if max <= min => min + item.margin.main_axis_sum(constants.dir),
+
// Else compute the min- or -max content size and apply the full formula for computing the
- // min- or max- content contributuon
+ // min- or max- content contribution
+ _ if item.is_scroll_container() => {
+ item.flex_basis + item.margin.main_axis_sum(constants.dir)
+ }
_ => {
// Parent size for child sizing
let cross_axis_parent_size = constants.node_inner_size.cross(dir);
diff --git a/test_fixtures/flex/taffy_issue_696.html b/test_fixtures/flex/taffy_issue_696.html
new file mode 100644
index 000000000..eab6cba62
--- /dev/null
+++ b/test_fixtures/flex/taffy_issue_696.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="display: flex; flex-direction: column; width: 200px;">
+ <div style="display: flex; flex-direction: column; overflow: hidden; min-height: 100px; padding: 20px; flex-basis: 0px;">
+ <div style="display: flex; height: 200px; flex-shrink: 0;"></div>
+ </div>
+ </div>
+</body>
+
+</html>
\ No newline at end of file
diff --git a/test_fixtures/flex/taffy_issue_696_flex_basis_20.html b/test_fixtures/flex/taffy_issue_696_flex_basis_20.html
new file mode 100644
index 000000000..8330f98d3
--- /dev/null
+++ b/test_fixtures/flex/taffy_issue_696_flex_basis_20.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="display: flex; flex-direction: column; width: 200px;">
+ <div style="display: flex; flex-direction: column; overflow: hidden; min-height: 100px; padding: 20px; flex-basis: 20px;">
+ <div style="display: flex; height: 200px; flex-shrink: 0;"></div>
+ </div>
+ </div>
+</body>
+
+</html>
\ No newline at end of file
diff --git a/test_fixtures/flex/taffy_issue_696_min_height.html b/test_fixtures/flex/taffy_issue_696_min_height.html
new file mode 100644
index 000000000..8b7bac8e8
--- /dev/null
+++ b/test_fixtures/flex/taffy_issue_696_min_height.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="display: flex; flex-direction: column; width: 200px;">
+ <div style="display: flex; flex-direction: column; min-height: 100px; padding: 20px; flex-basis: 0px;">
+ <div style="display: flex; height: 200px; flex-shrink: 0;"></div>
+ </div>
+ </div>
+</body>
+
+</html>
\ No newline at end of file
diff --git a/test_fixtures/flex/taffy_issue_696_no_flex_basis.html b/test_fixtures/flex/taffy_issue_696_no_flex_basis.html
new file mode 100644
index 000000000..c76fbece2
--- /dev/null
+++ b/test_fixtures/flex/taffy_issue_696_no_flex_basis.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="display: flex; flex-direction: column; width: 200px;">
+ <div style="display: flex; flex-direction: column; overflow: hidden; min-height: 100px; padding: 20px;">
+ <div style="display: flex; height: 200px; flex-shrink: 0;"></div>
+ </div>
+ </div>
+</body>
+
+</html>
\ No newline at end of file
diff --git a/test_fixtures/flex/taffy_issue_696_overflow_hidden.html b/test_fixtures/flex/taffy_issue_696_overflow_hidden.html
new file mode 100644
index 000000000..f06dbb76c
--- /dev/null
+++ b/test_fixtures/flex/taffy_issue_696_overflow_hidden.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="display: flex; flex-direction: column; width: 200px;">
+ <div style="display: flex; flex-direction: column; overflow: hidden; padding: 20px; flex-basis: 0px;">
+ <div style="display: flex; height: 200px; flex-shrink: 0;"></div>
+ </div>
+ </div>
+</body>
+
+</html>
\ No newline at end of file
diff --git a/tests/generated/flex/mod.rs b/tests/generated/flex/mod.rs
index 1da547ece..046c71e88 100644
--- a/tests/generated/flex/mod.rs
+++ b/tests/generated/flex/mod.rs
@@ -500,6 +500,11 @@ mod size_defined_by_child;
mod size_defined_by_child_with_border;
mod size_defined_by_child_with_padding;
mod size_defined_by_grand_child;
+mod taffy_issue_696;
+mod taffy_issue_696_flex_basis_20;
+mod taffy_issue_696_min_height;
+mod taffy_issue_696_no_flex_basis;
+mod taffy_issue_696_overflow_hidden;
mod undefined_height_with_min_max;
mod undefined_width_with_min_max;
mod undefined_width_with_min_max_row;
diff --git a/tests/generated/flex/taffy_issue_696.rs b/tests/generated/flex/taffy_issue_696.rs
new file mode 100644
index 000000000..fa5e4ce2d
--- /dev/null
+++ b/tests/generated/flex/taffy_issue_696.rs
@@ -0,0 +1,182 @@
+#[test]
+#[allow(non_snake_case)]
+fn taffy_issue_696__border_box() {
+ #[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 {
+ display: taffy::style::Display::Flex,
+ flex_shrink: 0f32,
+ size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(200f32) },
+ ..Default::default()
+ })
+ .unwrap();
+ let node0 = taffy
+ .new_with_children(
+ taffy::style::Style {
+ display: taffy::style::Display::Flex,
+ flex_direction: taffy::style::FlexDirection::Column,
+ overflow: taffy::geometry::Point {
+ x: taffy::style::Overflow::Hidden,
+ y: taffy::style::Overflow::Hidden,
+ },
+ scrollbar_width: 15f32,
+ flex_basis: taffy::style::Dimension::Length(0f32),
+ min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) },
+ padding: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Length(20f32),
+ right: taffy::style::LengthPercentage::Length(20f32),
+ top: taffy::style::LengthPercentage::Length(20f32),
+ bottom: taffy::style::LengthPercentage::Length(20f32),
+ },
+ ..Default::default()
+ },
+ &[node00],
+ )
+ .unwrap();
+ let node = taffy
+ .new_with_children(
+ taffy::style::Style {
+ display: taffy::style::Display::Flex,
+ flex_direction: taffy::style::FlexDirection::Column,
+ size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() },
+ ..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!();
+ let layout = taffy.layout(node).unwrap();
+ let Layout { size, location, .. } = layout;
+ 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);
+ let layout = taffy.layout(node0).unwrap();
+ let Layout { size, location, .. } = layout;
+ assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, 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(),
+ 140f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node0,
+ 140f32,
+ layout.scroll_height()
+ );
+ let layout = taffy.layout(node00).unwrap();
+ let Layout { size, location, .. } = layout;
+ assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width);
+ assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height);
+ assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x);
+ assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node00, 20f32, location.y);
+}
+
+#[test]
+#[allow(non_snake_case)]
+fn taffy_issue_696__content_box() {
+ #[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 {
+ display: taffy::style::Display::Flex,
+ box_sizing: taffy::style::BoxSizing::ContentBox,
+ flex_shrink: 0f32,
+ size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(200f32) },
+ ..Default::default()
+ })
+ .unwrap();
+ let node0 = taffy
+ .new_with_children(
+ taffy::style::Style {
+ display: taffy::style::Display::Flex,
+ box_sizing: taffy::style::BoxSizing::ContentBox,
+ flex_direction: taffy::style::FlexDirection::Column,
+ overflow: taffy::geometry::Point {
+ x: taffy::style::Overflow::Hidden,
+ y: taffy::style::Overflow::Hidden,
+ },
+ scrollbar_width: 15f32,
+ flex_basis: taffy::style::Dimension::Length(0f32),
+ min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) },
+ padding: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Length(20f32),
+ right: taffy::style::LengthPercentage::Length(20f32),
+ top: taffy::style::LengthPercentage::Length(20f32),
+ bottom: taffy::style::LengthPercentage::Length(20f32),
+ },
+ ..Default::default()
+ },
+ &[node00],
+ )
+ .unwrap();
+ let node = taffy
+ .new_with_children(
+ taffy::style::Style {
+ display: taffy::style::Display::Flex,
+ box_sizing: taffy::style::BoxSizing::ContentBox,
+ flex_direction: taffy::style::FlexDirection::Column,
+ size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() },
+ ..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!();
+ let layout = taffy.layout(node).unwrap();
+ let Layout { size, location, .. } = layout;
+ assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width);
+ assert_eq!(size.height, 140f32, "height of node {:?}. Expected {}. Actual {}", node, 140f32, 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);
+ let layout = taffy.layout(node0).unwrap();
+ let Layout { size, location, .. } = layout;
+ assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width);
+ assert_eq!(size.height, 140f32, "height of node {:?}. Expected {}. Actual {}", node0, 140f32, 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(),
+ 100f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node0,
+ 100f32,
+ layout.scroll_height()
+ );
+ let layout = taffy.layout(node00).unwrap();
+ let Layout { size, location, .. } = layout;
+ assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width);
+ assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height);
+ assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x);
+ assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node00, 20f32, location.y);
+}
diff --git a/tests/generated/flex/taffy_issue_696_flex_basis_20.rs b/tests/generated/flex/taffy_issue_696_flex_basis_20.rs
new file mode 100644
index 000000000..c9cfe4b31
--- /dev/null
+++ b/tests/generated/flex/taffy_issue_696_flex_basis_20.rs
@@ -0,0 +1,182 @@
+#[test]
+#[allow(non_snake_case)]
+fn taffy_issue_696_flex_basis_20__border_box() {
+ #[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 {
+ display: taffy::style::Display::Flex,
+ flex_shrink: 0f32,
+ size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(200f32) },
+ ..Default::default()
+ })
+ .unwrap();
+ let node0 = taffy
+ .new_with_children(
+ taffy::style::Style {
+ display: taffy::style::Display::Flex,
+ flex_direction: taffy::style::FlexDirection::Column,
+ overflow: taffy::geometry::Point {
+ x: taffy::style::Overflow::Hidden,
+ y: taffy::style::Overflow::Hidden,
+ },
+ scrollbar_width: 15f32,
+ flex_basis: taffy::style::Dimension::Length(20f32),
+ min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) },
+ padding: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Length(20f32),
+ right: taffy::style::LengthPercentage::Length(20f32),
+ top: taffy::style::LengthPercentage::Length(20f32),
+ bottom: taffy::style::LengthPercentage::Length(20f32),
+ },
+ ..Default::default()
+ },
+ &[node00],
+ )
+ .unwrap();
+ let node = taffy
+ .new_with_children(
+ taffy::style::Style {
+ display: taffy::style::Display::Flex,
+ flex_direction: taffy::style::FlexDirection::Column,
+ size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() },
+ ..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!();
+ let layout = taffy.layout(node).unwrap();
+ let Layout { size, location, .. } = layout;
+ 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);
+ let layout = taffy.layout(node0).unwrap();
+ let Layout { size, location, .. } = layout;
+ assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, 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(),
+ 140f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node0,
+ 140f32,
+ layout.scroll_height()
+ );
+ let layout = taffy.layout(node00).unwrap();
+ let Layout { size, location, .. } = layout;
+ assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width);
+ assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height);
+ assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x);
+ assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node00, 20f32, location.y);
+}
+
+#[test]
+#[allow(non_snake_case)]
+fn taffy_issue_696_flex_basis_20__content_box() {
+ #[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 {
+ display: taffy::style::Display::Flex,
+ box_sizing: taffy::style::BoxSizing::ContentBox,
+ flex_shrink: 0f32,
+ size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(200f32) },
+ ..Default::default()
+ })
+ .unwrap();
+ let node0 = taffy
+ .new_with_children(
+ taffy::style::Style {
+ display: taffy::style::Display::Flex,
+ box_sizing: taffy::style::BoxSizing::ContentBox,
+ flex_direction: taffy::style::FlexDirection::Column,
+ overflow: taffy::geometry::Point {
+ x: taffy::style::Overflow::Hidden,
+ y: taffy::style::Overflow::Hidden,
+ },
+ scrollbar_width: 15f32,
+ flex_basis: taffy::style::Dimension::Length(20f32),
+ min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) },
+ padding: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Length(20f32),
+ right: taffy::style::LengthPercentage::Length(20f32),
+ top: taffy::style::LengthPercentage::Length(20f32),
+ bottom: taffy::style::LengthPercentage::Length(20f32),
+ },
+ ..Default::default()
+ },
+ &[node00],
+ )
+ .unwrap();
+ let node = taffy
+ .new_with_children(
+ taffy::style::Style {
+ display: taffy::style::Display::Flex,
+ box_sizing: taffy::style::BoxSizing::ContentBox,
+ flex_direction: taffy::style::FlexDirection::Column,
+ size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() },
+ ..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!();
+ let layout = taffy.layout(node).unwrap();
+ let Layout { size, location, .. } = layout;
+ assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width);
+ assert_eq!(size.height, 140f32, "height of node {:?}. Expected {}. Actual {}", node, 140f32, 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);
+ let layout = taffy.layout(node0).unwrap();
+ let Layout { size, location, .. } = layout;
+ assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width);
+ assert_eq!(size.height, 140f32, "height of node {:?}. Expected {}. Actual {}", node0, 140f32, 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(),
+ 100f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node0,
+ 100f32,
+ layout.scroll_height()
+ );
+ let layout = taffy.layout(node00).unwrap();
+ let Layout { size, location, .. } = layout;
+ assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width);
+ assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height);
+ assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x);
+ assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node00, 20f32, location.y);
+}
diff --git a/tests/generated/flex/taffy_issue_696_min_height.rs b/tests/generated/flex/taffy_issue_696_min_height.rs
new file mode 100644
index 000000000..8f4454fad
--- /dev/null
+++ b/tests/generated/flex/taffy_issue_696_min_height.rs
@@ -0,0 +1,136 @@
+#[test]
+#[allow(non_snake_case)]
+fn taffy_issue_696_min_height__border_box() {
+ #[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 {
+ display: taffy::style::Display::Flex,
+ flex_shrink: 0f32,
+ size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(200f32) },
+ ..Default::default()
+ })
+ .unwrap();
+ let node0 = taffy
+ .new_with_children(
+ taffy::style::Style {
+ display: taffy::style::Display::Flex,
+ flex_direction: taffy::style::FlexDirection::Column,
+ flex_basis: taffy::style::Dimension::Length(0f32),
+ min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) },
+ padding: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Length(20f32),
+ right: taffy::style::LengthPercentage::Length(20f32),
+ top: taffy::style::LengthPercentage::Length(20f32),
+ bottom: taffy::style::LengthPercentage::Length(20f32),
+ },
+ ..Default::default()
+ },
+ &[node00],
+ )
+ .unwrap();
+ let node = taffy
+ .new_with_children(
+ taffy::style::Style {
+ display: taffy::style::Display::Flex,
+ flex_direction: taffy::style::FlexDirection::Column,
+ size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() },
+ ..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!();
+ let layout = taffy.layout(node).unwrap();
+ let Layout { size, location, .. } = layout;
+ 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);
+ let layout = taffy.layout(node0).unwrap();
+ let Layout { size, location, .. } = layout;
+ assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, 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);
+ let layout = taffy.layout(node00).unwrap();
+ let Layout { size, location, .. } = layout;
+ assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width);
+ assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height);
+ assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x);
+ assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node00, 20f32, location.y);
+}
+
+#[test]
+#[allow(non_snake_case)]
+fn taffy_issue_696_min_height__content_box() {
+ #[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 {
+ display: taffy::style::Display::Flex,
+ box_sizing: taffy::style::BoxSizing::ContentBox,
+ flex_shrink: 0f32,
+ size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(200f32) },
+ ..Default::default()
+ })
+ .unwrap();
+ let node0 = taffy
+ .new_with_children(
+ taffy::style::Style {
+ display: taffy::style::Display::Flex,
+ box_sizing: taffy::style::BoxSizing::ContentBox,
+ flex_direction: taffy::style::FlexDirection::Column,
+ flex_basis: taffy::style::Dimension::Length(0f32),
+ min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) },
+ padding: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Length(20f32),
+ right: taffy::style::LengthPercentage::Length(20f32),
+ top: taffy::style::LengthPercentage::Length(20f32),
+ bottom: taffy::style::LengthPercentage::Length(20f32),
+ },
+ ..Default::default()
+ },
+ &[node00],
+ )
+ .unwrap();
+ let node = taffy
+ .new_with_children(
+ taffy::style::Style {
+ display: taffy::style::Display::Flex,
+ box_sizing: taffy::style::BoxSizing::ContentBox,
+ flex_direction: taffy::style::FlexDirection::Column,
+ size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() },
+ ..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!();
+ let layout = taffy.layout(node).unwrap();
+ let Layout { size, location, .. } = layout;
+ assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width);
+ assert_eq!(size.height, 140f32, "height of node {:?}. Expected {}. Actual {}", node, 140f32, 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);
+ let layout = taffy.layout(node0).unwrap();
+ let Layout { size, location, .. } = layout;
+ assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width);
+ assert_eq!(size.height, 140f32, "height of node {:?}. Expected {}. Actual {}", node0, 140f32, 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);
+ let layout = taffy.layout(node00).unwrap();
+ let Layout { size, location, .. } = layout;
+ assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width);
+ assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height);
+ assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x);
+ assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node00, 20f32, location.y);
+}
diff --git a/tests/generated/flex/taffy_issue_696_no_flex_basis.rs b/tests/generated/flex/taffy_issue_696_no_flex_basis.rs
new file mode 100644
index 000000000..b01aed2dc
--- /dev/null
+++ b/tests/generated/flex/taffy_issue_696_no_flex_basis.rs
@@ -0,0 +1,180 @@
+#[test]
+#[allow(non_snake_case)]
+fn taffy_issue_696_no_flex_basis__border_box() {
+ #[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 {
+ display: taffy::style::Display::Flex,
+ flex_shrink: 0f32,
+ size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(200f32) },
+ ..Default::default()
+ })
+ .unwrap();
+ let node0 = taffy
+ .new_with_children(
+ taffy::style::Style {
+ display: taffy::style::Display::Flex,
+ flex_direction: taffy::style::FlexDirection::Column,
+ overflow: taffy::geometry::Point {
+ x: taffy::style::Overflow::Hidden,
+ y: taffy::style::Overflow::Hidden,
+ },
+ scrollbar_width: 15f32,
+ min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) },
+ padding: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Length(20f32),
+ right: taffy::style::LengthPercentage::Length(20f32),
+ top: taffy::style::LengthPercentage::Length(20f32),
+ bottom: taffy::style::LengthPercentage::Length(20f32),
+ },
+ ..Default::default()
+ },
+ &[node00],
+ )
+ .unwrap();
+ let node = taffy
+ .new_with_children(
+ taffy::style::Style {
+ display: taffy::style::Display::Flex,
+ flex_direction: taffy::style::FlexDirection::Column,
+ size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() },
+ ..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!();
+ let layout = taffy.layout(node).unwrap();
+ let Layout { size, location, .. } = layout;
+ assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width);
+ assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node, 240f32, 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);
+ let layout = taffy.layout(node0).unwrap();
+ let Layout { size, location, .. } = layout;
+ assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width);
+ assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node0, 240f32, 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()
+ );
+ let layout = taffy.layout(node00).unwrap();
+ let Layout { size, location, .. } = layout;
+ assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width);
+ assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height);
+ assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x);
+ assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node00, 20f32, location.y);
+}
+
+#[test]
+#[allow(non_snake_case)]
+fn taffy_issue_696_no_flex_basis__content_box() {
+ #[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 {
+ display: taffy::style::Display::Flex,
+ box_sizing: taffy::style::BoxSizing::ContentBox,
+ flex_shrink: 0f32,
+ size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(200f32) },
+ ..Default::default()
+ })
+ .unwrap();
+ let node0 = taffy
+ .new_with_children(
+ taffy::style::Style {
+ display: taffy::style::Display::Flex,
+ box_sizing: taffy::style::BoxSizing::ContentBox,
+ flex_direction: taffy::style::FlexDirection::Column,
+ overflow: taffy::geometry::Point {
+ x: taffy::style::Overflow::Hidden,
+ y: taffy::style::Overflow::Hidden,
+ },
+ scrollbar_width: 15f32,
+ min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) },
+ padding: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Length(20f32),
+ right: taffy::style::LengthPercentage::Length(20f32),
+ top: taffy::style::LengthPercentage::Length(20f32),
+ bottom: taffy::style::LengthPercentage::Length(20f32),
+ },
+ ..Default::default()
+ },
+ &[node00],
+ )
+ .unwrap();
+ let node = taffy
+ .new_with_children(
+ taffy::style::Style {
+ display: taffy::style::Display::Flex,
+ box_sizing: taffy::style::BoxSizing::ContentBox,
+ flex_direction: taffy::style::FlexDirection::Column,
+ size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() },
+ ..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!();
+ let layout = taffy.layout(node).unwrap();
+ let Layout { size, location, .. } = layout;
+ assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width);
+ assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node, 240f32, 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);
+ let layout = taffy.layout(node0).unwrap();
+ let Layout { size, location, .. } = layout;
+ assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width);
+ assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node0, 240f32, 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()
+ );
+ let layout = taffy.layout(node00).unwrap();
+ let Layout { size, location, .. } = layout;
+ assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width);
+ assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height);
+ assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x);
+ assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node00, 20f32, location.y);
+}
diff --git a/tests/generated/flex/taffy_issue_696_overflow_hidden.rs b/tests/generated/flex/taffy_issue_696_overflow_hidden.rs
new file mode 100644
index 000000000..072bd251e
--- /dev/null
+++ b/tests/generated/flex/taffy_issue_696_overflow_hidden.rs
@@ -0,0 +1,180 @@
+#[test]
+#[allow(non_snake_case)]
+fn taffy_issue_696_overflow_hidden__border_box() {
+ #[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 {
+ display: taffy::style::Display::Flex,
+ flex_shrink: 0f32,
+ size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(200f32) },
+ ..Default::default()
+ })
+ .unwrap();
+ let node0 = taffy
+ .new_with_children(
+ taffy::style::Style {
+ display: taffy::style::Display::Flex,
+ flex_direction: taffy::style::FlexDirection::Column,
+ overflow: taffy::geometry::Point {
+ x: taffy::style::Overflow::Hidden,
+ y: taffy::style::Overflow::Hidden,
+ },
+ scrollbar_width: 15f32,
+ flex_basis: taffy::style::Dimension::Length(0f32),
+ padding: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Length(20f32),
+ right: taffy::style::LengthPercentage::Length(20f32),
+ top: taffy::style::LengthPercentage::Length(20f32),
+ bottom: taffy::style::LengthPercentage::Length(20f32),
+ },
+ ..Default::default()
+ },
+ &[node00],
+ )
+ .unwrap();
+ let node = taffy
+ .new_with_children(
+ taffy::style::Style {
+ display: taffy::style::Display::Flex,
+ flex_direction: taffy::style::FlexDirection::Column,
+ size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() },
+ ..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!();
+ let layout = taffy.layout(node).unwrap();
+ let Layout { size, location, .. } = layout;
+ assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width);
+ assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, 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);
+ let layout = taffy.layout(node0).unwrap();
+ let Layout { size, location, .. } = layout;
+ assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width);
+ assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, 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(),
+ 200f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node0,
+ 200f32,
+ layout.scroll_height()
+ );
+ let layout = taffy.layout(node00).unwrap();
+ let Layout { size, location, .. } = layout;
+ assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width);
+ assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height);
+ assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x);
+ assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node00, 20f32, location.y);
+}
+
+#[test]
+#[allow(non_snake_case)]
+fn taffy_issue_696_overflow_hidden__content_box() {
+ #[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 {
+ display: taffy::style::Display::Flex,
+ box_sizing: taffy::style::BoxSizing::ContentBox,
+ flex_shrink: 0f32,
+ size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(200f32) },
+ ..Default::default()
+ })
+ .unwrap();
+ let node0 = taffy
+ .new_with_children(
+ taffy::style::Style {
+ display: taffy::style::Display::Flex,
+ box_sizing: taffy::style::BoxSizing::ContentBox,
+ flex_direction: taffy::style::FlexDirection::Column,
+ overflow: taffy::geometry::Point {
+ x: taffy::style::Overflow::Hidden,
+ y: taffy::style::Overflow::Hidden,
+ },
+ scrollbar_width: 15f32,
+ flex_basis: taffy::style::Dimension::Length(0f32),
+ padding: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Length(20f32),
+ right: taffy::style::LengthPercentage::Length(20f32),
+ top: taffy::style::LengthPercentage::Length(20f32),
+ bottom: taffy::style::LengthPercentage::Length(20f32),
+ },
+ ..Default::default()
+ },
+ &[node00],
+ )
+ .unwrap();
+ let node = taffy
+ .new_with_children(
+ taffy::style::Style {
+ display: taffy::style::Display::Flex,
+ box_sizing: taffy::style::BoxSizing::ContentBox,
+ flex_direction: taffy::style::FlexDirection::Column,
+ size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() },
+ ..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!();
+ let layout = taffy.layout(node).unwrap();
+ let Layout { size, location, .. } = layout;
+ assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width);
+ assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, 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);
+ let layout = taffy.layout(node0).unwrap();
+ let Layout { size, location, .. } = layout;
+ assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width);
+ assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, 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(),
+ 200f32,
+ "scroll_height of node {:?}. Expected {}. Actual {}",
+ node0,
+ 200f32,
+ layout.scroll_height()
+ );
+ let layout = taffy.layout(node00).unwrap();
+ let Layout { size, location, .. } = layout;
+ assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width);
+ assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height);
+ assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x);
+ assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node00, 20f32, location.y);
+}