diff --git a/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_aspect_ratio.html b/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_aspect_ratio.html new file mode 100644 index 000000000..bc038f016 --- /dev/null +++ b/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_aspect_ratio.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_border_bottom.html b/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_border_bottom.html new file mode 100644 index 000000000..5c4fb18b9 --- /dev/null +++ b/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_border_bottom.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_border_top.html b/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_border_top.html new file mode 100644 index 000000000..197d45b78 --- /dev/null +++ b/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_border_top.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_height.html b/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_height.html new file mode 100644 index 000000000..02384ceab --- /dev/null +++ b/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_height.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_line_box.html b/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_line_box.html new file mode 100644 index 000000000..0535d686d --- /dev/null +++ b/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_line_box.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
HH
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_line_box_with_height_zero.html b/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_line_box_with_height_zero.html new file mode 100644 index 000000000..5e60ec568 --- /dev/null +++ b/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_line_box_with_height_zero.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
HH
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_line_box_with_max_height_zero.html b/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_line_box_with_max_height_zero.html new file mode 100644 index 000000000..6a03e23fc --- /dev/null +++ b/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_line_box_with_max_height_zero.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
HH
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_min_height.html b/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_min_height.html new file mode 100644 index 000000000..40468b0e3 --- /dev/null +++ b/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_min_height.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_overflow_x_hidden.html b/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_overflow_x_hidden.html new file mode 100644 index 000000000..1afb344c3 --- /dev/null +++ b/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_overflow_x_hidden.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_overflow_x_scroll.html b/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_overflow_x_scroll.html new file mode 100644 index 000000000..ba33be8ee --- /dev/null +++ b/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_overflow_x_scroll.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_overflow_y_hidden.html b/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_overflow_y_hidden.html new file mode 100644 index 000000000..2e4db0e96 --- /dev/null +++ b/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_overflow_y_hidden.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_overflow_y_scroll.html b/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_overflow_y_scroll.html new file mode 100644 index 000000000..90971ecb2 --- /dev/null +++ b/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_overflow_y_scroll.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_padding_bottom.html b/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_padding_bottom.html new file mode 100644 index 000000000..062ba6b43 --- /dev/null +++ b/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_padding_bottom.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_padding_top.html b/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_padding_top.html new file mode 100644 index 000000000..84fb76b7e --- /dev/null +++ b/test_fixtures/block_margin_y_fixed_size_collapse_through_blocked_by_padding_top.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/block_margin_y_fixed_size_collapse_through_with_absolute_child.html b/test_fixtures/block_margin_y_fixed_size_collapse_through_with_absolute_child.html new file mode 100644 index 000000000..061b707f9 --- /dev/null +++ b/test_fixtures/block_margin_y_fixed_size_collapse_through_with_absolute_child.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
HH
+
+
+ + + \ No newline at end of file diff --git a/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_aspect_ratio.rs b/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_aspect_ratio.rs new file mode 100644 index 000000000..18aa8fb7c --- /dev/null +++ b/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_aspect_ratio.rs @@ -0,0 +1,79 @@ +#[test] +fn block_margin_y_fixed_size_collapse_through_blocked_by_aspect_ratio() { + #[allow(unused_imports)] + use taffy::{prelude::*, tree::Layout}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + aspect_ratio: Some(2f32), + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::util::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); + assert_eq!(size.height, 65f32, "height of node {:?}. Expected {}. Actual {}", node, 65f32, 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 { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); + assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1, 25f32, 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); + let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); + assert_eq!(location.y, 55f32, "y of node {:?}. Expected {}. Actual {}", node2, 55f32, location.y); +} diff --git a/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_border_bottom.rs b/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_border_bottom.rs new file mode 100644 index 000000000..b53ef8564 --- /dev/null +++ b/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_border_bottom.rs @@ -0,0 +1,78 @@ +#[test] +fn block_margin_y_fixed_size_collapse_through_blocked_by_border_bottom() { + #[allow(unused_imports)] + use taffy::{prelude::*, tree::Layout}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::util::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); + assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, 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 { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); + assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, 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); + let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); + assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); +} diff --git a/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_border_top.rs b/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_border_top.rs new file mode 100644 index 000000000..6addec372 --- /dev/null +++ b/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_border_top.rs @@ -0,0 +1,78 @@ +#[test] +fn block_margin_y_fixed_size_collapse_through_blocked_by_border_top() { + #[allow(unused_imports)] + use taffy::{prelude::*, tree::Layout}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::util::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); + assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, 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 { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); + assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, 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); + let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); + assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); +} diff --git a/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_height.rs b/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_height.rs new file mode 100644 index 000000000..dd4efcad2 --- /dev/null +++ b/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_height.rs @@ -0,0 +1,79 @@ +#[test] +fn block_margin_y_fixed_size_collapse_through_blocked_by_height() { + #[allow(unused_imports)] + use taffy::{prelude::*, tree::Layout}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(1f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::util::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); + assert_eq!(size.height, 41f32, "height of node {:?}. Expected {}. Actual {}", node, 41f32, 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 { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); + assert_eq!(size.height, 1f32, "height of node {:?}. Expected {}. Actual {}", node1, 1f32, 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); + let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); + assert_eq!(location.y, 31f32, "y of node {:?}. Expected {}. Actual {}", node2, 31f32, location.y); +} diff --git a/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_line_box.rs b/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_line_box.rs new file mode 100644 index 000000000..433883804 --- /dev/null +++ b/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_line_box.rs @@ -0,0 +1,90 @@ +#[test] +fn block_margin_y_fixed_size_collapse_through_blocked_by_line_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, tree::Layout}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf_with_measure( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH"; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) + }), + ) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::util::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); + assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, 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 { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, 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); + let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, 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); +} diff --git a/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_line_box_with_height_zero.rs b/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_line_box_with_height_zero.rs new file mode 100644 index 000000000..4963d8a81 --- /dev/null +++ b/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_line_box_with_height_zero.rs @@ -0,0 +1,91 @@ +#[test] +fn block_margin_y_fixed_size_collapse_through_blocked_by_line_box_with_height_zero() { + #[allow(unused_imports)] + use taffy::{prelude::*, tree::Layout}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf_with_measure( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(0f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH"; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) + }), + ) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::util::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, 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 { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); + assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, 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); + let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); + assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node2, 30f32, location.y); +} diff --git a/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_line_box_with_max_height_zero.rs b/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_line_box_with_max_height_zero.rs new file mode 100644 index 000000000..81fb8aae1 --- /dev/null +++ b/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_line_box_with_max_height_zero.rs @@ -0,0 +1,91 @@ +#[test] +fn block_margin_y_fixed_size_collapse_through_blocked_by_line_box_with_max_height_zero() { + #[allow(unused_imports)] + use taffy::{prelude::*, tree::Layout}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf_with_measure( + taffy::style::Style { + display: taffy::style::Display::Block, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(0f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH"; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) + }), + ) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::util::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, 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 { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); + assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, 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); + let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); + assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node2, 30f32, location.y); +} diff --git a/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_min_height.rs b/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_min_height.rs new file mode 100644 index 000000000..d4a66b30a --- /dev/null +++ b/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_min_height.rs @@ -0,0 +1,79 @@ +#[test] +fn block_margin_y_fixed_size_collapse_through_blocked_by_min_height() { + #[allow(unused_imports)] + use taffy::{prelude::*, tree::Layout}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(1f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::util::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); + assert_eq!(size.height, 41f32, "height of node {:?}. Expected {}. Actual {}", node, 41f32, 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 { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); + assert_eq!(size.height, 1f32, "height of node {:?}. Expected {}. Actual {}", node1, 1f32, 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); + let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); + assert_eq!(location.y, 31f32, "y of node {:?}. Expected {}. Actual {}", node2, 31f32, location.y); +} diff --git a/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_overflow_x_hidden.rs b/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_overflow_x_hidden.rs new file mode 100644 index 000000000..1b4b52f19 --- /dev/null +++ b/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_overflow_x_hidden.rs @@ -0,0 +1,80 @@ +#[test] +fn block_margin_y_fixed_size_collapse_through_blocked_by_overflow_x_hidden() { + #[allow(unused_imports)] + use taffy::{prelude::*, tree::Layout}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Hidden, y: taffy::style::Overflow::Visible }, + scrollbar_width: 15f32, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::util::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, 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 { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); + assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, 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); + let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); + assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node2, 30f32, location.y); +} diff --git a/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_overflow_x_scroll.rs b/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_overflow_x_scroll.rs new file mode 100644 index 000000000..04f7feff7 --- /dev/null +++ b/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_overflow_x_scroll.rs @@ -0,0 +1,80 @@ +#[test] +fn block_margin_y_fixed_size_collapse_through_blocked_by_overflow_x_scroll() { + #[allow(unused_imports)] + use taffy::{prelude::*, tree::Layout}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Scroll, y: taffy::style::Overflow::Visible }, + scrollbar_width: 15f32, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::util::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); + assert_eq!(size.height, 55f32, "height of node {:?}. Expected {}. Actual {}", node, 55f32, 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 { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); + assert_eq!(size.height, 15f32, "height of node {:?}. Expected {}. Actual {}", node1, 15f32, 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); + let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); + assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node2, 45f32, location.y); +} diff --git a/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_overflow_y_hidden.rs b/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_overflow_y_hidden.rs new file mode 100644 index 000000000..cd531877d --- /dev/null +++ b/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_overflow_y_hidden.rs @@ -0,0 +1,80 @@ +#[test] +fn block_margin_y_fixed_size_collapse_through_blocked_by_overflow_y_hidden() { + #[allow(unused_imports)] + use taffy::{prelude::*, tree::Layout}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Hidden }, + scrollbar_width: 15f32, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::util::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, 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 { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); + assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, 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); + let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); + assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node2, 30f32, location.y); +} diff --git a/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_overflow_y_scroll.rs b/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_overflow_y_scroll.rs new file mode 100644 index 000000000..2c829a7ac --- /dev/null +++ b/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_overflow_y_scroll.rs @@ -0,0 +1,80 @@ +#[test] +fn block_margin_y_fixed_size_collapse_through_blocked_by_overflow_y_scroll() { + #[allow(unused_imports)] + use taffy::{prelude::*, tree::Layout}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + overflow: taffy::geometry::Point { x: taffy::style::Overflow::Visible, y: taffy::style::Overflow::Scroll }, + scrollbar_width: 15f32, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::util::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, 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 { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); + assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, 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); + let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); + assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node2, 30f32, location.y); +} diff --git a/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_padding_bottom.rs b/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_padding_bottom.rs new file mode 100644 index 000000000..b028b8129 --- /dev/null +++ b/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_padding_bottom.rs @@ -0,0 +1,84 @@ +#[test] +fn block_margin_y_fixed_size_collapse_through_blocked_by_padding_bottom() { + #[allow(unused_imports)] + use taffy::{prelude::*, tree::Layout}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + padding: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentage::Length(1f32), + }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::util::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); + assert_eq!(size.height, 41f32, "height of node {:?}. Expected {}. Actual {}", node, 41f32, 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 { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); + assert_eq!(size.height, 1f32, "height of node {:?}. Expected {}. Actual {}", node1, 1f32, 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); + let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); + assert_eq!(location.y, 31f32, "y of node {:?}. Expected {}. Actual {}", node2, 31f32, location.y); +} diff --git a/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_padding_top.rs b/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_padding_top.rs new file mode 100644 index 000000000..8487d1bfe --- /dev/null +++ b/tests/generated/block_margin_y_fixed_size_collapse_through_blocked_by_padding_top.rs @@ -0,0 +1,84 @@ +#[test] +fn block_margin_y_fixed_size_collapse_through_blocked_by_padding_top() { + #[allow(unused_imports)] + use taffy::{prelude::*, tree::Layout}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + padding: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentage::Length(1f32), + bottom: zero(), + }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::util::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); + assert_eq!(size.height, 41f32, "height of node {:?}. Expected {}. Actual {}", node, 41f32, 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 { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); + assert_eq!(size.height, 1f32, "height of node {:?}. Expected {}. Actual {}", node1, 1f32, 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); + let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); + assert_eq!(location.y, 31f32, "y of node {:?}. Expected {}. Actual {}", node2, 31f32, location.y); +} diff --git a/tests/generated/block_margin_y_fixed_size_collapse_through_with_absolute_child.rs b/tests/generated/block_margin_y_fixed_size_collapse_through_with_absolute_child.rs new file mode 100644 index 000000000..db83f3043 --- /dev/null +++ b/tests/generated/block_margin_y_fixed_size_collapse_through_with_absolute_child.rs @@ -0,0 +1,101 @@ +#[test] +fn block_margin_y_fixed_size_collapse_through_with_absolute_child() { + #[allow(unused_imports)] + use taffy::{prelude::*, tree::Layout}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node10 = taffy + .new_leaf_with_measure( + taffy::style::Style { position: taffy::style::Position::Absolute, ..Default::default() }, + taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH"; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) + }), + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: taffy::style::LengthPercentageAuto::Length(10f32), + }, + ..Default::default() + }, + &[node10], + ) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Length(10f32), + bottom: zero(), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::util::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width); + assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node, 30f32, 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 { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width); + assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, 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); + let Layout { size, location, .. } = taffy.layout(node10).unwrap(); + assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node10, 20f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x); + assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y); +} diff --git a/tests/generated/mod.rs b/tests/generated/mod.rs index e9c63c006..bcb64bd41 100644 --- a/tests/generated/mod.rs +++ b/tests/generated/mod.rs @@ -310,9 +310,24 @@ mod block_margin_x_percentage_intrinsic_size_other_negative; mod block_margin_x_percentage_intrinsic_size_other_positive; mod block_margin_x_percentage_intrinsic_size_self_negative; mod block_margin_x_percentage_intrinsic_size_self_positive; +mod block_margin_y_fixed_size_collapse_through_blocked_by_aspect_ratio; +mod block_margin_y_fixed_size_collapse_through_blocked_by_border_bottom; +mod block_margin_y_fixed_size_collapse_through_blocked_by_border_top; +mod block_margin_y_fixed_size_collapse_through_blocked_by_height; +mod block_margin_y_fixed_size_collapse_through_blocked_by_line_box; +mod block_margin_y_fixed_size_collapse_through_blocked_by_line_box_with_height_zero; +mod block_margin_y_fixed_size_collapse_through_blocked_by_line_box_with_max_height_zero; +mod block_margin_y_fixed_size_collapse_through_blocked_by_min_height; +mod block_margin_y_fixed_size_collapse_through_blocked_by_overflow_x_hidden; +mod block_margin_y_fixed_size_collapse_through_blocked_by_overflow_x_scroll; +mod block_margin_y_fixed_size_collapse_through_blocked_by_overflow_y_hidden; +mod block_margin_y_fixed_size_collapse_through_blocked_by_overflow_y_scroll; +mod block_margin_y_fixed_size_collapse_through_blocked_by_padding_bottom; +mod block_margin_y_fixed_size_collapse_through_blocked_by_padding_top; mod block_margin_y_fixed_size_collapse_through_negative; mod block_margin_y_fixed_size_collapse_through_positive; mod block_margin_y_fixed_size_collapse_through_positive_and_negative; +mod block_margin_y_fixed_size_collapse_through_with_absolute_child; mod block_margin_y_fixed_size_first_child_collapse_negative_equal; mod block_margin_y_fixed_size_first_child_collapse_negative_parent_larger; mod block_margin_y_fixed_size_first_child_collapse_negative_parent_smaller;