Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: DioxusLabs/taffy
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: b56f22fab87c0e3705260f4ab8036948243154bd
Choose a base ref
..
head repository: DioxusLabs/taffy
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: bffafc7ce4b70f9d3a9af4240322eb46b2a0b479
Choose a head ref
Showing 708 changed files with 4,646 additions and 4,579 deletions.
1 change: 1 addition & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[alias]
gentest = "run --release --package gentest --"
import-yoga-tests = "run --package import-yoga-tests --"
xbench = "bench --package taffy_benchmarks"
61 changes: 40 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -8,6 +8,9 @@ on:

name: Continuous integration

env:
RUSTDOCFLAGS: "-D warnings"

jobs:
# None
test-features-none:
@@ -16,9 +19,8 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: Leafwing-Studios/cargo-cache@v1
- run: cargo build --no-default-features
- run: cargo test --no-default-features
- run: cargo test --no-default-features --features taffy_tree

# Default
test-features-default:
@@ -46,7 +48,8 @@ jobs:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- run: cargo build --no-default-features --features std
- run: cargo test --no-default-features --features std
- run: cargo build --no-default-features --features std,taffy_tree
- run: cargo test --no-default-features --features std,taffy_tree

# Flexbox
test-features-flexbox:
@@ -56,7 +59,8 @@ jobs:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- run: cargo build --no-default-features --features flexbox,std
- run: cargo test --no-default-features --features flexbox,std
- run: cargo build --no-default-features --features flexbox,std,taffy_tree
- run: cargo test --no-default-features --features flexbox,std,taffy_tree

# Grid
test-features-grid:
@@ -66,7 +70,8 @@ jobs:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- run: cargo build --no-default-features --features grid,std
- run: cargo test --no-default-features --features grid,std
- run: cargo build --no-default-features --features grid,std,taffy_tree
- run: cargo test --no-default-features --features grid,std,taffy_tree

test-features-grid-with-alloc:
name: "Test Suite [Features: grid + alloc]"
@@ -75,7 +80,8 @@ jobs:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- run: cargo build --no-default-features --features alloc,grid
- run: cargo test --no-default-features --features alloc,grid
- run: cargo build --no-default-features --features alloc,grid,taffy_tree
- run: cargo test --no-default-features --features alloc,grid,taffy_tree

test-features-alloc:
name: "Test Suite [Features: alloc]"
@@ -84,17 +90,18 @@ jobs:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- run: cargo build --no-default-features --features alloc
- run: cargo test --no-default-features --features alloc
- run: cargo build --no-default-features --features alloc,taffy_tree
- run: cargo test --no-default-features --features alloc,taffy_tree

test-features-default-no-grid:
name: "Test Suite [Features: std (no grid)]"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: Leafwing-Studios/cargo-cache@v1
- run: cargo build --no-default-features --features std
- run: cargo test --no-default-features --features std
- run: cargo build --no-default-features --features std,taffy_tree
- run: cargo test --no-default-features --features std,taffy_tree

fmt:
name: Rustfmt
@@ -105,7 +112,6 @@ jobs:
with:
toolchain: stable
components: rustfmt
- uses: Leafwing-Studios/cargo-cache@v1
- run: cargo fmt --all -- --check

clippy:
@@ -117,7 +123,6 @@ jobs:
with:
toolchain: nightly
components: clippy
- uses: Leafwing-Studios/cargo-cache@v1
- run: cargo +nightly clippy --workspace -- -D warnings

doc:
@@ -129,22 +134,36 @@ jobs:
with:
toolchain: stable
components: clippy
- uses: Leafwing-Studios/cargo-cache@v1
- run: cargo doc

benchmarks:
name: Build Benchmarks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- run: cargo xbench --no-run
name: Build benchmarks
env:
RUSTDOCFLAGS: "-D warnings"
RUSTFLAGS: "-C opt-level=0"

benchmarks-with-yoga:
name: Build Benchmarks (w/ yoga)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- run: cargo xbench --no-run --features yoga
name: Build benchmarks (w/yoga)
env:
RUSTFLAGS: "-C opt-level=0"

markdownlint:
name: Markdown Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
# Full git history is needed to get a proper list of changed files within `super-linter`
fetch-depth: 0
- name: Run Markdown Lint
uses: docker://ghcr.io/github/super-linter:slim-v4
env:
VALIDATE_ALL_CODEBASE: true
VALIDATE_MARKDOWN: true
DEFAULT_BRANCH: master
uses: DavidAnson/markdownlint-cli2-action@v9
with:
globs: '**/*.md'
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/target
/scripts/gentest/target
/yoga_test_fixtures
/yoga_test_fixtures_grouped

**/*.rs.bk
Cargo.lock
File renamed without changes.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -85,4 +85,4 @@ To add a new test case add another HTML file to `/test_fixtures` following the c
## Benchmarking

Benchmarks build on the same infrastructure as testing, and actually benchmarks are automatically generated from test fixtures just like tests.
Run `cargo bench` to run benchmarks locally.
Run `cargo xbench` to run benchmarks locally. To run head-to-head benchmarks with Yoga, run `cargo xbench --features yoga`. You will need `libclang-dev` or the xcode commandline tools installed in order to run the yoga benchmarks.
29 changes: 5 additions & 24 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -16,7 +16,6 @@ license = "MIT"
[dependencies]
arrayvec = { version = "0.7", default-features = false }
num-traits = { version = "0.2", default-features = false }
rand = { version = "0.8.5", optional = true }
serde = { version = "1.0", optional = true, features = ["serde_derive"] }
slotmap = { version = "1.0.6", optional = true }
grid = { version = "0.9.0", optional = true }
@@ -28,42 +27,24 @@ grid = ["alloc", "dep:grid"]
alloc = []
std = ["num-traits/std"]
serde = ["dep:serde"]
random = ["dep:rand"]
yoga_benchmark = []
debug = []
profile = []
taffy_tree = ["dep:slotmap"]

[dev-dependencies]
criterion = "0.4"
rstest = "0.17.0"
rand = "0.8.5"
rand_chacha = "0.3.1"
yoga = "0.4.0"
ordered-float = "3.4.0"
serde_json = "1.0.93"

# Enable example and test-specific features
taffy = { path = ".", features = ["random"] }
# Enable default features for tests and examples
taffy = { path = "." }

[profile.release]
lto = true
panic = 'abort'

[[bench]]
name = "tree_creation"
path = "benches/tree_creation.rs"
harness = false

[[bench]]
name = "flexbox"
path = "benches/flexbox.rs"
harness = false

[[bench]]
name = "grid"
path = "benches/grid.rs"
name = "dummy_benchmark"
path = "benches/dummy_benchmark.rs"
harness = false

[workspace]
members = ["scripts/gentest", "scripts/import-yoga-tests"]
members = ["scripts/gentest", "scripts/import-yoga-tests", "benches"]
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -28,15 +28,15 @@ let mut taffy = Taffy::new();
let header_node = taffy
.new_leaf(
Style {
size: Size { width: points(800.0), height: points(100.0) },
size: Size { width: length(800.0), height: length(100.0) },
..Default::default()
},
).unwrap();

let body_node = taffy
.new_leaf(
Style {
size: Size { width: points(800.0), height: auto() },
size: Size { width: length(800.0), height: auto() },
flex_grow: 1.0,
..Default::default()
},
@@ -46,7 +46,7 @@ let root_node = taffy
.new_with_children(
Style {
flex_direction: FlexDirection::Column,
size: Size { width: points(800.0), height: points(600.0) },
size: Size { width: length(800.0), height: length(600.0) },
..Default::default()
},
&[header_node, body_node],
26 changes: 26 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,32 @@

## Unreleased

### Breaking

Many APIs have been renamed to replace `points` or `Points` with `length` or `Length`.
This new name better describes one-dimentional measure of space in some unspecified unit
which is often unrelated to the PostScript point or the CSS `pt` unit.

This also removes a misleading similarity with the 2D `Point`,
whose components can have any unit and are not even necessarily absolute lengths.

Example usage change:

```diff
use taffy::prelude::*;

// …

let header_node = taffy
.new_leaf(
Style {
- size: Size { width: points(800.0), height: points(100.0) },
+ size: Size { width: length(800.0), height: length(100.0) },
..Default::default()
},
).unwrap();
```

### Removed

- `layout_flexbox()` has been removed from the prelude. Use `FlexboxAlgorithm::perform_layout()` instead.
39 changes: 39 additions & 0 deletions benches/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[package]
name = "taffy_benchmarks"
version = "0.1.0"
authors = [
"Alice Cecile <alice.i.cecile@gmail.com>",
"Johnathan Kelley <jkelleyrtp@gmail.com>",
]
edition = "2021"
description = "Benchmarks for the taffy crate"
repository = "https://github.com/DioxusLabs/taffy"
keywords = ["cross-platform", "layout", "benchmarks"]
categories = ["gui", "benchmarks"]
license = "MIT"

[dependencies]
criterion = "0.4"
taffy = { path = ".." }
rand = { version = "0.8.5" }
rand_chacha = "0.3.1"
yoga = { version = "0.4.0", optional = true }
ordered-float = { version = "3.4.0", optional = true }

[features]
yoga = ["dep:yoga", "dep:ordered-float"]

[[bench]]
name = "tree_creation"
path = "benches/tree_creation.rs"
harness = false

[[bench]]
name = "flexbox"
path = "benches/flexbox.rs"
harness = false

[[bench]]
name = "grid"
path = "benches/grid.rs"
harness = false
13 changes: 5 additions & 8 deletions benches/flexbox.rs → benches/benches/flexbox.rs
Original file line number Diff line number Diff line change
@@ -4,16 +4,13 @@ use rand::prelude::*;
use rand_chacha::ChaCha8Rng;
use taffy::prelude::*;
use taffy::style::Style;
use taffy::util::Randomizeable;
use taffy_benchmarks::{build_deep_tree, Randomizeable};

mod helpers;
use helpers::build_deep_tree;

#[cfg(feature = "yoga_benchmark")]
use helpers::yoga_helpers;
#[cfg(feature = "yoga_benchmark")]
use slotmap::SlotMap;
#[cfg(feature = "yoga_benchmark")]
use taffy_benchmarks::yoga_helpers;
#[cfg(feature = "yoga_benchmark")]
use yoga_helpers::yg;

/// Build a random leaf node
@@ -100,7 +97,7 @@ fn build_yoga_deep_hierarchy(node_count: u32, branching_factor: u32) -> (yg::Yog
/// A deep tree that matches the shape and styling that yoga use on their benchmarks
fn build_taffy_huge_nested_hierarchy(node_count: u32, branching_factor: u32) -> (Taffy, NodeId) {
let style = Style {
size: Size { width: Dimension::Points(10.0), height: Dimension::Points(10.0) },
size: Size { width: Dimension::Length(10.0), height: Dimension::Length(10.0) },
flex_grow: 1.0,
..Default::default()
};
@@ -118,7 +115,7 @@ fn build_taffy_huge_nested_hierarchy(node_count: u32, branching_factor: u32) ->
/// A deep tree that matches the shape and styling that yoga use on their benchmarks
fn build_yoga_huge_nested_hierarchy(node_count: u32, branching_factor: u32) -> (yg::YogaTree, yg::NodeId) {
let style = Style {
size: Size { width: Dimension::Points(10.0), height: Dimension::Points(10.0) },
size: Size { width: Dimension::Length(10.0), height: Dimension::Length(10.0) },
flex_grow: 1.0,
..Default::default()
};
10 changes: 5 additions & 5 deletions benches/grid.rs → benches/benches/grid.rs
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ use taffy::style::Style;

/// Build a random leaf node
fn build_random_leaf(taffy: &mut Taffy, _rng: &mut ChaCha8Rng) -> NodeId {
taffy.new_with_children(Style { size: points(20.0), ..Default::default() }, &[]).unwrap()
taffy.new_with_children(Style { size: length(20.0), ..Default::default() }, &[]).unwrap()
}

fn random_grid_track<R: Rng>(rng: &mut R) -> TrackSizingFunction {
@@ -22,9 +22,9 @@ fn random_grid_track<R: Rng>(rng: &mut R) -> TrackSizingFunction {
} else if switch < 0.5 {
fr(1.0)
} else if switch < 0.6 {
minmax(points(0.0), fr(1.0))
minmax(length(0.0), fr(1.0))
} else if switch < 0.8 {
points(40.0)
length(40.0)
} else {
percent(0.3)
}
@@ -110,7 +110,7 @@ fn taffy_benchmarks(c: &mut Criterion) {
|b, &track_count| {
b.iter_batched(
|| build_grid_flat_hierarchy(track_count, track_count),
|(mut taffy, root)| taffy.compute_layout(root, points(12000.0)).unwrap(),
|(mut taffy, root)| taffy.compute_layout(root, length(12000.0)).unwrap(),
criterion::BatchSize::SmallInput,
)
},
@@ -128,7 +128,7 @@ fn taffy_benchmarks(c: &mut Criterion) {
|b, &(levels, tracks)| {
b.iter_batched(
|| build_taffy_deep_grid_hierarchy(levels, tracks),
|(mut taffy, root)| taffy.compute_layout(root, points(12000.0)).unwrap(),
|(mut taffy, root)| taffy.compute_layout(root, length(12000.0)).unwrap(),
criterion::BatchSize::SmallInput,
)
},
Loading