From 3bc35ec3b541eea8ea62344722f155ce9b22e227 Mon Sep 17 00:00:00 2001 From: Nico Burns Date: Tue, 16 Jul 2024 18:02:53 +1200 Subject: [PATCH] Fix wrapping when a max main size style is present (#694) --- src/compute/flexbox.rs | 13 +- .../flex/multiline_column_max_height.html | 37 + tests/generated/flex/mod.rs | 1 + .../flex/multiline_column_max_height.rs | 1482 +++++++++++++++++ 4 files changed, 1532 insertions(+), 1 deletion(-) create mode 100644 test_fixtures/flex/multiline_column_max_height.html create mode 100644 tests/generated/flex/multiline_column_max_height.rs diff --git a/src/compute/flexbox.rs b/src/compute/flexbox.rs index 2ce9ec16d..8a44ed36d 100644 --- a/src/compute/flexbox.rs +++ b/src/compute/flexbox.rs @@ -815,7 +815,18 @@ fn collect_flex_lines<'a>( lines.push(FlexLine { items: flex_items.as_mut_slice(), cross_size: 0.0, offset_cross: 0.0 }); lines } else { - match available_space.main(constants.dir) { + let main_axis_available_space = match constants.max_size.main(constants.dir) { + Some(max_size) => AvailableSpace::Definite( + available_space + .main(constants.dir) + .into_option() + .unwrap_or(max_size) + .maybe_max(constants.min_size.main(constants.dir)), + ), + None => available_space.main(constants.dir), + }; + + match main_axis_available_space { // If we're sizing under a max-content constraint then the flex items will never wrap // (at least for now - future extensions to the CSS spec may add provisions for forced wrap points) AvailableSpace::MaxContent => { diff --git a/test_fixtures/flex/multiline_column_max_height.html b/test_fixtures/flex/multiline_column_max_height.html new file mode 100644 index 000000000..cc26eb548 --- /dev/null +++ b/test_fixtures/flex/multiline_column_max_height.html @@ -0,0 +1,37 @@ + + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + + diff --git a/tests/generated/flex/mod.rs b/tests/generated/flex/mod.rs index 91c6edd13..6da5bb0e6 100644 --- a/tests/generated/flex/mod.rs +++ b/tests/generated/flex/mod.rs @@ -411,6 +411,7 @@ mod min_width_larger_than_width; mod min_width_overrides_max_width; mod min_width_overrides_width; mod min_width_overrides_width_on_root; +mod multiline_column_max_height; mod multiline_min_max_12; mod multiline_min_max_13; mod multiline_min_max_14; diff --git a/tests/generated/flex/multiline_column_max_height.rs b/tests/generated/flex/multiline_column_max_height.rs new file mode 100644 index 000000000..e1e6c325c --- /dev/null +++ b/tests/generated/flex/multiline_column_max_height.rs @@ -0,0 +1,1482 @@ +#[test] +#[allow(non_snake_case)] +fn multiline_column_max_height__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, tree::Layout, TaffyTree}; + let mut taffy: TaffyTree = TaffyTree::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node9 = taffy + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node10 = taffy + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node11 = taffy + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node12 = taffy + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node13 = taffy + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node14 = taffy + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node15 = taffy + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node16 = taffy + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node17 = taffy + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node18 = taffy + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node19 = taffy + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + flex_direction: taffy::style::FlexDirection::Column, + flex_wrap: taffy::style::FlexWrap::Wrap, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(200f32) }, + ..Default::default() + }, + &[ + node0, node1, node2, node3, node4, node5, node6, node7, node8, node9, node10, node11, node12, node13, + node14, node15, node16, node17, node18, node19, + ], + ) + .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, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, 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(), + 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, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, 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(node1).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); + assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, 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(node2).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); + assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, 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(node3).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); + assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node3, 60f32, 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(node4).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); + assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node4, 80f32, location.y); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_width(), + 0f32, + "scroll_width of node {:?}. Expected {}. Actual {}", + node4, + 0f32, + layout.scroll_width() + ); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_height(), + 0f32, + "scroll_height of node {:?}. Expected {}. Actual {}", + node4, + 0f32, + layout.scroll_height() + ); + #[cfg_attr(not(feature = "content_size"), allow(unused_variables))] + let layout @ Layout { size, location, .. } = taffy.layout(node5).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node5, 20f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); + assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node5, 100f32, location.y); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_width(), + 0f32, + "scroll_width of node {:?}. Expected {}. Actual {}", + node5, + 0f32, + layout.scroll_width() + ); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_height(), + 0f32, + "scroll_height of node {:?}. Expected {}. Actual {}", + node5, + 0f32, + layout.scroll_height() + ); + #[cfg_attr(not(feature = "content_size"), allow(unused_variables))] + let layout @ Layout { size, location, .. } = taffy.layout(node6).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node6, 20f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); + assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node6, 120f32, location.y); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_width(), + 0f32, + "scroll_width of node {:?}. Expected {}. Actual {}", + node6, + 0f32, + layout.scroll_width() + ); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_height(), + 0f32, + "scroll_height of node {:?}. Expected {}. Actual {}", + node6, + 0f32, + layout.scroll_height() + ); + #[cfg_attr(not(feature = "content_size"), allow(unused_variables))] + let layout @ Layout { size, location, .. } = taffy.layout(node7).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node7, 20f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node7, 0f32, location.x); + assert_eq!(location.y, 140f32, "y of node {:?}. Expected {}. Actual {}", node7, 140f32, location.y); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_width(), + 0f32, + "scroll_width of node {:?}. Expected {}. Actual {}", + node7, + 0f32, + layout.scroll_width() + ); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_height(), + 0f32, + "scroll_height of node {:?}. Expected {}. Actual {}", + node7, + 0f32, + layout.scroll_height() + ); + #[cfg_attr(not(feature = "content_size"), allow(unused_variables))] + let layout @ Layout { size, location, .. } = taffy.layout(node8).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node8, 20f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node8, 0f32, location.x); + assert_eq!(location.y, 160f32, "y of node {:?}. Expected {}. Actual {}", node8, 160f32, location.y); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_width(), + 0f32, + "scroll_width of node {:?}. Expected {}. Actual {}", + node8, + 0f32, + layout.scroll_width() + ); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_height(), + 0f32, + "scroll_height of node {:?}. Expected {}. Actual {}", + node8, + 0f32, + layout.scroll_height() + ); + #[cfg_attr(not(feature = "content_size"), allow(unused_variables))] + let layout @ Layout { size, location, .. } = taffy.layout(node9).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node9, 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node9, 20f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node9, 0f32, location.x); + assert_eq!(location.y, 180f32, "y of node {:?}. Expected {}. Actual {}", node9, 180f32, location.y); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_width(), + 0f32, + "scroll_width of node {:?}. Expected {}. Actual {}", + node9, + 0f32, + layout.scroll_width() + ); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_height(), + 0f32, + "scroll_height of node {:?}. Expected {}. Actual {}", + node9, + 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, 40f32, "width of node {:?}. Expected {}. Actual {}", node10, 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node10, 20f32, size.height); + assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node10, 40f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, 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, 40f32, "width of node {:?}. Expected {}. Actual {}", node11, 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node11, 20f32, size.height); + assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node11, 40f32, 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() + ); + #[cfg_attr(not(feature = "content_size"), allow(unused_variables))] + let layout @ Layout { size, location, .. } = taffy.layout(node12).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node12, 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node12, 20f32, size.height); + assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node12, 40f32, location.x); + assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node12, 40f32, location.y); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_width(), + 0f32, + "scroll_width of node {:?}. Expected {}. Actual {}", + node12, + 0f32, + layout.scroll_width() + ); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_height(), + 0f32, + "scroll_height of node {:?}. Expected {}. Actual {}", + node12, + 0f32, + layout.scroll_height() + ); + #[cfg_attr(not(feature = "content_size"), allow(unused_variables))] + let layout @ Layout { size, location, .. } = taffy.layout(node13).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node13, 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node13, 20f32, size.height); + assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node13, 40f32, location.x); + assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node13, 60f32, location.y); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_width(), + 0f32, + "scroll_width of node {:?}. Expected {}. Actual {}", + node13, + 0f32, + layout.scroll_width() + ); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_height(), + 0f32, + "scroll_height of node {:?}. Expected {}. Actual {}", + node13, + 0f32, + layout.scroll_height() + ); + #[cfg_attr(not(feature = "content_size"), allow(unused_variables))] + let layout @ Layout { size, location, .. } = taffy.layout(node14).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node14, 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node14, 20f32, size.height); + assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node14, 40f32, location.x); + assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node14, 80f32, location.y); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_width(), + 0f32, + "scroll_width of node {:?}. Expected {}. Actual {}", + node14, + 0f32, + layout.scroll_width() + ); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_height(), + 0f32, + "scroll_height of node {:?}. Expected {}. Actual {}", + node14, + 0f32, + layout.scroll_height() + ); + #[cfg_attr(not(feature = "content_size"), allow(unused_variables))] + let layout @ Layout { size, location, .. } = taffy.layout(node15).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node15, 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node15, 20f32, size.height); + assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node15, 40f32, location.x); + assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node15, 100f32, location.y); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_width(), + 0f32, + "scroll_width of node {:?}. Expected {}. Actual {}", + node15, + 0f32, + layout.scroll_width() + ); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_height(), + 0f32, + "scroll_height of node {:?}. Expected {}. Actual {}", + node15, + 0f32, + layout.scroll_height() + ); + #[cfg_attr(not(feature = "content_size"), allow(unused_variables))] + let layout @ Layout { size, location, .. } = taffy.layout(node16).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node16, 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node16, 20f32, size.height); + assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node16, 40f32, location.x); + assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node16, 120f32, location.y); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_width(), + 0f32, + "scroll_width of node {:?}. Expected {}. Actual {}", + node16, + 0f32, + layout.scroll_width() + ); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_height(), + 0f32, + "scroll_height of node {:?}. Expected {}. Actual {}", + node16, + 0f32, + layout.scroll_height() + ); + #[cfg_attr(not(feature = "content_size"), allow(unused_variables))] + let layout @ Layout { size, location, .. } = taffy.layout(node17).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node17, 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node17, 20f32, size.height); + assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node17, 40f32, location.x); + assert_eq!(location.y, 140f32, "y of node {:?}. Expected {}. Actual {}", node17, 140f32, location.y); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_width(), + 0f32, + "scroll_width of node {:?}. Expected {}. Actual {}", + node17, + 0f32, + layout.scroll_width() + ); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_height(), + 0f32, + "scroll_height of node {:?}. Expected {}. Actual {}", + node17, + 0f32, + layout.scroll_height() + ); + #[cfg_attr(not(feature = "content_size"), allow(unused_variables))] + let layout @ Layout { size, location, .. } = taffy.layout(node18).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node18, 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node18, 20f32, size.height); + assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node18, 40f32, location.x); + assert_eq!(location.y, 160f32, "y of node {:?}. Expected {}. Actual {}", node18, 160f32, location.y); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_width(), + 0f32, + "scroll_width of node {:?}. Expected {}. Actual {}", + node18, + 0f32, + layout.scroll_width() + ); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_height(), + 0f32, + "scroll_height of node {:?}. Expected {}. Actual {}", + node18, + 0f32, + layout.scroll_height() + ); + #[cfg_attr(not(feature = "content_size"), allow(unused_variables))] + let layout @ Layout { size, location, .. } = taffy.layout(node19).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node19, 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node19, 20f32, size.height); + assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node19, 40f32, location.x); + assert_eq!(location.y, 180f32, "y of node {:?}. Expected {}. Actual {}", node19, 180f32, location.y); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_width(), + 0f32, + "scroll_width of node {:?}. Expected {}. Actual {}", + node19, + 0f32, + layout.scroll_width() + ); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_height(), + 0f32, + "scroll_height of node {:?}. Expected {}. Actual {}", + node19, + 0f32, + layout.scroll_height() + ); +} + +#[test] +#[allow(non_snake_case)] +fn multiline_column_max_height__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, tree::Layout, TaffyTree}; + let mut taffy: TaffyTree = TaffyTree::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node9 = taffy + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node10 = taffy + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node11 = taffy + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node12 = taffy + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node13 = taffy + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node14 = taffy + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node15 = taffy + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node16 = taffy + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node17 = taffy + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node18 = taffy + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node19 = taffy + .new_leaf(taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Length(40f32), + height: taffy::style::Dimension::Length(20f32), + }, + ..Default::default() + }) + .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, + flex_wrap: taffy::style::FlexWrap::Wrap, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(200f32) }, + ..Default::default() + }, + &[ + node0, node1, node2, node3, node4, node5, node6, node7, node8, node9, node10, node11, node12, node13, + node14, node15, node16, node17, node18, node19, + ], + ) + .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, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, 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(), + 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, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, 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(node1).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x); + assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, 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(node2).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); + assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, 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(node3).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x); + assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node3, 60f32, 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(node4).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x); + assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node4, 80f32, location.y); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_width(), + 0f32, + "scroll_width of node {:?}. Expected {}. Actual {}", + node4, + 0f32, + layout.scroll_width() + ); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_height(), + 0f32, + "scroll_height of node {:?}. Expected {}. Actual {}", + node4, + 0f32, + layout.scroll_height() + ); + #[cfg_attr(not(feature = "content_size"), allow(unused_variables))] + let layout @ Layout { size, location, .. } = taffy.layout(node5).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node5, 20f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x); + assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node5, 100f32, location.y); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_width(), + 0f32, + "scroll_width of node {:?}. Expected {}. Actual {}", + node5, + 0f32, + layout.scroll_width() + ); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_height(), + 0f32, + "scroll_height of node {:?}. Expected {}. Actual {}", + node5, + 0f32, + layout.scroll_height() + ); + #[cfg_attr(not(feature = "content_size"), allow(unused_variables))] + let layout @ Layout { size, location, .. } = taffy.layout(node6).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node6, 20f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x); + assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node6, 120f32, location.y); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_width(), + 0f32, + "scroll_width of node {:?}. Expected {}. Actual {}", + node6, + 0f32, + layout.scroll_width() + ); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_height(), + 0f32, + "scroll_height of node {:?}. Expected {}. Actual {}", + node6, + 0f32, + layout.scroll_height() + ); + #[cfg_attr(not(feature = "content_size"), allow(unused_variables))] + let layout @ Layout { size, location, .. } = taffy.layout(node7).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node7, 20f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node7, 0f32, location.x); + assert_eq!(location.y, 140f32, "y of node {:?}. Expected {}. Actual {}", node7, 140f32, location.y); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_width(), + 0f32, + "scroll_width of node {:?}. Expected {}. Actual {}", + node7, + 0f32, + layout.scroll_width() + ); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_height(), + 0f32, + "scroll_height of node {:?}. Expected {}. Actual {}", + node7, + 0f32, + layout.scroll_height() + ); + #[cfg_attr(not(feature = "content_size"), allow(unused_variables))] + let layout @ Layout { size, location, .. } = taffy.layout(node8).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node8, 20f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node8, 0f32, location.x); + assert_eq!(location.y, 160f32, "y of node {:?}. Expected {}. Actual {}", node8, 160f32, location.y); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_width(), + 0f32, + "scroll_width of node {:?}. Expected {}. Actual {}", + node8, + 0f32, + layout.scroll_width() + ); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_height(), + 0f32, + "scroll_height of node {:?}. Expected {}. Actual {}", + node8, + 0f32, + layout.scroll_height() + ); + #[cfg_attr(not(feature = "content_size"), allow(unused_variables))] + let layout @ Layout { size, location, .. } = taffy.layout(node9).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node9, 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node9, 20f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node9, 0f32, location.x); + assert_eq!(location.y, 180f32, "y of node {:?}. Expected {}. Actual {}", node9, 180f32, location.y); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_width(), + 0f32, + "scroll_width of node {:?}. Expected {}. Actual {}", + node9, + 0f32, + layout.scroll_width() + ); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_height(), + 0f32, + "scroll_height of node {:?}. Expected {}. Actual {}", + node9, + 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, 40f32, "width of node {:?}. Expected {}. Actual {}", node10, 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node10, 20f32, size.height); + assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node10, 40f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, 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, 40f32, "width of node {:?}. Expected {}. Actual {}", node11, 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node11, 20f32, size.height); + assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node11, 40f32, 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() + ); + #[cfg_attr(not(feature = "content_size"), allow(unused_variables))] + let layout @ Layout { size, location, .. } = taffy.layout(node12).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node12, 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node12, 20f32, size.height); + assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node12, 40f32, location.x); + assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node12, 40f32, location.y); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_width(), + 0f32, + "scroll_width of node {:?}. Expected {}. Actual {}", + node12, + 0f32, + layout.scroll_width() + ); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_height(), + 0f32, + "scroll_height of node {:?}. Expected {}. Actual {}", + node12, + 0f32, + layout.scroll_height() + ); + #[cfg_attr(not(feature = "content_size"), allow(unused_variables))] + let layout @ Layout { size, location, .. } = taffy.layout(node13).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node13, 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node13, 20f32, size.height); + assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node13, 40f32, location.x); + assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node13, 60f32, location.y); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_width(), + 0f32, + "scroll_width of node {:?}. Expected {}. Actual {}", + node13, + 0f32, + layout.scroll_width() + ); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_height(), + 0f32, + "scroll_height of node {:?}. Expected {}. Actual {}", + node13, + 0f32, + layout.scroll_height() + ); + #[cfg_attr(not(feature = "content_size"), allow(unused_variables))] + let layout @ Layout { size, location, .. } = taffy.layout(node14).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node14, 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node14, 20f32, size.height); + assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node14, 40f32, location.x); + assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node14, 80f32, location.y); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_width(), + 0f32, + "scroll_width of node {:?}. Expected {}. Actual {}", + node14, + 0f32, + layout.scroll_width() + ); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_height(), + 0f32, + "scroll_height of node {:?}. Expected {}. Actual {}", + node14, + 0f32, + layout.scroll_height() + ); + #[cfg_attr(not(feature = "content_size"), allow(unused_variables))] + let layout @ Layout { size, location, .. } = taffy.layout(node15).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node15, 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node15, 20f32, size.height); + assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node15, 40f32, location.x); + assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node15, 100f32, location.y); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_width(), + 0f32, + "scroll_width of node {:?}. Expected {}. Actual {}", + node15, + 0f32, + layout.scroll_width() + ); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_height(), + 0f32, + "scroll_height of node {:?}. Expected {}. Actual {}", + node15, + 0f32, + layout.scroll_height() + ); + #[cfg_attr(not(feature = "content_size"), allow(unused_variables))] + let layout @ Layout { size, location, .. } = taffy.layout(node16).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node16, 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node16, 20f32, size.height); + assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node16, 40f32, location.x); + assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node16, 120f32, location.y); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_width(), + 0f32, + "scroll_width of node {:?}. Expected {}. Actual {}", + node16, + 0f32, + layout.scroll_width() + ); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_height(), + 0f32, + "scroll_height of node {:?}. Expected {}. Actual {}", + node16, + 0f32, + layout.scroll_height() + ); + #[cfg_attr(not(feature = "content_size"), allow(unused_variables))] + let layout @ Layout { size, location, .. } = taffy.layout(node17).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node17, 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node17, 20f32, size.height); + assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node17, 40f32, location.x); + assert_eq!(location.y, 140f32, "y of node {:?}. Expected {}. Actual {}", node17, 140f32, location.y); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_width(), + 0f32, + "scroll_width of node {:?}. Expected {}. Actual {}", + node17, + 0f32, + layout.scroll_width() + ); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_height(), + 0f32, + "scroll_height of node {:?}. Expected {}. Actual {}", + node17, + 0f32, + layout.scroll_height() + ); + #[cfg_attr(not(feature = "content_size"), allow(unused_variables))] + let layout @ Layout { size, location, .. } = taffy.layout(node18).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node18, 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node18, 20f32, size.height); + assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node18, 40f32, location.x); + assert_eq!(location.y, 160f32, "y of node {:?}. Expected {}. Actual {}", node18, 160f32, location.y); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_width(), + 0f32, + "scroll_width of node {:?}. Expected {}. Actual {}", + node18, + 0f32, + layout.scroll_width() + ); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_height(), + 0f32, + "scroll_height of node {:?}. Expected {}. Actual {}", + node18, + 0f32, + layout.scroll_height() + ); + #[cfg_attr(not(feature = "content_size"), allow(unused_variables))] + let layout @ Layout { size, location, .. } = taffy.layout(node19).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node19, 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node19, 20f32, size.height); + assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node19, 40f32, location.x); + assert_eq!(location.y, 180f32, "y of node {:?}. Expected {}. Actual {}", node19, 180f32, location.y); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_width(), + 0f32, + "scroll_width of node {:?}. Expected {}. Actual {}", + node19, + 0f32, + layout.scroll_width() + ); + #[cfg(feature = "content_size")] + assert_eq!( + layout.scroll_height(), + 0f32, + "scroll_height of node {:?}. Expected {}. Actual {}", + node19, + 0f32, + layout.scroll_height() + ); +}