#[test] #[allow(non_snake_case)] fn blitz_issue_88__border_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf_with_context( taffy::style::Style { display: taffy::style::Display::Block, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(0f32), ..Default::default() }, crate::TestNodeContext::ahem_text( "HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH", crate::WritingMode::Horizontal, ), ) .unwrap(); let node00 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, flex_grow: 1f32, ..Default::default() }, &[node000], ) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, flex_direction: taffy::style::FlexDirection::Column, justify_content: Some(taffy::style::JustifyContent::Start), ..Default::default() }, &[node00], ) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(600f32), height: auto() }, ..Default::default() }, &[node0], ) .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); let layout = taffy.layout(node).unwrap(); let Layout { size, location, .. } = layout; assert_eq!(size.width, 600f32, "width of node {:?}. Expected {}. Actual {}", node, 600f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); let layout = taffy.layout(node0).unwrap(); let Layout { size, location, .. } = layout; assert_eq!(size.width, 600f32, "width of node {:?}. Expected {}. Actual {}", node0, 600f32, 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 = taffy.layout(node00).unwrap(); let Layout { size, location, .. } = layout; assert_eq!(size.width, 600f32, "width of node {:?}. Expected {}. Actual {}", node00, 600f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); let layout = taffy.layout(node000).unwrap(); let Layout { size, location, .. } = layout; assert_eq!(size.width, 600f32, "width of node {:?}. Expected {}. Actual {}", node000, 600f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); } #[test] #[allow(non_snake_case)] fn blitz_issue_88__content_box() { #[allow(unused_imports)] use taffy::{prelude::*, Layout}; let mut taffy = crate::new_test_tree(); let node000 = taffy .new_leaf_with_context( taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, flex_grow: 1f32, flex_basis: taffy::style::Dimension::from_length(0f32), ..Default::default() }, crate::TestNodeContext::ahem_text( "HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH", crate::WritingMode::Horizontal, ), ) .unwrap(); let node00 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_grow: 1f32, ..Default::default() }, &[node000], ) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Flex, box_sizing: taffy::style::BoxSizing::ContentBox, flex_direction: taffy::style::FlexDirection::Column, justify_content: Some(taffy::style::JustifyContent::Start), ..Default::default() }, &[node00], ) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { display: taffy::style::Display::Block, box_sizing: taffy::style::BoxSizing::ContentBox, size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(600f32), height: auto() }, ..Default::default() }, &[node0], ) .unwrap(); taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); println!("\nComputed tree:"); taffy.print_tree(node); println!(); let layout = taffy.layout(node).unwrap(); let Layout { size, location, .. } = layout; assert_eq!(size.width, 600f32, "width of node {:?}. Expected {}. Actual {}", node, 600f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); let layout = taffy.layout(node0).unwrap(); let Layout { size, location, .. } = layout; assert_eq!(size.width, 600f32, "width of node {:?}. Expected {}. Actual {}", node0, 600f32, 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 = taffy.layout(node00).unwrap(); let Layout { size, location, .. } = layout; assert_eq!(size.width, 600f32, "width of node {:?}. Expected {}. Actual {}", node00, 600f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y); let layout = taffy.layout(node000).unwrap(); let Layout { size, location, .. } = layout; assert_eq!(size.width, 600f32, "width of node {:?}. Expected {}. Actual {}", node000, 600f32, size.width); assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node000, 10f32, size.height); assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x); assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y); }