Replace per-node measure functions with a single measure function + per-node context (#490)
1#[test]
2fn grid_overflow_inline_axis_hidden() {
3 #[allow(unused_imports)]
4 use taffy::{prelude::*, tree::Layout, Taffy};
5 let mut taffy: Taffy<crate::TextMeasure> = Taffy::new();
6 let node0 = taffy
7 .new_leaf_with_context(
8 taffy::style::Style {
9 overflow: taffy::geometry::Point {
10 x: taffy::style::Overflow::Hidden,
11 y: taffy::style::Overflow::Hidden,
12 },
13 scrollbar_width: 15f32,
14 ..Default::default()
15 },
16 crate::TextMeasure {
17 text_content: "HHHHHHHHHH",
18 writing_mode: crate::WritingMode::Horizontal,
19 _aspect_ratio: None,
20 },
21 )
22 .unwrap();
23 let node = taffy
24 .new_with_children(
25 taffy::style::Style {
26 display: taffy::style::Display::Grid,
27 size: taffy::geometry::Size {
28 width: taffy::style::Dimension::Length(50f32),
29 height: taffy::style::Dimension::Length(50f32),
30 },
31 ..Default::default()
32 },
33 &[node0],
34 )
35 .unwrap();
36 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
37 println!("\nComputed tree:");
38 taffy.print_tree(node);
39 println!();
40 let Layout { size, location, .. } = taffy.layout(node).unwrap();
41 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width);
42 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height);
43 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
44 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
45 let Layout { size, location, .. } = taffy.layout(node0).unwrap();
46 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
47 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height);
48 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
49 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
50}