Skip to content

Commit

Permalink
Implement "gap" property for flexbox algorithm (#248)
Browse files Browse the repository at this point in the history
* Consistently use camelCase in test_helper.js

* Add support for parsing grid style properties to test_helper.js

* Add support for generating Taffy Grid styles in tests to gentest main.rs

* Add generated tests for flexbox gap

* Add gap property to style module

* Implement gap property for flexbox algorthim

* Add gap to changelog

* Add tests for percentage gutters with defined parent node size

* Add test for percentage gap with undefined parent node size

* Fix percentage main-axis column gaps in containers with undefined main size

* Gentest: delete generated tests before recreating (ensures tests are deleted if fixture is deleted)

* Cargo fmt

* Add test for percentage row gap in a flex-wrap container with undefined height

* gentest: fix clippy warnings

* Add more small benchmarks + harmonise benchmarks names with 0.1 benchmarks

* Create helper function for summing axis total gap

* Add flexbox-gap example

* Add test for fixed gaps with undefined parent size

* Remove commented out code in gentest script

Co-authored-by: Alice Cecile <[email protected]>

* Use Size::UNDEFINED as the default for the gap style property

* Fix fixed size column gaps with undefined parent width

* Add additional flexbox gap test

Co-authored-by: Alice Cecile <[email protected]>
  • Loading branch information
nicoburns and alice-i-cecile authored Nov 23, 2022
1 parent ba4cd3c commit 9e53f03
Show file tree
Hide file tree
Showing 98 changed files with 5,360 additions and 335 deletions.
1 change: 1 addition & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- Added support for `AlignContent::SpaceEvenly`
- Added `AvailableSpace` enum
- Added `debug` modules with a `print_tree` function, which prints a debug representation of the computed layout for a tree of nodes.
- Added support for `gap` property (shorthand form of `row-gap`/`column-gap`)

### 0.2.0 Changed

Expand Down
29 changes: 28 additions & 1 deletion benches/big_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,30 @@ fn taffy_benchmarks(c: &mut Criterion) {
drop(group);

// Decrease sample size, because the tasks take longer
let mut group = c.benchmark_group("big trees");
let mut group = c.benchmark_group("big trees (wide)");
group.sample_size(10);

group.bench_function("10 nodes (2-level hierarchy)", |b| {
let mut taffy = Taffy::new();
let root = build_flat_hierarchy(&mut taffy, 10);

b.iter(|| taffy.compute_layout(root, Size::MAX_CONTENT).unwrap())
});

group.bench_function("100 nodes (2-level hierarchy)", |b| {
let mut taffy = Taffy::new();
let root = build_flat_hierarchy(&mut taffy, 100);

b.iter(|| taffy.compute_layout(root, Size::MAX_CONTENT).unwrap())
});

group.bench_function("1_000 nodes (2-level hierarchy)", |b| {
let mut taffy = Taffy::new();
let root = build_flat_hierarchy(&mut taffy, 1_000);

b.iter(|| taffy.compute_layout(root, Size::MAX_CONTENT).unwrap())
});

group.bench_function("10_000 nodes (2-level hierarchy)", |b| {
let mut taffy = Taffy::new();
let root = build_flat_hierarchy(&mut taffy, 10_000);
Expand All @@ -150,6 +171,12 @@ fn taffy_benchmarks(c: &mut Criterion) {
b.iter(|| taffy.compute_layout(root, Size::MAX_CONTENT).unwrap())
});

drop(group);

// Decrease sample size, because the tasks take longer
let mut group = c.benchmark_group("big trees (deep)");
group.sample_size(10);

group.bench_function("4000 nodes (12-level hierarchy)", |b| {
let mut taffy = Taffy::new();
let root = build_deep_hierarchy(&mut taffy, 4000, 2);
Expand Down
66 changes: 66 additions & 0 deletions benches/generated/gap_column_gap_child_margins.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 55 additions & 0 deletions benches/generated/gap_column_gap_flexible.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 51 additions & 0 deletions benches/generated/gap_column_gap_flexible_undefined_parent.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions benches/generated/gap_column_gap_inflexible.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions benches/generated/gap_column_gap_inflexible_undefined_parent.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions benches/generated/gap_column_gap_justify_center.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9e53f03

Please sign in to comment.