From 610c92f3104d022ec1d8d8ada24f9db412ff4e2c Mon Sep 17 00:00:00 2001 From: Nico Burns Date: Thu, 12 Jan 2023 19:42:17 +0000 Subject: [PATCH] Fixes for aspect ratio and min/max sizes (#317) * Add aspect ratio support to gentest script + add aspect ratio support to text node content sizing * Add maybe_apply_aspect_ratio helper to Size> * Apply aspect ratio to leaf node style resolution * Apply aspect ratio when doing final placement of grid items * Make cargo gentest compile generator in release mode * Add tests for aspect ratio of leaf nodes in grid containers * Apply aspect ratio to grid container styles * Apply aspect ratio to automatic minimum size * Add tests for aspect ratio of content-sized leaf nodes * Use main size for flex-basis if flex-basis is not set * Resolve size, min_size, max_size against aspect ratio when generating flex items * Add gentests for aspect-ratio in flex-row (align-start) * Move aspect ratio handling from text measure func to leaf.rs * Tweak clamping of flex item minimum sizes * Add aspect ratio tests for flex-columns with align-items: start * FLexbox: don't apply aspect ratio to max_width when clamping stretched cross-sizes * Add tests for aspect ratio with align-items:stretch (flexbox) * Apply aspect ratio to absolute children of flex container * Remove duplicate test * Namespace grid aspect ratio tests under grid * Absolute positioning: Apply aspect ratio to inset-generated width before generating height from inset * Add tests for aspect ratio height/width for absolutely positioned nodes * Exclude hidden items from absolute positioning * Apply min/max sizes when finally positioning grid items * Add tests for interaction between inset and aspect ratio for absolutely positioned grid children * Always apply margins to absolutely positioned grid items * Rewrite flex item absolute positioning It now: - Applies margins correctly - Applies min/max correctly - Applies aspect ratio correctly * Take border into account when absolutely positioning grid items relative to the grid container * Add absolute positioning margin test * Apply suggestions from code review Co-authored-by: Andreas Weibye <13300393+Weibye@users.noreply.github.com> * Update release notes * Add test for absolutely positioned fallback to static position of grid item in container with border * Implement Add for Rect where the inner type implements Add * Apply aspect ratio and min/max size to flex container size * Cleanup TODOs in the flexbox algorithm * Remove one more TODO * Add min/max size tests for absolutely positioned flex items * Move absolute flex positioning aspect ratio tests under absolute namespace * Clamp available_space by min/max size for final layout * Add tests for applying aspect ratio to min/max size of flex items Co-authored-by: Andreas Weibye <13300393+Weibye@users.noreply.github.com> --- .cargo/config.toml | 2 +- RELEASES.md | 3 + ...ct_ratio_overrides_height_of_full_inset.rs | 32 ++ .../absolute_aspect_ratio_fill_height.rs | 33 ++ ...ute_aspect_ratio_fill_height_from_inset.rs | 32 ++ .../absolute_aspect_ratio_fill_max_height.rs | 20 + .../absolute_aspect_ratio_fill_max_width.rs | 20 + .../absolute_aspect_ratio_fill_min_height.rs | 27 ++ .../absolute_aspect_ratio_fill_min_width.rs | 27 ++ .../absolute_aspect_ratio_fill_width.rs | 33 ++ ...lute_aspect_ratio_fill_width_from_inset.rs | 32 ++ ...ute_aspect_ratio_height_overrides_inset.rs | 33 ++ ...lute_aspect_ratio_width_overrides_inset.rs | 33 ++ .../generated/absolute_margin_bottom_left.rs | 36 ++ .../absolute_minmax_bottom_right_max.rs | 38 ++ .../absolute_minmax_bottom_right_min_max.rs | 38 ++ ...e_minmax_bottom_right_min_max_preferred.rs | 42 ++ ...solute_minmax_top_left_bottom_right_max.rs | 34 ++ ...te_minmax_top_left_bottom_right_min_max.rs | 38 ++ .../aspect_ratio_flex_column_fill_height.rs | 28 ++ ...spect_ratio_flex_column_fill_max_height.rs | 22 + ...aspect_ratio_flex_column_fill_max_width.rs | 40 ++ ...spect_ratio_flex_column_fill_min_height.rs | 28 ++ ...aspect_ratio_flex_column_fill_min_width.rs | 40 ++ .../aspect_ratio_flex_column_fill_width.rs | 28 ++ ...spect_ratio_flex_column_fill_width_flex.rs | 27 ++ ...t_ratio_flex_column_stretch_fill_height.rs | 27 ++ ...tio_flex_column_stretch_fill_max_height.rs | 21 + ...atio_flex_column_stretch_fill_max_width.rs | 39 ++ ...ct_ratio_flex_column_stretch_fill_width.rs | 27 ++ .../aspect_ratio_flex_row_fill_height.rs | 27 ++ .../aspect_ratio_flex_row_fill_max_height.rs | 21 + .../aspect_ratio_flex_row_fill_max_width.rs | 39 ++ .../aspect_ratio_flex_row_fill_min_height.rs | 27 ++ .../aspect_ratio_flex_row_fill_min_width.rs | 39 ++ .../aspect_ratio_flex_row_fill_width.rs | 27 ++ .../aspect_ratio_flex_row_fill_width_flex.rs | 27 ++ ...pect_ratio_flex_row_stretch_fill_height.rs | 26 ++ ..._ratio_flex_row_stretch_fill_max_height.rs | 20 + ...t_ratio_flex_row_stretch_fill_max_width.rs | 38 ++ ...spect_ratio_flex_row_stretch_fill_width.rs | 26 ++ .../generated/display_none_absolute_child.rs | 36 ++ .../display_none_with_position_absolute.rs | 29 ++ .../grid_absolute_layout_within_border.rs | 107 +++++ ...id_absolute_layout_within_border_static.rs | 91 ++++ ...ct_ratio_overrides_height_of_full_inset.rs | 32 ++ ...t_ratio_absolute_fill_height_from_inset.rs | 32 ++ ...ct_ratio_absolute_fill_width_from_inset.rs | 32 ++ ...t_ratio_absolute_height_overrides_inset.rs | 33 ++ ...ct_ratio_absolute_width_overrides_inset.rs | 33 ++ ..._aspect_ratio_child_fill_content_height.rs | 33 ++ ...d_aspect_ratio_child_fill_content_width.rs | 33 ++ .../grid_aspect_ratio_fill_child_height.rs | 26 ++ ...grid_aspect_ratio_fill_child_max_height.rs | 38 ++ .../grid_aspect_ratio_fill_child_max_width.rs | 38 ++ ...grid_aspect_ratio_fill_child_min_height.rs | 26 ++ .../grid_aspect_ratio_fill_child_min_width.rs | 38 ++ .../grid_aspect_ratio_fill_child_width.rs | 26 ++ ...spect_ratio_overriden_by_explicit_sizes.rs | 29 ++ ..._ratio_overriden_by_explicit_sizes_flex.rs | 29 ++ .../grid_fit_content_points_argument.rs | 8 +- .../grid_fit_content_points_max_content.rs | 8 +- .../grid_fit_content_points_min_content.rs | 8 +- ...d_margins_auto_margins_override_stretch.rs | 8 +- .../grid_max_content_maximum_single_item.rs | 8 +- .../generated/grid_max_content_single_item.rs | 8 +- ...rid_max_content_single_item_margin_auto.rs | 8 +- ...id_max_content_single_item_margin_fixed.rs | 8 +- ..._max_content_single_item_margin_percent.rs | 8 +- .../generated/grid_min_content_flex_column.rs | 24 +- .../generated/grid_min_content_flex_row.rs | 24 +- .../grid_min_content_flex_single_item.rs | 8 +- ...in_content_flex_single_item_margin_auto.rs | 8 +- ...n_content_flex_single_item_margin_fixed.rs | 8 +- ...content_flex_single_item_margin_percent.rs | 8 +- .../grid_min_content_maximum_single_item.rs | 8 +- .../generated/grid_min_content_single_item.rs | 8 +- .../generated/grid_relayout_vertical_text.rs | 16 +- .../generated/grid_size_child_fixed_tracks.rs | 40 +- benches/generated/measure_child.rs | 8 +- benches/generated/measure_child_absolute.rs | 8 +- benches/generated/measure_child_constraint.rs | 2 +- ...measure_child_constraint_padding_parent.rs | 2 +- .../generated/measure_child_with_flex_grow.rs | 8 +- .../measure_child_with_flex_shrink.rs | 8 +- .../measure_flex_basis_overrides_measure.rs | 8 +- .../measure_height_overrides_measure.rs | 8 +- .../measure_remeasure_child_after_growing.rs | 8 +- ...measure_remeasure_child_after_shrinking.rs | 8 +- ...easure_remeasure_child_after_stretching.rs | 8 +- benches/generated/measure_root.rs | 8 +- .../measure_stretch_overrides_measure.rs | 8 +- .../measure_width_overrides_measure.rs | 8 +- benches/generated/mod.rs | 151 +++++++ scripts/gentest/src/main.rs | 23 +- scripts/gentest/test_helper.js | 15 + src/compute/flexbox.rs | 398 +++++++++--------- src/compute/grid/alignment.rs | 70 +-- src/compute/grid/mod.rs | 21 +- src/compute/grid/types/grid_item.rs | 12 +- src/compute/leaf.rs | 20 +- src/geometry.rs | 35 ++ ..._ratio_overrides_height_of_full_inset.html | 17 + .../absolute_aspect_ratio_fill_height.html | 17 + ...e_aspect_ratio_fill_height_from_inset.html | 17 + ...absolute_aspect_ratio_fill_max_height.html | 17 + .../absolute_aspect_ratio_fill_max_width.html | 17 + ...absolute_aspect_ratio_fill_min_height.html | 17 + .../absolute_aspect_ratio_fill_min_width.html | 17 + .../absolute_aspect_ratio_fill_width.html | 17 + ...te_aspect_ratio_fill_width_from_inset.html | 17 + ...e_aspect_ratio_height_overrides_inset.html | 17 + ...te_aspect_ratio_width_overrides_inset.html | 17 + .../absolute_margin_bottom_left.html | 17 + .../absolute_minmax_bottom_right_max.html | 17 + .../absolute_minmax_bottom_right_min_max.html | 17 + ...minmax_bottom_right_min_max_preferred.html | 17 + ...lute_minmax_top_left_bottom_right_max.html | 17 + ..._minmax_top_left_bottom_right_min_max.html | 17 + .../aspect_ratio_flex_column_fill_height.html | 17 + ...ect_ratio_flex_column_fill_max_height.html | 17 + ...pect_ratio_flex_column_fill_max_width.html | 17 + ...ect_ratio_flex_column_fill_min_height.html | 17 + ...pect_ratio_flex_column_fill_min_width.html | 19 + .../aspect_ratio_flex_column_fill_width.html | 17 + ...ect_ratio_flex_column_fill_width_flex.html | 17 + ...ratio_flex_column_stretch_fill_height.html | 17 + ...o_flex_column_stretch_fill_max_height.html | 17 + ...io_flex_column_stretch_fill_max_width.html | 17 + ..._ratio_flex_column_stretch_fill_width.html | 17 + .../aspect_ratio_flex_row_fill_height.html | 17 + ...aspect_ratio_flex_row_fill_max_height.html | 17 + .../aspect_ratio_flex_row_fill_max_width.html | 17 + ...aspect_ratio_flex_row_fill_min_height.html | 17 + .../aspect_ratio_flex_row_fill_min_width.html | 19 + .../aspect_ratio_flex_row_fill_width.html | 17 + ...aspect_ratio_flex_row_fill_width_flex.html | 17 + ...ct_ratio_flex_row_stretch_fill_height.html | 17 + ...atio_flex_row_stretch_fill_max_height.html | 17 + ...ratio_flex_row_stretch_fill_max_width.html | 17 + ...ect_ratio_flex_row_stretch_fill_width.html | 17 + .../display_none_absolute_child.html | 18 + .../display_none_with_position_absolute.html | 17 + .../grid_absolute_layout_within_border.html | 20 + ..._absolute_layout_within_border_static.html | 20 + ..._ratio_overrides_height_of_full_inset.html | 17 + ...ratio_absolute_fill_height_from_inset.html | 17 + ..._ratio_absolute_fill_width_from_inset.html | 17 + ...ratio_absolute_height_overrides_inset.html | 17 + ..._ratio_absolute_width_overrides_inset.html | 17 + ...spect_ratio_child_fill_content_height.html | 18 + ...aspect_ratio_child_fill_content_width.html | 18 + .../grid_aspect_ratio_fill_child_height.html | 17 + ...id_aspect_ratio_fill_child_max_height.html | 17 + ...rid_aspect_ratio_fill_child_max_width.html | 17 + ...id_aspect_ratio_fill_child_min_height.html | 17 + ...rid_aspect_ratio_fill_child_min_width.html | 19 + .../grid_aspect_ratio_fill_child_width.html | 17 + ...ect_ratio_overriden_by_explicit_sizes.html | 17 + ...atio_overriden_by_explicit_sizes_flex.html | 17 + ...o_flex_column_stretch_fill_min_height.html | 17 + ...io_flex_column_stretch_fill_min_width.html | 19 + ...atio_flex_row_stretch_fill_min_height.html | 17 + ...ratio_flex_row_stretch_fill_min_width.html | 19 + ...ct_ratio_overrides_height_of_full_inset.rs | 47 +++ .../absolute_aspect_ratio_fill_height.rs | 48 +++ ...ute_aspect_ratio_fill_height_from_inset.rs | 47 +++ .../absolute_aspect_ratio_fill_max_height.rs | 35 ++ .../absolute_aspect_ratio_fill_max_width.rs | 35 ++ .../absolute_aspect_ratio_fill_min_height.rs | 42 ++ .../absolute_aspect_ratio_fill_min_width.rs | 42 ++ .../absolute_aspect_ratio_fill_width.rs | 48 +++ ...lute_aspect_ratio_fill_width_from_inset.rs | 47 +++ ...ute_aspect_ratio_height_overrides_inset.rs | 48 +++ ...lute_aspect_ratio_width_overrides_inset.rs | 48 +++ .../generated/absolute_margin_bottom_left.rs | 51 +++ .../absolute_minmax_bottom_right_max.rs | 53 +++ .../absolute_minmax_bottom_right_min_max.rs | 53 +++ ...e_minmax_bottom_right_min_max_preferred.rs | 57 +++ ...solute_minmax_top_left_bottom_right_max.rs | 49 +++ ...te_minmax_top_left_bottom_right_min_max.rs | 53 +++ .../aspect_ratio_flex_column_fill_height.rs | 43 ++ ...spect_ratio_flex_column_fill_max_height.rs | 37 ++ ...aspect_ratio_flex_column_fill_max_width.rs | 55 +++ ...spect_ratio_flex_column_fill_min_height.rs | 43 ++ ...aspect_ratio_flex_column_fill_min_width.rs | 55 +++ .../aspect_ratio_flex_column_fill_width.rs | 43 ++ ...spect_ratio_flex_column_fill_width_flex.rs | 42 ++ ...t_ratio_flex_column_stretch_fill_height.rs | 42 ++ ...tio_flex_column_stretch_fill_max_height.rs | 36 ++ ...atio_flex_column_stretch_fill_max_width.rs | 54 +++ ...ct_ratio_flex_column_stretch_fill_width.rs | 42 ++ .../aspect_ratio_flex_row_fill_height.rs | 42 ++ .../aspect_ratio_flex_row_fill_max_height.rs | 36 ++ .../aspect_ratio_flex_row_fill_max_width.rs | 54 +++ .../aspect_ratio_flex_row_fill_min_height.rs | 42 ++ .../aspect_ratio_flex_row_fill_min_width.rs | 54 +++ .../aspect_ratio_flex_row_fill_width.rs | 42 ++ .../aspect_ratio_flex_row_fill_width_flex.rs | 42 ++ ...pect_ratio_flex_row_stretch_fill_height.rs | 41 ++ ..._ratio_flex_row_stretch_fill_max_height.rs | 35 ++ ...t_ratio_flex_row_stretch_fill_max_width.rs | 53 +++ ...spect_ratio_flex_row_stretch_fill_width.rs | 41 ++ .../generated/display_none_absolute_child.rs | 56 +++ .../display_none_with_position_absolute.rs | 44 ++ .../grid_absolute_layout_within_border.rs | 137 ++++++ ...id_absolute_layout_within_border_static.rs | 121 ++++++ ...ct_ratio_overrides_height_of_full_inset.rs | 47 +++ ...t_ratio_absolute_fill_height_from_inset.rs | 47 +++ ...ct_ratio_absolute_fill_width_from_inset.rs | 47 +++ ...t_ratio_absolute_height_overrides_inset.rs | 48 +++ ...ct_ratio_absolute_width_overrides_inset.rs | 48 +++ ..._aspect_ratio_child_fill_content_height.rs | 53 +++ ...d_aspect_ratio_child_fill_content_width.rs | 53 +++ .../grid_aspect_ratio_fill_child_height.rs | 41 ++ ...grid_aspect_ratio_fill_child_max_height.rs | 53 +++ .../grid_aspect_ratio_fill_child_max_width.rs | 53 +++ ...grid_aspect_ratio_fill_child_min_height.rs | 41 ++ .../grid_aspect_ratio_fill_child_min_width.rs | 53 +++ .../grid_aspect_ratio_fill_child_width.rs | 41 ++ ...spect_ratio_overriden_by_explicit_sizes.rs | 44 ++ ..._ratio_overriden_by_explicit_sizes_flex.rs | 44 ++ .../grid_fit_content_points_argument.rs | 8 +- .../grid_fit_content_points_max_content.rs | 8 +- .../grid_fit_content_points_min_content.rs | 8 +- ...d_margins_auto_margins_override_stretch.rs | 8 +- .../grid_max_content_maximum_single_item.rs | 8 +- .../generated/grid_max_content_single_item.rs | 8 +- ...rid_max_content_single_item_margin_auto.rs | 8 +- ...id_max_content_single_item_margin_fixed.rs | 8 +- ..._max_content_single_item_margin_percent.rs | 8 +- .../generated/grid_min_content_flex_column.rs | 24 +- tests/generated/grid_min_content_flex_row.rs | 24 +- .../grid_min_content_flex_single_item.rs | 8 +- ...in_content_flex_single_item_margin_auto.rs | 8 +- ...n_content_flex_single_item_margin_fixed.rs | 8 +- ...content_flex_single_item_margin_percent.rs | 8 +- .../grid_min_content_maximum_single_item.rs | 8 +- .../generated/grid_min_content_single_item.rs | 8 +- .../generated/grid_relayout_vertical_text.rs | 16 +- .../generated/grid_size_child_fixed_tracks.rs | 40 +- tests/generated/measure_child.rs | 8 +- tests/generated/measure_child_absolute.rs | 8 +- tests/generated/measure_child_constraint.rs | 2 +- ...measure_child_constraint_padding_parent.rs | 2 +- .../generated/measure_child_with_flex_grow.rs | 8 +- .../measure_child_with_flex_shrink.rs | 8 +- .../measure_flex_basis_overrides_measure.rs | 8 +- .../measure_height_overrides_measure.rs | 8 +- .../measure_remeasure_child_after_growing.rs | 8 +- ...measure_remeasure_child_after_shrinking.rs | 8 +- ...easure_remeasure_child_after_stretching.rs | 8 +- tests/generated/measure_root.rs | 8 +- .../measure_stretch_overrides_measure.rs | 8 +- .../measure_width_overrides_measure.rs | 8 +- tests/generated/mod.rs | 76 ++++ 256 files changed, 7001 insertions(+), 327 deletions(-) create mode 100644 benches/generated/absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset.rs create mode 100644 benches/generated/absolute_aspect_ratio_fill_height.rs create mode 100644 benches/generated/absolute_aspect_ratio_fill_height_from_inset.rs create mode 100644 benches/generated/absolute_aspect_ratio_fill_max_height.rs create mode 100644 benches/generated/absolute_aspect_ratio_fill_max_width.rs create mode 100644 benches/generated/absolute_aspect_ratio_fill_min_height.rs create mode 100644 benches/generated/absolute_aspect_ratio_fill_min_width.rs create mode 100644 benches/generated/absolute_aspect_ratio_fill_width.rs create mode 100644 benches/generated/absolute_aspect_ratio_fill_width_from_inset.rs create mode 100644 benches/generated/absolute_aspect_ratio_height_overrides_inset.rs create mode 100644 benches/generated/absolute_aspect_ratio_width_overrides_inset.rs create mode 100644 benches/generated/absolute_margin_bottom_left.rs create mode 100644 benches/generated/absolute_minmax_bottom_right_max.rs create mode 100644 benches/generated/absolute_minmax_bottom_right_min_max.rs create mode 100644 benches/generated/absolute_minmax_bottom_right_min_max_preferred.rs create mode 100644 benches/generated/absolute_minmax_top_left_bottom_right_max.rs create mode 100644 benches/generated/absolute_minmax_top_left_bottom_right_min_max.rs create mode 100644 benches/generated/aspect_ratio_flex_column_fill_height.rs create mode 100644 benches/generated/aspect_ratio_flex_column_fill_max_height.rs create mode 100644 benches/generated/aspect_ratio_flex_column_fill_max_width.rs create mode 100644 benches/generated/aspect_ratio_flex_column_fill_min_height.rs create mode 100644 benches/generated/aspect_ratio_flex_column_fill_min_width.rs create mode 100644 benches/generated/aspect_ratio_flex_column_fill_width.rs create mode 100644 benches/generated/aspect_ratio_flex_column_fill_width_flex.rs create mode 100644 benches/generated/aspect_ratio_flex_column_stretch_fill_height.rs create mode 100644 benches/generated/aspect_ratio_flex_column_stretch_fill_max_height.rs create mode 100644 benches/generated/aspect_ratio_flex_column_stretch_fill_max_width.rs create mode 100644 benches/generated/aspect_ratio_flex_column_stretch_fill_width.rs create mode 100644 benches/generated/aspect_ratio_flex_row_fill_height.rs create mode 100644 benches/generated/aspect_ratio_flex_row_fill_max_height.rs create mode 100644 benches/generated/aspect_ratio_flex_row_fill_max_width.rs create mode 100644 benches/generated/aspect_ratio_flex_row_fill_min_height.rs create mode 100644 benches/generated/aspect_ratio_flex_row_fill_min_width.rs create mode 100644 benches/generated/aspect_ratio_flex_row_fill_width.rs create mode 100644 benches/generated/aspect_ratio_flex_row_fill_width_flex.rs create mode 100644 benches/generated/aspect_ratio_flex_row_stretch_fill_height.rs create mode 100644 benches/generated/aspect_ratio_flex_row_stretch_fill_max_height.rs create mode 100644 benches/generated/aspect_ratio_flex_row_stretch_fill_max_width.rs create mode 100644 benches/generated/aspect_ratio_flex_row_stretch_fill_width.rs create mode 100644 benches/generated/display_none_absolute_child.rs create mode 100644 benches/generated/display_none_with_position_absolute.rs create mode 100644 benches/generated/grid_absolute_layout_within_border.rs create mode 100644 benches/generated/grid_absolute_layout_within_border_static.rs create mode 100644 benches/generated/grid_aspect_ratio_absolute_aspect_ratio_overrides_height_of_full_inset.rs create mode 100644 benches/generated/grid_aspect_ratio_absolute_fill_height_from_inset.rs create mode 100644 benches/generated/grid_aspect_ratio_absolute_fill_width_from_inset.rs create mode 100644 benches/generated/grid_aspect_ratio_absolute_height_overrides_inset.rs create mode 100644 benches/generated/grid_aspect_ratio_absolute_width_overrides_inset.rs create mode 100644 benches/generated/grid_aspect_ratio_child_fill_content_height.rs create mode 100644 benches/generated/grid_aspect_ratio_child_fill_content_width.rs create mode 100644 benches/generated/grid_aspect_ratio_fill_child_height.rs create mode 100644 benches/generated/grid_aspect_ratio_fill_child_max_height.rs create mode 100644 benches/generated/grid_aspect_ratio_fill_child_max_width.rs create mode 100644 benches/generated/grid_aspect_ratio_fill_child_min_height.rs create mode 100644 benches/generated/grid_aspect_ratio_fill_child_min_width.rs create mode 100644 benches/generated/grid_aspect_ratio_fill_child_width.rs create mode 100644 benches/generated/grid_aspect_ratio_overriden_by_explicit_sizes.rs create mode 100644 benches/generated/grid_aspect_ratio_overriden_by_explicit_sizes_flex.rs create mode 100644 test_fixtures/absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset.html create mode 100644 test_fixtures/absolute_aspect_ratio_fill_height.html create mode 100644 test_fixtures/absolute_aspect_ratio_fill_height_from_inset.html create mode 100644 test_fixtures/absolute_aspect_ratio_fill_max_height.html create mode 100644 test_fixtures/absolute_aspect_ratio_fill_max_width.html create mode 100644 test_fixtures/absolute_aspect_ratio_fill_min_height.html create mode 100644 test_fixtures/absolute_aspect_ratio_fill_min_width.html create mode 100644 test_fixtures/absolute_aspect_ratio_fill_width.html create mode 100644 test_fixtures/absolute_aspect_ratio_fill_width_from_inset.html create mode 100644 test_fixtures/absolute_aspect_ratio_height_overrides_inset.html create mode 100644 test_fixtures/absolute_aspect_ratio_width_overrides_inset.html create mode 100644 test_fixtures/absolute_margin_bottom_left.html create mode 100644 test_fixtures/absolute_minmax_bottom_right_max.html create mode 100644 test_fixtures/absolute_minmax_bottom_right_min_max.html create mode 100644 test_fixtures/absolute_minmax_bottom_right_min_max_preferred.html create mode 100644 test_fixtures/absolute_minmax_top_left_bottom_right_max.html create mode 100644 test_fixtures/absolute_minmax_top_left_bottom_right_min_max.html create mode 100644 test_fixtures/aspect_ratio_flex_column_fill_height.html create mode 100644 test_fixtures/aspect_ratio_flex_column_fill_max_height.html create mode 100644 test_fixtures/aspect_ratio_flex_column_fill_max_width.html create mode 100644 test_fixtures/aspect_ratio_flex_column_fill_min_height.html create mode 100644 test_fixtures/aspect_ratio_flex_column_fill_min_width.html create mode 100644 test_fixtures/aspect_ratio_flex_column_fill_width.html create mode 100644 test_fixtures/aspect_ratio_flex_column_fill_width_flex.html create mode 100644 test_fixtures/aspect_ratio_flex_column_stretch_fill_height.html create mode 100644 test_fixtures/aspect_ratio_flex_column_stretch_fill_max_height.html create mode 100644 test_fixtures/aspect_ratio_flex_column_stretch_fill_max_width.html create mode 100644 test_fixtures/aspect_ratio_flex_column_stretch_fill_width.html create mode 100644 test_fixtures/aspect_ratio_flex_row_fill_height.html create mode 100644 test_fixtures/aspect_ratio_flex_row_fill_max_height.html create mode 100644 test_fixtures/aspect_ratio_flex_row_fill_max_width.html create mode 100644 test_fixtures/aspect_ratio_flex_row_fill_min_height.html create mode 100644 test_fixtures/aspect_ratio_flex_row_fill_min_width.html create mode 100644 test_fixtures/aspect_ratio_flex_row_fill_width.html create mode 100644 test_fixtures/aspect_ratio_flex_row_fill_width_flex.html create mode 100644 test_fixtures/aspect_ratio_flex_row_stretch_fill_height.html create mode 100644 test_fixtures/aspect_ratio_flex_row_stretch_fill_max_height.html create mode 100644 test_fixtures/aspect_ratio_flex_row_stretch_fill_max_width.html create mode 100644 test_fixtures/aspect_ratio_flex_row_stretch_fill_width.html create mode 100644 test_fixtures/display_none_absolute_child.html create mode 100644 test_fixtures/display_none_with_position_absolute.html create mode 100644 test_fixtures/grid_absolute_layout_within_border.html create mode 100644 test_fixtures/grid_absolute_layout_within_border_static.html create mode 100644 test_fixtures/grid_aspect_ratio_absolute_aspect_ratio_overrides_height_of_full_inset.html create mode 100644 test_fixtures/grid_aspect_ratio_absolute_fill_height_from_inset.html create mode 100644 test_fixtures/grid_aspect_ratio_absolute_fill_width_from_inset.html create mode 100644 test_fixtures/grid_aspect_ratio_absolute_height_overrides_inset.html create mode 100644 test_fixtures/grid_aspect_ratio_absolute_width_overrides_inset.html create mode 100644 test_fixtures/grid_aspect_ratio_child_fill_content_height.html create mode 100644 test_fixtures/grid_aspect_ratio_child_fill_content_width.html create mode 100644 test_fixtures/grid_aspect_ratio_fill_child_height.html create mode 100644 test_fixtures/grid_aspect_ratio_fill_child_max_height.html create mode 100644 test_fixtures/grid_aspect_ratio_fill_child_max_width.html create mode 100644 test_fixtures/grid_aspect_ratio_fill_child_min_height.html create mode 100644 test_fixtures/grid_aspect_ratio_fill_child_min_width.html create mode 100644 test_fixtures/grid_aspect_ratio_fill_child_width.html create mode 100644 test_fixtures/grid_aspect_ratio_overriden_by_explicit_sizes.html create mode 100644 test_fixtures/grid_aspect_ratio_overriden_by_explicit_sizes_flex.html create mode 100644 test_fixtures/xaspect_ratio_flex_column_stretch_fill_min_height.html create mode 100644 test_fixtures/xaspect_ratio_flex_column_stretch_fill_min_width.html create mode 100644 test_fixtures/xaspect_ratio_flex_row_stretch_fill_min_height.html create mode 100644 test_fixtures/xaspect_ratio_flex_row_stretch_fill_min_width.html create mode 100644 tests/generated/absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset.rs create mode 100644 tests/generated/absolute_aspect_ratio_fill_height.rs create mode 100644 tests/generated/absolute_aspect_ratio_fill_height_from_inset.rs create mode 100644 tests/generated/absolute_aspect_ratio_fill_max_height.rs create mode 100644 tests/generated/absolute_aspect_ratio_fill_max_width.rs create mode 100644 tests/generated/absolute_aspect_ratio_fill_min_height.rs create mode 100644 tests/generated/absolute_aspect_ratio_fill_min_width.rs create mode 100644 tests/generated/absolute_aspect_ratio_fill_width.rs create mode 100644 tests/generated/absolute_aspect_ratio_fill_width_from_inset.rs create mode 100644 tests/generated/absolute_aspect_ratio_height_overrides_inset.rs create mode 100644 tests/generated/absolute_aspect_ratio_width_overrides_inset.rs create mode 100644 tests/generated/absolute_margin_bottom_left.rs create mode 100644 tests/generated/absolute_minmax_bottom_right_max.rs create mode 100644 tests/generated/absolute_minmax_bottom_right_min_max.rs create mode 100644 tests/generated/absolute_minmax_bottom_right_min_max_preferred.rs create mode 100644 tests/generated/absolute_minmax_top_left_bottom_right_max.rs create mode 100644 tests/generated/absolute_minmax_top_left_bottom_right_min_max.rs create mode 100644 tests/generated/aspect_ratio_flex_column_fill_height.rs create mode 100644 tests/generated/aspect_ratio_flex_column_fill_max_height.rs create mode 100644 tests/generated/aspect_ratio_flex_column_fill_max_width.rs create mode 100644 tests/generated/aspect_ratio_flex_column_fill_min_height.rs create mode 100644 tests/generated/aspect_ratio_flex_column_fill_min_width.rs create mode 100644 tests/generated/aspect_ratio_flex_column_fill_width.rs create mode 100644 tests/generated/aspect_ratio_flex_column_fill_width_flex.rs create mode 100644 tests/generated/aspect_ratio_flex_column_stretch_fill_height.rs create mode 100644 tests/generated/aspect_ratio_flex_column_stretch_fill_max_height.rs create mode 100644 tests/generated/aspect_ratio_flex_column_stretch_fill_max_width.rs create mode 100644 tests/generated/aspect_ratio_flex_column_stretch_fill_width.rs create mode 100644 tests/generated/aspect_ratio_flex_row_fill_height.rs create mode 100644 tests/generated/aspect_ratio_flex_row_fill_max_height.rs create mode 100644 tests/generated/aspect_ratio_flex_row_fill_max_width.rs create mode 100644 tests/generated/aspect_ratio_flex_row_fill_min_height.rs create mode 100644 tests/generated/aspect_ratio_flex_row_fill_min_width.rs create mode 100644 tests/generated/aspect_ratio_flex_row_fill_width.rs create mode 100644 tests/generated/aspect_ratio_flex_row_fill_width_flex.rs create mode 100644 tests/generated/aspect_ratio_flex_row_stretch_fill_height.rs create mode 100644 tests/generated/aspect_ratio_flex_row_stretch_fill_max_height.rs create mode 100644 tests/generated/aspect_ratio_flex_row_stretch_fill_max_width.rs create mode 100644 tests/generated/aspect_ratio_flex_row_stretch_fill_width.rs create mode 100644 tests/generated/display_none_absolute_child.rs create mode 100644 tests/generated/display_none_with_position_absolute.rs create mode 100644 tests/generated/grid_absolute_layout_within_border.rs create mode 100644 tests/generated/grid_absolute_layout_within_border_static.rs create mode 100644 tests/generated/grid_aspect_ratio_absolute_aspect_ratio_overrides_height_of_full_inset.rs create mode 100644 tests/generated/grid_aspect_ratio_absolute_fill_height_from_inset.rs create mode 100644 tests/generated/grid_aspect_ratio_absolute_fill_width_from_inset.rs create mode 100644 tests/generated/grid_aspect_ratio_absolute_height_overrides_inset.rs create mode 100644 tests/generated/grid_aspect_ratio_absolute_width_overrides_inset.rs create mode 100644 tests/generated/grid_aspect_ratio_child_fill_content_height.rs create mode 100644 tests/generated/grid_aspect_ratio_child_fill_content_width.rs create mode 100644 tests/generated/grid_aspect_ratio_fill_child_height.rs create mode 100644 tests/generated/grid_aspect_ratio_fill_child_max_height.rs create mode 100644 tests/generated/grid_aspect_ratio_fill_child_max_width.rs create mode 100644 tests/generated/grid_aspect_ratio_fill_child_min_height.rs create mode 100644 tests/generated/grid_aspect_ratio_fill_child_min_width.rs create mode 100644 tests/generated/grid_aspect_ratio_fill_child_width.rs create mode 100644 tests/generated/grid_aspect_ratio_overriden_by_explicit_sizes.rs create mode 100644 tests/generated/grid_aspect_ratio_overriden_by_explicit_sizes_flex.rs diff --git a/.cargo/config.toml b/.cargo/config.toml index 7e669f119..52ecae305 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,2 +1,2 @@ [alias] -gentest = "run --package gentest --" \ No newline at end of file +gentest = "run --release --package gentest --" \ No newline at end of file diff --git a/RELEASES.md b/RELEASES.md index af9b1a56a..419cb094c 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -13,6 +13,9 @@ ### Fixes - Flexbox nodes sized under a min-content constraint now size correctly (#291) +- Aspect ratio is now applied correctly in many circumstances +- Absolutely positioned items now apply margins correctly +- Min/max size are now applied correctly ### Removed diff --git a/benches/generated/absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset.rs b/benches/generated/absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset.rs new file mode 100644 index 000000000..ca171c053 --- /dev/null +++ b/benches/generated/absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset.rs @@ -0,0 +1,32 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.05f32), + right: taffy::style::LengthPercentageAuto::Percent(0.05f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.05f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(400f32), + height: taffy::style::Dimension::Points(300f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/absolute_aspect_ratio_fill_height.rs b/benches/generated/absolute_aspect_ratio_fill_height.rs new file mode 100644 index 000000000..bd566796a --- /dev/null +++ b/benches/generated/absolute_aspect_ratio_fill_height.rs @@ -0,0 +1,33 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.5f32), height: auto() }, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.05f32), + right: auto(), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: auto(), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(400f32), + height: taffy::style::Dimension::Points(300f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/absolute_aspect_ratio_fill_height_from_inset.rs b/benches/generated/absolute_aspect_ratio_fill_height_from_inset.rs new file mode 100644 index 000000000..cc8fef7e4 --- /dev/null +++ b/benches/generated/absolute_aspect_ratio_fill_height_from_inset.rs @@ -0,0 +1,32 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.1f32), + right: taffy::style::LengthPercentageAuto::Percent(0.1f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: auto(), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(400f32), + height: taffy::style::Dimension::Points(300f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/absolute_aspect_ratio_fill_max_height.rs b/benches/generated/absolute_aspect_ratio_fill_max_height.rs new file mode 100644 index 000000000..f3174beeb --- /dev/null +++ b/benches/generated/absolute_aspect_ratio_fill_max_height.rs @@ -0,0 +1,20 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy . new_leaf_with_measure (taffy :: style :: Style { position : taffy :: style :: Position :: Absolute , max_size : taffy :: geometry :: Size { width : taffy :: style :: Dimension :: Points (50f32) , height : auto () , } , aspect_ratio : Some (3f32) , .. Default :: default () } , taffy :: node :: MeasureFunc :: Raw (| known_dimensions , available_space | { const TEXT : & str = "HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH" ; super :: measure_standard_text (known_dimensions , available_space , TEXT , super :: WritingMode :: Horizontal , Some (3f32)) }) ,) . unwrap () ; + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(400f32), + height: taffy::style::Dimension::Points(300f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/absolute_aspect_ratio_fill_max_width.rs b/benches/generated/absolute_aspect_ratio_fill_max_width.rs new file mode 100644 index 000000000..69b2fd603 --- /dev/null +++ b/benches/generated/absolute_aspect_ratio_fill_max_width.rs @@ -0,0 +1,20 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy . new_leaf_with_measure (taffy :: style :: Style { position : taffy :: style :: Position :: Absolute , max_size : taffy :: geometry :: Size { width : auto () , height : taffy :: style :: Dimension :: Points (50f32) , } , aspect_ratio : Some (0.5f32) , .. Default :: default () } , taffy :: node :: MeasureFunc :: Raw (| known_dimensions , available_space | { const TEXT : & str = "HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH" ; super :: measure_standard_text (known_dimensions , available_space , TEXT , super :: WritingMode :: Horizontal , Some (0.5f32)) }) ,) . unwrap () ; + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(400f32), + height: taffy::style::Dimension::Points(300f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/absolute_aspect_ratio_fill_min_height.rs b/benches/generated/absolute_aspect_ratio_fill_min_height.rs new file mode 100644 index 000000000..f2fa1084c --- /dev/null +++ b/benches/generated/absolute_aspect_ratio_fill_min_height.rs @@ -0,0 +1,27 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() }, + aspect_ratio: Some(3f32), + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(400f32), + height: taffy::style::Dimension::Points(300f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/absolute_aspect_ratio_fill_min_width.rs b/benches/generated/absolute_aspect_ratio_fill_min_width.rs new file mode 100644 index 000000000..06d3649a5 --- /dev/null +++ b/benches/generated/absolute_aspect_ratio_fill_min_width.rs @@ -0,0 +1,27 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(50f32) }, + aspect_ratio: Some(0.5f32), + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(400f32), + height: taffy::style::Dimension::Points(300f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/absolute_aspect_ratio_fill_width.rs b/benches/generated/absolute_aspect_ratio_fill_width.rs new file mode 100644 index 000000000..11070af81 --- /dev/null +++ b/benches/generated/absolute_aspect_ratio_fill_width.rs @@ -0,0 +1,33 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.2f32) }, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.05f32), + right: auto(), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: auto(), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(400f32), + height: taffy::style::Dimension::Points(300f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/absolute_aspect_ratio_fill_width_from_inset.rs b/benches/generated/absolute_aspect_ratio_fill_width_from_inset.rs new file mode 100644 index 000000000..44d0490b0 --- /dev/null +++ b/benches/generated/absolute_aspect_ratio_fill_width_from_inset.rs @@ -0,0 +1,32 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Percent(0.3f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.5f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(400f32), + height: taffy::style::Dimension::Points(300f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/absolute_aspect_ratio_height_overrides_inset.rs b/benches/generated/absolute_aspect_ratio_height_overrides_inset.rs new file mode 100644 index 000000000..694d0fcc4 --- /dev/null +++ b/benches/generated/absolute_aspect_ratio_height_overrides_inset.rs @@ -0,0 +1,33 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.1f32) }, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Percent(0.3f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.5f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(400f32), + height: taffy::style::Dimension::Points(300f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/absolute_aspect_ratio_width_overrides_inset.rs b/benches/generated/absolute_aspect_ratio_width_overrides_inset.rs new file mode 100644 index 000000000..295697b68 --- /dev/null +++ b/benches/generated/absolute_aspect_ratio_width_overrides_inset.rs @@ -0,0 +1,33 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.4f32), height: auto() }, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.1f32), + right: taffy::style::LengthPercentageAuto::Percent(0.1f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: auto(), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(400f32), + height: taffy::style::Dimension::Points(300f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/absolute_margin_bottom_left.rs b/benches/generated/absolute_margin_bottom_left.rs new file mode 100644 index 000000000..9848f6ca6 --- /dev/null +++ b/benches/generated/absolute_margin_bottom_left.rs @@ -0,0 +1,36 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + justify_content: Some(taffy::style::JustifyContent::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/absolute_minmax_bottom_right_max.rs b/benches/generated/absolute_minmax_bottom_right_max.rs new file mode 100644 index 000000000..50bd1c3c5 --- /dev/null +++ b/benches/generated/absolute_minmax_bottom_right_max.rs @@ -0,0 +1,38 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(40f32), + height: taffy::style::Dimension::Points(30f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/absolute_minmax_bottom_right_min_max.rs b/benches/generated/absolute_minmax_bottom_right_min_max.rs new file mode 100644 index 000000000..d392d2f07 --- /dev/null +++ b/benches/generated/absolute_minmax_bottom_right_min_max.rs @@ -0,0 +1,38 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(60f32), + }, + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(40f32), + height: taffy::style::Dimension::Points(30f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/absolute_minmax_bottom_right_min_max_preferred.rs b/benches/generated/absolute_minmax_bottom_right_min_max_preferred.rs new file mode 100644 index 000000000..2ad7f333f --- /dev/null +++ b/benches/generated/absolute_minmax_bottom_right_min_max_preferred.rs @@ -0,0 +1,42 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(60f32), + }, + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(40f32), + height: taffy::style::Dimension::Points(30f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/absolute_minmax_top_left_bottom_right_max.rs b/benches/generated/absolute_minmax_top_left_bottom_right_max.rs new file mode 100644 index 000000000..0f09d6a2a --- /dev/null +++ b/benches/generated/absolute_minmax_top_left_bottom_right_max.rs @@ -0,0 +1,34 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(40f32), + height: taffy::style::Dimension::Points(30f32), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/absolute_minmax_top_left_bottom_right_min_max.rs b/benches/generated/absolute_minmax_top_left_bottom_right_min_max.rs new file mode 100644 index 000000000..356ba3d97 --- /dev/null +++ b/benches/generated/absolute_minmax_top_left_bottom_right_min_max.rs @@ -0,0 +1,38 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(60f32), + }, + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(40f32), + height: taffy::style::Dimension::Points(30f32), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/aspect_ratio_flex_column_fill_height.rs b/benches/generated/aspect_ratio_flex_column_fill_height.rs new file mode 100644 index 000000000..5f450c137 --- /dev/null +++ b/benches/generated/aspect_ratio_flex_column_fill_height.rs @@ -0,0 +1,28 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(40f32), height: auto() }, + aspect_ratio: Some(2f32), + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + flex_direction: taffy::style::FlexDirection::Column, + align_items: Some(taffy::style::AlignItems::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/aspect_ratio_flex_column_fill_max_height.rs b/benches/generated/aspect_ratio_flex_column_fill_max_height.rs new file mode 100644 index 000000000..545a90bb7 --- /dev/null +++ b/benches/generated/aspect_ratio_flex_column_fill_max_height.rs @@ -0,0 +1,22 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy . new_leaf_with_measure (taffy :: style :: Style { max_size : taffy :: geometry :: Size { width : taffy :: style :: Dimension :: Points (40f32) , height : auto () , } , aspect_ratio : Some (2f32) , .. Default :: default () } , taffy :: node :: MeasureFunc :: Raw (| known_dimensions , available_space | { const TEXT : & str = "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH" ; super :: measure_standard_text (known_dimensions , available_space , TEXT , super :: WritingMode :: Horizontal , Some (2f32)) }) ,) . unwrap () ; + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + flex_direction: taffy::style::FlexDirection::Column, + align_items: Some(taffy::style::AlignItems::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/aspect_ratio_flex_column_fill_max_width.rs b/benches/generated/aspect_ratio_flex_column_fill_max_width.rs new file mode 100644 index 000000000..aee7e7180 --- /dev/null +++ b/benches/generated/aspect_ratio_flex_column_fill_max_width.rs @@ -0,0 +1,40 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf_with_measure( + taffy::style::Style { + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(20f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH"; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + Some(2f32), + ) + }), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + flex_direction: taffy::style::FlexDirection::Column, + align_items: Some(taffy::style::AlignItems::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/aspect_ratio_flex_column_fill_min_height.rs b/benches/generated/aspect_ratio_flex_column_fill_min_height.rs new file mode 100644 index 000000000..b52b9b698 --- /dev/null +++ b/benches/generated/aspect_ratio_flex_column_fill_min_height.rs @@ -0,0 +1,28 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(40f32), height: auto() }, + aspect_ratio: Some(2f32), + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + flex_direction: taffy::style::FlexDirection::Column, + align_items: Some(taffy::style::AlignItems::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/aspect_ratio_flex_column_fill_min_width.rs b/benches/generated/aspect_ratio_flex_column_fill_min_width.rs new file mode 100644 index 000000000..adbe8fd7e --- /dev/null +++ b/benches/generated/aspect_ratio_flex_column_fill_min_width.rs @@ -0,0 +1,40 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf_with_measure( + taffy::style::Style { + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(40f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "\n \n "; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + Some(2f32), + ) + }), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + flex_direction: taffy::style::FlexDirection::Column, + align_items: Some(taffy::style::AlignItems::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/aspect_ratio_flex_column_fill_width.rs b/benches/generated/aspect_ratio_flex_column_fill_width.rs new file mode 100644 index 000000000..a05061cf6 --- /dev/null +++ b/benches/generated/aspect_ratio_flex_column_fill_width.rs @@ -0,0 +1,28 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(40f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + flex_direction: taffy::style::FlexDirection::Column, + align_items: Some(taffy::style::AlignItems::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/aspect_ratio_flex_column_fill_width_flex.rs b/benches/generated/aspect_ratio_flex_column_fill_width_flex.rs new file mode 100644 index 000000000..4cd3383d3 --- /dev/null +++ b/benches/generated/aspect_ratio_flex_column_fill_width_flex.rs @@ -0,0 +1,27 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(50f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/aspect_ratio_flex_column_stretch_fill_height.rs b/benches/generated/aspect_ratio_flex_column_stretch_fill_height.rs new file mode 100644 index 000000000..b2703bde7 --- /dev/null +++ b/benches/generated/aspect_ratio_flex_column_stretch_fill_height.rs @@ -0,0 +1,27 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(40f32), height: auto() }, + aspect_ratio: Some(2f32), + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/aspect_ratio_flex_column_stretch_fill_max_height.rs b/benches/generated/aspect_ratio_flex_column_stretch_fill_max_height.rs new file mode 100644 index 000000000..225527030 --- /dev/null +++ b/benches/generated/aspect_ratio_flex_column_stretch_fill_max_height.rs @@ -0,0 +1,21 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy . new_leaf_with_measure (taffy :: style :: Style { max_size : taffy :: geometry :: Size { width : taffy :: style :: Dimension :: Points (40f32) , height : auto () , } , aspect_ratio : Some (2f32) , .. Default :: default () } , taffy :: node :: MeasureFunc :: Raw (| known_dimensions , available_space | { const TEXT : & str = "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH" ; super :: measure_standard_text (known_dimensions , available_space , TEXT , super :: WritingMode :: Horizontal , Some (2f32)) }) ,) . unwrap () ; + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/aspect_ratio_flex_column_stretch_fill_max_width.rs b/benches/generated/aspect_ratio_flex_column_stretch_fill_max_width.rs new file mode 100644 index 000000000..dd8c40f0e --- /dev/null +++ b/benches/generated/aspect_ratio_flex_column_stretch_fill_max_width.rs @@ -0,0 +1,39 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf_with_measure( + taffy::style::Style { + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(20f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH"; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + Some(2f32), + ) + }), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/aspect_ratio_flex_column_stretch_fill_width.rs b/benches/generated/aspect_ratio_flex_column_stretch_fill_width.rs new file mode 100644 index 000000000..c00d49d30 --- /dev/null +++ b/benches/generated/aspect_ratio_flex_column_stretch_fill_width.rs @@ -0,0 +1,27 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(40f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/aspect_ratio_flex_row_fill_height.rs b/benches/generated/aspect_ratio_flex_row_fill_height.rs new file mode 100644 index 000000000..fa97a2080 --- /dev/null +++ b/benches/generated/aspect_ratio_flex_row_fill_height.rs @@ -0,0 +1,27 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(40f32), height: auto() }, + aspect_ratio: Some(2f32), + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + align_items: Some(taffy::style::AlignItems::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/aspect_ratio_flex_row_fill_max_height.rs b/benches/generated/aspect_ratio_flex_row_fill_max_height.rs new file mode 100644 index 000000000..809e0e909 --- /dev/null +++ b/benches/generated/aspect_ratio_flex_row_fill_max_height.rs @@ -0,0 +1,21 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy . new_leaf_with_measure (taffy :: style :: Style { max_size : taffy :: geometry :: Size { width : taffy :: style :: Dimension :: Points (40f32) , height : auto () , } , aspect_ratio : Some (2f32) , .. Default :: default () } , taffy :: node :: MeasureFunc :: Raw (| known_dimensions , available_space | { const TEXT : & str = "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH" ; super :: measure_standard_text (known_dimensions , available_space , TEXT , super :: WritingMode :: Horizontal , Some (2f32)) }) ,) . unwrap () ; + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + align_items: Some(taffy::style::AlignItems::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/aspect_ratio_flex_row_fill_max_width.rs b/benches/generated/aspect_ratio_flex_row_fill_max_width.rs new file mode 100644 index 000000000..8a9ef2899 --- /dev/null +++ b/benches/generated/aspect_ratio_flex_row_fill_max_width.rs @@ -0,0 +1,39 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf_with_measure( + taffy::style::Style { + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(20f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH"; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + Some(2f32), + ) + }), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + align_items: Some(taffy::style::AlignItems::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/aspect_ratio_flex_row_fill_min_height.rs b/benches/generated/aspect_ratio_flex_row_fill_min_height.rs new file mode 100644 index 000000000..5f71ff244 --- /dev/null +++ b/benches/generated/aspect_ratio_flex_row_fill_min_height.rs @@ -0,0 +1,27 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(40f32), height: auto() }, + aspect_ratio: Some(2f32), + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + align_items: Some(taffy::style::AlignItems::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/aspect_ratio_flex_row_fill_min_width.rs b/benches/generated/aspect_ratio_flex_row_fill_min_width.rs new file mode 100644 index 000000000..877da1c41 --- /dev/null +++ b/benches/generated/aspect_ratio_flex_row_fill_min_width.rs @@ -0,0 +1,39 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf_with_measure( + taffy::style::Style { + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(40f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "\n \n "; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + Some(2f32), + ) + }), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + align_items: Some(taffy::style::AlignItems::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/aspect_ratio_flex_row_fill_width.rs b/benches/generated/aspect_ratio_flex_row_fill_width.rs new file mode 100644 index 000000000..5859b0756 --- /dev/null +++ b/benches/generated/aspect_ratio_flex_row_fill_width.rs @@ -0,0 +1,27 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(40f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + align_items: Some(taffy::style::AlignItems::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/aspect_ratio_flex_row_fill_width_flex.rs b/benches/generated/aspect_ratio_flex_row_fill_width_flex.rs new file mode 100644 index 000000000..02b13b129 --- /dev/null +++ b/benches/generated/aspect_ratio_flex_row_fill_width_flex.rs @@ -0,0 +1,27 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(50f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_items: Some(taffy::style::AlignItems::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/aspect_ratio_flex_row_stretch_fill_height.rs b/benches/generated/aspect_ratio_flex_row_stretch_fill_height.rs new file mode 100644 index 000000000..0a3c7e687 --- /dev/null +++ b/benches/generated/aspect_ratio_flex_row_stretch_fill_height.rs @@ -0,0 +1,26 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(40f32), height: auto() }, + aspect_ratio: Some(2f32), + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/aspect_ratio_flex_row_stretch_fill_max_height.rs b/benches/generated/aspect_ratio_flex_row_stretch_fill_max_height.rs new file mode 100644 index 000000000..b78d778b0 --- /dev/null +++ b/benches/generated/aspect_ratio_flex_row_stretch_fill_max_height.rs @@ -0,0 +1,20 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy . new_leaf_with_measure (taffy :: style :: Style { max_size : taffy :: geometry :: Size { width : taffy :: style :: Dimension :: Points (40f32) , height : auto () , } , aspect_ratio : Some (2f32) , .. Default :: default () } , taffy :: node :: MeasureFunc :: Raw (| known_dimensions , available_space | { const TEXT : & str = "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH" ; super :: measure_standard_text (known_dimensions , available_space , TEXT , super :: WritingMode :: Horizontal , Some (2f32)) }) ,) . unwrap () ; + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/aspect_ratio_flex_row_stretch_fill_max_width.rs b/benches/generated/aspect_ratio_flex_row_stretch_fill_max_width.rs new file mode 100644 index 000000000..f8d66c06d --- /dev/null +++ b/benches/generated/aspect_ratio_flex_row_stretch_fill_max_width.rs @@ -0,0 +1,38 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf_with_measure( + taffy::style::Style { + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(20f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH"; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + Some(2f32), + ) + }), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/aspect_ratio_flex_row_stretch_fill_width.rs b/benches/generated/aspect_ratio_flex_row_stretch_fill_width.rs new file mode 100644 index 000000000..4bd68cfc6 --- /dev/null +++ b/benches/generated/aspect_ratio_flex_row_stretch_fill_width.rs @@ -0,0 +1,26 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(40f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/display_none_absolute_child.rs b/benches/generated/display_none_absolute_child.rs new file mode 100644 index 000000000..31e0950f1 --- /dev/null +++ b/benches/generated/display_none_absolute_child.rs @@ -0,0 +1,36 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::None, + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: auto(), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: auto(), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/display_none_with_position_absolute.rs b/benches/generated/display_none_with_position_absolute.rs new file mode 100644 index 000000000..b53a1f491 --- /dev/null +++ b/benches/generated/display_none_with_position_absolute.rs @@ -0,0 +1,29 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::None, + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_absolute_layout_within_border.rs b/benches/generated/grid_absolute_layout_within_border.rs new file mode 100644 index 000000000..87bcab3de --- /dev/null +++ b/benches/generated/grid_absolute_layout_within_border.rs @@ -0,0 +1,107 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(0f32), + right: auto(), + top: taffy::style::LengthPercentageAuto::Points(0f32), + bottom: auto(), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Points(0f32), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Points(0f32), + }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(0f32), + right: auto(), + top: taffy::style::LengthPercentageAuto::Points(0f32), + bottom: auto(), + }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Points(0f32), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Points(0f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(10f32), + right: taffy::style::LengthPercentage::Points(10f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(10f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(10f32), + right: taffy::style::LengthPercentage::Points(10f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(10f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_absolute_layout_within_border_static.rs b/benches/generated/grid_absolute_layout_within_border_static.rs new file mode 100644 index 000000000..36d05bab9 --- /dev/null +++ b/benches/generated/grid_absolute_layout_within_border_static.rs @@ -0,0 +1,91 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + align_self: Some(taffy::style::AlignSelf::Start), + justify_self: Some(taffy::style::JustifySelf::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + align_self: Some(taffy::style::AlignSelf::End), + justify_self: Some(taffy::style::JustifySelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + align_self: Some(taffy::style::AlignSelf::Start), + justify_self: Some(taffy::style::JustifySelf::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + align_self: Some(taffy::style::AlignSelf::End), + justify_self: Some(taffy::style::JustifySelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(10f32), + right: taffy::style::LengthPercentage::Points(10f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(10f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(10f32), + right: taffy::style::LengthPercentage::Points(10f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(10f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_aspect_ratio_absolute_aspect_ratio_overrides_height_of_full_inset.rs b/benches/generated/grid_aspect_ratio_absolute_aspect_ratio_overrides_height_of_full_inset.rs new file mode 100644 index 000000000..bc264cd9e --- /dev/null +++ b/benches/generated/grid_aspect_ratio_absolute_aspect_ratio_overrides_height_of_full_inset.rs @@ -0,0 +1,32 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.05f32), + right: taffy::style::LengthPercentageAuto::Percent(0.05f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.05f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(400f32), + height: taffy::style::Dimension::Points(300f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_aspect_ratio_absolute_fill_height_from_inset.rs b/benches/generated/grid_aspect_ratio_absolute_fill_height_from_inset.rs new file mode 100644 index 000000000..7f8a8d52e --- /dev/null +++ b/benches/generated/grid_aspect_ratio_absolute_fill_height_from_inset.rs @@ -0,0 +1,32 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.1f32), + right: taffy::style::LengthPercentageAuto::Percent(0.1f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: auto(), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(400f32), + height: taffy::style::Dimension::Points(300f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_aspect_ratio_absolute_fill_width_from_inset.rs b/benches/generated/grid_aspect_ratio_absolute_fill_width_from_inset.rs new file mode 100644 index 000000000..44d0490b0 --- /dev/null +++ b/benches/generated/grid_aspect_ratio_absolute_fill_width_from_inset.rs @@ -0,0 +1,32 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Percent(0.3f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.5f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(400f32), + height: taffy::style::Dimension::Points(300f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_aspect_ratio_absolute_height_overrides_inset.rs b/benches/generated/grid_aspect_ratio_absolute_height_overrides_inset.rs new file mode 100644 index 000000000..694d0fcc4 --- /dev/null +++ b/benches/generated/grid_aspect_ratio_absolute_height_overrides_inset.rs @@ -0,0 +1,33 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.1f32) }, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Percent(0.3f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.5f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(400f32), + height: taffy::style::Dimension::Points(300f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_aspect_ratio_absolute_width_overrides_inset.rs b/benches/generated/grid_aspect_ratio_absolute_width_overrides_inset.rs new file mode 100644 index 000000000..96bceea54 --- /dev/null +++ b/benches/generated/grid_aspect_ratio_absolute_width_overrides_inset.rs @@ -0,0 +1,33 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.4f32), height: auto() }, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.1f32), + right: taffy::style::LengthPercentageAuto::Percent(0.1f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: auto(), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(400f32), + height: taffy::style::Dimension::Points(300f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_aspect_ratio_child_fill_content_height.rs b/benches/generated/grid_aspect_ratio_child_fill_content_height.rs new file mode 100644 index 000000000..12523c8b9 --- /dev/null +++ b/benches/generated/grid_aspect_ratio_child_fill_content_height.rs @@ -0,0 +1,33 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf_with_measure( + taffy::style::Style { aspect_ratio: Some(0.5f32), ..Default::default() }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHH"; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + Some(0.5f32), + ) + }), + ) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(20f32) }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, ..Default::default() }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_aspect_ratio_child_fill_content_width.rs b/benches/generated/grid_aspect_ratio_child_fill_content_width.rs new file mode 100644 index 000000000..6b9c8dc00 --- /dev/null +++ b/benches/generated/grid_aspect_ratio_child_fill_content_width.rs @@ -0,0 +1,33 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf_with_measure( + taffy::style::Style { aspect_ratio: Some(2f32), ..Default::default() }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHH"; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + Some(2f32), + ) + }), + ) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(20f32) }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, ..Default::default() }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_aspect_ratio_fill_child_height.rs b/benches/generated/grid_aspect_ratio_fill_child_height.rs new file mode 100644 index 000000000..b90024157 --- /dev/null +++ b/benches/generated/grid_aspect_ratio_fill_child_height.rs @@ -0,0 +1,26 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() }, + aspect_ratio: Some(2f32), + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_aspect_ratio_fill_child_max_height.rs b/benches/generated/grid_aspect_ratio_fill_child_max_height.rs new file mode 100644 index 000000000..172dcb9ee --- /dev/null +++ b/benches/generated/grid_aspect_ratio_fill_child_max_height.rs @@ -0,0 +1,38 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf_with_measure( + taffy::style::Style { + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(40f32), height: auto() }, + aspect_ratio: Some(2f32), + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH"; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Vertical, + Some(2f32), + ) + }), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_aspect_ratio_fill_child_max_width.rs b/benches/generated/grid_aspect_ratio_fill_child_max_width.rs new file mode 100644 index 000000000..830cc29f4 --- /dev/null +++ b/benches/generated/grid_aspect_ratio_fill_child_max_width.rs @@ -0,0 +1,38 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf_with_measure( + taffy::style::Style { + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(20f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH"; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + Some(2f32), + ) + }), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_aspect_ratio_fill_child_min_height.rs b/benches/generated/grid_aspect_ratio_fill_child_min_height.rs new file mode 100644 index 000000000..819186737 --- /dev/null +++ b/benches/generated/grid_aspect_ratio_fill_child_min_height.rs @@ -0,0 +1,26 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() }, + aspect_ratio: Some(2f32), + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_aspect_ratio_fill_child_min_width.rs b/benches/generated/grid_aspect_ratio_fill_child_min_width.rs new file mode 100644 index 000000000..0df0c51d7 --- /dev/null +++ b/benches/generated/grid_aspect_ratio_fill_child_min_width.rs @@ -0,0 +1,38 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf_with_measure( + taffy::style::Style { + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(50f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "\n \n "; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + Some(2f32), + ) + }), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_aspect_ratio_fill_child_width.rs b/benches/generated/grid_aspect_ratio_fill_child_width.rs new file mode 100644 index 000000000..4f801930b --- /dev/null +++ b/benches/generated/grid_aspect_ratio_fill_child_width.rs @@ -0,0 +1,26 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(50f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_aspect_ratio_overriden_by_explicit_sizes.rs b/benches/generated/grid_aspect_ratio_overriden_by_explicit_sizes.rs new file mode 100644 index 000000000..39ed71ce2 --- /dev/null +++ b/benches/generated/grid_aspect_ratio_overriden_by_explicit_sizes.rs @@ -0,0 +1,29 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + }, + aspect_ratio: Some(2f32), + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_aspect_ratio_overriden_by_explicit_sizes_flex.rs b/benches/generated/grid_aspect_ratio_overriden_by_explicit_sizes_flex.rs new file mode 100644 index 000000000..39ed71ce2 --- /dev/null +++ b/benches/generated/grid_aspect_ratio_overriden_by_explicit_sizes_flex.rs @@ -0,0 +1,29 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + }, + aspect_ratio: Some(2f32), + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_fit_content_points_argument.rs b/benches/generated/grid_fit_content_points_argument.rs index 1a08d5bdb..a831b56e0 100644 --- a/benches/generated/grid_fit_content_points_argument.rs +++ b/benches/generated/grid_fit_content_points_argument.rs @@ -8,7 +8,13 @@ pub fn compute() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/benches/generated/grid_fit_content_points_max_content.rs b/benches/generated/grid_fit_content_points_max_content.rs index c2c3829bb..9fff48fd5 100644 --- a/benches/generated/grid_fit_content_points_max_content.rs +++ b/benches/generated/grid_fit_content_points_max_content.rs @@ -8,7 +8,13 @@ pub fn compute() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/benches/generated/grid_fit_content_points_min_content.rs b/benches/generated/grid_fit_content_points_min_content.rs index 611fda99c..cb4f1b256 100644 --- a/benches/generated/grid_fit_content_points_min_content.rs +++ b/benches/generated/grid_fit_content_points_min_content.rs @@ -8,7 +8,13 @@ pub fn compute() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HHHH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/benches/generated/grid_margins_auto_margins_override_stretch.rs b/benches/generated/grid_margins_auto_margins_override_stretch.rs index 8b51cc6a8..a12b36bd0 100644 --- a/benches/generated/grid_margins_auto_margins_override_stretch.rs +++ b/benches/generated/grid_margins_auto_margins_override_stretch.rs @@ -23,7 +23,13 @@ pub fn compute() { }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/benches/generated/grid_max_content_maximum_single_item.rs b/benches/generated/grid_max_content_maximum_single_item.rs index 88fc970e8..3c72bef01 100644 --- a/benches/generated/grid_max_content_maximum_single_item.rs +++ b/benches/generated/grid_max_content_maximum_single_item.rs @@ -8,7 +8,13 @@ pub fn compute() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/benches/generated/grid_max_content_single_item.rs b/benches/generated/grid_max_content_single_item.rs index 956d5ff70..ad6f03f09 100644 --- a/benches/generated/grid_max_content_single_item.rs +++ b/benches/generated/grid_max_content_single_item.rs @@ -8,7 +8,13 @@ pub fn compute() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/benches/generated/grid_max_content_single_item_margin_auto.rs b/benches/generated/grid_max_content_single_item_margin_auto.rs index 70799c6da..480c0dc44 100644 --- a/benches/generated/grid_max_content_single_item_margin_auto.rs +++ b/benches/generated/grid_max_content_single_item_margin_auto.rs @@ -16,7 +16,13 @@ pub fn compute() { }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/benches/generated/grid_max_content_single_item_margin_fixed.rs b/benches/generated/grid_max_content_single_item_margin_fixed.rs index 2a53d1ad8..086d3a4ca 100644 --- a/benches/generated/grid_max_content_single_item_margin_fixed.rs +++ b/benches/generated/grid_max_content_single_item_margin_fixed.rs @@ -16,7 +16,13 @@ pub fn compute() { }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/benches/generated/grid_max_content_single_item_margin_percent.rs b/benches/generated/grid_max_content_single_item_margin_percent.rs index 3cd508ee7..2c5663eed 100644 --- a/benches/generated/grid_max_content_single_item_margin_percent.rs +++ b/benches/generated/grid_max_content_single_item_margin_percent.rs @@ -16,7 +16,13 @@ pub fn compute() { }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/benches/generated/grid_min_content_flex_column.rs b/benches/generated/grid_min_content_flex_column.rs index 1ec016dd8..63e1aebbc 100644 --- a/benches/generated/grid_min_content_flex_column.rs +++ b/benches/generated/grid_min_content_flex_column.rs @@ -7,7 +7,13 @@ pub fn compute() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); @@ -16,7 +22,13 @@ pub fn compute() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); @@ -25,7 +37,13 @@ pub fn compute() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/benches/generated/grid_min_content_flex_row.rs b/benches/generated/grid_min_content_flex_row.rs index fce7e8674..9dbed47a7 100644 --- a/benches/generated/grid_min_content_flex_row.rs +++ b/benches/generated/grid_min_content_flex_row.rs @@ -7,7 +7,13 @@ pub fn compute() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); @@ -16,7 +22,13 @@ pub fn compute() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); @@ -25,7 +37,13 @@ pub fn compute() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/benches/generated/grid_min_content_flex_single_item.rs b/benches/generated/grid_min_content_flex_single_item.rs index c4c05db81..5649fc722 100644 --- a/benches/generated/grid_min_content_flex_single_item.rs +++ b/benches/generated/grid_min_content_flex_single_item.rs @@ -22,7 +22,13 @@ pub fn compute() { }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/benches/generated/grid_min_content_flex_single_item_margin_auto.rs b/benches/generated/grid_min_content_flex_single_item_margin_auto.rs index ce42e39d4..9ad8ef86f 100644 --- a/benches/generated/grid_min_content_flex_single_item_margin_auto.rs +++ b/benches/generated/grid_min_content_flex_single_item_margin_auto.rs @@ -34,7 +34,13 @@ pub fn compute() { }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/benches/generated/grid_min_content_flex_single_item_margin_fixed.rs b/benches/generated/grid_min_content_flex_single_item_margin_fixed.rs index e30c932d5..d27ef5f6e 100644 --- a/benches/generated/grid_min_content_flex_single_item_margin_fixed.rs +++ b/benches/generated/grid_min_content_flex_single_item_margin_fixed.rs @@ -34,7 +34,13 @@ pub fn compute() { }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/benches/generated/grid_min_content_flex_single_item_margin_percent.rs b/benches/generated/grid_min_content_flex_single_item_margin_percent.rs index ea3af0248..0e7ec42e0 100644 --- a/benches/generated/grid_min_content_flex_single_item_margin_percent.rs +++ b/benches/generated/grid_min_content_flex_single_item_margin_percent.rs @@ -34,7 +34,13 @@ pub fn compute() { }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/benches/generated/grid_min_content_maximum_single_item.rs b/benches/generated/grid_min_content_maximum_single_item.rs index 15e6fff5c..4506d354c 100644 --- a/benches/generated/grid_min_content_maximum_single_item.rs +++ b/benches/generated/grid_min_content_maximum_single_item.rs @@ -8,7 +8,13 @@ pub fn compute() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/benches/generated/grid_min_content_single_item.rs b/benches/generated/grid_min_content_single_item.rs index d1e871849..d13263c15 100644 --- a/benches/generated/grid_min_content_single_item.rs +++ b/benches/generated/grid_min_content_single_item.rs @@ -8,7 +8,13 @@ pub fn compute() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/benches/generated/grid_relayout_vertical_text.rs b/benches/generated/grid_relayout_vertical_text.rs index 93134c5cc..4b7b6c55b 100644 --- a/benches/generated/grid_relayout_vertical_text.rs +++ b/benches/generated/grid_relayout_vertical_text.rs @@ -7,7 +7,13 @@ pub fn compute() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Vertical) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Vertical, + None, + ) }), ) .unwrap(); @@ -16,7 +22,13 @@ pub fn compute() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/benches/generated/grid_size_child_fixed_tracks.rs b/benches/generated/grid_size_child_fixed_tracks.rs index a50d5e058..53e301a07 100644 --- a/benches/generated/grid_size_child_fixed_tracks.rs +++ b/benches/generated/grid_size_child_fixed_tracks.rs @@ -11,7 +11,13 @@ pub fn compute() { }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); @@ -24,7 +30,13 @@ pub fn compute() { }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HHH\u{200b}HHH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); @@ -37,7 +49,13 @@ pub fn compute() { }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HHHH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); @@ -51,7 +69,13 @@ pub fn compute() { }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); @@ -65,7 +89,13 @@ pub fn compute() { }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/benches/generated/measure_child.rs b/benches/generated/measure_child.rs index bc84bd19f..81570d5d2 100644 --- a/benches/generated/measure_child.rs +++ b/benches/generated/measure_child.rs @@ -7,7 +7,13 @@ pub fn compute() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HHHHHH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/benches/generated/measure_child_absolute.rs b/benches/generated/measure_child_absolute.rs index 679593802..5c7d4433c 100644 --- a/benches/generated/measure_child_absolute.rs +++ b/benches/generated/measure_child_absolute.rs @@ -7,7 +7,13 @@ pub fn compute() { taffy::style::Style { position: taffy::style::Position::Absolute, ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HHHHHH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/benches/generated/measure_child_constraint.rs b/benches/generated/measure_child_constraint.rs index e2fd457ad..3bc4c5150 100644 --- a/benches/generated/measure_child_constraint.rs +++ b/benches/generated/measure_child_constraint.rs @@ -2,7 +2,7 @@ pub fn compute() { #[allow(unused_imports)] use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); - let node0 = taffy . new_leaf_with_measure (taffy :: style :: Style { .. Default :: default () } , taffy :: node :: MeasureFunc :: Raw (| known_dimensions , available_space | { const TEXT : & str = "HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH" ; super :: measure_standard_text (known_dimensions , available_space , TEXT , super :: WritingMode :: Horizontal) }) ,) . unwrap () ; + let node0 = taffy . new_leaf_with_measure (taffy :: style :: Style { .. Default :: default () } , taffy :: node :: MeasureFunc :: Raw (| known_dimensions , available_space | { const TEXT : & str = "HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH" ; super :: measure_standard_text (known_dimensions , available_space , TEXT , super :: WritingMode :: Horizontal , None) }) ,) . unwrap () ; let node = taffy .new_with_children( taffy::style::Style { diff --git a/benches/generated/measure_child_constraint_padding_parent.rs b/benches/generated/measure_child_constraint_padding_parent.rs index fe5b0749d..68c9a589f 100644 --- a/benches/generated/measure_child_constraint_padding_parent.rs +++ b/benches/generated/measure_child_constraint_padding_parent.rs @@ -2,7 +2,7 @@ pub fn compute() { #[allow(unused_imports)] use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); - let node0 = taffy . new_leaf_with_measure (taffy :: style :: Style { .. Default :: default () } , taffy :: node :: MeasureFunc :: Raw (| known_dimensions , available_space | { const TEXT : & str = "HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH" ; super :: measure_standard_text (known_dimensions , available_space , TEXT , super :: WritingMode :: Horizontal) }) ,) . unwrap () ; + let node0 = taffy . new_leaf_with_measure (taffy :: style :: Style { .. Default :: default () } , taffy :: node :: MeasureFunc :: Raw (| known_dimensions , available_space | { const TEXT : & str = "HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH" ; super :: measure_standard_text (known_dimensions , available_space , TEXT , super :: WritingMode :: Horizontal , None) }) ,) . unwrap () ; let node = taffy .new_with_children( taffy::style::Style { diff --git a/benches/generated/measure_child_with_flex_grow.rs b/benches/generated/measure_child_with_flex_grow.rs index 09371b72b..f4b66a311 100644 --- a/benches/generated/measure_child_with_flex_grow.rs +++ b/benches/generated/measure_child_with_flex_grow.rs @@ -16,7 +16,13 @@ pub fn compute() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "H\u{200b}H\u{200b}H\u{200b}H\u{200b}H"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/benches/generated/measure_child_with_flex_shrink.rs b/benches/generated/measure_child_with_flex_shrink.rs index 927888a5a..7955458a8 100644 --- a/benches/generated/measure_child_with_flex_shrink.rs +++ b/benches/generated/measure_child_with_flex_shrink.rs @@ -16,7 +16,13 @@ pub fn compute() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/benches/generated/measure_flex_basis_overrides_measure.rs b/benches/generated/measure_flex_basis_overrides_measure.rs index d994ed75a..16bd75d1b 100644 --- a/benches/generated/measure_flex_basis_overrides_measure.rs +++ b/benches/generated/measure_flex_basis_overrides_measure.rs @@ -7,7 +7,13 @@ pub fn compute() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "H"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/benches/generated/measure_height_overrides_measure.rs b/benches/generated/measure_height_overrides_measure.rs index 7902a8cf2..7e20f3339 100644 --- a/benches/generated/measure_height_overrides_measure.rs +++ b/benches/generated/measure_height_overrides_measure.rs @@ -10,7 +10,13 @@ pub fn compute() { }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "H"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/benches/generated/measure_remeasure_child_after_growing.rs b/benches/generated/measure_remeasure_child_after_growing.rs index 587f7778f..f3f03056a 100644 --- a/benches/generated/measure_remeasure_child_after_growing.rs +++ b/benches/generated/measure_remeasure_child_after_growing.rs @@ -16,7 +16,13 @@ pub fn compute() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/benches/generated/measure_remeasure_child_after_shrinking.rs b/benches/generated/measure_remeasure_child_after_shrinking.rs index c7190de2e..c670c7603 100644 --- a/benches/generated/measure_remeasure_child_after_shrinking.rs +++ b/benches/generated/measure_remeasure_child_after_shrinking.rs @@ -17,7 +17,13 @@ pub fn compute() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/benches/generated/measure_remeasure_child_after_stretching.rs b/benches/generated/measure_remeasure_child_after_stretching.rs index 938e14bb2..15f5ac9ca 100644 --- a/benches/generated/measure_remeasure_child_after_stretching.rs +++ b/benches/generated/measure_remeasure_child_after_stretching.rs @@ -7,7 +7,13 @@ pub fn compute() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/benches/generated/measure_root.rs b/benches/generated/measure_root.rs index eb3859e81..f1dc0ea5a 100644 --- a/benches/generated/measure_root.rs +++ b/benches/generated/measure_root.rs @@ -7,7 +7,13 @@ pub fn compute() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HHHHHH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/benches/generated/measure_stretch_overrides_measure.rs b/benches/generated/measure_stretch_overrides_measure.rs index 04d4832b4..2327aaef0 100644 --- a/benches/generated/measure_stretch_overrides_measure.rs +++ b/benches/generated/measure_stretch_overrides_measure.rs @@ -18,7 +18,13 @@ pub fn compute() { }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "H"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/benches/generated/measure_width_overrides_measure.rs b/benches/generated/measure_width_overrides_measure.rs index 302751bd3..418a858db 100644 --- a/benches/generated/measure_width_overrides_measure.rs +++ b/benches/generated/measure_width_overrides_measure.rs @@ -10,7 +10,13 @@ pub fn compute() { }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HHHHHHHHHH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/benches/generated/mod.rs b/benches/generated/mod.rs index 30c35db8b..14b307b64 100644 --- a/benches/generated/mod.rs +++ b/benches/generated/mod.rs @@ -11,6 +11,7 @@ fn measure_standard_text( available_space: taffy::geometry::Size, text_content: &str, writing_mode: WritingMode, + _aspect_ratio: Option, ) -> taffy::geometry::Size { use taffy::axis::AbsoluteAxis; use taffy::prelude::*; @@ -60,6 +61,17 @@ fn measure_standard_text( WritingMode::Vertical => Size { width: block_size, height: inline_size }, } } +mod absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset; +mod absolute_aspect_ratio_fill_height; +mod absolute_aspect_ratio_fill_height_from_inset; +mod absolute_aspect_ratio_fill_max_height; +mod absolute_aspect_ratio_fill_max_width; +mod absolute_aspect_ratio_fill_min_height; +mod absolute_aspect_ratio_fill_min_width; +mod absolute_aspect_ratio_fill_width; +mod absolute_aspect_ratio_fill_width_from_inset; +mod absolute_aspect_ratio_height_overrides_inset; +mod absolute_aspect_ratio_width_overrides_inset; mod absolute_layout_align_items_and_justify_content_center; mod absolute_layout_align_items_and_justify_content_center_and_bottom_position; mod absolute_layout_align_items_and_justify_content_center_and_left_position; @@ -81,6 +93,12 @@ mod absolute_layout_width_height_end_bottom; mod absolute_layout_width_height_start_top; mod absolute_layout_width_height_start_top_end_bottom; mod absolute_layout_within_border; +mod absolute_margin_bottom_left; +mod absolute_minmax_bottom_right_max; +mod absolute_minmax_bottom_right_min_max; +mod absolute_minmax_bottom_right_min_max_preferred; +mod absolute_minmax_top_left_bottom_right_max; +mod absolute_minmax_top_left_bottom_right_min_max; mod align_baseline; mod align_baseline_child_multiline; mod align_baseline_nested_child; @@ -111,6 +129,28 @@ mod align_self_flex_end; mod align_self_flex_end_override_flex_start; mod align_self_flex_start; mod align_stretch_should_size_based_on_parent; +mod aspect_ratio_flex_column_fill_height; +mod aspect_ratio_flex_column_fill_max_height; +mod aspect_ratio_flex_column_fill_max_width; +mod aspect_ratio_flex_column_fill_min_height; +mod aspect_ratio_flex_column_fill_min_width; +mod aspect_ratio_flex_column_fill_width; +mod aspect_ratio_flex_column_fill_width_flex; +mod aspect_ratio_flex_column_stretch_fill_height; +mod aspect_ratio_flex_column_stretch_fill_max_height; +mod aspect_ratio_flex_column_stretch_fill_max_width; +mod aspect_ratio_flex_column_stretch_fill_width; +mod aspect_ratio_flex_row_fill_height; +mod aspect_ratio_flex_row_fill_max_height; +mod aspect_ratio_flex_row_fill_max_width; +mod aspect_ratio_flex_row_fill_min_height; +mod aspect_ratio_flex_row_fill_min_width; +mod aspect_ratio_flex_row_fill_width; +mod aspect_ratio_flex_row_fill_width_flex; +mod aspect_ratio_flex_row_stretch_fill_height; +mod aspect_ratio_flex_row_stretch_fill_max_height; +mod aspect_ratio_flex_row_stretch_fill_max_width; +mod aspect_ratio_flex_row_stretch_fill_width; mod border_center_child; mod border_flex_child; mod border_no_child; @@ -118,10 +158,12 @@ mod border_stretch_child; mod child_min_max_width_flexing; mod container_with_unsized_child; mod display_none; +mod display_none_absolute_child; mod display_none_fixed_size; mod display_none_with_child; mod display_none_with_margin; mod display_none_with_position; +mod display_none_with_position_absolute; mod flex_basis_and_main_dimen_set_when_flexing; mod flex_basis_flex_grow_column; mod flex_basis_flex_grow_row; @@ -233,6 +275,10 @@ mod grid_absolute_container_top_right_margin; #[cfg(feature = "grid")] mod grid_absolute_justify_self_sized_all; #[cfg(feature = "grid")] +mod grid_absolute_layout_within_border; +#[cfg(feature = "grid")] +mod grid_absolute_layout_within_border_static; +#[cfg(feature = "grid")] mod grid_absolute_row_end; #[cfg(feature = "grid")] mod grid_absolute_row_start; @@ -275,6 +321,36 @@ mod grid_align_items_sized_stretch; #[cfg(feature = "grid")] mod grid_align_self_sized_all; #[cfg(feature = "grid")] +mod grid_aspect_ratio_absolute_aspect_ratio_overrides_height_of_full_inset; +#[cfg(feature = "grid")] +mod grid_aspect_ratio_absolute_fill_height_from_inset; +#[cfg(feature = "grid")] +mod grid_aspect_ratio_absolute_fill_width_from_inset; +#[cfg(feature = "grid")] +mod grid_aspect_ratio_absolute_height_overrides_inset; +#[cfg(feature = "grid")] +mod grid_aspect_ratio_absolute_width_overrides_inset; +#[cfg(feature = "grid")] +mod grid_aspect_ratio_child_fill_content_height; +#[cfg(feature = "grid")] +mod grid_aspect_ratio_child_fill_content_width; +#[cfg(feature = "grid")] +mod grid_aspect_ratio_fill_child_height; +#[cfg(feature = "grid")] +mod grid_aspect_ratio_fill_child_max_height; +#[cfg(feature = "grid")] +mod grid_aspect_ratio_fill_child_max_width; +#[cfg(feature = "grid")] +mod grid_aspect_ratio_fill_child_min_height; +#[cfg(feature = "grid")] +mod grid_aspect_ratio_fill_child_min_width; +#[cfg(feature = "grid")] +mod grid_aspect_ratio_fill_child_width; +#[cfg(feature = "grid")] +mod grid_aspect_ratio_overriden_by_explicit_sizes; +#[cfg(feature = "grid")] +mod grid_aspect_ratio_overriden_by_explicit_sizes_flex; +#[cfg(feature = "grid")] mod grid_auto_columns_fixed_width; #[cfg(feature = "grid")] mod grid_auto_fill_fixed_size; @@ -584,6 +660,17 @@ mod wrapped_row_within_align_items_flex_start; fn benchmark(c: &mut Criterion) { c.bench_function("generated benchmarks", |b| { b.iter(|| { + absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset::compute(); + absolute_aspect_ratio_fill_height::compute(); + absolute_aspect_ratio_fill_height_from_inset::compute(); + absolute_aspect_ratio_fill_max_height::compute(); + absolute_aspect_ratio_fill_max_width::compute(); + absolute_aspect_ratio_fill_min_height::compute(); + absolute_aspect_ratio_fill_min_width::compute(); + absolute_aspect_ratio_fill_width::compute(); + absolute_aspect_ratio_fill_width_from_inset::compute(); + absolute_aspect_ratio_height_overrides_inset::compute(); + absolute_aspect_ratio_width_overrides_inset::compute(); absolute_layout_align_items_and_justify_content_center::compute(); absolute_layout_align_items_and_justify_content_center_and_bottom_position::compute(); absolute_layout_align_items_and_justify_content_center_and_left_position::compute(); @@ -605,6 +692,12 @@ fn benchmark(c: &mut Criterion) { absolute_layout_width_height_start_top::compute(); absolute_layout_width_height_start_top_end_bottom::compute(); absolute_layout_within_border::compute(); + absolute_margin_bottom_left::compute(); + absolute_minmax_bottom_right_max::compute(); + absolute_minmax_bottom_right_min_max::compute(); + absolute_minmax_bottom_right_min_max_preferred::compute(); + absolute_minmax_top_left_bottom_right_max::compute(); + absolute_minmax_top_left_bottom_right_min_max::compute(); align_baseline::compute(); align_baseline_child_multiline::compute(); align_baseline_nested_child::compute(); @@ -635,6 +728,28 @@ fn benchmark(c: &mut Criterion) { align_self_flex_end_override_flex_start::compute(); align_self_flex_start::compute(); align_stretch_should_size_based_on_parent::compute(); + aspect_ratio_flex_column_fill_height::compute(); + aspect_ratio_flex_column_fill_max_height::compute(); + aspect_ratio_flex_column_fill_max_width::compute(); + aspect_ratio_flex_column_fill_min_height::compute(); + aspect_ratio_flex_column_fill_min_width::compute(); + aspect_ratio_flex_column_fill_width::compute(); + aspect_ratio_flex_column_fill_width_flex::compute(); + aspect_ratio_flex_column_stretch_fill_height::compute(); + aspect_ratio_flex_column_stretch_fill_max_height::compute(); + aspect_ratio_flex_column_stretch_fill_max_width::compute(); + aspect_ratio_flex_column_stretch_fill_width::compute(); + aspect_ratio_flex_row_fill_height::compute(); + aspect_ratio_flex_row_fill_max_height::compute(); + aspect_ratio_flex_row_fill_max_width::compute(); + aspect_ratio_flex_row_fill_min_height::compute(); + aspect_ratio_flex_row_fill_min_width::compute(); + aspect_ratio_flex_row_fill_width::compute(); + aspect_ratio_flex_row_fill_width_flex::compute(); + aspect_ratio_flex_row_stretch_fill_height::compute(); + aspect_ratio_flex_row_stretch_fill_max_height::compute(); + aspect_ratio_flex_row_stretch_fill_max_width::compute(); + aspect_ratio_flex_row_stretch_fill_width::compute(); border_center_child::compute(); border_flex_child::compute(); border_no_child::compute(); @@ -642,10 +757,12 @@ fn benchmark(c: &mut Criterion) { child_min_max_width_flexing::compute(); container_with_unsized_child::compute(); display_none::compute(); + display_none_absolute_child::compute(); display_none_fixed_size::compute(); display_none_with_child::compute(); display_none_with_margin::compute(); display_none_with_position::compute(); + display_none_with_position_absolute::compute(); flex_basis_and_main_dimen_set_when_flexing::compute(); flex_basis_flex_grow_column::compute(); flex_basis_flex_grow_row::compute(); @@ -757,6 +874,10 @@ fn benchmark(c: &mut Criterion) { #[cfg(feature = "grid")] grid_absolute_justify_self_sized_all::compute(); #[cfg(feature = "grid")] + grid_absolute_layout_within_border::compute(); + #[cfg(feature = "grid")] + grid_absolute_layout_within_border_static::compute(); + #[cfg(feature = "grid")] grid_absolute_row_end::compute(); #[cfg(feature = "grid")] grid_absolute_row_start::compute(); @@ -799,6 +920,36 @@ fn benchmark(c: &mut Criterion) { #[cfg(feature = "grid")] grid_align_self_sized_all::compute(); #[cfg(feature = "grid")] + grid_aspect_ratio_absolute_aspect_ratio_overrides_height_of_full_inset::compute(); + #[cfg(feature = "grid")] + grid_aspect_ratio_absolute_fill_height_from_inset::compute(); + #[cfg(feature = "grid")] + grid_aspect_ratio_absolute_fill_width_from_inset::compute(); + #[cfg(feature = "grid")] + grid_aspect_ratio_absolute_height_overrides_inset::compute(); + #[cfg(feature = "grid")] + grid_aspect_ratio_absolute_width_overrides_inset::compute(); + #[cfg(feature = "grid")] + grid_aspect_ratio_child_fill_content_height::compute(); + #[cfg(feature = "grid")] + grid_aspect_ratio_child_fill_content_width::compute(); + #[cfg(feature = "grid")] + grid_aspect_ratio_fill_child_height::compute(); + #[cfg(feature = "grid")] + grid_aspect_ratio_fill_child_max_height::compute(); + #[cfg(feature = "grid")] + grid_aspect_ratio_fill_child_max_width::compute(); + #[cfg(feature = "grid")] + grid_aspect_ratio_fill_child_min_height::compute(); + #[cfg(feature = "grid")] + grid_aspect_ratio_fill_child_min_width::compute(); + #[cfg(feature = "grid")] + grid_aspect_ratio_fill_child_width::compute(); + #[cfg(feature = "grid")] + grid_aspect_ratio_overriden_by_explicit_sizes::compute(); + #[cfg(feature = "grid")] + grid_aspect_ratio_overriden_by_explicit_sizes_flex::compute(); + #[cfg(feature = "grid")] grid_auto_columns_fixed_width::compute(); #[cfg(feature = "grid")] grid_auto_fill_fixed_size::compute(); diff --git a/scripts/gentest/src/main.rs b/scripts/gentest/src/main.rs index 7d43e7b06..06eb5e165 100644 --- a/scripts/gentest/src/main.rs +++ b/scripts/gentest/src/main.rs @@ -334,6 +334,13 @@ fn generate_node(ident: &str, node: &Value) -> TokenStream { } } + fn get_number_value<'a, 'b, 'c: 'b>(prop_name: &'a str, style: &'c Value) -> Option { + match style[prop_name.to_case(Case::Camel)] { + Value::Number(ref value) => Some(value.as_f64().unwrap() as f32), + _ => None, + } + } + fn quote_number_prop(prop_name: &str, style: &Value, quoter: impl Fn(f32) -> TokenStream) -> TokenStream { let prop_name_snake_case = prop_name.to_case(Case::Snake); let prop_name_camel_case = prop_name.to_case(Case::Camel); @@ -484,6 +491,7 @@ fn generate_node(ident: &str, node: &Value) -> TokenStream { let size = quote_object_prop("size", style, generate_size); let min_size = quote_object_prop("min_size", style, generate_size); let max_size = quote_object_prop("max_size", style, generate_size); + let aspect_ratio = quote_number_prop("aspect_ratio", style, |value: f32| quote!(Some(#value))); let gap = quote_object_prop("gap", style, generate_gap); @@ -525,7 +533,9 @@ fn generate_node(ident: &str, node: &Value) -> TokenStream { let text_content = get_string_value("text_content", node); let writing_mode = get_string_value("writingMode", style); - let measure_func: Option<_> = text_content.map(|text| generate_measure_function(text, writing_mode)); + let raw_aspect_ratio = get_number_value("aspect_ratio", style); + let measure_func: Option<_> = + text_content.map(|text| generate_measure_function(text, writing_mode, raw_aspect_ratio)); edges_quoted!(style, margin, generate_length_percentage_auto, quote!(zero())); edges_quoted!(style, padding, generate_length_percentage, quote!(zero())); @@ -583,6 +593,7 @@ fn generate_node(ident: &str, node: &Value) -> TokenStream { #size #min_size #max_size + #aspect_ratio #margin #padding #inset @@ -834,6 +845,7 @@ fn generate_generic_measure_function() -> TokenStream { available_space: taffy::geometry::Size, text_content: &str, writing_mode: WritingMode, + _aspect_ratio: Option, ) -> taffy::geometry::Size { use taffy::axis::AbsoluteAxis; use taffy::prelude::*; @@ -891,16 +903,21 @@ fn generate_generic_measure_function() -> TokenStream { ) } -fn generate_measure_function(text_content: &str, writing_mode: Option<&str>) -> TokenStream { +fn generate_measure_function(text_content: &str, writing_mode: Option<&str>, aspect_ratio: Option) -> TokenStream { let writing_mode_token = match writing_mode { Some("vertical-rl" | "vertical-lr") => quote!(super::WritingMode::Vertical), _ => quote!(super::WritingMode::Horizontal), }; + let aspect_ratio_token = match aspect_ratio { + Some(ratio) => quote!(Some(#ratio)), + None => quote!(None), + }; + quote!( taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT : &str = #text_content; - super::measure_standard_text(known_dimensions, available_space, TEXT, #writing_mode_token) + super::measure_standard_text(known_dimensions, available_space, TEXT, #writing_mode_token, #aspect_ratio_token) }) ) } diff --git a/scripts/gentest/test_helper.js b/scripts/gentest/test_helper.js index 8a75ea4f6..070f55906 100644 --- a/scripts/gentest/test_helper.js +++ b/scripts/gentest/test_helper.js @@ -103,6 +103,20 @@ function parseNumber(input) { return Number(input); } +function parseRatio(input) { + if (!input) return undefined; + + if (input.includes('/')) { + let [width, height] = input.split("/").map(part => parseFloat(part.trim())); + if (!width || width < 0 || !height || height <= 0) return undefined; + return width / height; + } + + let ratio = parseFloat(input); + if (!ratio || ratio < 0) return undefined; + return ratio; +} + function parseEnum(input) { if (input) return input; return undefined; @@ -200,6 +214,7 @@ function describeElement(e) { size: parseSize({width: e.style.width, height: e.style.height}), minSize: parseSize({width: e.style.minWidth, height: e.style.minHeight}), maxSize: parseSize({width: e.style.maxWidth, height: e.style.maxHeight}), + aspectRatio: parseRatio(e.style.aspectRatio), margin: parseEdges({ left: e.style.marginLeft, diff --git a/src/compute/flexbox.rs b/src/compute/flexbox.rs index 185deb233..da92c3b31 100644 --- a/src/compute/flexbox.rs +++ b/src/compute/flexbox.rs @@ -16,6 +16,7 @@ use crate::style::{ LengthPercentageAuto, Position, }; use crate::style::{FlexDirection, Style}; +use crate::sys::f32_max; use crate::sys::Vec; use crate::tree::LayoutTree; @@ -208,7 +209,7 @@ fn compute_preliminary( // 3. Determine the flex base size and hypothetical main size of each item. #[cfg(feature = "debug")] NODE_LOGGER.log("determine_flex_base_size"); - determine_flex_base_size(tree, known_dimensions, &constants, available_space, &mut flex_items); + determine_flex_base_size(tree, &constants, available_space, &mut flex_items); #[cfg(feature = "debug")] for item in flex_items.iter() { @@ -219,7 +220,9 @@ fn compute_preliminary( NODE_LOGGER.labelled_debug_log("item.resolved_minimum_size", item.resolved_minimum_size); } - // TODO: Add step 4 according to spec: https://www.w3.org/TR/css-flexbox-1/#algo-main-container + // 4. Determine the main size of the flex container + // This has already been done as part of compute_constants. The inner size is exposed as constants.node_inner_size. + // 9.3. Main Size Determination // 5. Collect flex items into flex lines. @@ -247,8 +250,7 @@ fn compute_preliminary( resolve_flexible_lengths(tree, line, &constants, original_gap); } - // TODO: Cleanup and make according to spec - // Not part of the spec from what i can see but seems correct + // Find the inner and outer used main_size of the container constants.container_size.set_main( constants.dir, known_dimensions.main(constants.dir).unwrap_or({ @@ -261,7 +263,6 @@ fn compute_preliminary( } }), ); - constants.inner_container_size.set_main( constants.dir, constants.container_size.main(constants.dir) - constants.padding_border.main_axis_sum(constants.dir), @@ -389,25 +390,25 @@ fn compute_constants( let is_column = dir.is_column(); let is_wrap_reverse = style.flex_wrap == FlexWrap::WrapReverse; + let aspect_ratio = style.aspect_ratio; + let size = style.size.maybe_resolve(parent_size).maybe_apply_aspect_ratio(aspect_ratio); + let min_size = style.size.maybe_resolve(parent_size).maybe_apply_aspect_ratio(aspect_ratio); + let max_size = style.size.maybe_resolve(parent_size).maybe_apply_aspect_ratio(aspect_ratio); + let margin = style.margin.resolve_or_zero(parent_size.width); let padding = style.padding.resolve_or_zero(parent_size.width); let border = style.border.resolve_or_zero(parent_size.width); let align_items = style.align_items.unwrap_or(crate::style::AlignItems::Stretch); - let padding_border = Rect { - left: padding.left + border.left, - right: padding.right + border.right, - top: padding.top + border.top, - bottom: padding.bottom + border.bottom, - }; + let padding_border = padding + border; let node_outer_size = Size { width: known_dimensions .width - .or_else(|| style.size.width.maybe_resolve(parent_size.width).maybe_sub(margin.horizontal_axis_sum())), - height: known_dimensions - .height - .or_else(|| style.size.height.maybe_resolve(parent_size.height).maybe_sub(margin.vertical_axis_sum())), + .or_else(|| size.width.maybe_sub(margin.horizontal_axis_sum()).maybe_clamp(min_size.width, max_size.width)), + height: known_dimensions.height.or_else(|| { + size.height.maybe_sub(margin.vertical_axis_sum()).maybe_clamp(min_size.height, max_size.height) + }), }; let node_inner_size = Size { @@ -446,32 +447,41 @@ fn generate_anonymous_flex_items(tree: &impl LayoutTree, node: Node, constants: .map(|child| (child, tree.style(*child))) .filter(|(_, style)| style.position != Position::Absolute) .filter(|(_, style)| style.display != Display::None) - .map(|(child, child_style)| FlexItem { - node: *child, - size: child_style.size.maybe_resolve(constants.node_inner_size), - min_size: child_style.min_size.maybe_resolve(constants.node_inner_size), - max_size: child_style.max_size.maybe_resolve(constants.node_inner_size), - - inset: child_style.inset.zip_size(constants.node_inner_size, |p, s| p.maybe_resolve(s)), - margin: child_style.margin.resolve_or_zero(constants.node_inner_size.width), - padding: child_style.padding.resolve_or_zero(constants.node_inner_size.width), - border: child_style.border.resolve_or_zero(constants.node_inner_size.width), - align_self: child_style.align_self.unwrap_or(constants.align_items), - flex_basis: 0.0, - inner_flex_basis: 0.0, - violation: 0.0, - frozen: false, - - resolved_minimum_size: Size::zero(), - hypothetical_inner_size: Size::zero(), - hypothetical_outer_size: Size::zero(), - target_size: Size::zero(), - outer_target_size: Size::zero(), - - baseline: 0.0, - - offset_main: 0.0, - offset_cross: 0.0, + .map(|(child, child_style)| { + let aspect_ratio = child_style.aspect_ratio; + FlexItem { + node: *child, + size: child_style.size.maybe_resolve(constants.node_inner_size).maybe_apply_aspect_ratio(aspect_ratio), + min_size: child_style + .min_size + .maybe_resolve(constants.node_inner_size) + .maybe_apply_aspect_ratio(aspect_ratio), + max_size: child_style + .max_size + .maybe_resolve(constants.node_inner_size) + .maybe_apply_aspect_ratio(aspect_ratio), + + inset: child_style.inset.zip_size(constants.node_inner_size, |p, s| p.maybe_resolve(s)), + margin: child_style.margin.resolve_or_zero(constants.node_inner_size.width), + padding: child_style.padding.resolve_or_zero(constants.node_inner_size.width), + border: child_style.border.resolve_or_zero(constants.node_inner_size.width), + align_self: child_style.align_self.unwrap_or(constants.align_items), + flex_basis: 0.0, + inner_flex_basis: 0.0, + violation: 0.0, + frozen: false, + + resolved_minimum_size: Size::zero(), + hypothetical_inner_size: Size::zero(), + hypothetical_outer_size: Size::zero(), + target_size: Size::zero(), + outer_target_size: Size::zero(), + + baseline: 0.0, + + offset_main: 0.0, + offset_cross: 0.0, + } }) .collect() } @@ -541,36 +551,29 @@ fn determine_available_space( #[inline] fn determine_flex_base_size( tree: &mut impl LayoutTree, - node_size: Size>, constants: &AlgoConstants, available_space: Size, flex_items: &mut Vec, ) { - // TODO - this does not follow spec. See the TODOs below for child in flex_items.iter_mut() { let child_style = tree.style(child.node); // A. If the item has a definite used flex basis, that’s the flex base size. - let flex_basis = child_style.flex_basis.maybe_resolve(constants.node_inner_size.main(constants.dir)); - if flex_basis.is_some() { - child.flex_basis = flex_basis.unwrap_or(0.0); - continue; - }; - // B. If the flex item has an intrinsic aspect ratio, // a used flex basis of content, and a definite cross size, // then the flex base size is calculated from its inner // cross size and the flex item’s intrinsic aspect ratio. - if let Some(ratio) = child_style.aspect_ratio { - if let Some(cross) = node_size.cross(constants.dir) { - if child_style.flex_basis == Dimension::Auto { - child.flex_basis = cross * ratio; - continue; - } - } - } + // Note: `child.size` has already been resolved against aspect_ratio in generate_anonymous_flex_items + // So B will just work here by using main_size without special handling for aspect_ratio + + let flex_basis = child_style.flex_basis.maybe_resolve(constants.node_inner_size.main(constants.dir)); + let main_size = child.size.main(constants.dir); + if let Some(flex_basis) = flex_basis.or(main_size) { + child.flex_basis = flex_basis; + continue; + }; // C. If the used flex basis is content or depends on its available space, // and the flex container is being sized under a min-content or max-content @@ -578,7 +581,8 @@ fn determine_flex_base_size( // size the item under that constraint. The flex base size is the item’s // resulting main size. - // TODO - Probably need to cover this case in future + // This is covered by the implementation of E below, which passes the available_space constraint + // through to the child size computation. It may need a separate implementation if/when D is implemented. // D. Otherwise, if the used flex basis is content or depends on its // available space, the available main size is infinite, and the flex item’s @@ -586,7 +590,7 @@ fn determine_flex_base_size( // for a box in an orthogonal flow [CSS3-WRITING-MODES]. The flex base size // is the item’s max-content main size. - // TODO - Probably need to cover this case in future + // TODO if/when vertical writing modes are supported // E. Otherwise, size the item into the available space using its used flex basis // in place of its main size, treating a value of content as max-content. @@ -640,13 +644,10 @@ fn determine_flex_base_size( // 4.5. Automatic Minimum Size of Flex Items // https://www.w3.org/TR/css-flexbox-1/#min-size-auto - let specified = child.size.maybe_min(child.max_size); - child.resolved_minimum_size = child.min_size.unwrap_or(min_content_size.maybe_min(specified)); + child.resolved_minimum_size = + child.min_size.unwrap_or(min_content_size.maybe_min(child.size).maybe_min(child.max_size)); - let hypothetical_inner_min_main = min_content_size - .main(constants.dir) - .maybe_clamp(child.resolved_minimum_size.main(constants.dir).into(), child.size.main(constants.dir)) - .into(); + let hypothetical_inner_min_main = child.resolved_minimum_size.main(constants.dir).into(); child.hypothetical_inner_size.set_main( constants.dir, child.flex_basis.maybe_clamp(hypothetical_inner_min_main, child.max_size.main(constants.dir)), @@ -782,7 +783,6 @@ fn resolve_flexible_lengths( // TODO this should really only be set inside the if-statement below but // that causes the target_main_size to never be set for some items - child .outer_target_size .set_main(constants.dir, child.target_size.main(constants.dir) + child.margin.main_axis_sum(constants.dir)); @@ -1187,8 +1187,15 @@ fn determine_used_cross_size(tree: &mut impl LayoutTree, flex_lines: &mut [FlexL && child_style.margin.cross_end(constants.dir) != LengthPercentageAuto::Auto && child_style.size.cross(constants.dir) == Dimension::Auto { - (line_cross_size - child.margin.cross_axis_sum(constants.dir)) - .maybe_clamp(child.min_size.cross(constants.dir), child.max_size.cross(constants.dir)) + // For some reason this particular usage of max_width is an exception to the rule that max_width's transfer + // using the aspect_ratio (if set). Both Chrome and Firefox agree on this. And reading the spec, it seems like + // a reasonable interpretation. Although it seems to me that the spec *should* apply aspect_ratio here. + let max_size_ignoring_aspect_ratio = child_style.max_size.maybe_resolve(constants.node_inner_size); + + (line_cross_size - child.margin.cross_axis_sum(constants.dir)).maybe_clamp( + child.min_size.cross(constants.dir), + max_size_ignoring_aspect_ratio.cross(constants.dir), + ) } else { child.hypothetical_inner_size.cross(constants.dir) }, @@ -1579,157 +1586,183 @@ fn final_layout_pass(tree: &mut impl LayoutTree, node: Node, flex_lines: &mut [F /// Perform absolute layout on all absolutely positioned children. #[inline] fn perform_absolute_layout_on_absolute_children(tree: &mut impl LayoutTree, node: Node, constants: &AlgoConstants) { - // TODO: remove number of Vec<_> generated - let candidates = tree - .children(node) - .cloned() - .enumerate() - .filter(|(_, child)| tree.style(*child).position == Position::Absolute) - .collect::>(); - - for (order, child) in candidates { - let container_width = constants.container_size.width; - let container_height = constants.container_size.height; + let container_width = constants.container_size.width; + let container_height = constants.container_size.height; + for order in 0..tree.child_count(node) { + let child = tree.child(node, order); let child_style = tree.style(child); - // X-axis - let child_position_start = child_style.inset.left.maybe_resolve(container_width); - let child_margin_start = child_style.margin.left.maybe_resolve(container_width); - let start = child_position_start.maybe_add(child_margin_start); - - let child_position_end = child_style.inset.right.maybe_resolve(container_width); - let child_margin_end = child_style.margin.right.maybe_resolve(container_width); - let end = child_position_end.maybe_add(child_margin_end); - - // Y-axis - let child_position_top = child_style.inset.top.maybe_resolve(container_height); - let child_margin_top = child_style.margin.top.maybe_resolve(container_height); - let top = child_position_top.maybe_add(child_margin_top); + // Skip items that are display:none or are not position:absolute + if child_style.display == Display::None || child_style.position != Position::Absolute { + continue; + } - let child_position_bottom = child_style.inset.bottom.maybe_resolve(container_height); - let child_margin_bottom = child_style.margin.bottom.maybe_resolve(container_height); - let bottom = child_position_bottom.maybe_add(child_margin_bottom); + let aspect_ratio = child_style.aspect_ratio; + let margin = child_style.margin.map(|margin| margin.resolve_to_option(container_width)); + let align_self = child_style.align_self.unwrap_or(constants.align_items); - let (start_main, end_main) = if constants.is_row { (start, end) } else { (top, bottom) }; - let (start_cross, end_cross) = if constants.is_row { (top, bottom) } else { (start, end) }; + // Resolve inset + let left = child_style.inset.left.maybe_resolve(container_width); + let right = child_style.inset.right.maybe_resolve(container_width); + let top = child_style.inset.top.maybe_resolve(container_height); + let bottom = child_style.inset.bottom.maybe_resolve(container_height); // Compute known dimensions from min/max/inherent size styles - let style_size = child_style.size.maybe_resolve(constants.container_size); - let min_size = child_style.min_size.maybe_resolve(constants.container_size); - let max_size = child_style.max_size.maybe_resolve(constants.container_size); + let style_size = + child_style.size.maybe_resolve(constants.container_size).maybe_apply_aspect_ratio(aspect_ratio); + let min_size = + child_style.min_size.maybe_resolve(constants.container_size).maybe_apply_aspect_ratio(aspect_ratio); + let max_size = + child_style.max_size.maybe_resolve(constants.container_size).maybe_apply_aspect_ratio(aspect_ratio); let mut known_dimensions = style_size.maybe_clamp(min_size, max_size); - // Fill in width from left/right and height from top/bottom is appropriate - if known_dimensions.width.is_none() && start.is_some() && end.is_some() { - known_dimensions.width = Some(container_width.maybe_sub(start).maybe_sub(end)); + // Fill in width from left/right and reapply aspect ratio if: + // - Width is not already known + // - Item has both left and right inset properties set + if let (None, Some(left), Some(right)) = (known_dimensions.width, left, right) { + let new_width_raw = container_width.maybe_sub(margin.left).maybe_sub(margin.right) - left - right; + known_dimensions.width = Some(f32_max(new_width_raw, 0.0)); + known_dimensions = known_dimensions.maybe_apply_aspect_ratio(aspect_ratio).maybe_clamp(min_size, max_size); } - if known_dimensions.height.is_none() && top.is_some() && bottom.is_some() { - known_dimensions.height = Some(container_height.maybe_sub(top).maybe_sub(bottom)); + + // Fill in height from top/bottom and reapply aspect ratio if: + // - Height is not already known + // - Item has both top and bottom inset properties set + if let (None, Some(top), Some(bottom)) = (known_dimensions.height, top, bottom) { + let new_height_raw = container_height.maybe_sub(margin.top).maybe_sub(margin.bottom) - top - bottom; + known_dimensions.height = Some(f32_max(new_height_raw, 0.0)); + known_dimensions = known_dimensions.maybe_apply_aspect_ratio(aspect_ratio).maybe_clamp(min_size, max_size); } - let preliminary_size = compute_node_layout( + let measured_size = compute_node_layout( tree, child, known_dimensions, constants.node_inner_size, Size { - width: AvailableSpace::Definite(container_width), - height: AvailableSpace::Definite(container_height), + width: AvailableSpace::Definite(container_width.maybe_clamp(min_size.width, max_size.width)), + height: AvailableSpace::Definite(container_height.maybe_clamp(min_size.height, max_size.height)), }, RunMode::PeformLayout, SizingMode::ContentSize, ); + let final_size = known_dimensions.unwrap_or(measured_size).maybe_clamp(min_size, max_size); - // Satisfy the borrow checker by re-requesting the style from above. - // This shortens the lifetime of the original binding - let child_style = tree.style(child); + let non_auto_margin = margin.map(|m| m.unwrap_or(0.0)); - let free_main_space = constants.container_size.main(constants.dir) - - preliminary_size - .main(constants.dir) - .maybe_max( - child_style - .min_size - .main(constants.dir) - .maybe_resolve(constants.node_inner_size.main(constants.dir)), - ) - .maybe_min( - child_style - .max_size - .main(constants.dir) - .maybe_resolve(constants.node_inner_size.main(constants.dir)), - ); + let free_space = Size { + width: constants.container_size.width - final_size.width - non_auto_margin.horizontal_axis_sum(), + height: constants.container_size.height - final_size.height - non_auto_margin.vertical_axis_sum(), + } + .f32_max(Size::ZERO); + + // Expand auto margins to fill available space + let resolved_margin = { + let auto_margin_size = Size { + width: { + let auto_margin_count = margin.left.is_none() as u8 + margin.right.is_none() as u8; + if auto_margin_count > 0 { + free_space.width / auto_margin_count as f32 + } else { + 0.0 + } + }, + height: { + let auto_margin_count = margin.top.is_none() as u8 + margin.bottom.is_none() as u8; + if auto_margin_count > 0 { + free_space.height / auto_margin_count as f32 + } else { + 0.0 + } + }, + }; - let free_cross_space = constants.container_size.cross(constants.dir) - - preliminary_size - .cross(constants.dir) - .maybe_max( - child_style - .min_size - .cross(constants.dir) - .maybe_resolve(constants.node_inner_size.cross(constants.dir)), - ) - .maybe_min( - child_style - .max_size - .cross(constants.dir) - .maybe_resolve(constants.node_inner_size.cross(constants.dir)), - ); + Rect { + left: margin.left.unwrap_or(auto_margin_size.width), + right: margin.right.unwrap_or(auto_margin_size.width), + top: margin.top.unwrap_or(auto_margin_size.height), + bottom: margin.bottom.unwrap_or(auto_margin_size.height), + } + }; - let offset_main = if start_main.is_some() { - start_main.unwrap_or(0.0) + constants.border.main_start(constants.dir) - } else if end_main.is_some() { - free_main_space - end_main.unwrap_or(0.0) - constants.border.main_end(constants.dir) + // Determine flex-relative insets + let (start_main, end_main) = if constants.is_row { (left, right) } else { (top, bottom) }; + let (start_cross, end_cross) = if constants.is_row { (top, bottom) } else { (left, right) }; + + // Apply main-axis alignment + // let free_main_space = free_space.main(constants.dir) - resolved_margin.main_axis_sum(constants.dir); + let offset_main = if let Some(start) = start_main { + start + constants.border.main_start(constants.dir) + resolved_margin.main_start(constants.dir) + } else if let Some(end) = end_main { + constants.container_size.main(constants.dir) + - constants.border.main_end(constants.dir) + - final_size.main(constants.dir) + - end + - resolved_margin.main_end(constants.dir) } else { match tree.style(node).justify_content.unwrap_or(JustifyContent::Start) { // Stretch is an invalid value for justify_content in the flexbox algorithm, so we // treat it as if it wasn't set (and thus we default to FlexStart behaviour) JustifyContent::SpaceBetween | JustifyContent::Start | JustifyContent::Stretch => { - constants.padding_border.main_start(constants.dir) + constants.padding_border.main_start(constants.dir) + resolved_margin.main_start(constants.dir) + } + JustifyContent::End => { + constants.container_size.main(constants.dir) + - constants.padding_border.main_end(constants.dir) + - final_size.main(constants.dir) + - resolved_margin.main_end(constants.dir) } - JustifyContent::End => free_main_space - constants.padding_border.main_end(constants.dir), JustifyContent::SpaceEvenly | JustifyContent::SpaceAround | JustifyContent::Center => { - free_main_space / 2.0 + (constants.container_size.main(constants.dir) + constants.padding_border.main_start(constants.dir) + - constants.padding_border.main_end(constants.dir) + - final_size.main(constants.dir) + + resolved_margin.main_start(constants.dir) + - resolved_margin.main_end(constants.dir)) + / 2.0 } } }; - let offset_cross = if start_cross.is_some() { - start_cross.unwrap_or(0.0) + constants.border.cross_start(constants.dir) - } else if end_cross.is_some() { - free_cross_space - end_cross.unwrap_or(0.0) - constants.border.cross_end(constants.dir) + // Apply cross-axis alignment + // let free_cross_space = free_space.cross(constants.dir) - resolved_margin.cross_axis_sum(constants.dir); + let offset_cross = if let Some(start) = start_cross { + start + constants.border.cross_start(constants.dir) + resolved_margin.cross_start(constants.dir) + } else if let Some(end) = end_cross { + constants.container_size.cross(constants.dir) + - constants.border.cross_end(constants.dir) + - final_size.cross(constants.dir) + - end + - resolved_margin.cross_end(constants.dir) } else { - match child_style.align_self.unwrap_or(constants.align_items) { - AlignSelf::Start => { - if constants.is_wrap_reverse { - free_cross_space - constants.padding_border.cross_end(constants.dir) - } else { - constants.padding_border.cross_start(constants.dir) - } + match (align_self, constants.is_wrap_reverse) { + // Stretch alignment does not apply to absolutely positioned items + // See "Example 3" at https://www.w3.org/TR/css-flexbox-1/#abspos-items + // Note: Stretch should be FlexStart not Start when we support both + (AlignSelf::Baseline | AlignSelf::Stretch | AlignSelf::Start, false) | (AlignSelf::End, true) => { + constants.padding_border.cross_start(constants.dir) + resolved_margin.cross_start(constants.dir) } - AlignSelf::End => { - if constants.is_wrap_reverse { - constants.padding_border.cross_start(constants.dir) - } else { - free_cross_space - constants.padding_border.cross_end(constants.dir) - } + (AlignSelf::Baseline | AlignSelf::Stretch | AlignSelf::Start, true) | (AlignSelf::End, false) => { + constants.container_size.cross(constants.dir) + - constants.padding_border.cross_end(constants.dir) + - final_size.cross(constants.dir) + - resolved_margin.cross_end(constants.dir) } - AlignSelf::Center => free_cross_space / 2.0, - AlignSelf::Baseline => free_cross_space / 2.0, // Treat as center for now until we have baseline support - AlignSelf::Stretch => { - if constants.is_wrap_reverse { - free_cross_space - constants.padding_border.cross_end(constants.dir) - } else { - constants.padding_border.cross_start(constants.dir) - } + (AlignSelf::Center, _) => { + (constants.container_size.cross(constants.dir) + + constants.padding_border.cross_start(constants.dir) + - constants.padding_border.cross_end(constants.dir) + - final_size.cross(constants.dir) + + resolved_margin.cross_start(constants.dir) + - resolved_margin.cross_end(constants.dir)) + / 2.0 } } }; *tree.layout_mut(child) = Layout { order: order as u32, - size: preliminary_size, + size: final_size, location: Point { x: if constants.is_row { offset_main } else { offset_cross }, y: if constants.is_column { offset_main } else { offset_cross }, @@ -1758,8 +1791,8 @@ mod tests { #![allow(clippy::redundant_clone)] use crate::{ + geometry::Size, math::MaybeMath, - prelude::{Rect, Size}, resolve::ResolveOrZero, style::{FlexWrap, Style}, Taffy, @@ -1777,7 +1810,6 @@ mod tests { let parent_size = Size::NONE; let constants = super::compute_constants(tree.style(node_id).unwrap(), node_size, parent_size); - // let constants = super::compute_constants(&tree.nodes[node_id], node_size, parent_size); assert!(constants.dir == style.flex_direction); assert!(constants.is_row == style.flex_direction.is_row()); @@ -1788,21 +1820,11 @@ mod tests { assert_eq!(constants.margin, margin); let border = style.border.resolve_or_zero(parent_size); - assert_eq!(constants.border, border); - let padding = style.padding.resolve_or_zero(parent_size); - - // TODO: Replace with something less hardcoded? - let padding_border = Rect { - left: padding.left + border.left, - right: padding.right + border.right, - top: padding.top + border.top, - bottom: padding.bottom + border.bottom, - }; - + let padding_border = padding + border; + assert_eq!(constants.border, border); assert_eq!(constants.padding_border, padding_border); - // TODO: Replace with something less hardcoded? let inner_size = Size { width: node_size.width.maybe_sub(padding_border.horizontal_axis_sum()), height: node_size.height.maybe_sub(padding_border.vertical_axis_sum()), diff --git a/src/compute/grid/alignment.rs b/src/compute/grid/alignment.rs index 44e377c87..cd8cf13f2 100644 --- a/src/compute/grid/alignment.rs +++ b/src/compute/grid/alignment.rs @@ -87,14 +87,17 @@ pub(super) fn align_and_position_item( let position = style.position; let inset_horizontal = style.inset.horizontal_components().map(|size| size.resolve_to_option(grid_area_size.width)); let inset_vertical = style.inset.vertical_components().map(|size| size.resolve_to_option(grid_area_size.height)); - let inherent_size = style.size.maybe_resolve(grid_area_size); - let min_size = style.min_size.maybe_resolve(grid_area_size); - let max_size = style.max_size.maybe_resolve(grid_area_size); + let inherent_size = style.size.maybe_resolve(grid_area_size).maybe_apply_aspect_ratio(aspect_ratio); + let min_size = style.min_size.maybe_resolve(grid_area_size).maybe_apply_aspect_ratio(aspect_ratio); + let max_size = style.max_size.maybe_resolve(grid_area_size).maybe_apply_aspect_ratio(aspect_ratio); // Resolve default alignment styles if they are set on neither the parent or the node itself + // Note: if the child has a preferred aspect ratio but neither width or height are set, then the width is stretched + // and the then height is calculated from the width according the aspect ratio + // See: https://www.w3.org/TR/css-grid-1/#grid-item-sizing let alignment_styles = InBothAbsAxis { horizontal: container_alignment_styles.horizontal.or(justify_self).unwrap_or_else(|| { - if inherent_size.width.is_some() || aspect_ratio.is_some() { + if inherent_size.width.is_some() { AlignSelf::Start } else { AlignSelf::Stretch @@ -124,11 +127,11 @@ pub(super) fn align_and_position_item( // positioned element being set if position == Position::Absolute { if let (Some(left), Some(right)) = (inset_horizontal.start, inset_horizontal.end) { - return Some(f32_max(grid_area_size.width - left - right, 0.0)); + return Some(f32_max(grid_area_minus_item_margins_size.width - left - right, 0.0)); } } - // Apply width based on stretch alignment (clamped by max size) if: + // Apply width based on stretch alignment if: // - Alignment style is "stretch" // - The node is not absolutely positioned // - The node does not have auto margins in this axis. @@ -137,19 +140,22 @@ pub(super) fn align_and_position_item( && alignment_styles.horizontal == AlignSelf::Stretch && position != Position::Absolute { - return Some(grid_area_minus_item_margins_size.width.maybe_min(max_size.width).maybe_max(min_size.width)); + return Some(grid_area_minus_item_margins_size.width); } None }); - let height = inherent_size.height.or_else(|| { + // Reapply aspect ratio after stretch and absolute position width adjustments + let Size { width, height } = Size { width, height: inherent_size.height }.maybe_apply_aspect_ratio(aspect_ratio); + + let height = height.or_else(|| { if position == Position::Absolute { if let (Some(top), Some(bottom)) = (inset_vertical.start, inset_vertical.end) { - return Some(f32_max(grid_area_size.height - top - bottom, 0.0)); + return Some(f32_max(grid_area_minus_item_margins_size.height - top - bottom, 0.0)); } } - // Apply height based on stretch alignment (clamped by max size) if: + // Apply height based on stretch alignment if: // - Alignment style is "stretch" // - The node is not absolutely positioned // - The node does not have auto margins in this axis. @@ -158,13 +164,16 @@ pub(super) fn align_and_position_item( && alignment_styles.vertical == AlignSelf::Stretch && position != Position::Absolute { - return Some( - grid_area_minus_item_margins_size.height.maybe_min(max_size.height).maybe_max(min_size.height), - ); + return Some(grid_area_minus_item_margins_size.height); } None }); + // Reapply aspect ratio after stretch and absolute position height adjustments + let Size { width, height } = Size { width, height }.maybe_apply_aspect_ratio(aspect_ratio); + + // Clamp size by min and max width/height + let Size { width, height } = Size { width, height }.maybe_clamp(min_size, max_size); // Layout node let measured_size = compute_node_layout( @@ -177,20 +186,21 @@ pub(super) fn align_and_position_item( SizingMode::InherentSize, ); - let (x, width) = align_and_size_item_within_area( + // Resolve final size + let Size { width, height } = Size { width, height }.unwrap_or(measured_size).maybe_clamp(min_size, max_size); + + let x = align_item_within_area( Line { start: grid_area.left, end: grid_area.right }, justify_self.unwrap_or(alignment_styles.horizontal), width, - measured_size.width, position, inset_horizontal, margin.horizontal_components(), ); - let (y, height) = align_and_size_item_within_area( + let y = align_item_within_area( Line { start: grid_area.top, end: grid_area.bottom }, align_self.unwrap_or(alignment_styles.vertical), height, - measured_size.height, position, inset_vertical, margin.vertical_components(), @@ -200,19 +210,18 @@ pub(super) fn align_and_position_item( } /// Align and size a grid item along a single axis -pub(super) fn align_and_size_item_within_area( +pub(super) fn align_item_within_area( grid_area: Line, alignment_style: AlignSelf, - style_size: Option, - measured_size: f32, + resolved_size: f32, position: Position, inset: Line>, margin: Line>, -) -> (f32, f32) { +) -> f32 { // Calculate grid area dimension in the axis let non_auto_margin = Line { start: margin.start.unwrap_or(0.0), end: margin.end.unwrap_or(0.0) }; let grid_area_size = f32_max(grid_area.end - grid_area.start, 0.0); - let free_space = f32_max(grid_area_size - style_size.unwrap_or(measured_size) - non_auto_margin.sum(), 0.0); + let free_space = f32_max(grid_area_size - resolved_size - non_auto_margin.sum(), 0.0); // Expand auto margins to fill available space let auto_margin_count = margin.start.is_none() as u8 + margin.end.is_none() as u8; @@ -220,20 +229,11 @@ pub(super) fn align_and_size_item_within_area( let resolved_margin = Line { start: margin.start.unwrap_or(auto_margin_size), end: margin.end.unwrap_or(auto_margin_size) }; - // Compute size in the axis - let size = style_size.unwrap_or_else(|| { - if alignment_style == AlignItems::Stretch && position != Position::Absolute { - f32_max(grid_area_size - resolved_margin.sum(), measured_size) - } else { - measured_size - } - }); - // Compute offset in the axis let alignment_based_offset = match alignment_style { AlignSelf::Start => resolved_margin.start, - AlignSelf::End => grid_area_size - size - resolved_margin.end, - AlignSelf::Center => (grid_area_size - size + resolved_margin.start - resolved_margin.end) / 2.0, + AlignSelf::End => grid_area_size - resolved_size - resolved_margin.end, + AlignSelf::Center => (grid_area_size - resolved_size + resolved_margin.start - resolved_margin.end) / 2.0, // TODO: Add support for baseline alignment. For now we treat it as "start". AlignSelf::Baseline => resolved_margin.start, AlignSelf::Stretch => resolved_margin.start, @@ -243,7 +243,7 @@ pub(super) fn align_and_size_item_within_area( if let Some(start) = inset.start { start + non_auto_margin.start } else if let Some(end) = inset.end { - grid_area_size - end - size - non_auto_margin.end + grid_area_size - end - resolved_size - non_auto_margin.end } else { alignment_based_offset } @@ -256,5 +256,5 @@ pub(super) fn align_and_size_item_within_area( start += inset.start.or(inset.end.map(|pos| -pos)).unwrap_or(0.0); } - (start, size) + start } diff --git a/src/compute/grid/mod.rs b/src/compute/grid/mod.rs index 529dadaff..5cca095ce 100644 --- a/src/compute/grid/mod.rs +++ b/src/compute/grid/mod.rs @@ -105,9 +105,10 @@ pub fn compute( let padding = style.padding.resolve_or_zero(parent_size.width); let border = style.border.resolve_or_zero(parent_size.width); let margin = style.margin.resolve_or_zero(parent_size.width); - let min_size = style.min_size.maybe_resolve(parent_size); - let max_size = style.max_size.maybe_resolve(parent_size); - let size = style.size.maybe_resolve(parent_size); + let aspect_ratio = style.aspect_ratio; + let min_size = style.min_size.maybe_resolve(parent_size).maybe_apply_aspect_ratio(aspect_ratio); + let max_size = style.max_size.maybe_resolve(parent_size).maybe_apply_aspect_ratio(aspect_ratio); + let size = style.size.maybe_resolve(parent_size).maybe_apply_aspect_ratio(aspect_ratio); let constrained_available_space = size .maybe_clamp(min_size, max_size) @@ -324,10 +325,16 @@ pub fn compute( }); let grid_area = Rect { - top: maybe_row_indexes.start.map(|index| rows[index].offset).unwrap_or(0.0), - bottom: maybe_row_indexes.end.map(|index| rows[index].offset).unwrap_or(container_border_box.height), - left: maybe_col_indexes.start.map(|index| columns[index].offset).unwrap_or(0.0), - right: maybe_col_indexes.end.map(|index| columns[index].offset).unwrap_or(container_border_box.width), + top: maybe_row_indexes.start.map(|index| rows[index].offset).unwrap_or(border.top), + bottom: maybe_row_indexes + .end + .map(|index| rows[index].offset) + .unwrap_or(container_border_box.height - border.bottom), + left: maybe_col_indexes.start.map(|index| columns[index].offset).unwrap_or(border.left), + right: maybe_col_indexes + .end + .map(|index| columns[index].offset) + .unwrap_or(container_border_box.width - border.right), }; align_and_position_item(tree, child, order, grid_area, container_alignment_styles); order += 1; diff --git a/src/compute/grid/types/grid_item.rs b/src/compute/grid/types/grid_item.rs index b38d84b15..fcd76cd41 100644 --- a/src/compute/grid/types/grid_item.rs +++ b/src/compute/grid/types/grid_item.rs @@ -241,12 +241,18 @@ impl GridItem { ) -> f32 { self.minimum_contribution_cache.unwrap_or_else(|| { let style = tree.style(self.node); - let axis_available_space = available_space.get(axis).into_option(); style .size + .maybe_resolve(available_space.into_options()) + .maybe_apply_aspect_ratio(style.aspect_ratio) .get(axis) - .maybe_resolve(axis_available_space) - .or_else(|| style.min_size.get(axis).maybe_resolve(axis_available_space)) + .or_else(|| { + style + .min_size + .maybe_resolve(available_space.into_options()) + .maybe_apply_aspect_ratio(style.aspect_ratio) + .get(axis) + }) .unwrap_or_else(|| { // Automatic minimum size. See https://www.w3.org/TR/css-grid-1/#min-size-auto diff --git a/src/compute/leaf.rs b/src/compute/leaf.rs index 4b06360a0..9257c10d1 100644 --- a/src/compute/leaf.rs +++ b/src/compute/leaf.rs @@ -6,6 +6,7 @@ use crate::math::MaybeMath; use crate::node::Node; use crate::resolve::{MaybeResolve, ResolveOrZero}; use crate::style::AvailableSpace; +use crate::sys::f32_max; use crate::tree::LayoutTree; #[cfg(feature = "debug")] @@ -25,19 +26,21 @@ pub(crate) fn compute( // Resolve node's preferred/min/max sizes (width/heights) against the available space (percentages resolve to pixel values) // For ContentSize mode, we pretend that the node has no size styles as these should be ignored. - let (node_size, node_min_size, node_max_size) = match sizing_mode { + let (node_size, node_min_size, node_max_size, aspect_ratio) = match sizing_mode { SizingMode::ContentSize => { let node_size = known_dimensions; let node_min_size = Size::NONE; let node_max_size = Size::NONE; - (node_size, node_min_size, node_max_size) + (node_size, node_min_size, node_max_size, None) } SizingMode::InherentSize => { - let style_size = style.size.maybe_resolve(parent_size); + let aspect_ratio = style.aspect_ratio; + let style_size = style.size.maybe_resolve(parent_size).maybe_apply_aspect_ratio(aspect_ratio); + let style_min_size = style.min_size.maybe_resolve(parent_size).maybe_apply_aspect_ratio(aspect_ratio); + let style_max_size = style.max_size.maybe_resolve(parent_size).maybe_apply_aspect_ratio(aspect_ratio); + let node_size = known_dimensions.or(style_size); - let node_min_size = style.min_size.maybe_resolve(parent_size); - let node_max_size = style.max_size.maybe_resolve(parent_size); - (node_size, node_min_size, node_max_size) + (node_size, style_min_size, style_max_size, aspect_ratio) } }; @@ -73,6 +76,11 @@ pub(crate) fn compute( // Measure node let measured_size = tree.measure_node(node, known_dimensions, available_space); + let measured_size = Size { + width: measured_size.width, + height: f32_max(measured_size.height, aspect_ratio.map(|ratio| measured_size.width / ratio).unwrap_or(0.0)), + }; + return node_size.unwrap_or(measured_size).maybe_clamp(node_min_size, node_max_size); } diff --git a/src/geometry.rs b/src/geometry.rs index 0d1590b64..3df769443 100644 --- a/src/geometry.rs +++ b/src/geometry.rs @@ -1,6 +1,7 @@ //! Geometric primitives useful for layout use crate::style::{Dimension, FlexDirection}; +use crate::sys::f32_max; use core::ops::Add; #[cfg(feature = "grid")] @@ -42,6 +43,19 @@ impl Default for Rect { } } +impl> Add> for Rect { + type Output = Rect; + + fn add(self, rhs: Rect) -> Self::Output { + Rect { + left: self.left + rhs.left, + right: self.right + rhs.right, + top: self.top + rhs.top, + bottom: self.bottom + rhs.bottom, + } + } +} + impl Rect { /// Applies the function `f` to all four sides of the rect /// @@ -354,6 +368,11 @@ impl Size { impl Size { /// A [`Size`] with zero width and height pub const ZERO: Size = Self { width: 0.0, height: 0.0 }; + + /// Applies f32_max to each component separately + pub fn f32_max(self, rhs: Size) -> Size { + Size { width: f32_max(self.width, rhs.width), height: f32_max(self.height, rhs.height) } + } } impl Size> { @@ -365,6 +384,22 @@ impl Size> { pub const fn new(width: f32, height: f32) -> Self { Size { width: Some(width), height: Some(height) } } + + /// Applies aspect_ratio (if one is supplied) to the Size: + /// - If width is `Some` but height is `None`, then height is computed from width and aspect_ratio + /// - If height is `Some` but width is `None`, then width is computed from height and aspect_ratio + /// + /// If aspect_ratio is `None` then this function simply returns self. + pub fn maybe_apply_aspect_ratio(self, aspect_ratio: Option) -> Size> { + match aspect_ratio { + Some(ratio) => match (self.width, self.height) { + (Some(width), None) => Size { width: Some(width), height: Some(width / ratio) }, + (None, Some(height)) => Size { width: Some(height * ratio), height: Some(height) }, + _ => self, + }, + None => self, + } + } } impl Size> { diff --git a/test_fixtures/absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset.html b/test_fixtures/absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset.html new file mode 100644 index 000000000..b3510e54d --- /dev/null +++ b/test_fixtures/absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/absolute_aspect_ratio_fill_height.html b/test_fixtures/absolute_aspect_ratio_fill_height.html new file mode 100644 index 000000000..8b681acf9 --- /dev/null +++ b/test_fixtures/absolute_aspect_ratio_fill_height.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/absolute_aspect_ratio_fill_height_from_inset.html b/test_fixtures/absolute_aspect_ratio_fill_height_from_inset.html new file mode 100644 index 000000000..f38e94965 --- /dev/null +++ b/test_fixtures/absolute_aspect_ratio_fill_height_from_inset.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/absolute_aspect_ratio_fill_max_height.html b/test_fixtures/absolute_aspect_ratio_fill_max_height.html new file mode 100644 index 000000000..cbeea766d --- /dev/null +++ b/test_fixtures/absolute_aspect_ratio_fill_max_height.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
HHHH​HHHH​HHHH​HHHH​HHHH​HHHH​HHHH​HHHH​HHHH
+
+ + + \ No newline at end of file diff --git a/test_fixtures/absolute_aspect_ratio_fill_max_width.html b/test_fixtures/absolute_aspect_ratio_fill_max_width.html new file mode 100644 index 000000000..aaab17279 --- /dev/null +++ b/test_fixtures/absolute_aspect_ratio_fill_max_width.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
HHHH​HHHH​HHHH​HHHH​HHHH​HHHH​HHHH​HHHH​HHHH
+
+ + + \ No newline at end of file diff --git a/test_fixtures/absolute_aspect_ratio_fill_min_height.html b/test_fixtures/absolute_aspect_ratio_fill_min_height.html new file mode 100644 index 000000000..4c6b72080 --- /dev/null +++ b/test_fixtures/absolute_aspect_ratio_fill_min_height.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/absolute_aspect_ratio_fill_min_width.html b/test_fixtures/absolute_aspect_ratio_fill_min_width.html new file mode 100644 index 000000000..a5d5fcfc3 --- /dev/null +++ b/test_fixtures/absolute_aspect_ratio_fill_min_width.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/absolute_aspect_ratio_fill_width.html b/test_fixtures/absolute_aspect_ratio_fill_width.html new file mode 100644 index 000000000..f5e3d5e13 --- /dev/null +++ b/test_fixtures/absolute_aspect_ratio_fill_width.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/absolute_aspect_ratio_fill_width_from_inset.html b/test_fixtures/absolute_aspect_ratio_fill_width_from_inset.html new file mode 100644 index 000000000..423325007 --- /dev/null +++ b/test_fixtures/absolute_aspect_ratio_fill_width_from_inset.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/absolute_aspect_ratio_height_overrides_inset.html b/test_fixtures/absolute_aspect_ratio_height_overrides_inset.html new file mode 100644 index 000000000..75c82ed09 --- /dev/null +++ b/test_fixtures/absolute_aspect_ratio_height_overrides_inset.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/absolute_aspect_ratio_width_overrides_inset.html b/test_fixtures/absolute_aspect_ratio_width_overrides_inset.html new file mode 100644 index 000000000..eb25a576b --- /dev/null +++ b/test_fixtures/absolute_aspect_ratio_width_overrides_inset.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/absolute_margin_bottom_left.html b/test_fixtures/absolute_margin_bottom_left.html new file mode 100644 index 000000000..7a4480e6f --- /dev/null +++ b/test_fixtures/absolute_margin_bottom_left.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/absolute_minmax_bottom_right_max.html b/test_fixtures/absolute_minmax_bottom_right_max.html new file mode 100644 index 000000000..49b90d674 --- /dev/null +++ b/test_fixtures/absolute_minmax_bottom_right_max.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/absolute_minmax_bottom_right_min_max.html b/test_fixtures/absolute_minmax_bottom_right_min_max.html new file mode 100644 index 000000000..16898105a --- /dev/null +++ b/test_fixtures/absolute_minmax_bottom_right_min_max.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/absolute_minmax_bottom_right_min_max_preferred.html b/test_fixtures/absolute_minmax_bottom_right_min_max_preferred.html new file mode 100644 index 000000000..a1a27952a --- /dev/null +++ b/test_fixtures/absolute_minmax_bottom_right_min_max_preferred.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/absolute_minmax_top_left_bottom_right_max.html b/test_fixtures/absolute_minmax_top_left_bottom_right_max.html new file mode 100644 index 000000000..0c2bf8aa2 --- /dev/null +++ b/test_fixtures/absolute_minmax_top_left_bottom_right_max.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/absolute_minmax_top_left_bottom_right_min_max.html b/test_fixtures/absolute_minmax_top_left_bottom_right_min_max.html new file mode 100644 index 000000000..d29b9f0c6 --- /dev/null +++ b/test_fixtures/absolute_minmax_top_left_bottom_right_min_max.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/aspect_ratio_flex_column_fill_height.html b/test_fixtures/aspect_ratio_flex_column_fill_height.html new file mode 100644 index 000000000..9b3e62690 --- /dev/null +++ b/test_fixtures/aspect_ratio_flex_column_fill_height.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/aspect_ratio_flex_column_fill_max_height.html b/test_fixtures/aspect_ratio_flex_column_fill_max_height.html new file mode 100644 index 000000000..c3c08ae72 --- /dev/null +++ b/test_fixtures/aspect_ratio_flex_column_fill_max_height.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
HH​HH​HH​HH​HH​HH​HH​HH​HH​HH​HH
+
+ + + \ No newline at end of file diff --git a/test_fixtures/aspect_ratio_flex_column_fill_max_width.html b/test_fixtures/aspect_ratio_flex_column_fill_max_width.html new file mode 100644 index 000000000..8b5996b8d --- /dev/null +++ b/test_fixtures/aspect_ratio_flex_column_fill_max_width.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
HH​HH​HH​HH
+
+ + + \ No newline at end of file diff --git a/test_fixtures/aspect_ratio_flex_column_fill_min_height.html b/test_fixtures/aspect_ratio_flex_column_fill_min_height.html new file mode 100644 index 000000000..dfc6580b3 --- /dev/null +++ b/test_fixtures/aspect_ratio_flex_column_fill_min_height.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/aspect_ratio_flex_column_fill_min_width.html b/test_fixtures/aspect_ratio_flex_column_fill_min_width.html new file mode 100644 index 000000000..78434d38a --- /dev/null +++ b/test_fixtures/aspect_ratio_flex_column_fill_min_width.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+ +
+
+ + + \ No newline at end of file diff --git a/test_fixtures/aspect_ratio_flex_column_fill_width.html b/test_fixtures/aspect_ratio_flex_column_fill_width.html new file mode 100644 index 000000000..2a401a098 --- /dev/null +++ b/test_fixtures/aspect_ratio_flex_column_fill_width.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/aspect_ratio_flex_column_fill_width_flex.html b/test_fixtures/aspect_ratio_flex_column_fill_width_flex.html new file mode 100644 index 000000000..2714b744d --- /dev/null +++ b/test_fixtures/aspect_ratio_flex_column_fill_width_flex.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/aspect_ratio_flex_column_stretch_fill_height.html b/test_fixtures/aspect_ratio_flex_column_stretch_fill_height.html new file mode 100644 index 000000000..cd2d48b10 --- /dev/null +++ b/test_fixtures/aspect_ratio_flex_column_stretch_fill_height.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/aspect_ratio_flex_column_stretch_fill_max_height.html b/test_fixtures/aspect_ratio_flex_column_stretch_fill_max_height.html new file mode 100644 index 000000000..c57582db0 --- /dev/null +++ b/test_fixtures/aspect_ratio_flex_column_stretch_fill_max_height.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
HH​HH​HH​HH​HH​HH​HH​HH​HH​HH​HH
+
+ + + \ No newline at end of file diff --git a/test_fixtures/aspect_ratio_flex_column_stretch_fill_max_width.html b/test_fixtures/aspect_ratio_flex_column_stretch_fill_max_width.html new file mode 100644 index 000000000..2343fe878 --- /dev/null +++ b/test_fixtures/aspect_ratio_flex_column_stretch_fill_max_width.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
HH​HH​HH​HH
+
+ + + \ No newline at end of file diff --git a/test_fixtures/aspect_ratio_flex_column_stretch_fill_width.html b/test_fixtures/aspect_ratio_flex_column_stretch_fill_width.html new file mode 100644 index 000000000..b1c3100d6 --- /dev/null +++ b/test_fixtures/aspect_ratio_flex_column_stretch_fill_width.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/aspect_ratio_flex_row_fill_height.html b/test_fixtures/aspect_ratio_flex_row_fill_height.html new file mode 100644 index 000000000..d4b52a8d2 --- /dev/null +++ b/test_fixtures/aspect_ratio_flex_row_fill_height.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/aspect_ratio_flex_row_fill_max_height.html b/test_fixtures/aspect_ratio_flex_row_fill_max_height.html new file mode 100644 index 000000000..7d50d7826 --- /dev/null +++ b/test_fixtures/aspect_ratio_flex_row_fill_max_height.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
HH​HH​HH​HH​HH​HH​HH​HH​HH​HH​HH
+
+ + + \ No newline at end of file diff --git a/test_fixtures/aspect_ratio_flex_row_fill_max_width.html b/test_fixtures/aspect_ratio_flex_row_fill_max_width.html new file mode 100644 index 000000000..12a94733c --- /dev/null +++ b/test_fixtures/aspect_ratio_flex_row_fill_max_width.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
HH​HH​HH​HH
+
+ + + \ No newline at end of file diff --git a/test_fixtures/aspect_ratio_flex_row_fill_min_height.html b/test_fixtures/aspect_ratio_flex_row_fill_min_height.html new file mode 100644 index 000000000..fb8aef515 --- /dev/null +++ b/test_fixtures/aspect_ratio_flex_row_fill_min_height.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/aspect_ratio_flex_row_fill_min_width.html b/test_fixtures/aspect_ratio_flex_row_fill_min_width.html new file mode 100644 index 000000000..b92f16218 --- /dev/null +++ b/test_fixtures/aspect_ratio_flex_row_fill_min_width.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+ +
+
+ + + \ No newline at end of file diff --git a/test_fixtures/aspect_ratio_flex_row_fill_width.html b/test_fixtures/aspect_ratio_flex_row_fill_width.html new file mode 100644 index 000000000..dfe5c09e9 --- /dev/null +++ b/test_fixtures/aspect_ratio_flex_row_fill_width.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/aspect_ratio_flex_row_fill_width_flex.html b/test_fixtures/aspect_ratio_flex_row_fill_width_flex.html new file mode 100644 index 000000000..84c3b5e6b --- /dev/null +++ b/test_fixtures/aspect_ratio_flex_row_fill_width_flex.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/aspect_ratio_flex_row_stretch_fill_height.html b/test_fixtures/aspect_ratio_flex_row_stretch_fill_height.html new file mode 100644 index 000000000..b1785946f --- /dev/null +++ b/test_fixtures/aspect_ratio_flex_row_stretch_fill_height.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/aspect_ratio_flex_row_stretch_fill_max_height.html b/test_fixtures/aspect_ratio_flex_row_stretch_fill_max_height.html new file mode 100644 index 000000000..e5302432e --- /dev/null +++ b/test_fixtures/aspect_ratio_flex_row_stretch_fill_max_height.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
HH​HH​HH​HH​HH​HH​HH​HH​HH​HH​HH
+
+ + + \ No newline at end of file diff --git a/test_fixtures/aspect_ratio_flex_row_stretch_fill_max_width.html b/test_fixtures/aspect_ratio_flex_row_stretch_fill_max_width.html new file mode 100644 index 000000000..08c6727b8 --- /dev/null +++ b/test_fixtures/aspect_ratio_flex_row_stretch_fill_max_width.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
HH​HH​HH​HH
+
+ + + \ No newline at end of file diff --git a/test_fixtures/aspect_ratio_flex_row_stretch_fill_width.html b/test_fixtures/aspect_ratio_flex_row_stretch_fill_width.html new file mode 100644 index 000000000..1afa1ffc2 --- /dev/null +++ b/test_fixtures/aspect_ratio_flex_row_stretch_fill_width.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/display_none_absolute_child.html b/test_fixtures/display_none_absolute_child.html new file mode 100644 index 000000000..fccdd23d3 --- /dev/null +++ b/test_fixtures/display_none_absolute_child.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/display_none_with_position_absolute.html b/test_fixtures/display_none_with_position_absolute.html new file mode 100644 index 000000000..6d7eee4a6 --- /dev/null +++ b/test_fixtures/display_none_with_position_absolute.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_absolute_layout_within_border.html b/test_fixtures/grid_absolute_layout_within_border.html new file mode 100644 index 000000000..1470c383f --- /dev/null +++ b/test_fixtures/grid_absolute_layout_within_border.html @@ -0,0 +1,20 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_absolute_layout_within_border_static.html b/test_fixtures/grid_absolute_layout_within_border_static.html new file mode 100644 index 000000000..b3fc38395 --- /dev/null +++ b/test_fixtures/grid_absolute_layout_within_border_static.html @@ -0,0 +1,20 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_aspect_ratio_absolute_aspect_ratio_overrides_height_of_full_inset.html b/test_fixtures/grid_aspect_ratio_absolute_aspect_ratio_overrides_height_of_full_inset.html new file mode 100644 index 000000000..94b2c4a43 --- /dev/null +++ b/test_fixtures/grid_aspect_ratio_absolute_aspect_ratio_overrides_height_of_full_inset.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_aspect_ratio_absolute_fill_height_from_inset.html b/test_fixtures/grid_aspect_ratio_absolute_fill_height_from_inset.html new file mode 100644 index 000000000..e30d0ffa7 --- /dev/null +++ b/test_fixtures/grid_aspect_ratio_absolute_fill_height_from_inset.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_aspect_ratio_absolute_fill_width_from_inset.html b/test_fixtures/grid_aspect_ratio_absolute_fill_width_from_inset.html new file mode 100644 index 000000000..423325007 --- /dev/null +++ b/test_fixtures/grid_aspect_ratio_absolute_fill_width_from_inset.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_aspect_ratio_absolute_height_overrides_inset.html b/test_fixtures/grid_aspect_ratio_absolute_height_overrides_inset.html new file mode 100644 index 000000000..75c82ed09 --- /dev/null +++ b/test_fixtures/grid_aspect_ratio_absolute_height_overrides_inset.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_aspect_ratio_absolute_width_overrides_inset.html b/test_fixtures/grid_aspect_ratio_absolute_width_overrides_inset.html new file mode 100644 index 000000000..77b5d38aa --- /dev/null +++ b/test_fixtures/grid_aspect_ratio_absolute_width_overrides_inset.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_aspect_ratio_child_fill_content_height.html b/test_fixtures/grid_aspect_ratio_child_fill_content_height.html new file mode 100644 index 000000000..d914fd152 --- /dev/null +++ b/test_fixtures/grid_aspect_ratio_child_fill_content_height.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
HHHH
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_aspect_ratio_child_fill_content_width.html b/test_fixtures/grid_aspect_ratio_child_fill_content_width.html new file mode 100644 index 000000000..db240459c --- /dev/null +++ b/test_fixtures/grid_aspect_ratio_child_fill_content_width.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
HHHH
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_aspect_ratio_fill_child_height.html b/test_fixtures/grid_aspect_ratio_fill_child_height.html new file mode 100644 index 000000000..c0e301774 --- /dev/null +++ b/test_fixtures/grid_aspect_ratio_fill_child_height.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_aspect_ratio_fill_child_max_height.html b/test_fixtures/grid_aspect_ratio_fill_child_max_height.html new file mode 100644 index 000000000..6abb462d4 --- /dev/null +++ b/test_fixtures/grid_aspect_ratio_fill_child_max_height.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
HH​HH​HH​HH​HH​HH
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_aspect_ratio_fill_child_max_width.html b/test_fixtures/grid_aspect_ratio_fill_child_max_width.html new file mode 100644 index 000000000..d6ebcf5d7 --- /dev/null +++ b/test_fixtures/grid_aspect_ratio_fill_child_max_width.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
HH​HH​HH​HH
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_aspect_ratio_fill_child_min_height.html b/test_fixtures/grid_aspect_ratio_fill_child_min_height.html new file mode 100644 index 000000000..908d5907f --- /dev/null +++ b/test_fixtures/grid_aspect_ratio_fill_child_min_height.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_aspect_ratio_fill_child_min_width.html b/test_fixtures/grid_aspect_ratio_fill_child_min_width.html new file mode 100644 index 000000000..2a30c8f10 --- /dev/null +++ b/test_fixtures/grid_aspect_ratio_fill_child_min_width.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+ +
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_aspect_ratio_fill_child_width.html b/test_fixtures/grid_aspect_ratio_fill_child_width.html new file mode 100644 index 000000000..37acb9990 --- /dev/null +++ b/test_fixtures/grid_aspect_ratio_fill_child_width.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_aspect_ratio_overriden_by_explicit_sizes.html b/test_fixtures/grid_aspect_ratio_overriden_by_explicit_sizes.html new file mode 100644 index 000000000..f01c566e0 --- /dev/null +++ b/test_fixtures/grid_aspect_ratio_overriden_by_explicit_sizes.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_aspect_ratio_overriden_by_explicit_sizes_flex.html b/test_fixtures/grid_aspect_ratio_overriden_by_explicit_sizes_flex.html new file mode 100644 index 000000000..f01c566e0 --- /dev/null +++ b/test_fixtures/grid_aspect_ratio_overriden_by_explicit_sizes_flex.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/xaspect_ratio_flex_column_stretch_fill_min_height.html b/test_fixtures/xaspect_ratio_flex_column_stretch_fill_min_height.html new file mode 100644 index 000000000..f4c783987 --- /dev/null +++ b/test_fixtures/xaspect_ratio_flex_column_stretch_fill_min_height.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/xaspect_ratio_flex_column_stretch_fill_min_width.html b/test_fixtures/xaspect_ratio_flex_column_stretch_fill_min_width.html new file mode 100644 index 000000000..9def9017d --- /dev/null +++ b/test_fixtures/xaspect_ratio_flex_column_stretch_fill_min_width.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+ +
+
+ + + \ No newline at end of file diff --git a/test_fixtures/xaspect_ratio_flex_row_stretch_fill_min_height.html b/test_fixtures/xaspect_ratio_flex_row_stretch_fill_min_height.html new file mode 100644 index 000000000..051d88c56 --- /dev/null +++ b/test_fixtures/xaspect_ratio_flex_row_stretch_fill_min_height.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/xaspect_ratio_flex_row_stretch_fill_min_width.html b/test_fixtures/xaspect_ratio_flex_row_stretch_fill_min_width.html new file mode 100644 index 000000000..d86f6aa42 --- /dev/null +++ b/test_fixtures/xaspect_ratio_flex_row_stretch_fill_min_width.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+ +
+
+ + + \ No newline at end of file diff --git a/tests/generated/absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset.rs b/tests/generated/absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset.rs new file mode 100644 index 000000000..26b9c034b --- /dev/null +++ b/tests/generated/absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset.rs @@ -0,0 +1,47 @@ +#[test] +fn absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.05f32), + right: taffy::style::LengthPercentageAuto::Percent(0.05f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.05f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(400f32), + height: taffy::style::Dimension::Points(300f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 400f32, size.width); + assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 300f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 360f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 360f32, size.width); + assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 120f32, size.height); + assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 20f32, location.x); + assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 15f32, location.y); +} diff --git a/tests/generated/absolute_aspect_ratio_fill_height.rs b/tests/generated/absolute_aspect_ratio_fill_height.rs new file mode 100644 index 000000000..6f15c88f9 --- /dev/null +++ b/tests/generated/absolute_aspect_ratio_fill_height.rs @@ -0,0 +1,48 @@ +#[test] +fn absolute_aspect_ratio_fill_height() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.5f32), height: auto() }, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.05f32), + right: auto(), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: auto(), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(400f32), + height: taffy::style::Dimension::Points(300f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 400f32, size.width); + assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 300f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 200f32, size.width); + assert_eq!(size.height, 67f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 67f32, size.height); + assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 20f32, location.x); + assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 15f32, location.y); +} diff --git a/tests/generated/absolute_aspect_ratio_fill_height_from_inset.rs b/tests/generated/absolute_aspect_ratio_fill_height_from_inset.rs new file mode 100644 index 000000000..55718abc0 --- /dev/null +++ b/tests/generated/absolute_aspect_ratio_fill_height_from_inset.rs @@ -0,0 +1,47 @@ +#[test] +fn absolute_aspect_ratio_fill_height_from_inset() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.1f32), + right: taffy::style::LengthPercentageAuto::Percent(0.1f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: auto(), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(400f32), + height: taffy::style::Dimension::Points(300f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 400f32, size.width); + assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 300f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 320f32, size.width); + assert_eq!(size.height, 107f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 107f32, size.height); + assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 40f32, location.x); + assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 15f32, location.y); +} diff --git a/tests/generated/absolute_aspect_ratio_fill_max_height.rs b/tests/generated/absolute_aspect_ratio_fill_max_height.rs new file mode 100644 index 000000000..4eb2afcbd --- /dev/null +++ b/tests/generated/absolute_aspect_ratio_fill_max_height.rs @@ -0,0 +1,35 @@ +#[test] +fn absolute_aspect_ratio_fill_max_height() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy . new_leaf_with_measure (taffy :: style :: Style { position : taffy :: style :: Position :: Absolute , max_size : taffy :: geometry :: Size { width : taffy :: style :: Dimension :: Points (50f32) , height : auto () , } , aspect_ratio : Some (3f32) , .. Default :: default () } , taffy :: node :: MeasureFunc :: Raw (| known_dimensions , available_space | { const TEXT : & str = "HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH" ; super :: measure_standard_text (known_dimensions , available_space , TEXT , super :: WritingMode :: Horizontal , Some (3f32)) }) ,) . unwrap () ; + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(400f32), + height: taffy::style::Dimension::Points(300f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 400f32, size.width); + assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 300f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 50f32, size.width); + assert_eq!(size.height, 17f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 17f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y); +} diff --git a/tests/generated/absolute_aspect_ratio_fill_max_width.rs b/tests/generated/absolute_aspect_ratio_fill_max_width.rs new file mode 100644 index 000000000..b5174abec --- /dev/null +++ b/tests/generated/absolute_aspect_ratio_fill_max_width.rs @@ -0,0 +1,35 @@ +#[test] +fn absolute_aspect_ratio_fill_max_width() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy . new_leaf_with_measure (taffy :: style :: Style { position : taffy :: style :: Position :: Absolute , max_size : taffy :: geometry :: Size { width : auto () , height : taffy :: style :: Dimension :: Points (50f32) , } , aspect_ratio : Some (0.5f32) , .. Default :: default () } , taffy :: node :: MeasureFunc :: Raw (| known_dimensions , available_space | { const TEXT : & str = "HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH" ; super :: measure_standard_text (known_dimensions , available_space , TEXT , super :: WritingMode :: Horizontal , Some (0.5f32)) }) ,) . unwrap () ; + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(400f32), + height: taffy::style::Dimension::Points(300f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 400f32, size.width); + assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 300f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 25f32, size.width); + assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 50f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y); +} diff --git a/tests/generated/absolute_aspect_ratio_fill_min_height.rs b/tests/generated/absolute_aspect_ratio_fill_min_height.rs new file mode 100644 index 000000000..939b47849 --- /dev/null +++ b/tests/generated/absolute_aspect_ratio_fill_min_height.rs @@ -0,0 +1,42 @@ +#[test] +fn absolute_aspect_ratio_fill_min_height() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() }, + aspect_ratio: Some(3f32), + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(400f32), + height: taffy::style::Dimension::Points(300f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 400f32, size.width); + assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 300f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 50f32, size.width); + assert_eq!(size.height, 17f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 17f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y); +} diff --git a/tests/generated/absolute_aspect_ratio_fill_min_width.rs b/tests/generated/absolute_aspect_ratio_fill_min_width.rs new file mode 100644 index 000000000..e91f28059 --- /dev/null +++ b/tests/generated/absolute_aspect_ratio_fill_min_width.rs @@ -0,0 +1,42 @@ +#[test] +fn absolute_aspect_ratio_fill_min_width() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(50f32) }, + aspect_ratio: Some(0.5f32), + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(400f32), + height: taffy::style::Dimension::Points(300f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 400f32, size.width); + assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 300f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 25f32, size.width); + assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 50f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y); +} diff --git a/tests/generated/absolute_aspect_ratio_fill_width.rs b/tests/generated/absolute_aspect_ratio_fill_width.rs new file mode 100644 index 000000000..a69a193fb --- /dev/null +++ b/tests/generated/absolute_aspect_ratio_fill_width.rs @@ -0,0 +1,48 @@ +#[test] +fn absolute_aspect_ratio_fill_width() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.2f32) }, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.05f32), + right: auto(), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: auto(), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(400f32), + height: taffy::style::Dimension::Points(300f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 400f32, size.width); + assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 300f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 180f32, size.width); + assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 60f32, size.height); + assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 20f32, location.x); + assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 15f32, location.y); +} diff --git a/tests/generated/absolute_aspect_ratio_fill_width_from_inset.rs b/tests/generated/absolute_aspect_ratio_fill_width_from_inset.rs new file mode 100644 index 000000000..b7e8c524e --- /dev/null +++ b/tests/generated/absolute_aspect_ratio_fill_width_from_inset.rs @@ -0,0 +1,47 @@ +#[test] +fn absolute_aspect_ratio_fill_width_from_inset() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Percent(0.3f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.5f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(400f32), + height: taffy::style::Dimension::Points(300f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 400f32, size.width); + assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 300f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 180f32, size.width); + assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 60f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 90f32, location.y); +} diff --git a/tests/generated/absolute_aspect_ratio_height_overrides_inset.rs b/tests/generated/absolute_aspect_ratio_height_overrides_inset.rs new file mode 100644 index 000000000..5c2165548 --- /dev/null +++ b/tests/generated/absolute_aspect_ratio_height_overrides_inset.rs @@ -0,0 +1,48 @@ +#[test] +fn absolute_aspect_ratio_height_overrides_inset() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.1f32) }, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Percent(0.3f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.5f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(400f32), + height: taffy::style::Dimension::Points(300f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 400f32, size.width); + assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 300f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 90f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 90f32, size.width); + assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 30f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 90f32, location.y); +} diff --git a/tests/generated/absolute_aspect_ratio_width_overrides_inset.rs b/tests/generated/absolute_aspect_ratio_width_overrides_inset.rs new file mode 100644 index 000000000..97a8052ea --- /dev/null +++ b/tests/generated/absolute_aspect_ratio_width_overrides_inset.rs @@ -0,0 +1,48 @@ +#[test] +fn absolute_aspect_ratio_width_overrides_inset() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.4f32), height: auto() }, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.1f32), + right: taffy::style::LengthPercentageAuto::Percent(0.1f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: auto(), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(400f32), + height: taffy::style::Dimension::Points(300f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 400f32, size.width); + assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 300f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 160f32, size.width); + assert_eq!(size.height, 53f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 53f32, size.height); + assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 40f32, location.x); + assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 15f32, location.y); +} diff --git a/tests/generated/absolute_margin_bottom_left.rs b/tests/generated/absolute_margin_bottom_left.rs new file mode 100644 index 000000000..7061fbcc4 --- /dev/null +++ b/tests/generated/absolute_margin_bottom_left.rs @@ -0,0 +1,51 @@ +#[test] +fn absolute_margin_bottom_left() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + flex_direction: taffy::style::FlexDirection::Column, + justify_content: Some(taffy::style::JustifyContent::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 10f32, size.width); + assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 10f32, size.height); + assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 10f32, location.x); + assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 80f32, location.y); +} diff --git a/tests/generated/absolute_minmax_bottom_right_max.rs b/tests/generated/absolute_minmax_bottom_right_max.rs new file mode 100644 index 000000000..19825a2e8 --- /dev/null +++ b/tests/generated/absolute_minmax_bottom_right_max.rs @@ -0,0 +1,53 @@ +#[test] +fn absolute_minmax_bottom_right_max() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(40f32), + height: taffy::style::Dimension::Points(30f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 40f32, size.width); + assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 30f32, size.height); + assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 50f32, location.x); + assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 60f32, location.y); +} diff --git a/tests/generated/absolute_minmax_bottom_right_min_max.rs b/tests/generated/absolute_minmax_bottom_right_min_max.rs new file mode 100644 index 000000000..16fdc80a7 --- /dev/null +++ b/tests/generated/absolute_minmax_bottom_right_min_max.rs @@ -0,0 +1,53 @@ +#[test] +fn absolute_minmax_bottom_right_min_max() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(60f32), + }, + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(40f32), + height: taffy::style::Dimension::Points(30f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 50f32, size.width); + assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 60f32, size.height); + assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 40f32, location.x); + assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 30f32, location.y); +} diff --git a/tests/generated/absolute_minmax_bottom_right_min_max_preferred.rs b/tests/generated/absolute_minmax_bottom_right_min_max_preferred.rs new file mode 100644 index 000000000..006a1dafc --- /dev/null +++ b/tests/generated/absolute_minmax_bottom_right_min_max_preferred.rs @@ -0,0 +1,57 @@ +#[test] +fn absolute_minmax_bottom_right_min_max_preferred() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(60f32), + }, + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(40f32), + height: taffy::style::Dimension::Points(30f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 50f32, size.width); + assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 60f32, size.height); + assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 40f32, location.x); + assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 30f32, location.y); +} diff --git a/tests/generated/absolute_minmax_top_left_bottom_right_max.rs b/tests/generated/absolute_minmax_top_left_bottom_right_max.rs new file mode 100644 index 000000000..51b2ef5d1 --- /dev/null +++ b/tests/generated/absolute_minmax_top_left_bottom_right_max.rs @@ -0,0 +1,49 @@ +#[test] +fn absolute_minmax_top_left_bottom_right_max() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(40f32), + height: taffy::style::Dimension::Points(30f32), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 40f32, size.width); + assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 30f32, size.height); + assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 10f32, location.x); + assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 10f32, location.y); +} diff --git a/tests/generated/absolute_minmax_top_left_bottom_right_min_max.rs b/tests/generated/absolute_minmax_top_left_bottom_right_min_max.rs new file mode 100644 index 000000000..52ca307dd --- /dev/null +++ b/tests/generated/absolute_minmax_top_left_bottom_right_min_max.rs @@ -0,0 +1,53 @@ +#[test] +fn absolute_minmax_top_left_bottom_right_min_max() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(60f32), + }, + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(40f32), + height: taffy::style::Dimension::Points(30f32), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 50f32, size.width); + assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 60f32, size.height); + assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 10f32, location.x); + assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 10f32, location.y); +} diff --git a/tests/generated/aspect_ratio_flex_column_fill_height.rs b/tests/generated/aspect_ratio_flex_column_fill_height.rs new file mode 100644 index 000000000..b72209a28 --- /dev/null +++ b/tests/generated/aspect_ratio_flex_column_fill_height.rs @@ -0,0 +1,43 @@ +#[test] +fn aspect_ratio_flex_column_fill_height() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(40f32), height: auto() }, + aspect_ratio: Some(2f32), + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + flex_direction: taffy::style::FlexDirection::Column, + align_items: Some(taffy::style::AlignItems::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 20f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y); +} diff --git a/tests/generated/aspect_ratio_flex_column_fill_max_height.rs b/tests/generated/aspect_ratio_flex_column_fill_max_height.rs new file mode 100644 index 000000000..f9c5ca4ab --- /dev/null +++ b/tests/generated/aspect_ratio_flex_column_fill_max_height.rs @@ -0,0 +1,37 @@ +#[test] +fn aspect_ratio_flex_column_fill_max_height() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy . new_leaf_with_measure (taffy :: style :: Style { max_size : taffy :: geometry :: Size { width : taffy :: style :: Dimension :: Points (40f32) , height : auto () , } , aspect_ratio : Some (2f32) , .. Default :: default () } , taffy :: node :: MeasureFunc :: Raw (| known_dimensions , available_space | { const TEXT : & str = "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH" ; super :: measure_standard_text (known_dimensions , available_space , TEXT , super :: WritingMode :: Horizontal , Some (2f32)) }) ,) . unwrap () ; + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + flex_direction: taffy::style::FlexDirection::Column, + align_items: Some(taffy::style::AlignItems::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 20f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y); +} diff --git a/tests/generated/aspect_ratio_flex_column_fill_max_width.rs b/tests/generated/aspect_ratio_flex_column_fill_max_width.rs new file mode 100644 index 000000000..3017455ab --- /dev/null +++ b/tests/generated/aspect_ratio_flex_column_fill_max_width.rs @@ -0,0 +1,55 @@ +#[test] +fn aspect_ratio_flex_column_fill_max_width() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf_with_measure( + taffy::style::Style { + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(20f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH"; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + Some(2f32), + ) + }), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + flex_direction: taffy::style::FlexDirection::Column, + align_items: Some(taffy::style::AlignItems::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 20f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y); +} diff --git a/tests/generated/aspect_ratio_flex_column_fill_min_height.rs b/tests/generated/aspect_ratio_flex_column_fill_min_height.rs new file mode 100644 index 000000000..9c59accd9 --- /dev/null +++ b/tests/generated/aspect_ratio_flex_column_fill_min_height.rs @@ -0,0 +1,43 @@ +#[test] +fn aspect_ratio_flex_column_fill_min_height() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(40f32), height: auto() }, + aspect_ratio: Some(2f32), + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + flex_direction: taffy::style::FlexDirection::Column, + align_items: Some(taffy::style::AlignItems::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 20f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y); +} diff --git a/tests/generated/aspect_ratio_flex_column_fill_min_width.rs b/tests/generated/aspect_ratio_flex_column_fill_min_width.rs new file mode 100644 index 000000000..c1ccf2a4f --- /dev/null +++ b/tests/generated/aspect_ratio_flex_column_fill_min_width.rs @@ -0,0 +1,55 @@ +#[test] +fn aspect_ratio_flex_column_fill_min_width() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf_with_measure( + taffy::style::Style { + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(40f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "\n \n "; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + Some(2f32), + ) + }), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + flex_direction: taffy::style::FlexDirection::Column, + align_items: Some(taffy::style::AlignItems::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 80f32, size.width); + assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 40f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y); +} diff --git a/tests/generated/aspect_ratio_flex_column_fill_width.rs b/tests/generated/aspect_ratio_flex_column_fill_width.rs new file mode 100644 index 000000000..2dd2d380e --- /dev/null +++ b/tests/generated/aspect_ratio_flex_column_fill_width.rs @@ -0,0 +1,43 @@ +#[test] +fn aspect_ratio_flex_column_fill_width() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(40f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + flex_direction: taffy::style::FlexDirection::Column, + align_items: Some(taffy::style::AlignItems::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 80f32, size.width); + assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 40f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y); +} diff --git a/tests/generated/aspect_ratio_flex_column_fill_width_flex.rs b/tests/generated/aspect_ratio_flex_column_fill_width_flex.rs new file mode 100644 index 000000000..298755699 --- /dev/null +++ b/tests/generated/aspect_ratio_flex_column_fill_width_flex.rs @@ -0,0 +1,42 @@ +#[test] +fn aspect_ratio_flex_column_fill_width_flex() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(50f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 100f32, size.width); + assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 50f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y); +} diff --git a/tests/generated/aspect_ratio_flex_column_stretch_fill_height.rs b/tests/generated/aspect_ratio_flex_column_stretch_fill_height.rs new file mode 100644 index 000000000..1602cfda4 --- /dev/null +++ b/tests/generated/aspect_ratio_flex_column_stretch_fill_height.rs @@ -0,0 +1,42 @@ +#[test] +fn aspect_ratio_flex_column_stretch_fill_height() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(40f32), height: auto() }, + aspect_ratio: Some(2f32), + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 20f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y); +} diff --git a/tests/generated/aspect_ratio_flex_column_stretch_fill_max_height.rs b/tests/generated/aspect_ratio_flex_column_stretch_fill_max_height.rs new file mode 100644 index 000000000..4d00231b0 --- /dev/null +++ b/tests/generated/aspect_ratio_flex_column_stretch_fill_max_height.rs @@ -0,0 +1,36 @@ +#[test] +fn aspect_ratio_flex_column_stretch_fill_max_height() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy . new_leaf_with_measure (taffy :: style :: Style { max_size : taffy :: geometry :: Size { width : taffy :: style :: Dimension :: Points (40f32) , height : auto () , } , aspect_ratio : Some (2f32) , .. Default :: default () } , taffy :: node :: MeasureFunc :: Raw (| known_dimensions , available_space | { const TEXT : & str = "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH" ; super :: measure_standard_text (known_dimensions , available_space , TEXT , super :: WritingMode :: Horizontal , Some (2f32)) }) ,) . unwrap () ; + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 20f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y); +} diff --git a/tests/generated/aspect_ratio_flex_column_stretch_fill_max_width.rs b/tests/generated/aspect_ratio_flex_column_stretch_fill_max_width.rs new file mode 100644 index 000000000..79c7b78b4 --- /dev/null +++ b/tests/generated/aspect_ratio_flex_column_stretch_fill_max_width.rs @@ -0,0 +1,54 @@ +#[test] +fn aspect_ratio_flex_column_stretch_fill_max_width() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf_with_measure( + taffy::style::Style { + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(20f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH"; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + Some(2f32), + ) + }), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 100f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 20f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y); +} diff --git a/tests/generated/aspect_ratio_flex_column_stretch_fill_width.rs b/tests/generated/aspect_ratio_flex_column_stretch_fill_width.rs new file mode 100644 index 000000000..89beefa0c --- /dev/null +++ b/tests/generated/aspect_ratio_flex_column_stretch_fill_width.rs @@ -0,0 +1,42 @@ +#[test] +fn aspect_ratio_flex_column_stretch_fill_width() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(40f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 100f32, size.width); + assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 40f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y); +} diff --git a/tests/generated/aspect_ratio_flex_row_fill_height.rs b/tests/generated/aspect_ratio_flex_row_fill_height.rs new file mode 100644 index 000000000..516b0256f --- /dev/null +++ b/tests/generated/aspect_ratio_flex_row_fill_height.rs @@ -0,0 +1,42 @@ +#[test] +fn aspect_ratio_flex_row_fill_height() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(40f32), height: auto() }, + aspect_ratio: Some(2f32), + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + align_items: Some(taffy::style::AlignItems::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 20f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y); +} diff --git a/tests/generated/aspect_ratio_flex_row_fill_max_height.rs b/tests/generated/aspect_ratio_flex_row_fill_max_height.rs new file mode 100644 index 000000000..b4a5ad5c5 --- /dev/null +++ b/tests/generated/aspect_ratio_flex_row_fill_max_height.rs @@ -0,0 +1,36 @@ +#[test] +fn aspect_ratio_flex_row_fill_max_height() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy . new_leaf_with_measure (taffy :: style :: Style { max_size : taffy :: geometry :: Size { width : taffy :: style :: Dimension :: Points (40f32) , height : auto () , } , aspect_ratio : Some (2f32) , .. Default :: default () } , taffy :: node :: MeasureFunc :: Raw (| known_dimensions , available_space | { const TEXT : & str = "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH" ; super :: measure_standard_text (known_dimensions , available_space , TEXT , super :: WritingMode :: Horizontal , Some (2f32)) }) ,) . unwrap () ; + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + align_items: Some(taffy::style::AlignItems::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 20f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y); +} diff --git a/tests/generated/aspect_ratio_flex_row_fill_max_width.rs b/tests/generated/aspect_ratio_flex_row_fill_max_width.rs new file mode 100644 index 000000000..e730fa0fc --- /dev/null +++ b/tests/generated/aspect_ratio_flex_row_fill_max_width.rs @@ -0,0 +1,54 @@ +#[test] +fn aspect_ratio_flex_row_fill_max_width() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf_with_measure( + taffy::style::Style { + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(20f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH"; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + Some(2f32), + ) + }), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + align_items: Some(taffy::style::AlignItems::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 20f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y); +} diff --git a/tests/generated/aspect_ratio_flex_row_fill_min_height.rs b/tests/generated/aspect_ratio_flex_row_fill_min_height.rs new file mode 100644 index 000000000..977f5c589 --- /dev/null +++ b/tests/generated/aspect_ratio_flex_row_fill_min_height.rs @@ -0,0 +1,42 @@ +#[test] +fn aspect_ratio_flex_row_fill_min_height() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(40f32), height: auto() }, + aspect_ratio: Some(2f32), + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + align_items: Some(taffy::style::AlignItems::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 20f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y); +} diff --git a/tests/generated/aspect_ratio_flex_row_fill_min_width.rs b/tests/generated/aspect_ratio_flex_row_fill_min_width.rs new file mode 100644 index 000000000..de53e47a1 --- /dev/null +++ b/tests/generated/aspect_ratio_flex_row_fill_min_width.rs @@ -0,0 +1,54 @@ +#[test] +fn aspect_ratio_flex_row_fill_min_width() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf_with_measure( + taffy::style::Style { + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(40f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "\n \n "; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + Some(2f32), + ) + }), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + align_items: Some(taffy::style::AlignItems::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 80f32, size.width); + assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 40f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y); +} diff --git a/tests/generated/aspect_ratio_flex_row_fill_width.rs b/tests/generated/aspect_ratio_flex_row_fill_width.rs new file mode 100644 index 000000000..4a26d970d --- /dev/null +++ b/tests/generated/aspect_ratio_flex_row_fill_width.rs @@ -0,0 +1,42 @@ +#[test] +fn aspect_ratio_flex_row_fill_width() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(40f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + align_items: Some(taffy::style::AlignItems::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 80f32, size.width); + assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 40f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y); +} diff --git a/tests/generated/aspect_ratio_flex_row_fill_width_flex.rs b/tests/generated/aspect_ratio_flex_row_fill_width_flex.rs new file mode 100644 index 000000000..8db4152dd --- /dev/null +++ b/tests/generated/aspect_ratio_flex_row_fill_width_flex.rs @@ -0,0 +1,42 @@ +#[test] +fn aspect_ratio_flex_row_fill_width_flex() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(50f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_items: Some(taffy::style::AlignItems::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 100f32, size.width); + assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 50f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y); +} diff --git a/tests/generated/aspect_ratio_flex_row_stretch_fill_height.rs b/tests/generated/aspect_ratio_flex_row_stretch_fill_height.rs new file mode 100644 index 000000000..0e28c50e4 --- /dev/null +++ b/tests/generated/aspect_ratio_flex_row_stretch_fill_height.rs @@ -0,0 +1,41 @@ +#[test] +fn aspect_ratio_flex_row_stretch_fill_height() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(40f32), height: auto() }, + aspect_ratio: Some(2f32), + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 40f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y); +} diff --git a/tests/generated/aspect_ratio_flex_row_stretch_fill_max_height.rs b/tests/generated/aspect_ratio_flex_row_stretch_fill_max_height.rs new file mode 100644 index 000000000..4935d24e0 --- /dev/null +++ b/tests/generated/aspect_ratio_flex_row_stretch_fill_max_height.rs @@ -0,0 +1,35 @@ +#[test] +fn aspect_ratio_flex_row_stretch_fill_max_height() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy . new_leaf_with_measure (taffy :: style :: Style { max_size : taffy :: geometry :: Size { width : taffy :: style :: Dimension :: Points (40f32) , height : auto () , } , aspect_ratio : Some (2f32) , .. Default :: default () } , taffy :: node :: MeasureFunc :: Raw (| known_dimensions , available_space | { const TEXT : & str = "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH" ; super :: measure_standard_text (known_dimensions , available_space , TEXT , super :: WritingMode :: Horizontal , Some (2f32)) }) ,) . unwrap () ; + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 40f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y); +} diff --git a/tests/generated/aspect_ratio_flex_row_stretch_fill_max_width.rs b/tests/generated/aspect_ratio_flex_row_stretch_fill_max_width.rs new file mode 100644 index 000000000..c2a14a370 --- /dev/null +++ b/tests/generated/aspect_ratio_flex_row_stretch_fill_max_width.rs @@ -0,0 +1,53 @@ +#[test] +fn aspect_ratio_flex_row_stretch_fill_max_width() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf_with_measure( + taffy::style::Style { + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(20f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH"; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + Some(2f32), + ) + }), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 20f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y); +} diff --git a/tests/generated/aspect_ratio_flex_row_stretch_fill_width.rs b/tests/generated/aspect_ratio_flex_row_stretch_fill_width.rs new file mode 100644 index 000000000..809b4d9e8 --- /dev/null +++ b/tests/generated/aspect_ratio_flex_row_stretch_fill_width.rs @@ -0,0 +1,41 @@ +#[test] +fn aspect_ratio_flex_row_stretch_fill_width() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(40f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 80f32, size.width); + assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 40f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y); +} diff --git a/tests/generated/display_none_absolute_child.rs b/tests/generated/display_none_absolute_child.rs new file mode 100644 index 000000000..cebdddb25 --- /dev/null +++ b/tests/generated/display_none_absolute_child.rs @@ -0,0 +1,56 @@ +#[test] +fn display_none_absolute_child() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::None, + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: auto(), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: auto(), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1.data(), 0f32, size.width); + assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1.data(), 0f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1.data(), 0f32, location.y); +} diff --git a/tests/generated/display_none_with_position_absolute.rs b/tests/generated/display_none_with_position_absolute.rs new file mode 100644 index 000000000..d323b3911 --- /dev/null +++ b/tests/generated/display_none_with_position_absolute.rs @@ -0,0 +1,44 @@ +#[test] +fn display_none_with_position_absolute() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + display: taffy::style::Display::None, + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, size.width); + assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y); +} diff --git a/tests/generated/grid_absolute_layout_within_border.rs b/tests/generated/grid_absolute_layout_within_border.rs new file mode 100644 index 000000000..be52434ea --- /dev/null +++ b/tests/generated/grid_absolute_layout_within_border.rs @@ -0,0 +1,137 @@ +#[test] +fn grid_absolute_layout_within_border() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(0f32), + right: auto(), + top: taffy::style::LengthPercentageAuto::Points(0f32), + bottom: auto(), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Points(0f32), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Points(0f32), + }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(0f32), + right: auto(), + top: taffy::style::LengthPercentageAuto::Points(0f32), + bottom: auto(), + }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), + }, + inset: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Points(0f32), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Points(0f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(10f32), + right: taffy::style::LengthPercentage::Points(10f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(10f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(10f32), + right: taffy::style::LengthPercentage::Points(10f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(10f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 50f32, size.width); + assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 50f32, size.height); + assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 10f32, location.x); + assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 10f32, location.y); + let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1.data(), 50f32, size.width); + assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1.data(), 50f32, size.height); + assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1.data(), 40f32, location.x); + assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1.data(), 40f32, location.y); + let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2.data(), 50f32, size.width); + assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2.data(), 50f32, size.height); + assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node2.data(), 20f32, location.x); + assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2.data(), 20f32, location.y); + let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3.data(), 50f32, size.width); + assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node3.data(), 50f32, size.height); + assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node3.data(), 30f32, location.x); + assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node3.data(), 30f32, location.y); +} diff --git a/tests/generated/grid_absolute_layout_within_border_static.rs b/tests/generated/grid_absolute_layout_within_border_static.rs new file mode 100644 index 000000000..723e6e83a --- /dev/null +++ b/tests/generated/grid_absolute_layout_within_border_static.rs @@ -0,0 +1,121 @@ +#[test] +fn grid_absolute_layout_within_border_static() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + align_self: Some(taffy::style::AlignSelf::Start), + justify_self: Some(taffy::style::JustifySelf::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + align_self: Some(taffy::style::AlignSelf::End), + justify_self: Some(taffy::style::JustifySelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + align_self: Some(taffy::style::AlignSelf::Start), + justify_self: Some(taffy::style::JustifySelf::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + align_self: Some(taffy::style::AlignSelf::End), + justify_self: Some(taffy::style::JustifySelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(10f32), + right: taffy::style::LengthPercentage::Points(10f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(10f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(10f32), + right: taffy::style::LengthPercentage::Points(10f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(10f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 50f32, size.width); + assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 50f32, size.height); + assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 10f32, location.x); + assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 10f32, location.y); + let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1.data(), 50f32, size.width); + assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1.data(), 50f32, size.height); + assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1.data(), 40f32, location.x); + assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1.data(), 40f32, location.y); + let Layout { size, location, .. } = taffy.layout(node2).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2.data(), 50f32, size.width); + assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2.data(), 50f32, size.height); + assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node2.data(), 20f32, location.x); + assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2.data(), 20f32, location.y); + let Layout { size, location, .. } = taffy.layout(node3).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3.data(), 50f32, size.width); + assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node3.data(), 50f32, size.height); + assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node3.data(), 30f32, location.x); + assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node3.data(), 30f32, location.y); +} diff --git a/tests/generated/grid_aspect_ratio_absolute_aspect_ratio_overrides_height_of_full_inset.rs b/tests/generated/grid_aspect_ratio_absolute_aspect_ratio_overrides_height_of_full_inset.rs new file mode 100644 index 000000000..8cbb2425c --- /dev/null +++ b/tests/generated/grid_aspect_ratio_absolute_aspect_ratio_overrides_height_of_full_inset.rs @@ -0,0 +1,47 @@ +#[test] +fn grid_aspect_ratio_absolute_aspect_ratio_overrides_height_of_full_inset() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.05f32), + right: taffy::style::LengthPercentageAuto::Percent(0.05f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.05f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(400f32), + height: taffy::style::Dimension::Points(300f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 400f32, size.width); + assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 300f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 360f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 360f32, size.width); + assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 120f32, size.height); + assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 20f32, location.x); + assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 15f32, location.y); +} diff --git a/tests/generated/grid_aspect_ratio_absolute_fill_height_from_inset.rs b/tests/generated/grid_aspect_ratio_absolute_fill_height_from_inset.rs new file mode 100644 index 000000000..e5c2f1c24 --- /dev/null +++ b/tests/generated/grid_aspect_ratio_absolute_fill_height_from_inset.rs @@ -0,0 +1,47 @@ +#[test] +fn grid_aspect_ratio_absolute_fill_height_from_inset() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.1f32), + right: taffy::style::LengthPercentageAuto::Percent(0.1f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: auto(), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(400f32), + height: taffy::style::Dimension::Points(300f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 400f32, size.width); + assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 300f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 320f32, size.width); + assert_eq!(size.height, 107f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 107f32, size.height); + assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 40f32, location.x); + assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 15f32, location.y); +} diff --git a/tests/generated/grid_aspect_ratio_absolute_fill_width_from_inset.rs b/tests/generated/grid_aspect_ratio_absolute_fill_width_from_inset.rs new file mode 100644 index 000000000..d66ca520b --- /dev/null +++ b/tests/generated/grid_aspect_ratio_absolute_fill_width_from_inset.rs @@ -0,0 +1,47 @@ +#[test] +fn grid_aspect_ratio_absolute_fill_width_from_inset() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Percent(0.3f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.5f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(400f32), + height: taffy::style::Dimension::Points(300f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 400f32, size.width); + assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 300f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 180f32, size.width); + assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 60f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 90f32, location.y); +} diff --git a/tests/generated/grid_aspect_ratio_absolute_height_overrides_inset.rs b/tests/generated/grid_aspect_ratio_absolute_height_overrides_inset.rs new file mode 100644 index 000000000..062932c08 --- /dev/null +++ b/tests/generated/grid_aspect_ratio_absolute_height_overrides_inset.rs @@ -0,0 +1,48 @@ +#[test] +fn grid_aspect_ratio_absolute_height_overrides_inset() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.1f32) }, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Percent(0.3f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.5f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Flex, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(400f32), + height: taffy::style::Dimension::Points(300f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 400f32, size.width); + assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 300f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 90f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 90f32, size.width); + assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 30f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 90f32, location.y); +} diff --git a/tests/generated/grid_aspect_ratio_absolute_width_overrides_inset.rs b/tests/generated/grid_aspect_ratio_absolute_width_overrides_inset.rs new file mode 100644 index 000000000..6806d2a66 --- /dev/null +++ b/tests/generated/grid_aspect_ratio_absolute_width_overrides_inset.rs @@ -0,0 +1,48 @@ +#[test] +fn grid_aspect_ratio_absolute_width_overrides_inset() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.4f32), height: auto() }, + aspect_ratio: Some(3f32), + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.1f32), + right: taffy::style::LengthPercentageAuto::Percent(0.1f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: auto(), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(400f32), + height: taffy::style::Dimension::Points(300f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 400f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 400f32, size.width); + assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 300f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 160f32, size.width); + assert_eq!(size.height, 53f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 53f32, size.height); + assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 40f32, location.x); + assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 15f32, location.y); +} diff --git a/tests/generated/grid_aspect_ratio_child_fill_content_height.rs b/tests/generated/grid_aspect_ratio_child_fill_content_height.rs new file mode 100644 index 000000000..f62d70ffe --- /dev/null +++ b/tests/generated/grid_aspect_ratio_child_fill_content_height.rs @@ -0,0 +1,53 @@ +#[test] +fn grid_aspect_ratio_child_fill_content_height() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf_with_measure( + taffy::style::Style { aspect_ratio: Some(0.5f32), ..Default::default() }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHH"; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + Some(0.5f32), + ) + }), + ) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(20f32) }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, ..Default::default() }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 40f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 40f32, size.width); + assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 80f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1.data(), 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1.data(), 20f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1.data(), 0f32, location.x); + assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node1.data(), 80f32, location.y); +} diff --git a/tests/generated/grid_aspect_ratio_child_fill_content_width.rs b/tests/generated/grid_aspect_ratio_child_fill_content_width.rs new file mode 100644 index 000000000..acedf2436 --- /dev/null +++ b/tests/generated/grid_aspect_ratio_child_fill_content_width.rs @@ -0,0 +1,53 @@ +#[test] +fn grid_aspect_ratio_child_fill_content_width() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf_with_measure( + taffy::style::Style { aspect_ratio: Some(2f32), ..Default::default() }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHH"; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + Some(2f32), + ) + }), + ) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(20f32) }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { display: taffy::style::Display::Grid, ..Default::default() }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 40f32, size.width); + assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 40f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 20f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node1).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1.data(), 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1.data(), 20f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1.data(), 0f32, location.x); + assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1.data(), 20f32, location.y); +} diff --git a/tests/generated/grid_aspect_ratio_fill_child_height.rs b/tests/generated/grid_aspect_ratio_fill_child_height.rs new file mode 100644 index 000000000..c97e77781 --- /dev/null +++ b/tests/generated/grid_aspect_ratio_fill_child_height.rs @@ -0,0 +1,41 @@ +#[test] +fn grid_aspect_ratio_fill_child_height() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() }, + aspect_ratio: Some(2f32), + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 50f32, size.width); + assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 25f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y); +} diff --git a/tests/generated/grid_aspect_ratio_fill_child_max_height.rs b/tests/generated/grid_aspect_ratio_fill_child_max_height.rs new file mode 100644 index 000000000..d36031511 --- /dev/null +++ b/tests/generated/grid_aspect_ratio_fill_child_max_height.rs @@ -0,0 +1,53 @@ +#[test] +fn grid_aspect_ratio_fill_child_max_height() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf_with_measure( + taffy::style::Style { + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(40f32), height: auto() }, + aspect_ratio: Some(2f32), + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH"; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Vertical, + Some(2f32), + ) + }), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 20f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y); +} diff --git a/tests/generated/grid_aspect_ratio_fill_child_max_width.rs b/tests/generated/grid_aspect_ratio_fill_child_max_width.rs new file mode 100644 index 000000000..23d7c6bd6 --- /dev/null +++ b/tests/generated/grid_aspect_ratio_fill_child_max_width.rs @@ -0,0 +1,53 @@ +#[test] +fn grid_aspect_ratio_fill_child_max_width() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf_with_measure( + taffy::style::Style { + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(20f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH"; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + Some(2f32), + ) + }), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 40f32, size.width); + assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 20f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y); +} diff --git a/tests/generated/grid_aspect_ratio_fill_child_min_height.rs b/tests/generated/grid_aspect_ratio_fill_child_min_height.rs new file mode 100644 index 000000000..d21f86188 --- /dev/null +++ b/tests/generated/grid_aspect_ratio_fill_child_min_height.rs @@ -0,0 +1,41 @@ +#[test] +fn grid_aspect_ratio_fill_child_min_height() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() }, + aspect_ratio: Some(2f32), + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 100f32, size.width); + assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 50f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y); +} diff --git a/tests/generated/grid_aspect_ratio_fill_child_min_width.rs b/tests/generated/grid_aspect_ratio_fill_child_min_width.rs new file mode 100644 index 000000000..75dfb6302 --- /dev/null +++ b/tests/generated/grid_aspect_ratio_fill_child_min_width.rs @@ -0,0 +1,53 @@ +#[test] +fn grid_aspect_ratio_fill_child_min_width() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf_with_measure( + taffy::style::Style { + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(50f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "\n \n "; + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + Some(2f32), + ) + }), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 100f32, size.width); + assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 50f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y); +} diff --git a/tests/generated/grid_aspect_ratio_fill_child_width.rs b/tests/generated/grid_aspect_ratio_fill_child_width.rs new file mode 100644 index 000000000..45fabfdfe --- /dev/null +++ b/tests/generated/grid_aspect_ratio_fill_child_width.rs @@ -0,0 +1,41 @@ +#[test] +fn grid_aspect_ratio_fill_child_width() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(50f32) }, + aspect_ratio: Some(2f32), + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 100f32, size.width); + assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 50f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y); +} diff --git a/tests/generated/grid_aspect_ratio_overriden_by_explicit_sizes.rs b/tests/generated/grid_aspect_ratio_overriden_by_explicit_sizes.rs new file mode 100644 index 000000000..5778d3f89 --- /dev/null +++ b/tests/generated/grid_aspect_ratio_overriden_by_explicit_sizes.rs @@ -0,0 +1,44 @@ +#[test] +fn grid_aspect_ratio_overriden_by_explicit_sizes() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + }, + aspect_ratio: Some(2f32), + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 50f32, size.width); + assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 50f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y); +} diff --git a/tests/generated/grid_aspect_ratio_overriden_by_explicit_sizes_flex.rs b/tests/generated/grid_aspect_ratio_overriden_by_explicit_sizes_flex.rs new file mode 100644 index 000000000..a6b546caf --- /dev/null +++ b/tests/generated/grid_aspect_ratio_overriden_by_explicit_sizes_flex.rs @@ -0,0 +1,44 @@ +#[test] +fn grid_aspect_ratio_overriden_by_explicit_sizes_flex() { + use slotmap::Key; + #[allow(unused_imports)] + use taffy::{layout::Layout, prelude::*}; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + }, + aspect_ratio: Some(2f32), + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + let Layout { size, location, .. } = taffy.layout(node).unwrap(); + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y); + let Layout { size, location, .. } = taffy.layout(node0).unwrap(); + assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 50f32, size.width); + assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 50f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y); +} diff --git a/tests/generated/grid_fit_content_points_argument.rs b/tests/generated/grid_fit_content_points_argument.rs index 70fb4e8a3..d2f2a80e4 100644 --- a/tests/generated/grid_fit_content_points_argument.rs +++ b/tests/generated/grid_fit_content_points_argument.rs @@ -10,7 +10,13 @@ fn grid_fit_content_points_argument() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/tests/generated/grid_fit_content_points_max_content.rs b/tests/generated/grid_fit_content_points_max_content.rs index 45e84d4d0..dd4980fab 100644 --- a/tests/generated/grid_fit_content_points_max_content.rs +++ b/tests/generated/grid_fit_content_points_max_content.rs @@ -10,7 +10,13 @@ fn grid_fit_content_points_max_content() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/tests/generated/grid_fit_content_points_min_content.rs b/tests/generated/grid_fit_content_points_min_content.rs index 5e9fceee4..437b8ba54 100644 --- a/tests/generated/grid_fit_content_points_min_content.rs +++ b/tests/generated/grid_fit_content_points_min_content.rs @@ -10,7 +10,13 @@ fn grid_fit_content_points_min_content() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HHHH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/tests/generated/grid_margins_auto_margins_override_stretch.rs b/tests/generated/grid_margins_auto_margins_override_stretch.rs index e9c129f1b..9b3484a9f 100644 --- a/tests/generated/grid_margins_auto_margins_override_stretch.rs +++ b/tests/generated/grid_margins_auto_margins_override_stretch.rs @@ -25,7 +25,13 @@ fn grid_margins_auto_margins_override_stretch() { }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/tests/generated/grid_max_content_maximum_single_item.rs b/tests/generated/grid_max_content_maximum_single_item.rs index 016f92eb2..bfadfdd93 100644 --- a/tests/generated/grid_max_content_maximum_single_item.rs +++ b/tests/generated/grid_max_content_maximum_single_item.rs @@ -10,7 +10,13 @@ fn grid_max_content_maximum_single_item() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/tests/generated/grid_max_content_single_item.rs b/tests/generated/grid_max_content_single_item.rs index b7926c016..1bcd397d7 100644 --- a/tests/generated/grid_max_content_single_item.rs +++ b/tests/generated/grid_max_content_single_item.rs @@ -10,7 +10,13 @@ fn grid_max_content_single_item() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/tests/generated/grid_max_content_single_item_margin_auto.rs b/tests/generated/grid_max_content_single_item_margin_auto.rs index 854b507c2..d993eb4a8 100644 --- a/tests/generated/grid_max_content_single_item_margin_auto.rs +++ b/tests/generated/grid_max_content_single_item_margin_auto.rs @@ -18,7 +18,13 @@ fn grid_max_content_single_item_margin_auto() { }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/tests/generated/grid_max_content_single_item_margin_fixed.rs b/tests/generated/grid_max_content_single_item_margin_fixed.rs index 51fe1346a..450c449a4 100644 --- a/tests/generated/grid_max_content_single_item_margin_fixed.rs +++ b/tests/generated/grid_max_content_single_item_margin_fixed.rs @@ -18,7 +18,13 @@ fn grid_max_content_single_item_margin_fixed() { }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/tests/generated/grid_max_content_single_item_margin_percent.rs b/tests/generated/grid_max_content_single_item_margin_percent.rs index 7a42b8df3..8f6f57214 100644 --- a/tests/generated/grid_max_content_single_item_margin_percent.rs +++ b/tests/generated/grid_max_content_single_item_margin_percent.rs @@ -18,7 +18,13 @@ fn grid_max_content_single_item_margin_percent() { }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/tests/generated/grid_min_content_flex_column.rs b/tests/generated/grid_min_content_flex_column.rs index 9cd01654d..e19b39c0e 100644 --- a/tests/generated/grid_min_content_flex_column.rs +++ b/tests/generated/grid_min_content_flex_column.rs @@ -9,7 +9,13 @@ fn grid_min_content_flex_column() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); @@ -18,7 +24,13 @@ fn grid_min_content_flex_column() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); @@ -27,7 +39,13 @@ fn grid_min_content_flex_column() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/tests/generated/grid_min_content_flex_row.rs b/tests/generated/grid_min_content_flex_row.rs index 66a005699..68f65b7f0 100644 --- a/tests/generated/grid_min_content_flex_row.rs +++ b/tests/generated/grid_min_content_flex_row.rs @@ -9,7 +9,13 @@ fn grid_min_content_flex_row() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); @@ -18,7 +24,13 @@ fn grid_min_content_flex_row() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); @@ -27,7 +39,13 @@ fn grid_min_content_flex_row() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/tests/generated/grid_min_content_flex_single_item.rs b/tests/generated/grid_min_content_flex_single_item.rs index c942f782b..7401a84fa 100644 --- a/tests/generated/grid_min_content_flex_single_item.rs +++ b/tests/generated/grid_min_content_flex_single_item.rs @@ -24,7 +24,13 @@ fn grid_min_content_flex_single_item() { }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/tests/generated/grid_min_content_flex_single_item_margin_auto.rs b/tests/generated/grid_min_content_flex_single_item_margin_auto.rs index f77d88d4c..d7a7a3b7a 100644 --- a/tests/generated/grid_min_content_flex_single_item_margin_auto.rs +++ b/tests/generated/grid_min_content_flex_single_item_margin_auto.rs @@ -36,7 +36,13 @@ fn grid_min_content_flex_single_item_margin_auto() { }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/tests/generated/grid_min_content_flex_single_item_margin_fixed.rs b/tests/generated/grid_min_content_flex_single_item_margin_fixed.rs index 47d7cd1b3..b675dc335 100644 --- a/tests/generated/grid_min_content_flex_single_item_margin_fixed.rs +++ b/tests/generated/grid_min_content_flex_single_item_margin_fixed.rs @@ -36,7 +36,13 @@ fn grid_min_content_flex_single_item_margin_fixed() { }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/tests/generated/grid_min_content_flex_single_item_margin_percent.rs b/tests/generated/grid_min_content_flex_single_item_margin_percent.rs index e353b5932..1328c61de 100644 --- a/tests/generated/grid_min_content_flex_single_item_margin_percent.rs +++ b/tests/generated/grid_min_content_flex_single_item_margin_percent.rs @@ -36,7 +36,13 @@ fn grid_min_content_flex_single_item_margin_percent() { }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/tests/generated/grid_min_content_maximum_single_item.rs b/tests/generated/grid_min_content_maximum_single_item.rs index 9b4eb821f..c3bf75ff0 100644 --- a/tests/generated/grid_min_content_maximum_single_item.rs +++ b/tests/generated/grid_min_content_maximum_single_item.rs @@ -10,7 +10,13 @@ fn grid_min_content_maximum_single_item() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/tests/generated/grid_min_content_single_item.rs b/tests/generated/grid_min_content_single_item.rs index 628462049..0bec76a5b 100644 --- a/tests/generated/grid_min_content_single_item.rs +++ b/tests/generated/grid_min_content_single_item.rs @@ -10,7 +10,13 @@ fn grid_min_content_single_item() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/tests/generated/grid_relayout_vertical_text.rs b/tests/generated/grid_relayout_vertical_text.rs index 5e56b42ad..ce46aa687 100644 --- a/tests/generated/grid_relayout_vertical_text.rs +++ b/tests/generated/grid_relayout_vertical_text.rs @@ -9,7 +9,13 @@ fn grid_relayout_vertical_text() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Vertical) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Vertical, + None, + ) }), ) .unwrap(); @@ -18,7 +24,13 @@ fn grid_relayout_vertical_text() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/tests/generated/grid_size_child_fixed_tracks.rs b/tests/generated/grid_size_child_fixed_tracks.rs index 4b9604d84..3f66a0767 100644 --- a/tests/generated/grid_size_child_fixed_tracks.rs +++ b/tests/generated/grid_size_child_fixed_tracks.rs @@ -13,7 +13,13 @@ fn grid_size_child_fixed_tracks() { }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); @@ -26,7 +32,13 @@ fn grid_size_child_fixed_tracks() { }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HHH\u{200b}HHH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); @@ -39,7 +51,13 @@ fn grid_size_child_fixed_tracks() { }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HHHH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); @@ -53,7 +71,13 @@ fn grid_size_child_fixed_tracks() { }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); @@ -67,7 +91,13 @@ fn grid_size_child_fixed_tracks() { }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/tests/generated/measure_child.rs b/tests/generated/measure_child.rs index 0e6214615..ac143afae 100644 --- a/tests/generated/measure_child.rs +++ b/tests/generated/measure_child.rs @@ -9,7 +9,13 @@ fn measure_child() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HHHHHH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/tests/generated/measure_child_absolute.rs b/tests/generated/measure_child_absolute.rs index 9f15cc4fc..c46619328 100644 --- a/tests/generated/measure_child_absolute.rs +++ b/tests/generated/measure_child_absolute.rs @@ -9,7 +9,13 @@ fn measure_child_absolute() { taffy::style::Style { position: taffy::style::Position::Absolute, ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HHHHHH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/tests/generated/measure_child_constraint.rs b/tests/generated/measure_child_constraint.rs index 6b445402a..87752dd90 100644 --- a/tests/generated/measure_child_constraint.rs +++ b/tests/generated/measure_child_constraint.rs @@ -4,7 +4,7 @@ fn measure_child_constraint() { #[allow(unused_imports)] use taffy::{layout::Layout, prelude::*}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy . new_leaf_with_measure (taffy :: style :: Style { .. Default :: default () } , taffy :: node :: MeasureFunc :: Raw (| known_dimensions , available_space | { const TEXT : & str = "HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH" ; super :: measure_standard_text (known_dimensions , available_space , TEXT , super :: WritingMode :: Horizontal) }) ,) . unwrap () ; + let node0 = taffy . new_leaf_with_measure (taffy :: style :: Style { .. Default :: default () } , taffy :: node :: MeasureFunc :: Raw (| known_dimensions , available_space | { const TEXT : & str = "HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH" ; super :: measure_standard_text (known_dimensions , available_space , TEXT , super :: WritingMode :: Horizontal , None) }) ,) . unwrap () ; let node = taffy .new_with_children( taffy::style::Style { diff --git a/tests/generated/measure_child_constraint_padding_parent.rs b/tests/generated/measure_child_constraint_padding_parent.rs index 5dc3c0d42..3980c91e0 100644 --- a/tests/generated/measure_child_constraint_padding_parent.rs +++ b/tests/generated/measure_child_constraint_padding_parent.rs @@ -4,7 +4,7 @@ fn measure_child_constraint_padding_parent() { #[allow(unused_imports)] use taffy::{layout::Layout, prelude::*}; let mut taffy = taffy::Taffy::new(); - let node0 = taffy . new_leaf_with_measure (taffy :: style :: Style { .. Default :: default () } , taffy :: node :: MeasureFunc :: Raw (| known_dimensions , available_space | { const TEXT : & str = "HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH" ; super :: measure_standard_text (known_dimensions , available_space , TEXT , super :: WritingMode :: Horizontal) }) ,) . unwrap () ; + let node0 = taffy . new_leaf_with_measure (taffy :: style :: Style { .. Default :: default () } , taffy :: node :: MeasureFunc :: Raw (| known_dimensions , available_space | { const TEXT : & str = "HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH" ; super :: measure_standard_text (known_dimensions , available_space , TEXT , super :: WritingMode :: Horizontal , None) }) ,) . unwrap () ; let node = taffy .new_with_children( taffy::style::Style { diff --git a/tests/generated/measure_child_with_flex_grow.rs b/tests/generated/measure_child_with_flex_grow.rs index 90e186806..332611386 100644 --- a/tests/generated/measure_child_with_flex_grow.rs +++ b/tests/generated/measure_child_with_flex_grow.rs @@ -18,7 +18,13 @@ fn measure_child_with_flex_grow() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "H\u{200b}H\u{200b}H\u{200b}H\u{200b}H"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/tests/generated/measure_child_with_flex_shrink.rs b/tests/generated/measure_child_with_flex_shrink.rs index a3787c73f..f14bc3ab7 100644 --- a/tests/generated/measure_child_with_flex_shrink.rs +++ b/tests/generated/measure_child_with_flex_shrink.rs @@ -18,7 +18,13 @@ fn measure_child_with_flex_shrink() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/tests/generated/measure_flex_basis_overrides_measure.rs b/tests/generated/measure_flex_basis_overrides_measure.rs index 8b9f9461e..b5735ce07 100644 --- a/tests/generated/measure_flex_basis_overrides_measure.rs +++ b/tests/generated/measure_flex_basis_overrides_measure.rs @@ -9,7 +9,13 @@ fn measure_flex_basis_overrides_measure() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "H"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/tests/generated/measure_height_overrides_measure.rs b/tests/generated/measure_height_overrides_measure.rs index fba584fab..5a2bae1ab 100644 --- a/tests/generated/measure_height_overrides_measure.rs +++ b/tests/generated/measure_height_overrides_measure.rs @@ -12,7 +12,13 @@ fn measure_height_overrides_measure() { }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "H"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/tests/generated/measure_remeasure_child_after_growing.rs b/tests/generated/measure_remeasure_child_after_growing.rs index 75713f3b9..13e23cc33 100644 --- a/tests/generated/measure_remeasure_child_after_growing.rs +++ b/tests/generated/measure_remeasure_child_after_growing.rs @@ -18,7 +18,13 @@ fn measure_remeasure_child_after_growing() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/tests/generated/measure_remeasure_child_after_shrinking.rs b/tests/generated/measure_remeasure_child_after_shrinking.rs index 24265d2c6..51a04defa 100644 --- a/tests/generated/measure_remeasure_child_after_shrinking.rs +++ b/tests/generated/measure_remeasure_child_after_shrinking.rs @@ -19,7 +19,13 @@ fn measure_remeasure_child_after_shrinking() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/tests/generated/measure_remeasure_child_after_stretching.rs b/tests/generated/measure_remeasure_child_after_stretching.rs index f381f437a..8dc16c090 100644 --- a/tests/generated/measure_remeasure_child_after_stretching.rs +++ b/tests/generated/measure_remeasure_child_after_stretching.rs @@ -9,7 +9,13 @@ fn measure_remeasure_child_after_stretching() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/tests/generated/measure_root.rs b/tests/generated/measure_root.rs index a7c72dd8d..011887af4 100644 --- a/tests/generated/measure_root.rs +++ b/tests/generated/measure_root.rs @@ -9,7 +9,13 @@ fn measure_root() { taffy::style::Style { ..Default::default() }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HHHHHH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/tests/generated/measure_stretch_overrides_measure.rs b/tests/generated/measure_stretch_overrides_measure.rs index b4a0ce571..05961e1cd 100644 --- a/tests/generated/measure_stretch_overrides_measure.rs +++ b/tests/generated/measure_stretch_overrides_measure.rs @@ -20,7 +20,13 @@ fn measure_stretch_overrides_measure() { }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "H"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/tests/generated/measure_width_overrides_measure.rs b/tests/generated/measure_width_overrides_measure.rs index ce224ec80..73cc15abe 100644 --- a/tests/generated/measure_width_overrides_measure.rs +++ b/tests/generated/measure_width_overrides_measure.rs @@ -12,7 +12,13 @@ fn measure_width_overrides_measure() { }, taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { const TEXT: &str = "HHHHHHHHHH"; - super::measure_standard_text(known_dimensions, available_space, TEXT, super::WritingMode::Horizontal) + super::measure_standard_text( + known_dimensions, + available_space, + TEXT, + super::WritingMode::Horizontal, + None, + ) }), ) .unwrap(); diff --git a/tests/generated/mod.rs b/tests/generated/mod.rs index 965ebe5e9..659a0cd77 100644 --- a/tests/generated/mod.rs +++ b/tests/generated/mod.rs @@ -10,6 +10,7 @@ fn measure_standard_text( available_space: taffy::geometry::Size, text_content: &str, writing_mode: WritingMode, + _aspect_ratio: Option, ) -> taffy::geometry::Size { use taffy::axis::AbsoluteAxis; use taffy::prelude::*; @@ -59,6 +60,17 @@ fn measure_standard_text( WritingMode::Vertical => Size { width: block_size, height: inline_size }, } } +mod absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset; +mod absolute_aspect_ratio_fill_height; +mod absolute_aspect_ratio_fill_height_from_inset; +mod absolute_aspect_ratio_fill_max_height; +mod absolute_aspect_ratio_fill_max_width; +mod absolute_aspect_ratio_fill_min_height; +mod absolute_aspect_ratio_fill_min_width; +mod absolute_aspect_ratio_fill_width; +mod absolute_aspect_ratio_fill_width_from_inset; +mod absolute_aspect_ratio_height_overrides_inset; +mod absolute_aspect_ratio_width_overrides_inset; mod absolute_layout_align_items_and_justify_content_center; mod absolute_layout_align_items_and_justify_content_center_and_bottom_position; mod absolute_layout_align_items_and_justify_content_center_and_left_position; @@ -80,6 +92,12 @@ mod absolute_layout_width_height_end_bottom; mod absolute_layout_width_height_start_top; mod absolute_layout_width_height_start_top_end_bottom; mod absolute_layout_within_border; +mod absolute_margin_bottom_left; +mod absolute_minmax_bottom_right_max; +mod absolute_minmax_bottom_right_min_max; +mod absolute_minmax_bottom_right_min_max_preferred; +mod absolute_minmax_top_left_bottom_right_max; +mod absolute_minmax_top_left_bottom_right_min_max; mod align_baseline; mod align_baseline_child_multiline; mod align_baseline_nested_child; @@ -110,6 +128,28 @@ mod align_self_flex_end; mod align_self_flex_end_override_flex_start; mod align_self_flex_start; mod align_stretch_should_size_based_on_parent; +mod aspect_ratio_flex_column_fill_height; +mod aspect_ratio_flex_column_fill_max_height; +mod aspect_ratio_flex_column_fill_max_width; +mod aspect_ratio_flex_column_fill_min_height; +mod aspect_ratio_flex_column_fill_min_width; +mod aspect_ratio_flex_column_fill_width; +mod aspect_ratio_flex_column_fill_width_flex; +mod aspect_ratio_flex_column_stretch_fill_height; +mod aspect_ratio_flex_column_stretch_fill_max_height; +mod aspect_ratio_flex_column_stretch_fill_max_width; +mod aspect_ratio_flex_column_stretch_fill_width; +mod aspect_ratio_flex_row_fill_height; +mod aspect_ratio_flex_row_fill_max_height; +mod aspect_ratio_flex_row_fill_max_width; +mod aspect_ratio_flex_row_fill_min_height; +mod aspect_ratio_flex_row_fill_min_width; +mod aspect_ratio_flex_row_fill_width; +mod aspect_ratio_flex_row_fill_width_flex; +mod aspect_ratio_flex_row_stretch_fill_height; +mod aspect_ratio_flex_row_stretch_fill_max_height; +mod aspect_ratio_flex_row_stretch_fill_max_width; +mod aspect_ratio_flex_row_stretch_fill_width; mod border_center_child; mod border_flex_child; mod border_no_child; @@ -117,10 +157,12 @@ mod border_stretch_child; mod child_min_max_width_flexing; mod container_with_unsized_child; mod display_none; +mod display_none_absolute_child; mod display_none_fixed_size; mod display_none_with_child; mod display_none_with_margin; mod display_none_with_position; +mod display_none_with_position_absolute; mod flex_basis_and_main_dimen_set_when_flexing; mod flex_basis_flex_grow_column; mod flex_basis_flex_grow_row; @@ -232,6 +274,10 @@ mod grid_absolute_container_top_right_margin; #[cfg(feature = "grid")] mod grid_absolute_justify_self_sized_all; #[cfg(feature = "grid")] +mod grid_absolute_layout_within_border; +#[cfg(feature = "grid")] +mod grid_absolute_layout_within_border_static; +#[cfg(feature = "grid")] mod grid_absolute_row_end; #[cfg(feature = "grid")] mod grid_absolute_row_start; @@ -274,6 +320,36 @@ mod grid_align_items_sized_stretch; #[cfg(feature = "grid")] mod grid_align_self_sized_all; #[cfg(feature = "grid")] +mod grid_aspect_ratio_absolute_aspect_ratio_overrides_height_of_full_inset; +#[cfg(feature = "grid")] +mod grid_aspect_ratio_absolute_fill_height_from_inset; +#[cfg(feature = "grid")] +mod grid_aspect_ratio_absolute_fill_width_from_inset; +#[cfg(feature = "grid")] +mod grid_aspect_ratio_absolute_height_overrides_inset; +#[cfg(feature = "grid")] +mod grid_aspect_ratio_absolute_width_overrides_inset; +#[cfg(feature = "grid")] +mod grid_aspect_ratio_child_fill_content_height; +#[cfg(feature = "grid")] +mod grid_aspect_ratio_child_fill_content_width; +#[cfg(feature = "grid")] +mod grid_aspect_ratio_fill_child_height; +#[cfg(feature = "grid")] +mod grid_aspect_ratio_fill_child_max_height; +#[cfg(feature = "grid")] +mod grid_aspect_ratio_fill_child_max_width; +#[cfg(feature = "grid")] +mod grid_aspect_ratio_fill_child_min_height; +#[cfg(feature = "grid")] +mod grid_aspect_ratio_fill_child_min_width; +#[cfg(feature = "grid")] +mod grid_aspect_ratio_fill_child_width; +#[cfg(feature = "grid")] +mod grid_aspect_ratio_overriden_by_explicit_sizes; +#[cfg(feature = "grid")] +mod grid_aspect_ratio_overriden_by_explicit_sizes_flex; +#[cfg(feature = "grid")] mod grid_auto_columns_fixed_width; #[cfg(feature = "grid")] mod grid_auto_fill_fixed_size;