⎇ ebd376fbebd0ba73c79aa00d1835918680ef82a0
benches/generated/grid_min_content_flex_single_item_margin_fixed.rs
Ñawpa willay
Pi imata llamkarqan
ch'uya
Fixes for aspect ratio and min/max sizes (#317)
1pub fn compute() {
2 #[allow(unused_imports)]
3 use taffy::prelude::*;
4 let mut taffy = taffy::Taffy::new();
5 let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
6 let node1 = taffy
7 .new_leaf(taffy::style::Style {
8 min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() },
9 margin: taffy::geometry::Rect {
10 left: taffy::style::LengthPercentageAuto::Points(20f32),
11 right: taffy::style::LengthPercentageAuto::Points(10f32),
12 top: taffy::style::LengthPercentageAuto::Points(5f32),
13 bottom: taffy::style::LengthPercentageAuto::Points(15f32),
14 },
15 ..Default::default()
16 })
17 .unwrap();
18 let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
19 let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
20 let node4 = taffy
21 .new_leaf_with_measure(
22 taffy::style::Style {
23 grid_column: taffy::geometry::Line {
24 start: taffy::style::GridPlacement::Span(2u16),
25 end: taffy::style::GridPlacement::Auto,
26 },
27 margin: taffy::geometry::Rect {
28 left: taffy::style::LengthPercentageAuto::Points(20f32),
29 right: taffy::style::LengthPercentageAuto::Points(10f32),
30 top: taffy::style::LengthPercentageAuto::Points(5f32),
31 bottom: taffy::style::LengthPercentageAuto::Points(15f32),
32 },
33 ..Default::default()
34 },
35 taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| {
36 const TEXT: &str = "HH\u{200b}HH";
37 super::measure_standard_text(
38 known_dimensions,
39 available_space,
40 TEXT,
41 super::WritingMode::Horizontal,
42 None,
43 )
44 }),
45 )
46 .unwrap();
47 let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
48 let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
49 let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
50 let node = taffy
51 .new_with_children(
52 taffy::style::Style {
53 display: taffy::style::Display::Grid,
54 grid_template_rows: vec![points(40f32), points(40f32), points(40f32)],
55 grid_template_columns: vec![points(40f32), min_content(), flex(1f32)],
56 ..Default::default()
57 },
58 &[node0, node1, node2, node3, node4, node5, node6, node7],
59 )
60 .unwrap();
61 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
62}