diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..965c54f01 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +/tests/generated/** linguist-generated=true +/benches/generated/** linguist-generated=true diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 000000000..55feca4d6 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,39 @@ +--- +name: Bug Report +about: Report a bug to help us improve! +title: '' +labels: bug +assignees: '' +--- + +## `taffy` version + +The release number or commit hash of the version you're using. + +## Platform + +What platform are you using `taffy` on? e.g. Rust, Android, IOS, JavaScript/TypeScript + +## What you did + +The steps you took to uncover this bug. + +Please provide a runnable code snippet or link to an example that demonstrates the problem if you can. + +## What went wrong + +If it's not clear: + +- what were you expecting? +- what actually happened? + +## Additional information + +Other information that can be used to further reproduce or isolate the problem. +This commonly includes: + +- screenshots +- logs +- theories about what might be going wrong +- workarounds that you used +- links to related bugs, PRs or discussions diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 000000000..238a7ad57 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,24 @@ +--- +name: Feature Request +about: Propose a new feature! +title: '' +labels: enhancement +assignees: '' +--- + +## What problem does this solve or what need does it fill? + +A description of why this particular feature should be added. + +## What solution would you like? + +The solution you propose for the problem presented. + +## What alternative(s) have you considered? + +Other solutions to solve and/or work around the problem presented. + +## Additional context + +Any other information you would like to add such as related previous work, +screenshots, benchmarks, etc. diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..dfdce9efe --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,14 @@ +version: 2 +updates: + - package-ecosystem: cargo + directory: / + schedule: + interval: weekly + labels: + - "dependencies" + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + labels: + - "dependencies" diff --git a/.github/linters/.markdown-lint.yml b/.github/linters/.markdown-lint.yml new file mode 100644 index 000000000..760686631 --- /dev/null +++ b/.github/linters/.markdown-lint.yml @@ -0,0 +1,29 @@ +--- +########################### +########################### +## Markdown Linter rules ## +########################### +########################### + +# Linter rules doc: +# - https://github.com/DavidAnson/markdownlint +# +# Note: +# To comment out a single error: +# +# any violations you want +# +# + +############### +# Rules by id # +############### +# MD013: +# line_length: 120 + +################# +# Rules by tags # +################# +# blank_lines: false # Error on blank lines +line_length: false # Ignore excessively long lines +no-duplicate-heading: false # This is useful in RELEASES.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 000000000..caf1d7674 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,21 @@ +# Objective + +Why did you make this PR? + +If you're fixing a specific issue, say "Fixes #X" and the linked issue will be automatically closed when this PR is merged. +If it's not obvious, describe how this changes made addressed the objectives. + +**Changes that will affect external library users must update RELEASES.md before they will be merged.** + +## Context + +Discuss any context that may be needed for reviewers to understand the changes you've made. +This may include related issues, previous discussion, or links to documentation or code. + +## Feedback wanted + +> This section is optional. If there are no particularly tricky or controversial changes, you can delete this section. + +Which parts of this PR were you unsure about? Which parts were particularly tricky? + +If you're stuck on part of the changes or want feedback early, open a draft PR and list the items that need to be completed here using a [checklist](https://github.blog/2014-04-28-task-lists-in-all-markdown-documents/). diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..450ab85d2 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,95 @@ +on: [push, pull_request] + +name: Continuous integration + +jobs: + test-features-none: + name: "Test Suite [Features: None]" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - uses: actions-rs/cargo@v1 + with: + command: test + args: --no-default-features + + test-features-default: + name: "Test Suite [Features: Default]" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - uses: actions-rs/cargo@v1 + with: + command: test + + test-features-alloc: + name: "Test Suite [Features: alloc]" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - uses: actions-rs/cargo@v1 + with: + command: test + args: --no-default-features --features alloc + + fmt: + name: Rustfmt + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - run: rustup component add rustfmt + - uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check + + clippy: + name: Clippy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: nightly + override: true + - run: rustup component add clippy + - uses: actions-rs/cargo@v1 + with: + command: clippy + args: -- -D warnings + + 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 diff --git a/.github/workflows/dependencies.yml b/.github/workflows/dependencies.yml new file mode 100644 index 000000000..14df77370 --- /dev/null +++ b/.github/workflows/dependencies.yml @@ -0,0 +1,71 @@ +name: Dependencies + +on: + pull_request: + paths: + - '**/Cargo.toml' + - 'deny.toml' + push: + paths: + - '**/Cargo.toml' + - 'deny.toml' + branches-ignore: + - 'dependabot/**' + # schedule: + # - cron: "0 0 * * 0" + +env: + CARGO_TERM_COLOR: always + +jobs: + check-advisories: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + - name: Install cargo-deny + run: cargo install cargo-deny + - name: Check for security advisories and unmaintained crates + run: cargo deny check advisories + + check-bans: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + - name: Install cargo-deny + run: cargo install cargo-deny + - name: Check for banned and duplicated dependencies + run: cargo deny check bans + + check-licenses: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + - name: Install cargo-deny + run: cargo install cargo-deny + - name: Check for unauthorized licenses + run: cargo deny check licenses + + check-sources: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + - name: Install cargo-deny + run: cargo install cargo-deny + - name: Checked for unauthorized crate sources + run: cargo deny check sources diff --git a/.gitignore b/.gitignore index 693699042..5188ccbf6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,8 @@ /target +/scripts/gentest/target + **/*.rs.bk Cargo.lock +.DS_Store + +.vscode diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..62235a37c --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,82 @@ +# Contributing + +This is a cross-team project, aiming to build solid foundations for Rust UI libraries of all sorts. +New contributions are extremely welcome! + +The basic process is simple: + +1. Pick an [issue](https://github.com/DioxusLabs/taffy/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22), or [file a new one](https://github.com/DioxusLabs/taffy/issues/new). +2. Comment in the issue that you plan to tackle it, and the team will assign the task to you. +3. Submit a PR. +4. Respond to feedback from reviewers and make sure CI passes. + +The PR review process is completely open: help us by commenting on, testing and approving PRs. + +If you'd like to help on a consistent basis or are interested in project management, create a Discussions post, and we'll be happy to hand out triage rights. + +## Testing + +### Running tests + +Flexbox layouts are tested by validating that layouts written in this crate perform the same as in Chrome. +This is done by rendering an equivalent layout in HTML and then generating a Rust test case which asserts that the resulting layout is the same when run through our layout engine. + +You can run these tests without setting up a webdriver environment but if you are looking to add any test case you will need to install [chromedriver](http://chromedriver.chromium.org) and [Chrome](https://www.google.com/chrome/). +If you are developing on macOS this is easy to do through brew. + +```bash +brew install chromedriver +``` + +Once you have chromedriver installed and available in `PATH` you can re-generate all tests by running `cargo run --package gentest`. You should not manually update the tests in `tests/generated`. Instead, fix the script in `scripts/gentest/` and re-generate them. This can happen after a refactor. It can be helpful to commit the updated tests in a dedicated commit so that they can be easier to ignore during review. + +To add a new test case add another HTML file to `/test_fixtures` following the current tests as a template for new tests. + +### Writing tests + +1. All tests should be wrapped in a module called `tests` gated by the standard `test` feature flag, to ensure they are not compiled unless tests are being run. + + ```rs + #[cfg(test)] + mod tests { + // Place tests here + } + ``` + +2. For unit-testing this should be placed in the same file as the code they are testing + 1. If files become extremely long (more than a couple thousand lines of code), tests should be split out into its own file under the same module + + ```rs + // file: ./src/my_struct.rs + struct MyStruct; + + impl MyStruct { + fn some_method() { .. } + } + + #[cfg(test)] + mod tests { + #[test] + fn test_of_some_method() { .. } + } + ``` + +3. For integration tests this should be placed within the `./tests` folder + + ```rs + // file: ./tests/my_integration_test.rs + #[test] + fn integration_test_one() { .. } + #[test] + fn integration_test_two() { .. } + ``` + +4. Each test should have a clear intent + 1. It should be evident what is being tested (naming, code, comments) + 2. When this test fails, it should be easy to understand what went wrong + 3. Fixture-based tests (`#[rstest]`) can help improve clarity when many related scenarios need to be checked + +## 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. diff --git a/Cargo.toml b/Cargo.toml index 7ef034ff2..39f68ffa3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,51 @@ [package] -name = "stretch" -version = "0.1.0" -authors = ["Emil Sjölander "] +name = "taffy" +version = "0.2.0" +authors = [ + "Alice Cecile ", + "Johnathan Kelley ", +] +edition = "2021" +include = ["src/**/*", "Cargo.toml"] +description = "A flexible UI layout library" +repository = "https://github.com/DioxusLabs/taffy" +keywords = ["cross-platform", "layout", "flexbox"] +categories = ["gui"] +license = "MIT" [dependencies] +arrayvec = { version = "0.7", default-features = false } +hash32 = "0.2" +hash32-derive = "0.1" +num-traits = { version = "0.2", default-features = false } +typenum = "1" +hashbrown = { version = "0.12", optional = true } +serde = { version = "1.0", optional = true, features = ["serde_derive"] } +slotmap = "1.0.6" + +[features] +default = ["std"] +alloc = ["hashbrown"] +std = ["num-traits/std"] +serde = ["dep:serde"] + +[dev-dependencies] +criterion = "0.3" +rstest = "0.15.0" + +[profile.release] +lto = true +panic = 'abort' + +[[bench]] +name = "generated" +path = "benches/generated/mod.rs" +harness = false + +[[bench]] +name = "complex" +path = "benches/complex.rs" +harness = false + +[workspace] +members = ["scripts/gentest"] diff --git a/LICENSE b/LICENSE.md similarity index 72% rename from LICENSE rename to LICENSE.md index 5c31aa9d1..d45edd349 100644 --- a/LICENSE +++ b/LICENSE.md @@ -1,6 +1,10 @@ -MIT License +# License -Copyright (c) 2018 Visly Inc. +The copyright of all contributions to this open source software library remains with the original authors, who by contributing grant others a license to freely use, share and modify their work under the MIT license below. + +This library was forked from the [`stretch`](https://github.com/vislyhq/stretch) crate under the MIT License, which was copyright 2018 Visly Inc. + +## MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -19,4 +23,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - diff --git a/README.md b/README.md new file mode 100644 index 000000000..601778954 --- /dev/null +++ b/README.md @@ -0,0 +1,18 @@ +# taffy + +[![GitHub CI](https://github.com/DioxusLabs/taffy/actions/workflows/ci.yml/badge.svg)](https://github.com/DioxusLabs/taffy/actions/workflows/ci.yml) +[![crates.io](https://img.shields.io/crates/v/taffy.svg)](https://crates.io/crates/taffy) + +`taffy` is a flexible, high-performance, cross-platform UI layout library written in [Rust](https://www.rust-lang.org). + +Currently, we only support a [flexbox](https://css-tricks.com/snippets/css/a-guide-to-flexbox/) layout algorithm, but support for other paradigms [is planned](https://github.com/DioxusLabs/taffy/issues/28). + +This crate is a collaborative, cross-team project, and is designed to be used as a dependency for other UI and GUI libraries. +Right now, it powers: + +- [Dioxus](https://dioxuslabs.com/): a React-like library for building fast, portable, and beautiful user interfaces with Rust +- [Bevy](https://bevyengine.org/): an ergonomic, ECS-first Rust game engine + +[Contributions welcome](https://github.com/DioxusLabs/taffy/blob/main/CONTRIBUTING.md): +if you'd like to use, improve or build `taffy`, feel free to join the conversation, open an [issue](https://github.com/DioxusLabs/taffy/issues) or submit a [PR](https://github.com/DioxusLabs/taffy/pulls). +If you have questions about how to use `taffy`, open a [discussion](https://github.com/DioxusLabs/taffy/discussions) so we can answer your questions in a way that others can find. diff --git a/RELEASES.md b/RELEASES.md new file mode 100644 index 000000000..64f40990a --- /dev/null +++ b/RELEASES.md @@ -0,0 +1,79 @@ +# Release Notes + +## 0.2.0 + +### 0.2.0 Added + +- Added `taffy::error::InvalidChild` Error type +- `taffy::node::Taffy.new_leaf()` which allows the creation of new leaf-nodes without having to supply a measure function + +### 0.2.0 Changed + +- `Size.zero()` is now `Size::::ZERO` +- `Point.zero()` is now `Point::::ZERO` +- renamed `taffy::node::Taffy.new_leaf()` -> `taffy::node::Taffy.new_leaf_with_measure()` +- removed the public `Number` type; a more idiomatic `Option` is used instead + - the associated public `MinMax` and `OrElse` traits have also been removed; these should never have been public +- `Sprawl::remove` now returns a `Result`, to indicate if the operation was sucessful, and if it was, which ID was invalidated. +- renamed `taffy::forest::Forest.new-node(..)` `taffy::forest::Forest.new_with_children(..)` +- renamed `taffy::node::Taffy.new-node(..)` -> `taffy::node::Taffy.new_with_children(..)` +- renamed `taffy::style::Style` -> `taffy::style::FlexboxLayout` to more precicely indicate its purpose +- renamed `taffy::Error` -> `taffy::error::TaffyError` +- `taffy::Taffy::remove_child_at_index`, `taffy::Taffy::replace_child_at_index`, and `taffy::Taffy::child_at_index` now return `taffy::InvalidChild::ChildIndexOutOfBounds` instead of panicing +- `taffy::Node` is now unique only to the Taffy instance from which it was created. +- `taffy::error::InvalidChild` is now `taffy::error::TaffyError` +- `taffy::error::InvalidNode` has been removed and is now just a branch on the `TaffyError` enum +- `taffy::forest::Forest` has been merged into `taffy::node::Taffy` for a performance boost up to 90% + +### 0.2.0 Fixed + +- nodes can only ever have one parent +- fixed rounding of fractional values to follow latest Chrome - values are now rounded the same regardless of their position +- fixed computing free space when using both `flex-grow` and a minimum size +- padding is now only subtracted when determining the available space if the node size is unspecified, following [section 9.2.2 of the flexbox spec](https://www.w3.org/TR/css-flexbox-1/#line-sizing) +- `MeasureFunc` (and hence `NodeData` and hence `Forest` and hence the public `Taffy` type) are now `Send` and `Sync`, enabling their use in async and parallel applications + +### 0.2.0 Removed + +- various internal types are no longer public + - if you needed one of these, please file an issue! + +## 0.1.0 + +### 0.1.0 Changed + +- the `order` field of `Layout` is now public, and describes the relative z-ordering of nodes +- renamed crate from `stretch2` to `taffy` +- updated to the latest version of all dependencies to reduce upstream pain caused by duplicate dependencies +- renamed `stretch::node::Strech` -> `taffy::node::Taffy` + +### 0.1.0 Fixed + +- fixed feature strategy for `alloc` and `std`: these can now be compiled together, with `std`'s types taking priority + +### 0.1.0 Removed + +- removed Javascript / Kotlin / Swift bindings + - the maintainer team lacks expertise to keep these working + - more serious refactors are planned, and this will be challenging to keep working through that process + - if you are interested in helping us maintain bindings to other languages, [get in touch](https://github.com/DioxusLabs/taffy/discussions)! +- the `serde_camel_case` and `serde_kebab_case` features have been removed: they were poorly motivated and were not correctly additive (if both were enabled compilation would fail) +- removed the `Direction` and `Overflow` structs, and the corresponding `direction` and `overflow` fields from `Style` + - these had no effect in the current code base and were actively misleading + +## stretch2 0.4.3 + +This is the final release of `stretch`: migrate to the crate named `taffy` for future fixes and features! + +These notes describe the differences between this release and `stretch` 0.3.2, the abandoned crate from which this library was forked. + +### Changed + +- updated [assorted dependencies](https://github.com/vislyhq/stretch/commit/a6491117379cea52dedc9584d892594a143e8cb0) + +### Fixed + +- fixed an exponential performance blow-up with deep nesting +- fixed percent height values, which were using parent width +- recomputing layout no longer moves children of non-zero-positioned parent +- fixed broken Swift bindings diff --git a/benches/complex.rs b/benches/complex.rs new file mode 100644 index 000000000..7b32586be --- /dev/null +++ b/benches/complex.rs @@ -0,0 +1,126 @@ +use criterion::{criterion_group, criterion_main, Criterion}; + +fn build_deep_hierarchy(taffy: &mut taffy::node::SimpleTaffy) -> taffy::node::Node { + let node111 = taffy + .new_leaf(taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10.0), + height: taffy::style::Dimension::Points(10.0), + }, + ..Default::default() + }) + .unwrap(); + let node112 = taffy + .new_leaf(taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10.0), + height: taffy::style::Dimension::Points(10.0), + }, + ..Default::default() + }) + .unwrap(); + + let node121 = taffy + .new_leaf(taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10.0), + height: taffy::style::Dimension::Points(10.0), + }, + ..Default::default() + }) + .unwrap(); + let node122 = taffy + .new_leaf(taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10.0), + height: taffy::style::Dimension::Points(10.0), + }, + ..Default::default() + }) + .unwrap(); + + let node11 = + taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[node111, node112]).unwrap(); + let node12 = + taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[node121, node122]).unwrap(); + let node1 = + taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[node11, node12]).unwrap(); + + let node211 = taffy + .new_leaf(taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10.0), + height: taffy::style::Dimension::Points(10.0), + }, + ..Default::default() + }) + .unwrap(); + let node212 = taffy + .new_leaf(taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10.0), + height: taffy::style::Dimension::Points(10.0), + }, + ..Default::default() + }) + .unwrap(); + + let node221 = taffy + .new_leaf(taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10.0), + height: taffy::style::Dimension::Points(10.0), + }, + ..Default::default() + }) + .unwrap(); + let node222 = taffy + .new_leaf(taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10.0), + height: taffy::style::Dimension::Points(10.0), + }, + ..Default::default() + }) + .unwrap(); + + let node21 = + taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[node211, node212]).unwrap(); + let node22 = + taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[node221, node222]).unwrap(); + + let node2 = + taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[node21, node22]).unwrap(); + + taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[node1, node2]).unwrap() +} + +fn taffy_benchmarks(c: &mut Criterion) { + c.bench_function("deep hierarchy - build", |b| { + b.iter(|| { + let mut taffy = taffy::node::Taffy::new(); + build_deep_hierarchy(&mut taffy); + }) + }); + + c.bench_function("deep hierarchy - single", |b| { + b.iter(|| { + let mut taffy = taffy::node::Taffy::new(); + let root = build_deep_hierarchy(&mut taffy); + taffy.compute_layout(root, taffy::geometry::Size::undefined()).unwrap() + }) + }); + + c.bench_function("deep hierarchy - relayout", |b| { + let mut taffy = taffy::node::Taffy::new(); + let root = build_deep_hierarchy(&mut taffy); + + b.iter(|| { + taffy.mark_dirty(root).unwrap(); + taffy.compute_layout(root, taffy::geometry::Size::undefined()).unwrap() + }) + }); +} + +criterion_group!(benches, taffy_benchmarks); +criterion_main!(benches); diff --git a/benches/generated/absolute_layout_align_items_and_justify_content_center.rs b/benches/generated/absolute_layout_align_items_and_justify_content_center.rs new file mode 100644 index 000000000..e1fe4b3c0 --- /dev/null +++ b/benches/generated/absolute_layout_align_items_and_justify_content_center.rs @@ -0,0 +1,33 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(110f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/absolute_layout_align_items_and_justify_content_center_and_bottom_position.rs b/benches/generated/absolute_layout_align_items_and_justify_content_center_and_bottom_position.rs new file mode 100644 index 000000000..1d935b71c --- /dev/null +++ b/benches/generated/absolute_layout_align_items_and_justify_content_center_and_bottom_position.rs @@ -0,0 +1,37 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + position: taffy::geometry::Rect { + bottom: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(110f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/absolute_layout_align_items_and_justify_content_center_and_left_position.rs b/benches/generated/absolute_layout_align_items_and_justify_content_center_and_left_position.rs new file mode 100644 index 000000000..4a1349862 --- /dev/null +++ b/benches/generated/absolute_layout_align_items_and_justify_content_center_and_left_position.rs @@ -0,0 +1,34 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + position: taffy::geometry::Rect { start: taffy::style::Dimension::Points(5f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(110f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/absolute_layout_align_items_and_justify_content_center_and_right_position.rs b/benches/generated/absolute_layout_align_items_and_justify_content_center_and_right_position.rs new file mode 100644 index 000000000..2af8e462a --- /dev/null +++ b/benches/generated/absolute_layout_align_items_and_justify_content_center_and_right_position.rs @@ -0,0 +1,34 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + position: taffy::geometry::Rect { end: taffy::style::Dimension::Points(5f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(110f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/absolute_layout_align_items_and_justify_content_center_and_top_position.rs b/benches/generated/absolute_layout_align_items_and_justify_content_center_and_top_position.rs new file mode 100644 index 000000000..0061986a0 --- /dev/null +++ b/benches/generated/absolute_layout_align_items_and_justify_content_center_and_top_position.rs @@ -0,0 +1,34 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + position: taffy::geometry::Rect { top: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(110f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/absolute_layout_align_items_and_justify_content_flex_end.rs b/benches/generated/absolute_layout_align_items_and_justify_content_flex_end.rs new file mode 100644 index 000000000..589f664c8 --- /dev/null +++ b/benches/generated/absolute_layout_align_items_and_justify_content_flex_end.rs @@ -0,0 +1,33 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::FlexEnd, + justify_content: taffy::style::JustifyContent::FlexEnd, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(110f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/absolute_layout_align_items_center.rs b/benches/generated/absolute_layout_align_items_center.rs new file mode 100644 index 000000000..7f4c0e867 --- /dev/null +++ b/benches/generated/absolute_layout_align_items_center.rs @@ -0,0 +1,32 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(110f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/absolute_layout_align_items_center_on_child_only.rs b/benches/generated/absolute_layout_align_items_center_on_child_only.rs new file mode 100644 index 000000000..28da3478a --- /dev/null +++ b/benches/generated/absolute_layout_align_items_center_on_child_only.rs @@ -0,0 +1,32 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + align_self: taffy::style::AlignSelf::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(110f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/absolute_layout_child_order.rs b/benches/generated/absolute_layout_child_order.rs new file mode 100644 index 000000000..dd473c440 --- /dev/null +++ b/benches/generated/absolute_layout_child_order.rs @@ -0,0 +1,59 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(110f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/absolute_layout_in_wrap_reverse_column_container.rs b/benches/generated/absolute_layout_in_wrap_reverse_column_container.rs new file mode 100644 index 000000000..05bdbc67c --- /dev/null +++ b/benches/generated/absolute_layout_in_wrap_reverse_column_container.rs @@ -0,0 +1,33 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_wrap: taffy::style::FlexWrap::WrapReverse, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/absolute_layout_in_wrap_reverse_column_container_flex_end.rs b/benches/generated/absolute_layout_in_wrap_reverse_column_container_flex_end.rs new file mode 100644 index 000000000..4bdd27338 --- /dev/null +++ b/benches/generated/absolute_layout_in_wrap_reverse_column_container_flex_end.rs @@ -0,0 +1,34 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + align_self: taffy::style::AlignSelf::FlexEnd, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_wrap: taffy::style::FlexWrap::WrapReverse, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/absolute_layout_in_wrap_reverse_row_container.rs b/benches/generated/absolute_layout_in_wrap_reverse_row_container.rs new file mode 100644 index 000000000..31e27ad22 --- /dev/null +++ b/benches/generated/absolute_layout_in_wrap_reverse_row_container.rs @@ -0,0 +1,32 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_wrap: taffy::style::FlexWrap::WrapReverse, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/absolute_layout_in_wrap_reverse_row_container_flex_end.rs b/benches/generated/absolute_layout_in_wrap_reverse_row_container_flex_end.rs new file mode 100644 index 000000000..2c4d2883c --- /dev/null +++ b/benches/generated/absolute_layout_in_wrap_reverse_row_container_flex_end.rs @@ -0,0 +1,33 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + align_self: taffy::style::AlignSelf::FlexEnd, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_wrap: taffy::style::FlexWrap::WrapReverse, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/absolute_layout_justify_content_center.rs b/benches/generated/absolute_layout_justify_content_center.rs new file mode 100644 index 000000000..ea2fceb51 --- /dev/null +++ b/benches/generated/absolute_layout_justify_content_center.rs @@ -0,0 +1,32 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(110f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/absolute_layout_no_size.rs b/benches/generated/absolute_layout_no_size.rs new file mode 100644 index 000000000..8423fe9fd --- /dev/null +++ b/benches/generated/absolute_layout_no_size.rs @@ -0,0 +1,23 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { position_type: taffy::style::PositionType::Absolute, ..Default::default() }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/absolute_layout_percentage_bottom_based_on_parent_height.rs b/benches/generated/absolute_layout_percentage_bottom_based_on_parent_height.rs new file mode 100644 index 000000000..85b21ebe3 --- /dev/null +++ b/benches/generated/absolute_layout_percentage_bottom_based_on_parent_height.rs @@ -0,0 +1,65 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + position: taffy::geometry::Rect { top: taffy::style::Dimension::Percent(0.5f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + position: taffy::geometry::Rect { + bottom: taffy::style::Dimension::Percent(0.5f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + position: taffy::geometry::Rect { + top: taffy::style::Dimension::Percent(0.1f32), + bottom: taffy::style::Dimension::Percent(0.1f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/absolute_layout_start_top_end_bottom.rs b/benches/generated/absolute_layout_start_top_end_bottom.rs new file mode 100644 index 000000000..31eb20376 --- /dev/null +++ b/benches/generated/absolute_layout_start_top_end_bottom.rs @@ -0,0 +1,33 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + position: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Points(10f32), + top: taffy::style::Dimension::Points(10f32), + bottom: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/absolute_layout_width_height_end_bottom.rs b/benches/generated/absolute_layout_width_height_end_bottom.rs new file mode 100644 index 000000000..d2b4aa616 --- /dev/null +++ b/benches/generated/absolute_layout_width_height_end_bottom.rs @@ -0,0 +1,36 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + position: taffy::geometry::Rect { + end: taffy::style::Dimension::Points(10f32), + bottom: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/absolute_layout_width_height_start_top.rs b/benches/generated/absolute_layout_width_height_start_top.rs new file mode 100644 index 000000000..b6213cb72 --- /dev/null +++ b/benches/generated/absolute_layout_width_height_start_top.rs @@ -0,0 +1,36 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + position: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + top: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/absolute_layout_width_height_start_top_end_bottom.rs b/benches/generated/absolute_layout_width_height_start_top_end_bottom.rs new file mode 100644 index 000000000..8b3edd78e --- /dev/null +++ b/benches/generated/absolute_layout_width_height_start_top_end_bottom.rs @@ -0,0 +1,38 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + position: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Points(10f32), + top: taffy::style::Dimension::Points(10f32), + bottom: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/absolute_layout_within_border.rs b/benches/generated/absolute_layout_within_border.rs new file mode 100644 index 000000000..785567712 --- /dev/null +++ b/benches/generated/absolute_layout_within_border.rs @@ -0,0 +1,121 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + position: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(0f32), + top: taffy::style::Dimension::Points(0f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + position: taffy::geometry::Rect { + end: taffy::style::Dimension::Points(0f32), + bottom: taffy::style::Dimension::Points(0f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Points(10f32), + top: taffy::style::Dimension::Points(10f32), + bottom: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + position: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(0f32), + top: taffy::style::Dimension::Points(0f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node3 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Points(10f32), + top: taffy::style::Dimension::Points(10f32), + bottom: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + position: taffy::geometry::Rect { + end: taffy::style::Dimension::Points(0f32), + bottom: taffy::style::Dimension::Points(0f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + padding: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Points(10f32), + top: taffy::style::Dimension::Points(10f32), + bottom: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + border: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Points(10f32), + top: taffy::style::Dimension::Points(10f32), + bottom: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2, node3], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/align_baseline.rs b/benches/generated/align_baseline.rs new file mode 100644 index 000000000..a5a4187c6 --- /dev/null +++ b/benches/generated/align_baseline.rs @@ -0,0 +1,44 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Baseline, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/align_baseline_child_multiline.rs b/benches/generated/align_baseline_child_multiline.rs new file mode 100644 index 000000000..13dee7286 --- /dev/null +++ b/benches/generated/align_baseline_child_multiline.rs @@ -0,0 +1,89 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(60f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node10 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(25f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node11 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(25f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node12 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(25f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node13 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(25f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_wrap: taffy::style::FlexWrap::Wrap, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), ..Default::default() }, + ..Default::default() + }, + &[node10, node11, node12, node13], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Baseline, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/align_baseline_nested_child.rs b/benches/generated/align_baseline_nested_child.rs new file mode 100644 index 000000000..c6d70b18c --- /dev/null +++ b/benches/generated/align_baseline_nested_child.rs @@ -0,0 +1,58 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node10 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[node10], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Baseline, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/align_center_should_size_based_on_content.rs b/benches/generated/align_center_should_size_based_on_content.rs new file mode 100644 index 000000000..b16d6488c --- /dev/null +++ b/benches/generated/align_center_should_size_based_on_content.rs @@ -0,0 +1,48 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node000 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, + &[node000], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + justify_content: taffy::style::JustifyContent::Center, + flex_grow: 0f32, + flex_shrink: 1f32, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/align_flex_start_with_shrinking_children.rs b/benches/generated/align_flex_start_with_shrinking_children.rs new file mode 100644 index 000000000..50206ee6a --- /dev/null +++ b/benches/generated/align_flex_start_with_shrinking_children.rs @@ -0,0 +1,35 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node000 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, + &[], + ) + .unwrap(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, + &[node000], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { align_items: taffy::style::AlignItems::FlexStart, ..Default::default() }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(500f32), + height: taffy::style::Dimension::Points(500f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/align_flex_start_with_shrinking_children_with_stretch.rs b/benches/generated/align_flex_start_with_shrinking_children_with_stretch.rs new file mode 100644 index 000000000..50206ee6a --- /dev/null +++ b/benches/generated/align_flex_start_with_shrinking_children_with_stretch.rs @@ -0,0 +1,35 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node000 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, + &[], + ) + .unwrap(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, + &[node000], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { align_items: taffy::style::AlignItems::FlexStart, ..Default::default() }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(500f32), + height: taffy::style::Dimension::Points(500f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/align_flex_start_with_stretching_children.rs b/benches/generated/align_flex_start_with_stretching_children.rs new file mode 100644 index 000000000..480033286 --- /dev/null +++ b/benches/generated/align_flex_start_with_stretching_children.rs @@ -0,0 +1,30 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node000 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, + &[], + ) + .unwrap(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, + &[node000], + ) + .unwrap(); + let node0 = taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[node00]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(500f32), + height: taffy::style::Dimension::Points(500f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/align_items_center.rs b/benches/generated/align_items_center.rs new file mode 100644 index 000000000..c9b3d2468 --- /dev/null +++ b/benches/generated/align_items_center.rs @@ -0,0 +1,31 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/align_items_center_child_with_margin_bigger_than_parent.rs b/benches/generated/align_items_center_child_with_margin_bigger_than_parent.rs new file mode 100644 index 000000000..560002e96 --- /dev/null +++ b/benches/generated/align_items_center_child_with_margin_bigger_than_parent.rs @@ -0,0 +1,43 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { align_items: taffy::style::AlignItems::Center, ..Default::default() }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/align_items_center_child_without_margin_bigger_than_parent.rs b/benches/generated/align_items_center_child_without_margin_bigger_than_parent.rs new file mode 100644 index 000000000..865935f92 --- /dev/null +++ b/benches/generated/align_items_center_child_without_margin_bigger_than_parent.rs @@ -0,0 +1,38 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(70f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { align_items: taffy::style::AlignItems::Center, ..Default::default() }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/align_items_center_with_child_margin.rs b/benches/generated/align_items_center_with_child_margin.rs new file mode 100644 index 000000000..5def29f5a --- /dev/null +++ b/benches/generated/align_items_center_with_child_margin.rs @@ -0,0 +1,32 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { top: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/align_items_center_with_child_top.rs b/benches/generated/align_items_center_with_child_top.rs new file mode 100644 index 000000000..92a89630b --- /dev/null +++ b/benches/generated/align_items_center_with_child_top.rs @@ -0,0 +1,32 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + position: taffy::geometry::Rect { top: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/align_items_flex_end.rs b/benches/generated/align_items_flex_end.rs new file mode 100644 index 000000000..0a9adad85 --- /dev/null +++ b/benches/generated/align_items_flex_end.rs @@ -0,0 +1,31 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::FlexEnd, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/align_items_flex_end_child_with_margin_bigger_than_parent.rs b/benches/generated/align_items_flex_end_child_with_margin_bigger_than_parent.rs new file mode 100644 index 000000000..69ff987e8 --- /dev/null +++ b/benches/generated/align_items_flex_end_child_with_margin_bigger_than_parent.rs @@ -0,0 +1,43 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { align_items: taffy::style::AlignItems::FlexEnd, ..Default::default() }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/align_items_flex_end_child_without_margin_bigger_than_parent.rs b/benches/generated/align_items_flex_end_child_without_margin_bigger_than_parent.rs new file mode 100644 index 000000000..63f9f16d5 --- /dev/null +++ b/benches/generated/align_items_flex_end_child_without_margin_bigger_than_parent.rs @@ -0,0 +1,38 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(70f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { align_items: taffy::style::AlignItems::FlexEnd, ..Default::default() }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/align_items_flex_start.rs b/benches/generated/align_items_flex_start.rs new file mode 100644 index 000000000..db8166b3b --- /dev/null +++ b/benches/generated/align_items_flex_start.rs @@ -0,0 +1,31 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::FlexStart, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/align_items_min_max.rs b/benches/generated/align_items_min_max.rs new file mode 100644 index 000000000..4938dd39f --- /dev/null +++ b/benches/generated/align_items_min_max.rs @@ -0,0 +1,36 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + align_items: taffy::style::AlignItems::Center, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Default::default() }, + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/align_items_stretch.rs b/benches/generated/align_items_stretch.rs new file mode 100644 index 000000000..a45d2f566 --- /dev/null +++ b/benches/generated/align_items_stretch.rs @@ -0,0 +1,26 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/align_self_baseline.rs b/benches/generated/align_self_baseline.rs new file mode 100644 index 000000000..f1c6f2ca3 --- /dev/null +++ b/benches/generated/align_self_baseline.rs @@ -0,0 +1,58 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_self: taffy::style::AlignSelf::Baseline, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node10 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_self: taffy::style::AlignSelf::Baseline, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[node10], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/align_self_center.rs b/benches/generated/align_self_center.rs new file mode 100644 index 000000000..baab76860 --- /dev/null +++ b/benches/generated/align_self_center.rs @@ -0,0 +1,31 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_self: taffy::style::AlignSelf::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/align_self_flex_end.rs b/benches/generated/align_self_flex_end.rs new file mode 100644 index 000000000..ef541d323 --- /dev/null +++ b/benches/generated/align_self_flex_end.rs @@ -0,0 +1,31 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_self: taffy::style::AlignSelf::FlexEnd, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/align_self_flex_end_override_flex_start.rs b/benches/generated/align_self_flex_end_override_flex_start.rs new file mode 100644 index 000000000..7c813b88b --- /dev/null +++ b/benches/generated/align_self_flex_end_override_flex_start.rs @@ -0,0 +1,32 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_self: taffy::style::AlignSelf::FlexEnd, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::FlexStart, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/align_self_flex_start.rs b/benches/generated/align_self_flex_start.rs new file mode 100644 index 000000000..c62df4ebb --- /dev/null +++ b/benches/generated/align_self_flex_start.rs @@ -0,0 +1,31 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_self: taffy::style::AlignSelf::FlexStart, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/align_strech_should_size_based_on_parent.rs b/benches/generated/align_strech_should_size_based_on_parent.rs new file mode 100644 index 000000000..6728c4fa2 --- /dev/null +++ b/benches/generated/align_strech_should_size_based_on_parent.rs @@ -0,0 +1,47 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node000 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, + &[node000], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + justify_content: taffy::style::JustifyContent::Center, + flex_grow: 0f32, + flex_shrink: 1f32, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/border_center_child.rs b/benches/generated/border_center_child.rs new file mode 100644 index 000000000..c1244f623 --- /dev/null +++ b/benches/generated/border_center_child.rs @@ -0,0 +1,37 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + border: taffy::geometry::Rect { + top: taffy::style::Dimension::Points(10f32), + bottom: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/border_flex_child.rs b/benches/generated/border_flex_child.rs new file mode 100644 index 000000000..6cada747d --- /dev/null +++ b/benches/generated/border_flex_child.rs @@ -0,0 +1,34 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + border: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Points(10f32), + top: taffy::style::Dimension::Points(10f32), + bottom: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/border_no_child.rs b/benches/generated/border_no_child.rs new file mode 100644 index 000000000..1ef2dedb1 --- /dev/null +++ b/benches/generated/border_no_child.rs @@ -0,0 +1,19 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + border: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Points(10f32), + top: taffy::style::Dimension::Points(10f32), + bottom: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/border_stretch_child.rs b/benches/generated/border_stretch_child.rs new file mode 100644 index 000000000..837bc8832 --- /dev/null +++ b/benches/generated/border_stretch_child.rs @@ -0,0 +1,33 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + border: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Points(10f32), + top: taffy::style::Dimension::Points(10f32), + bottom: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/child_min_max_width_flexing.rs b/benches/generated/child_min_max_width_flexing.rs new file mode 100644 index 000000000..0ca098406 --- /dev/null +++ b/benches/generated/child_min_max_width_flexing.rs @@ -0,0 +1,41 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_shrink: 0f32, + flex_basis: taffy::style::Dimension::Points(0f32), + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_shrink: 0f32, + flex_basis: taffy::style::Dimension::Percent(0.5f32), + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/container_with_unsized_child.rs b/benches/generated/container_with_unsized_child.rs new file mode 100644 index 000000000..7f5791e3b --- /dev/null +++ b/benches/generated/container_with_unsized_child.rs @@ -0,0 +1,18 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/display_none.rs b/benches/generated/display_none.rs new file mode 100644 index 000000000..7a1b4c755 --- /dev/null +++ b/benches/generated/display_none.rs @@ -0,0 +1,25 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { display: taffy::style::Display::None, flex_grow: 1f32, ..Default::default() }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/display_none_fixed_size.rs b/benches/generated/display_none_fixed_size.rs new file mode 100644 index 000000000..7703fe7b2 --- /dev/null +++ b/benches/generated/display_none_fixed_size.rs @@ -0,0 +1,33 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + display: taffy::style::Display::None, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/display_none_with_child.rs b/benches/generated/display_none_with_child.rs new file mode 100644 index 000000000..0d5f3fb93 --- /dev/null +++ b/benches/generated/display_none_with_child.rs @@ -0,0 +1,64 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }, + &[], + ) + .unwrap(); + let node10 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + display: taffy::style::Display::None, + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }, + &[node10], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/display_none_with_margin.rs b/benches/generated/display_none_with_margin.rs new file mode 100644 index 000000000..cb57920af --- /dev/null +++ b/benches/generated/display_none_with_margin.rs @@ -0,0 +1,40 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + display: taffy::style::Display::None, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Points(10f32), + top: taffy::style::Dimension::Points(10f32), + bottom: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/display_none_with_position.rs b/benches/generated/display_none_with_position.rs new file mode 100644 index 000000000..01c8657a8 --- /dev/null +++ b/benches/generated/display_none_with_position.rs @@ -0,0 +1,30 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + display: taffy::style::Display::None, + flex_grow: 1f32, + position: taffy::geometry::Rect { top: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_basis_and_main_dimen_set_when_flexing.rs b/benches/generated/flex_basis_and_main_dimen_set_when_flexing.rs new file mode 100644 index 000000000..edd877a69 --- /dev/null +++ b/benches/generated/flex_basis_and_main_dimen_set_when_flexing.rs @@ -0,0 +1,43 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(10f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(10f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(0f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_basis_flex_grow_column.rs b/benches/generated/flex_basis_flex_grow_column.rs new file mode 100644 index 000000000..18d9672f2 --- /dev/null +++ b/benches/generated/flex_basis_flex_grow_column.rs @@ -0,0 +1,30 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_basis_flex_grow_row.rs b/benches/generated/flex_basis_flex_grow_row.rs new file mode 100644 index 000000000..b69013fd4 --- /dev/null +++ b/benches/generated/flex_basis_flex_grow_row.rs @@ -0,0 +1,29 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_basis_flex_shrink_column.rs b/benches/generated/flex_basis_flex_shrink_column.rs new file mode 100644 index 000000000..726700dfd --- /dev/null +++ b/benches/generated/flex_basis_flex_shrink_column.rs @@ -0,0 +1,30 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_basis: taffy::style::Dimension::Points(100f32), ..Default::default() }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_basis: taffy::style::Dimension::Points(50f32), ..Default::default() }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_basis_flex_shrink_row.rs b/benches/generated/flex_basis_flex_shrink_row.rs new file mode 100644 index 000000000..5256a55b9 --- /dev/null +++ b/benches/generated/flex_basis_flex_shrink_row.rs @@ -0,0 +1,29 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_basis: taffy::style::Dimension::Points(100f32), ..Default::default() }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_basis: taffy::style::Dimension::Points(50f32), ..Default::default() }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_basis_larger_than_content_column.rs b/benches/generated/flex_basis_larger_than_content_column.rs new file mode 100644 index 000000000..2063adcff --- /dev/null +++ b/benches/generated/flex_basis_larger_than_content_column.rs @@ -0,0 +1,37 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_basis: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_basis_larger_than_content_row.rs b/benches/generated/flex_basis_larger_than_content_row.rs new file mode 100644 index 000000000..c8cac2b92 --- /dev/null +++ b/benches/generated/flex_basis_larger_than_content_row.rs @@ -0,0 +1,36 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_basis: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_basis_overrides_main_size.rs b/benches/generated/flex_basis_overrides_main_size.rs new file mode 100644 index 000000000..300769645 --- /dev/null +++ b/benches/generated/flex_basis_overrides_main_size.rs @@ -0,0 +1,48 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(50f32), + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_basis_slightly_smaller_then_content_with_flex_grow_large_size.rs b/benches/generated/flex_basis_slightly_smaller_then_content_with_flex_grow_large_size.rs new file mode 100644 index 000000000..57e0961e6 --- /dev/null +++ b/benches/generated/flex_basis_slightly_smaller_then_content_with_flex_grow_large_size.rs @@ -0,0 +1,61 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(60f32), + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node10 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(0f32), + ..Default::default() + }, + &[node10], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_basis_smaller_than_content_column.rs b/benches/generated/flex_basis_smaller_than_content_column.rs new file mode 100644 index 000000000..fa7bfb587 --- /dev/null +++ b/benches/generated/flex_basis_smaller_than_content_column.rs @@ -0,0 +1,37 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_basis: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_basis_smaller_than_content_row.rs b/benches/generated/flex_basis_smaller_than_content_row.rs new file mode 100644 index 000000000..8a4913216 --- /dev/null +++ b/benches/generated/flex_basis_smaller_than_content_row.rs @@ -0,0 +1,36 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_basis: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_basis_smaller_than_main_dimen_column.rs b/benches/generated/flex_basis_smaller_than_main_dimen_column.rs new file mode 100644 index 000000000..bcd4f8fe2 --- /dev/null +++ b/benches/generated/flex_basis_smaller_than_main_dimen_column.rs @@ -0,0 +1,28 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_basis: taffy::style::Dimension::Points(10f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_basis_smaller_than_main_dimen_row.rs b/benches/generated/flex_basis_smaller_than_main_dimen_row.rs new file mode 100644 index 000000000..5aa5d6e01 --- /dev/null +++ b/benches/generated/flex_basis_smaller_than_main_dimen_row.rs @@ -0,0 +1,27 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_basis: taffy::style::Dimension::Points(10f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_basis_smaller_then_content_with_flex_grow_large_size.rs b/benches/generated/flex_basis_smaller_then_content_with_flex_grow_large_size.rs new file mode 100644 index 000000000..06a8cc3a5 --- /dev/null +++ b/benches/generated/flex_basis_smaller_then_content_with_flex_grow_large_size.rs @@ -0,0 +1,61 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(0f32), + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node10 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(0f32), + ..Default::default() + }, + &[node10], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_basis_smaller_then_content_with_flex_grow_small_size.rs b/benches/generated/flex_basis_smaller_then_content_with_flex_grow_small_size.rs new file mode 100644 index 000000000..c55c32cd8 --- /dev/null +++ b/benches/generated/flex_basis_smaller_then_content_with_flex_grow_small_size.rs @@ -0,0 +1,61 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(0f32), + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node10 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(0f32), + ..Default::default() + }, + &[node10], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_basis_smaller_then_content_with_flex_grow_unconstraint_size.rs b/benches/generated/flex_basis_smaller_then_content_with_flex_grow_unconstraint_size.rs new file mode 100644 index 000000000..645f570f5 --- /dev/null +++ b/benches/generated/flex_basis_smaller_then_content_with_flex_grow_unconstraint_size.rs @@ -0,0 +1,53 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(0f32), + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node10 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(0f32), + ..Default::default() + }, + &[node10], + ) + .unwrap(); + let node = taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[node0, node1]).unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_basis_smaller_then_content_with_flex_grow_very_large_size.rs b/benches/generated/flex_basis_smaller_then_content_with_flex_grow_very_large_size.rs new file mode 100644 index 000000000..2af9ae9d7 --- /dev/null +++ b/benches/generated/flex_basis_smaller_then_content_with_flex_grow_very_large_size.rs @@ -0,0 +1,61 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(0f32), + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node10 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(0f32), + ..Default::default() + }, + &[node10], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_basis_unconstraint_column.rs b/benches/generated/flex_basis_unconstraint_column.rs new file mode 100644 index 000000000..68a1a18e1 --- /dev/null +++ b/benches/generated/flex_basis_unconstraint_column.rs @@ -0,0 +1,20 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_basis: taffy::style::Dimension::Points(50f32), + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_basis_unconstraint_row.rs b/benches/generated/flex_basis_unconstraint_row.rs new file mode 100644 index 000000000..c9787039f --- /dev/null +++ b/benches/generated/flex_basis_unconstraint_row.rs @@ -0,0 +1,15 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_basis: taffy::style::Dimension::Points(50f32), + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[node0]).unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_direction_column.rs b/benches/generated/flex_direction_column.rs new file mode 100644 index 000000000..849217abe --- /dev/null +++ b/benches/generated/flex_direction_column.rs @@ -0,0 +1,45 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_direction_column_no_height.rs b/benches/generated/flex_direction_column_no_height.rs new file mode 100644 index 000000000..4a0362b79 --- /dev/null +++ b/benches/generated/flex_direction_column_no_height.rs @@ -0,0 +1,41 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_direction_column_reverse.rs b/benches/generated/flex_direction_column_reverse.rs new file mode 100644 index 000000000..5b6b36ac3 --- /dev/null +++ b/benches/generated/flex_direction_column_reverse.rs @@ -0,0 +1,45 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::ColumnReverse, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_direction_row.rs b/benches/generated/flex_direction_row.rs new file mode 100644 index 000000000..a82cc92ad --- /dev/null +++ b/benches/generated/flex_direction_row.rs @@ -0,0 +1,44 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_direction_row_no_width.rs b/benches/generated/flex_direction_row_no_width.rs new file mode 100644 index 000000000..6c7566987 --- /dev/null +++ b/benches/generated/flex_direction_row_no_width.rs @@ -0,0 +1,40 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_direction_row_reverse.rs b/benches/generated/flex_direction_row_reverse.rs new file mode 100644 index 000000000..a5510f55f --- /dev/null +++ b/benches/generated/flex_direction_row_reverse.rs @@ -0,0 +1,45 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::RowReverse, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_grow_child.rs b/benches/generated/flex_grow_child.rs new file mode 100644 index 000000000..1ff31c391 --- /dev/null +++ b/benches/generated/flex_grow_child.rs @@ -0,0 +1,16 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(0f32), + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[node0]).unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_grow_flex_basis_percent_min_max.rs b/benches/generated/flex_grow_flex_basis_percent_min_max.rs new file mode 100644 index 000000000..d4c077ac6 --- /dev/null +++ b/benches/generated/flex_grow_flex_basis_percent_min_max.rs @@ -0,0 +1,43 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_shrink: 0f32, + flex_basis: taffy::style::Dimension::Points(0f32), + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20f32), ..Default::default() }, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_shrink: 0f32, + flex_basis: taffy::style::Dimension::Percent(0.5f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(120f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_grow_height_maximized.rs b/benches/generated/flex_grow_height_maximized.rs new file mode 100644 index 000000000..dfe9c4bf6 --- /dev/null +++ b/benches/generated/flex_grow_height_maximized.rs @@ -0,0 +1,55 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + &[], + ) + .unwrap(); + let node01 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + min_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + max_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(500f32), + ..Default::default() + }, + ..Default::default() + }, + &[node00, node01], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(500f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_grow_in_at_most_container.rs b/benches/generated/flex_grow_in_at_most_container.rs new file mode 100644 index 000000000..6640c251a --- /dev/null +++ b/benches/generated/flex_grow_in_at_most_container.rs @@ -0,0 +1,29 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(0f32), + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[node00]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::FlexStart, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_grow_less_than_factor_one.rs b/benches/generated/flex_grow_less_than_factor_one.rs new file mode 100644 index 000000000..7641060f4 --- /dev/null +++ b/benches/generated/flex_grow_less_than_factor_one.rs @@ -0,0 +1,40 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 0.2f32, + flex_shrink: 0f32, + flex_basis: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_grow: 0.2f32, flex_shrink: 0f32, ..Default::default() }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_grow: 0.4f32, flex_shrink: 0f32, ..Default::default() }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(500f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_grow_root_minimized.rs b/benches/generated/flex_grow_root_minimized.rs new file mode 100644 index 000000000..b9f59f10f --- /dev/null +++ b/benches/generated/flex_grow_root_minimized.rs @@ -0,0 +1,59 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + &[], + ) + .unwrap(); + let node01 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + min_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + max_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(500f32), + ..Default::default() + }, + ..Default::default() + }, + &[node00, node01], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + min_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + max_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(500f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_grow_shrink_at_most.rs b/benches/generated/flex_grow_shrink_at_most.rs new file mode 100644 index 000000000..3d4f2f075 --- /dev/null +++ b/benches/generated/flex_grow_shrink_at_most.rs @@ -0,0 +1,24 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, + &[], + ) + .unwrap(); + let node0 = taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[node00]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_grow_to_min.rs b/benches/generated/flex_grow_to_min.rs new file mode 100644 index 000000000..c360f0eb9 --- /dev/null +++ b/benches/generated/flex_grow_to_min.rs @@ -0,0 +1,37 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + min_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + max_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(500f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_grow_within_constrained_max_column.rs b/benches/generated/flex_grow_within_constrained_max_column.rs new file mode 100644 index 000000000..8d2e7e572 --- /dev/null +++ b/benches/generated/flex_grow_within_constrained_max_column.rs @@ -0,0 +1,37 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + max_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_grow_within_constrained_max_row.rs b/benches/generated/flex_grow_within_constrained_max_row.rs new file mode 100644 index 000000000..00d86b6c6 --- /dev/null +++ b/benches/generated/flex_grow_within_constrained_max_row.rs @@ -0,0 +1,46 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + &[], + ) + .unwrap(); + let node01 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Default::default() }, + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node00, node01], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), ..Default::default() }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_grow_within_constrained_max_width.rs b/benches/generated/flex_grow_within_constrained_max_width.rs new file mode 100644 index 000000000..41aad7c9d --- /dev/null +++ b/benches/generated/flex_grow_within_constrained_max_width.rs @@ -0,0 +1,40 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(300f32), + ..Default::default() + }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_grow_within_constrained_min_column.rs b/benches/generated/flex_grow_within_constrained_min_column.rs new file mode 100644 index 000000000..c1104a7a9 --- /dev/null +++ b/benches/generated/flex_grow_within_constrained_min_column.rs @@ -0,0 +1,28 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + min_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_grow_within_constrained_min_max_column.rs b/benches/generated/flex_grow_within_constrained_min_max_column.rs new file mode 100644 index 000000000..1c40314a7 --- /dev/null +++ b/benches/generated/flex_grow_within_constrained_min_max_column.rs @@ -0,0 +1,27 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + min_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_grow_within_constrained_min_row.rs b/benches/generated/flex_grow_within_constrained_min_row.rs new file mode 100644 index 000000000..6d64bdf10 --- /dev/null +++ b/benches/generated/flex_grow_within_constrained_min_row.rs @@ -0,0 +1,28 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Default::default() }, + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_grow_within_max_width.rs b/benches/generated/flex_grow_within_max_width.rs new file mode 100644 index 000000000..c7e7d6127 --- /dev/null +++ b/benches/generated/flex_grow_within_max_width.rs @@ -0,0 +1,40 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_root_ignored.rs b/benches/generated/flex_root_ignored.rs new file mode 100644 index 000000000..17f1d924f --- /dev/null +++ b/benches/generated/flex_root_ignored.rs @@ -0,0 +1,41 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + min_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + max_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(500f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_shrink_by_outer_margin_with_max_size.rs b/benches/generated/flex_shrink_by_outer_margin_with_max_size.rs new file mode 100644 index 000000000..01f73c571 --- /dev/null +++ b/benches/generated/flex_shrink_by_outer_margin_with_max_size.rs @@ -0,0 +1,32 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { top: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Default::default() }, + max_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(80f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_shrink_flex_grow_child_flex_shrink_other_child.rs b/benches/generated/flex_shrink_flex_grow_child_flex_shrink_other_child.rs new file mode 100644 index 000000000..e6e4fd18e --- /dev/null +++ b/benches/generated/flex_shrink_flex_grow_child_flex_shrink_other_child.rs @@ -0,0 +1,47 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 0f32, + flex_shrink: 1f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(500f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_shrink: 1f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(500f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(500f32), + height: taffy::style::Dimension::Points(500f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_shrink_flex_grow_row.rs b/benches/generated/flex_shrink_flex_grow_row.rs new file mode 100644 index 000000000..548cadab3 --- /dev/null +++ b/benches/generated/flex_shrink_flex_grow_row.rs @@ -0,0 +1,47 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 0f32, + flex_shrink: 1f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(500f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 0f32, + flex_shrink: 1f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(500f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(500f32), + height: taffy::style::Dimension::Points(500f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_shrink_to_zero.rs b/benches/generated/flex_shrink_to_zero.rs new file mode 100644 index 000000000..81b0a9da9 --- /dev/null +++ b/benches/generated/flex_shrink_to_zero.rs @@ -0,0 +1,55 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_shrink: 1f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(75f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_wrap_align_stretch_fits_one_row.rs b/benches/generated/flex_wrap_align_stretch_fits_one_row.rs new file mode 100644 index 000000000..a2443b2bd --- /dev/null +++ b/benches/generated/flex_wrap_align_stretch_fits_one_row.rs @@ -0,0 +1,36 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_wrap: taffy::style::FlexWrap::Wrap, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(150f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_wrap_children_with_min_main_overriding_flex_basis.rs b/benches/generated/flex_wrap_children_with_min_main_overriding_flex_basis.rs new file mode 100644 index 000000000..0666c127d --- /dev/null +++ b/benches/generated/flex_wrap_children_with_min_main_overriding_flex_basis.rs @@ -0,0 +1,36 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_basis: taffy::style::Dimension::Points(50f32), + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Default::default() }, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(55f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_basis: taffy::style::Dimension::Points(50f32), + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Default::default() }, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(55f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_wrap: taffy::style::FlexWrap::Wrap, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/flex_wrap_wrap_to_child_height.rs b/benches/generated/flex_wrap_wrap_to_child_height.rs new file mode 100644 index 000000000..3efbb6dc5 --- /dev/null +++ b/benches/generated/flex_wrap_wrap_to_child_height.rs @@ -0,0 +1,56 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node000 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node000], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_wrap: taffy::style::FlexWrap::Wrap, + align_items: taffy::style::AlignItems::FlexStart, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/justify_content_column_center.rs b/benches/generated/justify_content_column_center.rs new file mode 100644 index 000000000..e9c384279 --- /dev/null +++ b/benches/generated/justify_content_column_center.rs @@ -0,0 +1,46 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/justify_content_column_flex_end.rs b/benches/generated/justify_content_column_flex_end.rs new file mode 100644 index 000000000..3b239ebf4 --- /dev/null +++ b/benches/generated/justify_content_column_flex_end.rs @@ -0,0 +1,46 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + justify_content: taffy::style::JustifyContent::FlexEnd, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/justify_content_column_flex_start.rs b/benches/generated/justify_content_column_flex_start.rs new file mode 100644 index 000000000..849217abe --- /dev/null +++ b/benches/generated/justify_content_column_flex_start.rs @@ -0,0 +1,45 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/justify_content_column_min_height_and_margin_bottom.rs b/benches/generated/justify_content_column_min_height_and_margin_bottom.rs new file mode 100644 index 000000000..706e3e43a --- /dev/null +++ b/benches/generated/justify_content_column_min_height_and_margin_bottom.rs @@ -0,0 +1,32 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { bottom: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + justify_content: taffy::style::JustifyContent::Center, + min_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/justify_content_column_min_height_and_margin_top.rs b/benches/generated/justify_content_column_min_height_and_margin_top.rs new file mode 100644 index 000000000..f8788e993 --- /dev/null +++ b/benches/generated/justify_content_column_min_height_and_margin_top.rs @@ -0,0 +1,32 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { top: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + justify_content: taffy::style::JustifyContent::Center, + min_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/justify_content_column_space_around.rs b/benches/generated/justify_content_column_space_around.rs new file mode 100644 index 000000000..fd6947674 --- /dev/null +++ b/benches/generated/justify_content_column_space_around.rs @@ -0,0 +1,46 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + justify_content: taffy::style::JustifyContent::SpaceAround, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/justify_content_column_space_between.rs b/benches/generated/justify_content_column_space_between.rs new file mode 100644 index 000000000..d6d49e1ac --- /dev/null +++ b/benches/generated/justify_content_column_space_between.rs @@ -0,0 +1,46 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + justify_content: taffy::style::JustifyContent::SpaceBetween, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/justify_content_column_space_evenly.rs b/benches/generated/justify_content_column_space_evenly.rs new file mode 100644 index 000000000..46ca3a3f1 --- /dev/null +++ b/benches/generated/justify_content_column_space_evenly.rs @@ -0,0 +1,46 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + justify_content: taffy::style::JustifyContent::SpaceEvenly, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/justify_content_min_max.rs b/benches/generated/justify_content_min_max.rs new file mode 100644 index 000000000..b05df0f81 --- /dev/null +++ b/benches/generated/justify_content_min_max.rs @@ -0,0 +1,36 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + min_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + max_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/justify_content_min_width_with_padding_child_width_greater_than_parent.rs b/benches/generated/justify_content_min_width_with_padding_child_width_greater_than_parent.rs new file mode 100644 index 000000000..acad54843 --- /dev/null +++ b/benches/generated/justify_content_min_width_with_padding_child_width_greater_than_parent.rs @@ -0,0 +1,50 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node000 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(300f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + justify_content: taffy::style::JustifyContent::Center, + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(400f32), + ..Default::default() + }, + padding: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(100f32), + end: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node000], + ) + .unwrap(); + let node0 = taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[node00]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(1000f32), + height: taffy::style::Dimension::Points(1584f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/justify_content_min_width_with_padding_child_width_lower_than_parent.rs b/benches/generated/justify_content_min_width_with_padding_child_width_lower_than_parent.rs new file mode 100644 index 000000000..1206e4121 --- /dev/null +++ b/benches/generated/justify_content_min_width_with_padding_child_width_lower_than_parent.rs @@ -0,0 +1,50 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node000 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(199f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + justify_content: taffy::style::JustifyContent::Center, + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(400f32), + ..Default::default() + }, + padding: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(100f32), + end: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node000], + ) + .unwrap(); + let node0 = taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[node00]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(1080f32), + height: taffy::style::Dimension::Points(1584f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/justify_content_overflow_min_max.rs b/benches/generated/justify_content_overflow_min_max.rs new file mode 100644 index 000000000..4d2cb93cc --- /dev/null +++ b/benches/generated/justify_content_overflow_min_max.rs @@ -0,0 +1,64 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + justify_content: taffy::style::JustifyContent::Center, + min_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + max_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(110f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/justify_content_row_center.rs b/benches/generated/justify_content_row_center.rs new file mode 100644 index 000000000..0cb6dcb05 --- /dev/null +++ b/benches/generated/justify_content_row_center.rs @@ -0,0 +1,45 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/justify_content_row_flex_end.rs b/benches/generated/justify_content_row_flex_end.rs new file mode 100644 index 000000000..60e3790cc --- /dev/null +++ b/benches/generated/justify_content_row_flex_end.rs @@ -0,0 +1,45 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + justify_content: taffy::style::JustifyContent::FlexEnd, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/justify_content_row_flex_start.rs b/benches/generated/justify_content_row_flex_start.rs new file mode 100644 index 000000000..a82cc92ad --- /dev/null +++ b/benches/generated/justify_content_row_flex_start.rs @@ -0,0 +1,44 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/justify_content_row_max_width_and_margin.rs b/benches/generated/justify_content_row_max_width_and_margin.rs new file mode 100644 index 000000000..acba6f4b7 --- /dev/null +++ b/benches/generated/justify_content_row_max_width_and_margin.rs @@ -0,0 +1,29 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { start: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(80f32), ..Default::default() }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/justify_content_row_min_width_and_margin.rs b/benches/generated/justify_content_row_min_width_and_margin.rs new file mode 100644 index 000000000..07e8cfde8 --- /dev/null +++ b/benches/generated/justify_content_row_min_width_and_margin.rs @@ -0,0 +1,28 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { start: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + justify_content: taffy::style::JustifyContent::Center, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), ..Default::default() }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/justify_content_row_space_around.rs b/benches/generated/justify_content_row_space_around.rs new file mode 100644 index 000000000..c16bfe776 --- /dev/null +++ b/benches/generated/justify_content_row_space_around.rs @@ -0,0 +1,45 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + justify_content: taffy::style::JustifyContent::SpaceAround, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/justify_content_row_space_between.rs b/benches/generated/justify_content_row_space_between.rs new file mode 100644 index 000000000..1deb7955a --- /dev/null +++ b/benches/generated/justify_content_row_space_between.rs @@ -0,0 +1,45 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + justify_content: taffy::style::JustifyContent::SpaceBetween, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/justify_content_row_space_evenly.rs b/benches/generated/justify_content_row_space_evenly.rs new file mode 100644 index 000000000..4e3a0c4fc --- /dev/null +++ b/benches/generated/justify_content_row_space_evenly.rs @@ -0,0 +1,45 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + justify_content: taffy::style::JustifyContent::SpaceEvenly, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/margin_and_flex_column.rs b/benches/generated/margin_and_flex_column.rs new file mode 100644 index 000000000..37e10ff6e --- /dev/null +++ b/benches/generated/margin_and_flex_column.rs @@ -0,0 +1,32 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + margin: taffy::geometry::Rect { + top: taffy::style::Dimension::Points(10f32), + bottom: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/margin_and_flex_row.rs b/benches/generated/margin_and_flex_row.rs new file mode 100644 index 000000000..65c29918d --- /dev/null +++ b/benches/generated/margin_and_flex_row.rs @@ -0,0 +1,31 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + margin: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/margin_and_stretch_column.rs b/benches/generated/margin_and_stretch_column.rs new file mode 100644 index 000000000..25fc95f4c --- /dev/null +++ b/benches/generated/margin_and_stretch_column.rs @@ -0,0 +1,32 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + margin: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/margin_and_stretch_row.rs b/benches/generated/margin_and_stretch_row.rs new file mode 100644 index 000000000..648ff6291 --- /dev/null +++ b/benches/generated/margin_and_stretch_row.rs @@ -0,0 +1,31 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + margin: taffy::geometry::Rect { + top: taffy::style::Dimension::Points(10f32), + bottom: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/margin_auto_bottom.rs b/benches/generated/margin_auto_bottom.rs new file mode 100644 index 000000000..9505bbe6b --- /dev/null +++ b/benches/generated/margin_auto_bottom.rs @@ -0,0 +1,45 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { bottom: taffy::style::Dimension::Auto, ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/margin_auto_bottom_and_top.rs b/benches/generated/margin_auto_bottom_and_top.rs new file mode 100644 index 000000000..f7fcaab1a --- /dev/null +++ b/benches/generated/margin_auto_bottom_and_top.rs @@ -0,0 +1,49 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { + top: taffy::style::Dimension::Auto, + bottom: taffy::style::Dimension::Auto, + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/margin_auto_bottom_and_top_justify_center.rs b/benches/generated/margin_auto_bottom_and_top_justify_center.rs new file mode 100644 index 000000000..0440c2b34 --- /dev/null +++ b/benches/generated/margin_auto_bottom_and_top_justify_center.rs @@ -0,0 +1,49 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { + top: taffy::style::Dimension::Auto, + bottom: taffy::style::Dimension::Auto, + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/margin_auto_left.rs b/benches/generated/margin_auto_left.rs new file mode 100644 index 000000000..f3c75baca --- /dev/null +++ b/benches/generated/margin_auto_left.rs @@ -0,0 +1,45 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { start: taffy::style::Dimension::Auto, ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/margin_auto_left_and_right.rs b/benches/generated/margin_auto_left_and_right.rs new file mode 100644 index 000000000..7e518b75b --- /dev/null +++ b/benches/generated/margin_auto_left_and_right.rs @@ -0,0 +1,48 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { + start: taffy::style::Dimension::Auto, + end: taffy::style::Dimension::Auto, + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/margin_auto_left_and_right_column.rs b/benches/generated/margin_auto_left_and_right_column.rs new file mode 100644 index 000000000..02aa00194 --- /dev/null +++ b/benches/generated/margin_auto_left_and_right_column.rs @@ -0,0 +1,49 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { + start: taffy::style::Dimension::Auto, + end: taffy::style::Dimension::Auto, + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/margin_auto_left_and_right_column_and_center.rs b/benches/generated/margin_auto_left_and_right_column_and_center.rs new file mode 100644 index 000000000..02aa00194 --- /dev/null +++ b/benches/generated/margin_auto_left_and_right_column_and_center.rs @@ -0,0 +1,49 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { + start: taffy::style::Dimension::Auto, + end: taffy::style::Dimension::Auto, + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/margin_auto_left_and_right_strech.rs b/benches/generated/margin_auto_left_and_right_strech.rs new file mode 100644 index 000000000..7e518b75b --- /dev/null +++ b/benches/generated/margin_auto_left_and_right_strech.rs @@ -0,0 +1,48 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { + start: taffy::style::Dimension::Auto, + end: taffy::style::Dimension::Auto, + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/margin_auto_left_child_bigger_than_parent.rs b/benches/generated/margin_auto_left_child_bigger_than_parent.rs new file mode 100644 index 000000000..db10950f2 --- /dev/null +++ b/benches/generated/margin_auto_left_child_bigger_than_parent.rs @@ -0,0 +1,32 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(72f32), + height: taffy::style::Dimension::Points(72f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { start: taffy::style::Dimension::Auto, ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(52f32), + height: taffy::style::Dimension::Points(52f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/margin_auto_left_fix_right_child_bigger_than_parent.rs b/benches/generated/margin_auto_left_fix_right_child_bigger_than_parent.rs new file mode 100644 index 000000000..2aa082102 --- /dev/null +++ b/benches/generated/margin_auto_left_fix_right_child_bigger_than_parent.rs @@ -0,0 +1,36 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(72f32), + height: taffy::style::Dimension::Points(72f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { + start: taffy::style::Dimension::Auto, + end: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(52f32), + height: taffy::style::Dimension::Points(52f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/margin_auto_left_right_child_bigger_than_parent.rs b/benches/generated/margin_auto_left_right_child_bigger_than_parent.rs new file mode 100644 index 000000000..b11b6ba06 --- /dev/null +++ b/benches/generated/margin_auto_left_right_child_bigger_than_parent.rs @@ -0,0 +1,36 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(72f32), + height: taffy::style::Dimension::Points(72f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { + start: taffy::style::Dimension::Auto, + end: taffy::style::Dimension::Auto, + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(52f32), + height: taffy::style::Dimension::Points(52f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/margin_auto_left_stretching_child.rs b/benches/generated/margin_auto_left_stretching_child.rs new file mode 100644 index 000000000..169168067 --- /dev/null +++ b/benches/generated/margin_auto_left_stretching_child.rs @@ -0,0 +1,43 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + margin: taffy::geometry::Rect { start: taffy::style::Dimension::Auto, ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/margin_auto_mutiple_children_column.rs b/benches/generated/margin_auto_mutiple_children_column.rs new file mode 100644 index 000000000..0596295c4 --- /dev/null +++ b/benches/generated/margin_auto_mutiple_children_column.rs @@ -0,0 +1,60 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { top: taffy::style::Dimension::Auto, ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { top: taffy::style::Dimension::Auto, ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + align_items: taffy::style::AlignItems::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/margin_auto_mutiple_children_row.rs b/benches/generated/margin_auto_mutiple_children_row.rs new file mode 100644 index 000000000..3659e9044 --- /dev/null +++ b/benches/generated/margin_auto_mutiple_children_row.rs @@ -0,0 +1,59 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { end: taffy::style::Dimension::Auto, ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { end: taffy::style::Dimension::Auto, ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/margin_auto_right.rs b/benches/generated/margin_auto_right.rs new file mode 100644 index 000000000..390701e15 --- /dev/null +++ b/benches/generated/margin_auto_right.rs @@ -0,0 +1,45 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { end: taffy::style::Dimension::Auto, ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/margin_auto_top.rs b/benches/generated/margin_auto_top.rs new file mode 100644 index 000000000..f2d445cce --- /dev/null +++ b/benches/generated/margin_auto_top.rs @@ -0,0 +1,45 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { top: taffy::style::Dimension::Auto, ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/margin_auto_top_and_bottom_strech.rs b/benches/generated/margin_auto_top_and_bottom_strech.rs new file mode 100644 index 000000000..e7940492a --- /dev/null +++ b/benches/generated/margin_auto_top_and_bottom_strech.rs @@ -0,0 +1,49 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { + top: taffy::style::Dimension::Auto, + bottom: taffy::style::Dimension::Auto, + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/margin_auto_top_stretching_child.rs b/benches/generated/margin_auto_top_stretching_child.rs new file mode 100644 index 000000000..4649a19fa --- /dev/null +++ b/benches/generated/margin_auto_top_stretching_child.rs @@ -0,0 +1,43 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + margin: taffy::geometry::Rect { top: taffy::style::Dimension::Auto, ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/margin_bottom.rs b/benches/generated/margin_bottom.rs new file mode 100644 index 000000000..768b8b51a --- /dev/null +++ b/benches/generated/margin_bottom.rs @@ -0,0 +1,29 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + margin: taffy::geometry::Rect { bottom: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + justify_content: taffy::style::JustifyContent::FlexEnd, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/margin_fix_left_auto_right_child_bigger_than_parent.rs b/benches/generated/margin_fix_left_auto_right_child_bigger_than_parent.rs new file mode 100644 index 000000000..f2e76da8b --- /dev/null +++ b/benches/generated/margin_fix_left_auto_right_child_bigger_than_parent.rs @@ -0,0 +1,36 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(72f32), + height: taffy::style::Dimension::Points(72f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Auto, + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(52f32), + height: taffy::style::Dimension::Points(52f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/margin_left.rs b/benches/generated/margin_left.rs new file mode 100644 index 000000000..07400cae1 --- /dev/null +++ b/benches/generated/margin_left.rs @@ -0,0 +1,27 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + margin: taffy::geometry::Rect { start: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/margin_right.rs b/benches/generated/margin_right.rs new file mode 100644 index 000000000..00ed840d8 --- /dev/null +++ b/benches/generated/margin_right.rs @@ -0,0 +1,28 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + margin: taffy::geometry::Rect { end: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + justify_content: taffy::style::JustifyContent::FlexEnd, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/margin_should_not_be_part_of_max_height.rs b/benches/generated/margin_should_not_be_part_of_max_height.rs new file mode 100644 index 000000000..e66471cd9 --- /dev/null +++ b/benches/generated/margin_should_not_be_part_of_max_height.rs @@ -0,0 +1,35 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + max_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { top: taffy::style::Dimension::Points(20f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(250f32), + height: taffy::style::Dimension::Points(250f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/margin_should_not_be_part_of_max_width.rs b/benches/generated/margin_should_not_be_part_of_max_width.rs new file mode 100644 index 000000000..55f6167a9 --- /dev/null +++ b/benches/generated/margin_should_not_be_part_of_max_width.rs @@ -0,0 +1,35 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { start: taffy::style::Dimension::Points(20f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(250f32), + height: taffy::style::Dimension::Points(250f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/margin_top.rs b/benches/generated/margin_top.rs new file mode 100644 index 000000000..7f2f6ca81 --- /dev/null +++ b/benches/generated/margin_top.rs @@ -0,0 +1,28 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + margin: taffy::geometry::Rect { top: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/margin_with_sibling_column.rs b/benches/generated/margin_with_sibling_column.rs new file mode 100644 index 000000000..61fffdaf4 --- /dev/null +++ b/benches/generated/margin_with_sibling_column.rs @@ -0,0 +1,30 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + margin: taffy::geometry::Rect { bottom: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/margin_with_sibling_row.rs b/benches/generated/margin_with_sibling_row.rs new file mode 100644 index 000000000..3f8296fad --- /dev/null +++ b/benches/generated/margin_with_sibling_row.rs @@ -0,0 +1,29 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + margin: taffy::geometry::Rect { end: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/max_height.rs b/benches/generated/max_height.rs new file mode 100644 index 000000000..9457d75b9 --- /dev/null +++ b/benches/generated/max_height.rs @@ -0,0 +1,30 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + max_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/max_height_overrides_height.rs b/benches/generated/max_height_overrides_height.rs new file mode 100644 index 000000000..8874c05c8 --- /dev/null +++ b/benches/generated/max_height_overrides_height.rs @@ -0,0 +1,18 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(200f32), ..Default::default() }, + max_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[node0]).unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/max_height_overrides_height_on_root.rs b/benches/generated/max_height_overrides_height_on_root.rs new file mode 100644 index 000000000..7caa6c006 --- /dev/null +++ b/benches/generated/max_height_overrides_height_on_root.rs @@ -0,0 +1,17 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(200f32), ..Default::default() }, + max_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/max_width.rs b/benches/generated/max_width.rs new file mode 100644 index 000000000..dba2a51a0 --- /dev/null +++ b/benches/generated/max_width.rs @@ -0,0 +1,28 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/max_width_overrides_width.rs b/benches/generated/max_width_overrides_width.rs new file mode 100644 index 000000000..0e1cd77ba --- /dev/null +++ b/benches/generated/max_width_overrides_width.rs @@ -0,0 +1,18 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), ..Default::default() }, + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[node0]).unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/max_width_overrides_width_on_root.rs b/benches/generated/max_width_overrides_width_on_root.rs new file mode 100644 index 000000000..470eac9c5 --- /dev/null +++ b/benches/generated/max_width_overrides_width_on_root.rs @@ -0,0 +1,17 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), ..Default::default() }, + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/min_height.rs b/benches/generated/min_height.rs new file mode 100644 index 000000000..a9e4320fb --- /dev/null +++ b/benches/generated/min_height.rs @@ -0,0 +1,33 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + min_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(60f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/min_height_overrides_height.rs b/benches/generated/min_height_overrides_height.rs new file mode 100644 index 000000000..82b61cb8c --- /dev/null +++ b/benches/generated/min_height_overrides_height.rs @@ -0,0 +1,18 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Default::default() }, + min_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[node0]).unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/min_height_overrides_height_on_root.rs b/benches/generated/min_height_overrides_height_on_root.rs new file mode 100644 index 000000000..3dac0c5ea --- /dev/null +++ b/benches/generated/min_height_overrides_height_on_root.rs @@ -0,0 +1,17 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Default::default() }, + min_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/min_max_percent_no_width_height.rs b/benches/generated/min_max_percent_no_width_height.rs new file mode 100644 index 000000000..6d1245865 --- /dev/null +++ b/benches/generated/min_max_percent_no_width_height.rs @@ -0,0 +1,37 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.1f32), + height: taffy::style::Dimension::Percent(0.1f32), + ..Default::default() + }, + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.1f32), + height: taffy::style::Dimension::Percent(0.1f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + align_items: taffy::style::AlignItems::FlexStart, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/min_width.rs b/benches/generated/min_width.rs new file mode 100644 index 000000000..90a5de04d --- /dev/null +++ b/benches/generated/min_width.rs @@ -0,0 +1,29 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/min_width_overrides_width.rs b/benches/generated/min_width_overrides_width.rs new file mode 100644 index 000000000..da5229c26 --- /dev/null +++ b/benches/generated/min_width_overrides_width.rs @@ -0,0 +1,18 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), ..Default::default() }, + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[node0]).unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/min_width_overrides_width_on_root.rs b/benches/generated/min_width_overrides_width_on_root.rs new file mode 100644 index 000000000..a01813c1d --- /dev/null +++ b/benches/generated/min_width_overrides_width_on_root.rs @@ -0,0 +1,17 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), ..Default::default() }, + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/mod.rs b/benches/generated/mod.rs new file mode 100644 index 000000000..62062ffc5 --- /dev/null +++ b/benches/generated/mod.rs @@ -0,0 +1,485 @@ +use criterion::{criterion_group, criterion_main, Criterion}; +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; +mod absolute_layout_align_items_and_justify_content_center_and_right_position; +mod absolute_layout_align_items_and_justify_content_center_and_top_position; +mod absolute_layout_align_items_and_justify_content_flex_end; +mod absolute_layout_align_items_center; +mod absolute_layout_align_items_center_on_child_only; +mod absolute_layout_child_order; +mod absolute_layout_in_wrap_reverse_column_container; +mod absolute_layout_in_wrap_reverse_column_container_flex_end; +mod absolute_layout_in_wrap_reverse_row_container; +mod absolute_layout_in_wrap_reverse_row_container_flex_end; +mod absolute_layout_justify_content_center; +mod absolute_layout_no_size; +mod absolute_layout_percentage_bottom_based_on_parent_height; +mod absolute_layout_start_top_end_bottom; +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 align_baseline; +mod align_baseline_child_multiline; +mod align_baseline_nested_child; +mod align_center_should_size_based_on_content; +mod align_flex_start_with_shrinking_children; +mod align_flex_start_with_shrinking_children_with_stretch; +mod align_flex_start_with_stretching_children; +mod align_items_center; +mod align_items_center_child_with_margin_bigger_than_parent; +mod align_items_center_child_without_margin_bigger_than_parent; +mod align_items_center_with_child_margin; +mod align_items_center_with_child_top; +mod align_items_flex_end; +mod align_items_flex_end_child_with_margin_bigger_than_parent; +mod align_items_flex_end_child_without_margin_bigger_than_parent; +mod align_items_flex_start; +mod align_items_min_max; +mod align_items_stretch; +mod align_self_baseline; +mod align_self_center; +mod align_self_flex_end; +mod align_self_flex_end_override_flex_start; +mod align_self_flex_start; +mod align_strech_should_size_based_on_parent; +mod border_center_child; +mod border_flex_child; +mod border_no_child; +mod border_stretch_child; +mod child_min_max_width_flexing; +mod container_with_unsized_child; +mod display_none; +mod display_none_fixed_size; +mod display_none_with_child; +mod display_none_with_margin; +mod display_none_with_position; +mod flex_basis_and_main_dimen_set_when_flexing; +mod flex_basis_flex_grow_column; +mod flex_basis_flex_grow_row; +mod flex_basis_flex_shrink_column; +mod flex_basis_flex_shrink_row; +mod flex_basis_larger_than_content_column; +mod flex_basis_larger_than_content_row; +mod flex_basis_overrides_main_size; +mod flex_basis_slightly_smaller_then_content_with_flex_grow_large_size; +mod flex_basis_smaller_than_content_column; +mod flex_basis_smaller_than_content_row; +mod flex_basis_smaller_than_main_dimen_column; +mod flex_basis_smaller_than_main_dimen_row; +mod flex_basis_smaller_then_content_with_flex_grow_large_size; +mod flex_basis_smaller_then_content_with_flex_grow_small_size; +mod flex_basis_smaller_then_content_with_flex_grow_unconstraint_size; +mod flex_basis_smaller_then_content_with_flex_grow_very_large_size; +mod flex_basis_unconstraint_column; +mod flex_basis_unconstraint_row; +mod flex_direction_column; +mod flex_direction_column_no_height; +mod flex_direction_column_reverse; +mod flex_direction_row; +mod flex_direction_row_no_width; +mod flex_direction_row_reverse; +mod flex_grow_child; +mod flex_grow_flex_basis_percent_min_max; +mod flex_grow_height_maximized; +mod flex_grow_in_at_most_container; +mod flex_grow_less_than_factor_one; +mod flex_grow_root_minimized; +mod flex_grow_shrink_at_most; +mod flex_grow_to_min; +mod flex_grow_within_constrained_max_column; +mod flex_grow_within_constrained_max_row; +mod flex_grow_within_constrained_max_width; +mod flex_grow_within_constrained_min_column; +mod flex_grow_within_constrained_min_max_column; +mod flex_grow_within_constrained_min_row; +mod flex_grow_within_max_width; +mod flex_root_ignored; +mod flex_shrink_by_outer_margin_with_max_size; +mod flex_shrink_flex_grow_child_flex_shrink_other_child; +mod flex_shrink_flex_grow_row; +mod flex_shrink_to_zero; +mod flex_wrap_align_stretch_fits_one_row; +mod flex_wrap_children_with_min_main_overriding_flex_basis; +mod flex_wrap_wrap_to_child_height; +mod justify_content_column_center; +mod justify_content_column_flex_end; +mod justify_content_column_flex_start; +mod justify_content_column_min_height_and_margin_bottom; +mod justify_content_column_min_height_and_margin_top; +mod justify_content_column_space_around; +mod justify_content_column_space_between; +mod justify_content_column_space_evenly; +mod justify_content_min_max; +mod justify_content_min_width_with_padding_child_width_greater_than_parent; +mod justify_content_min_width_with_padding_child_width_lower_than_parent; +mod justify_content_overflow_min_max; +mod justify_content_row_center; +mod justify_content_row_flex_end; +mod justify_content_row_flex_start; +mod justify_content_row_max_width_and_margin; +mod justify_content_row_min_width_and_margin; +mod justify_content_row_space_around; +mod justify_content_row_space_between; +mod justify_content_row_space_evenly; +mod margin_and_flex_column; +mod margin_and_flex_row; +mod margin_and_stretch_column; +mod margin_and_stretch_row; +mod margin_auto_bottom; +mod margin_auto_bottom_and_top; +mod margin_auto_bottom_and_top_justify_center; +mod margin_auto_left; +mod margin_auto_left_and_right; +mod margin_auto_left_and_right_column; +mod margin_auto_left_and_right_column_and_center; +mod margin_auto_left_and_right_strech; +mod margin_auto_left_child_bigger_than_parent; +mod margin_auto_left_fix_right_child_bigger_than_parent; +mod margin_auto_left_right_child_bigger_than_parent; +mod margin_auto_left_stretching_child; +mod margin_auto_mutiple_children_column; +mod margin_auto_mutiple_children_row; +mod margin_auto_right; +mod margin_auto_top; +mod margin_auto_top_and_bottom_strech; +mod margin_auto_top_stretching_child; +mod margin_bottom; +mod margin_fix_left_auto_right_child_bigger_than_parent; +mod margin_left; +mod margin_right; +mod margin_should_not_be_part_of_max_height; +mod margin_should_not_be_part_of_max_width; +mod margin_top; +mod margin_with_sibling_column; +mod margin_with_sibling_row; +mod max_height; +mod max_height_overrides_height; +mod max_height_overrides_height_on_root; +mod max_width; +mod max_width_overrides_width; +mod max_width_overrides_width_on_root; +mod min_height; +mod min_height_overrides_height; +mod min_height_overrides_height_on_root; +mod min_max_percent_no_width_height; +mod min_width; +mod min_width_overrides_width; +mod min_width_overrides_width_on_root; +mod nested_overflowing_child; +mod nested_overflowing_child_in_constraint_parent; +mod overflow_cross_axis; +mod overflow_main_axis; +mod padding_align_end_child; +mod padding_center_child; +mod padding_flex_child; +mod padding_no_child; +mod padding_stretch_child; +mod parent_wrap_child_size_overflowing_parent; +mod percent_absolute_position; +mod percent_within_flex_grow; +mod percentage_absolute_position; +mod percentage_container_in_wrapping_container; +mod percentage_flex_basis; +mod percentage_flex_basis_cross; +mod percentage_flex_basis_cross_max_height; +mod percentage_flex_basis_cross_max_width; +mod percentage_flex_basis_cross_min_height; +mod percentage_flex_basis_cross_min_width; +mod percentage_flex_basis_main_max_height; +mod percentage_flex_basis_main_max_width; +mod percentage_flex_basis_main_min_width; +mod percentage_margin_should_calculate_based_only_on_width; +mod percentage_multiple_nested_with_padding_margin_and_percentage_values; +mod percentage_padding_should_calculate_based_only_on_width; +mod percentage_position_bottom_right; +mod percentage_position_left_top; +mod percentage_size_based_on_parent_inner_size; +mod percentage_size_of_flex_basis; +mod percentage_width_height; +mod percentage_width_height_undefined_parent_size; +mod relative_position_should_not_nudge_siblings; +mod rounding_flex_basis_flex_grow_row_prime_number_width; +mod rounding_flex_basis_flex_grow_row_width_of_100; +mod rounding_flex_basis_flex_shrink_row; +mod rounding_flex_basis_overrides_main_size; +mod rounding_fractial_input_1; +mod rounding_fractial_input_2; +mod rounding_fractial_input_3; +mod rounding_fractial_input_4; +mod rounding_total_fractial; +mod rounding_total_fractial_nested; +mod size_defined_by_child; +mod size_defined_by_child_with_border; +mod size_defined_by_child_with_padding; +mod size_defined_by_grand_child; +mod width_smaller_then_content_with_flex_grow_large_size; +mod width_smaller_then_content_with_flex_grow_small_size; +mod width_smaller_then_content_with_flex_grow_unconstraint_size; +mod width_smaller_then_content_with_flex_grow_very_large_size; +mod wrap_column; +mod wrap_nodes_with_content_sizing_margin_cross; +mod wrap_nodes_with_content_sizing_overflowing_margin; +mod wrap_reverse_column; +mod wrap_reverse_column_fixed_size; +mod wrap_reverse_row; +mod wrap_reverse_row_align_content_center; +mod wrap_reverse_row_align_content_flex_start; +mod wrap_reverse_row_align_content_space_around; +mod wrap_reverse_row_align_content_stretch; +mod wrap_reverse_row_single_line_different_size; +mod wrap_row; +mod wrap_row_align_items_center; +mod wrap_row_align_items_flex_end; +mod wrapped_column_max_height; +mod wrapped_column_max_height_flex; +mod wrapped_row_within_align_items_center; +mod wrapped_row_within_align_items_flex_end; +mod wrapped_row_within_align_items_flex_start; +fn benchmark(c: &mut Criterion) { + c.bench_function("generated benchmarks", |b| { + b.iter(|| { + 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(); + absolute_layout_align_items_and_justify_content_center_and_right_position::compute(); + absolute_layout_align_items_and_justify_content_center_and_top_position::compute(); + absolute_layout_align_items_and_justify_content_flex_end::compute(); + absolute_layout_align_items_center::compute(); + absolute_layout_align_items_center_on_child_only::compute(); + absolute_layout_child_order::compute(); + absolute_layout_in_wrap_reverse_column_container::compute(); + absolute_layout_in_wrap_reverse_column_container_flex_end::compute(); + absolute_layout_in_wrap_reverse_row_container::compute(); + absolute_layout_in_wrap_reverse_row_container_flex_end::compute(); + absolute_layout_justify_content_center::compute(); + absolute_layout_no_size::compute(); + absolute_layout_percentage_bottom_based_on_parent_height::compute(); + absolute_layout_start_top_end_bottom::compute(); + absolute_layout_width_height_end_bottom::compute(); + absolute_layout_width_height_start_top::compute(); + absolute_layout_width_height_start_top_end_bottom::compute(); + absolute_layout_within_border::compute(); + align_baseline::compute(); + align_baseline_child_multiline::compute(); + align_baseline_nested_child::compute(); + align_center_should_size_based_on_content::compute(); + align_flex_start_with_shrinking_children::compute(); + align_flex_start_with_shrinking_children_with_stretch::compute(); + align_flex_start_with_stretching_children::compute(); + align_items_center::compute(); + align_items_center_child_with_margin_bigger_than_parent::compute(); + align_items_center_child_without_margin_bigger_than_parent::compute(); + align_items_center_with_child_margin::compute(); + align_items_center_with_child_top::compute(); + align_items_flex_end::compute(); + align_items_flex_end_child_with_margin_bigger_than_parent::compute(); + align_items_flex_end_child_without_margin_bigger_than_parent::compute(); + align_items_flex_start::compute(); + align_items_min_max::compute(); + align_items_stretch::compute(); + align_self_baseline::compute(); + align_self_center::compute(); + align_self_flex_end::compute(); + align_self_flex_end_override_flex_start::compute(); + align_self_flex_start::compute(); + align_strech_should_size_based_on_parent::compute(); + border_center_child::compute(); + border_flex_child::compute(); + border_no_child::compute(); + border_stretch_child::compute(); + child_min_max_width_flexing::compute(); + container_with_unsized_child::compute(); + display_none::compute(); + display_none_fixed_size::compute(); + display_none_with_child::compute(); + display_none_with_margin::compute(); + display_none_with_position::compute(); + flex_basis_and_main_dimen_set_when_flexing::compute(); + flex_basis_flex_grow_column::compute(); + flex_basis_flex_grow_row::compute(); + flex_basis_flex_shrink_column::compute(); + flex_basis_flex_shrink_row::compute(); + flex_basis_larger_than_content_column::compute(); + flex_basis_larger_than_content_row::compute(); + flex_basis_overrides_main_size::compute(); + flex_basis_slightly_smaller_then_content_with_flex_grow_large_size::compute(); + flex_basis_smaller_than_content_column::compute(); + flex_basis_smaller_than_content_row::compute(); + flex_basis_smaller_than_main_dimen_column::compute(); + flex_basis_smaller_than_main_dimen_row::compute(); + flex_basis_smaller_then_content_with_flex_grow_large_size::compute(); + flex_basis_smaller_then_content_with_flex_grow_small_size::compute(); + flex_basis_smaller_then_content_with_flex_grow_unconstraint_size::compute(); + flex_basis_smaller_then_content_with_flex_grow_very_large_size::compute(); + flex_basis_unconstraint_column::compute(); + flex_basis_unconstraint_row::compute(); + flex_direction_column::compute(); + flex_direction_column_no_height::compute(); + flex_direction_column_reverse::compute(); + flex_direction_row::compute(); + flex_direction_row_no_width::compute(); + flex_direction_row_reverse::compute(); + flex_grow_child::compute(); + flex_grow_flex_basis_percent_min_max::compute(); + flex_grow_height_maximized::compute(); + flex_grow_in_at_most_container::compute(); + flex_grow_less_than_factor_one::compute(); + flex_grow_root_minimized::compute(); + flex_grow_shrink_at_most::compute(); + flex_grow_to_min::compute(); + flex_grow_within_constrained_max_column::compute(); + flex_grow_within_constrained_max_row::compute(); + flex_grow_within_constrained_max_width::compute(); + flex_grow_within_constrained_min_column::compute(); + flex_grow_within_constrained_min_max_column::compute(); + flex_grow_within_constrained_min_row::compute(); + flex_grow_within_max_width::compute(); + flex_root_ignored::compute(); + flex_shrink_by_outer_margin_with_max_size::compute(); + flex_shrink_flex_grow_child_flex_shrink_other_child::compute(); + flex_shrink_flex_grow_row::compute(); + flex_shrink_to_zero::compute(); + flex_wrap_align_stretch_fits_one_row::compute(); + flex_wrap_children_with_min_main_overriding_flex_basis::compute(); + flex_wrap_wrap_to_child_height::compute(); + justify_content_column_center::compute(); + justify_content_column_flex_end::compute(); + justify_content_column_flex_start::compute(); + justify_content_column_min_height_and_margin_bottom::compute(); + justify_content_column_min_height_and_margin_top::compute(); + justify_content_column_space_around::compute(); + justify_content_column_space_between::compute(); + justify_content_column_space_evenly::compute(); + justify_content_min_max::compute(); + justify_content_min_width_with_padding_child_width_greater_than_parent::compute(); + justify_content_min_width_with_padding_child_width_lower_than_parent::compute(); + justify_content_overflow_min_max::compute(); + justify_content_row_center::compute(); + justify_content_row_flex_end::compute(); + justify_content_row_flex_start::compute(); + justify_content_row_max_width_and_margin::compute(); + justify_content_row_min_width_and_margin::compute(); + justify_content_row_space_around::compute(); + justify_content_row_space_between::compute(); + justify_content_row_space_evenly::compute(); + margin_and_flex_column::compute(); + margin_and_flex_row::compute(); + margin_and_stretch_column::compute(); + margin_and_stretch_row::compute(); + margin_auto_bottom::compute(); + margin_auto_bottom_and_top::compute(); + margin_auto_bottom_and_top_justify_center::compute(); + margin_auto_left::compute(); + margin_auto_left_and_right::compute(); + margin_auto_left_and_right_column::compute(); + margin_auto_left_and_right_column_and_center::compute(); + margin_auto_left_and_right_strech::compute(); + margin_auto_left_child_bigger_than_parent::compute(); + margin_auto_left_fix_right_child_bigger_than_parent::compute(); + margin_auto_left_right_child_bigger_than_parent::compute(); + margin_auto_left_stretching_child::compute(); + margin_auto_mutiple_children_column::compute(); + margin_auto_mutiple_children_row::compute(); + margin_auto_right::compute(); + margin_auto_top::compute(); + margin_auto_top_and_bottom_strech::compute(); + margin_auto_top_stretching_child::compute(); + margin_bottom::compute(); + margin_fix_left_auto_right_child_bigger_than_parent::compute(); + margin_left::compute(); + margin_right::compute(); + margin_should_not_be_part_of_max_height::compute(); + margin_should_not_be_part_of_max_width::compute(); + margin_top::compute(); + margin_with_sibling_column::compute(); + margin_with_sibling_row::compute(); + max_height::compute(); + max_height_overrides_height::compute(); + max_height_overrides_height_on_root::compute(); + max_width::compute(); + max_width_overrides_width::compute(); + max_width_overrides_width_on_root::compute(); + min_height::compute(); + min_height_overrides_height::compute(); + min_height_overrides_height_on_root::compute(); + min_max_percent_no_width_height::compute(); + min_width::compute(); + min_width_overrides_width::compute(); + min_width_overrides_width_on_root::compute(); + nested_overflowing_child::compute(); + nested_overflowing_child_in_constraint_parent::compute(); + overflow_cross_axis::compute(); + overflow_main_axis::compute(); + padding_align_end_child::compute(); + padding_center_child::compute(); + padding_flex_child::compute(); + padding_no_child::compute(); + padding_stretch_child::compute(); + parent_wrap_child_size_overflowing_parent::compute(); + percent_absolute_position::compute(); + percent_within_flex_grow::compute(); + percentage_absolute_position::compute(); + percentage_container_in_wrapping_container::compute(); + percentage_flex_basis::compute(); + percentage_flex_basis_cross::compute(); + percentage_flex_basis_cross_max_height::compute(); + percentage_flex_basis_cross_max_width::compute(); + percentage_flex_basis_cross_min_height::compute(); + percentage_flex_basis_cross_min_width::compute(); + percentage_flex_basis_main_max_height::compute(); + percentage_flex_basis_main_max_width::compute(); + percentage_flex_basis_main_min_width::compute(); + percentage_margin_should_calculate_based_only_on_width::compute(); + percentage_multiple_nested_with_padding_margin_and_percentage_values::compute(); + percentage_padding_should_calculate_based_only_on_width::compute(); + percentage_position_bottom_right::compute(); + percentage_position_left_top::compute(); + percentage_size_based_on_parent_inner_size::compute(); + percentage_size_of_flex_basis::compute(); + percentage_width_height::compute(); + percentage_width_height_undefined_parent_size::compute(); + relative_position_should_not_nudge_siblings::compute(); + rounding_flex_basis_flex_grow_row_prime_number_width::compute(); + rounding_flex_basis_flex_grow_row_width_of_100::compute(); + rounding_flex_basis_flex_shrink_row::compute(); + rounding_flex_basis_overrides_main_size::compute(); + rounding_fractial_input_1::compute(); + rounding_fractial_input_2::compute(); + rounding_fractial_input_3::compute(); + rounding_fractial_input_4::compute(); + rounding_total_fractial::compute(); + rounding_total_fractial_nested::compute(); + size_defined_by_child::compute(); + size_defined_by_child_with_border::compute(); + size_defined_by_child_with_padding::compute(); + size_defined_by_grand_child::compute(); + width_smaller_then_content_with_flex_grow_large_size::compute(); + width_smaller_then_content_with_flex_grow_small_size::compute(); + width_smaller_then_content_with_flex_grow_unconstraint_size::compute(); + width_smaller_then_content_with_flex_grow_very_large_size::compute(); + wrap_column::compute(); + wrap_nodes_with_content_sizing_margin_cross::compute(); + wrap_nodes_with_content_sizing_overflowing_margin::compute(); + wrap_reverse_column::compute(); + wrap_reverse_column_fixed_size::compute(); + wrap_reverse_row::compute(); + wrap_reverse_row_align_content_center::compute(); + wrap_reverse_row_align_content_flex_start::compute(); + wrap_reverse_row_align_content_space_around::compute(); + wrap_reverse_row_align_content_stretch::compute(); + wrap_reverse_row_single_line_different_size::compute(); + wrap_row::compute(); + wrap_row_align_items_center::compute(); + wrap_row_align_items_flex_end::compute(); + wrapped_column_max_height::compute(); + wrapped_column_max_height_flex::compute(); + wrapped_row_within_align_items_center::compute(); + wrapped_row_within_align_items_flex_end::compute(); + wrapped_row_within_align_items_flex_start::compute(); + }) + }); +} +criterion_group!(benches, benchmark); +criterion_main!(benches); diff --git a/benches/generated/nested_overflowing_child.rs b/benches/generated/nested_overflowing_child.rs new file mode 100644 index 000000000..4b50c8d7b --- /dev/null +++ b/benches/generated/nested_overflowing_child.rs @@ -0,0 +1,31 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[node00]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/nested_overflowing_child_in_constraint_parent.rs b/benches/generated/nested_overflowing_child_in_constraint_parent.rs new file mode 100644 index 000000000..0b2ad7c0c --- /dev/null +++ b/benches/generated/nested_overflowing_child_in_constraint_parent.rs @@ -0,0 +1,43 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/overflow_cross_axis.rs b/benches/generated/overflow_cross_axis.rs new file mode 100644 index 000000000..01530cf71 --- /dev/null +++ b/benches/generated/overflow_cross_axis.rs @@ -0,0 +1,30 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/overflow_main_axis.rs b/benches/generated/overflow_main_axis.rs new file mode 100644 index 000000000..65e2e1676 --- /dev/null +++ b/benches/generated/overflow_main_axis.rs @@ -0,0 +1,27 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_shrink: 0f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/padding_align_end_child.rs b/benches/generated/padding_align_end_child.rs new file mode 100644 index 000000000..d669ef626 --- /dev/null +++ b/benches/generated/padding_align_end_child.rs @@ -0,0 +1,39 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + padding: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(20f32), + end: taffy::style::Dimension::Points(20f32), + top: taffy::style::Dimension::Points(20f32), + bottom: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::FlexEnd, + justify_content: taffy::style::JustifyContent::FlexEnd, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/padding_center_child.rs b/benches/generated/padding_center_child.rs new file mode 100644 index 000000000..7aa9246ca --- /dev/null +++ b/benches/generated/padding_center_child.rs @@ -0,0 +1,39 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + padding: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Points(20f32), + top: taffy::style::Dimension::Points(10f32), + bottom: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/padding_flex_child.rs b/benches/generated/padding_flex_child.rs new file mode 100644 index 000000000..39e7820b8 --- /dev/null +++ b/benches/generated/padding_flex_child.rs @@ -0,0 +1,34 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + padding: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Points(10f32), + top: taffy::style::Dimension::Points(10f32), + bottom: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/padding_no_child.rs b/benches/generated/padding_no_child.rs new file mode 100644 index 000000000..c3eeca788 --- /dev/null +++ b/benches/generated/padding_no_child.rs @@ -0,0 +1,19 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + padding: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Points(10f32), + top: taffy::style::Dimension::Points(10f32), + bottom: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/padding_stretch_child.rs b/benches/generated/padding_stretch_child.rs new file mode 100644 index 000000000..f5f25c0d9 --- /dev/null +++ b/benches/generated/padding_stretch_child.rs @@ -0,0 +1,33 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + padding: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Points(10f32), + top: taffy::style::Dimension::Points(10f32), + bottom: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/parent_wrap_child_size_overflowing_parent.rs b/benches/generated/parent_wrap_child_size_overflowing_parent.rs new file mode 100644 index 000000000..cd099407d --- /dev/null +++ b/benches/generated/parent_wrap_child_size_overflowing_parent.rs @@ -0,0 +1,39 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/percent_absolute_position.rs b/benches/generated/percent_absolute_position.rs new file mode 100644 index 000000000..619f73281 --- /dev/null +++ b/benches/generated/percent_absolute_position.rs @@ -0,0 +1,54 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node01 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(1f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + position: taffy::geometry::Rect { + start: taffy::style::Dimension::Percent(0.5f32), + ..Default::default() + }, + ..Default::default() + }, + &[node00, node01], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/percent_within_flex_grow.rs b/benches/generated/percent_within_flex_grow.rs new file mode 100644 index 000000000..fc473387b --- /dev/null +++ b/benches/generated/percent_within_flex_grow.rs @@ -0,0 +1,54 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node10 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + ..Default::default() + }, + &[node10], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(350f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/percentage_absolute_position.rs b/benches/generated/percentage_absolute_position.rs new file mode 100644 index 000000000..c14a32794 --- /dev/null +++ b/benches/generated/percentage_absolute_position.rs @@ -0,0 +1,37 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + position: taffy::geometry::Rect { + start: taffy::style::Dimension::Percent(0.3f32), + top: taffy::style::Dimension::Percent(0.1f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/percentage_container_in_wrapping_container.rs b/benches/generated/percentage_container_in_wrapping_container.rs new file mode 100644 index 000000000..33dd189e7 --- /dev/null +++ b/benches/generated/percentage_container_in_wrapping_container.rs @@ -0,0 +1,62 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node000 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node001 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), ..Default::default() }, + ..Default::default() + }, + &[node000, node001], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + align_items: taffy::style::AlignItems::Center, + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/percentage_flex_basis.rs b/benches/generated/percentage_flex_basis.rs new file mode 100644 index 000000000..018119bdc --- /dev/null +++ b/benches/generated/percentage_flex_basis.rs @@ -0,0 +1,37 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.5f32), + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.25f32), + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/percentage_flex_basis_cross.rs b/benches/generated/percentage_flex_basis_cross.rs new file mode 100644 index 000000000..70860d3b9 --- /dev/null +++ b/benches/generated/percentage_flex_basis_cross.rs @@ -0,0 +1,38 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.5f32), + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.25f32), + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(400f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/percentage_flex_basis_cross_max_height.rs b/benches/generated/percentage_flex_basis_cross_max_height.rs new file mode 100644 index 000000000..f466969c2 --- /dev/null +++ b/benches/generated/percentage_flex_basis_cross_max_height.rs @@ -0,0 +1,46 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + max_size: taffy::geometry::Size { + height: taffy::style::Dimension::Percent(0.6f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 4f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + max_size: taffy::geometry::Size { + height: taffy::style::Dimension::Percent(0.2f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(400f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/percentage_flex_basis_cross_max_width.rs b/benches/generated/percentage_flex_basis_cross_max_width.rs new file mode 100644 index 000000000..83a52937b --- /dev/null +++ b/benches/generated/percentage_flex_basis_cross_max_width.rs @@ -0,0 +1,46 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.6f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 4f32, + flex_basis: taffy::style::Dimension::Percent(0.15f32), + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.2f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(400f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/percentage_flex_basis_cross_min_height.rs b/benches/generated/percentage_flex_basis_cross_min_height.rs new file mode 100644 index 000000000..7185d1241 --- /dev/null +++ b/benches/generated/percentage_flex_basis_cross_min_height.rs @@ -0,0 +1,44 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + min_size: taffy::geometry::Size { + height: taffy::style::Dimension::Percent(0.6f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 2f32, + min_size: taffy::geometry::Size { + height: taffy::style::Dimension::Percent(0.1f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(400f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/percentage_flex_basis_cross_min_width.rs b/benches/generated/percentage_flex_basis_cross_min_width.rs new file mode 100644 index 000000000..190298c37 --- /dev/null +++ b/benches/generated/percentage_flex_basis_cross_min_width.rs @@ -0,0 +1,46 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.6f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 4f32, + flex_basis: taffy::style::Dimension::Percent(0.15f32), + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.2f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(400f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/percentage_flex_basis_main_max_height.rs b/benches/generated/percentage_flex_basis_main_max_height.rs new file mode 100644 index 000000000..dbe76527f --- /dev/null +++ b/benches/generated/percentage_flex_basis_main_max_height.rs @@ -0,0 +1,45 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + max_size: taffy::geometry::Size { + height: taffy::style::Dimension::Percent(0.6f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 4f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + max_size: taffy::geometry::Size { + height: taffy::style::Dimension::Percent(0.2f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(400f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/percentage_flex_basis_main_max_width.rs b/benches/generated/percentage_flex_basis_main_max_width.rs new file mode 100644 index 000000000..2d7f8c2b2 --- /dev/null +++ b/benches/generated/percentage_flex_basis_main_max_width.rs @@ -0,0 +1,45 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.15f32), + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.6f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 4f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.2f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(400f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/percentage_flex_basis_main_min_width.rs b/benches/generated/percentage_flex_basis_main_min_width.rs new file mode 100644 index 000000000..253e6d719 --- /dev/null +++ b/benches/generated/percentage_flex_basis_main_min_width.rs @@ -0,0 +1,45 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.15f32), + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.6f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 4f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.2f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(400f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/percentage_margin_should_calculate_based_only_on_width.rs b/benches/generated/percentage_margin_should_calculate_based_only_on_width.rs new file mode 100644 index 000000000..4f88d2e37 --- /dev/null +++ b/benches/generated/percentage_margin_should_calculate_based_only_on_width.rs @@ -0,0 +1,48 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + margin: taffy::geometry::Rect { + start: taffy::style::Dimension::Percent(0.1f32), + end: taffy::style::Dimension::Percent(0.1f32), + top: taffy::style::Dimension::Percent(0.1f32), + bottom: taffy::style::Dimension::Percent(0.1f32), + ..Default::default() + }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/percentage_multiple_nested_with_padding_margin_and_percentage_values.rs b/benches/generated/percentage_multiple_nested_with_padding_margin_and_percentage_values.rs new file mode 100644 index 000000000..a05fa43f8 --- /dev/null +++ b/benches/generated/percentage_multiple_nested_with_padding_margin_and_percentage_values.rs @@ -0,0 +1,108 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node000 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.45f32), ..Default::default() }, + margin: taffy::geometry::Rect { + start: taffy::style::Dimension::Percent(0.05f32), + end: taffy::style::Dimension::Percent(0.05f32), + top: taffy::style::Dimension::Percent(0.05f32), + bottom: taffy::style::Dimension::Percent(0.05f32), + ..Default::default() + }, + padding: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(3f32), + end: taffy::style::Dimension::Points(3f32), + top: taffy::style::Dimension::Points(3f32), + bottom: taffy::style::Dimension::Points(3f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.5f32), ..Default::default() }, + margin: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(5f32), + end: taffy::style::Dimension::Points(5f32), + top: taffy::style::Dimension::Points(5f32), + bottom: taffy::style::Dimension::Points(5f32), + ..Default::default() + }, + padding: taffy::geometry::Rect { + start: taffy::style::Dimension::Percent(0.03f32), + end: taffy::style::Dimension::Percent(0.03f32), + top: taffy::style::Dimension::Percent(0.03f32), + bottom: taffy::style::Dimension::Percent(0.03f32), + ..Default::default() + }, + ..Default::default() + }, + &[node000], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.6f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(5f32), + end: taffy::style::Dimension::Points(5f32), + top: taffy::style::Dimension::Points(5f32), + bottom: taffy::style::Dimension::Points(5f32), + ..Default::default() + }, + padding: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(3f32), + end: taffy::style::Dimension::Points(3f32), + top: taffy::style::Dimension::Points(3f32), + bottom: taffy::style::Dimension::Points(3f32), + ..Default::default() + }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 4f32, + flex_basis: taffy::style::Dimension::Percent(0.15f32), + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.2f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/percentage_padding_should_calculate_based_only_on_width.rs b/benches/generated/percentage_padding_should_calculate_based_only_on_width.rs new file mode 100644 index 000000000..1d6466b53 --- /dev/null +++ b/benches/generated/percentage_padding_should_calculate_based_only_on_width.rs @@ -0,0 +1,48 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + padding: taffy::geometry::Rect { + start: taffy::style::Dimension::Percent(0.1f32), + end: taffy::style::Dimension::Percent(0.1f32), + top: taffy::style::Dimension::Percent(0.1f32), + bottom: taffy::style::Dimension::Percent(0.1f32), + ..Default::default() + }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/percentage_position_bottom_right.rs b/benches/generated/percentage_position_bottom_right.rs new file mode 100644 index 000000000..1a112b918 --- /dev/null +++ b/benches/generated/percentage_position_bottom_right.rs @@ -0,0 +1,35 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.55f32), + height: taffy::style::Dimension::Percent(0.15f32), + ..Default::default() + }, + position: taffy::geometry::Rect { + end: taffy::style::Dimension::Percent(0.2f32), + bottom: taffy::style::Dimension::Percent(0.1f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(500f32), + height: taffy::style::Dimension::Points(500f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/percentage_position_left_top.rs b/benches/generated/percentage_position_left_top.rs new file mode 100644 index 000000000..3944f4ae0 --- /dev/null +++ b/benches/generated/percentage_position_left_top.rs @@ -0,0 +1,35 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.45f32), + height: taffy::style::Dimension::Percent(0.55f32), + ..Default::default() + }, + position: taffy::geometry::Rect { + start: taffy::style::Dimension::Percent(0.1f32), + top: taffy::style::Dimension::Percent(0.2f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(400f32), + height: taffy::style::Dimension::Points(400f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/percentage_size_based_on_parent_inner_size.rs b/benches/generated/percentage_size_based_on_parent_inner_size.rs new file mode 100644 index 000000000..f4b99dfdd --- /dev/null +++ b/benches/generated/percentage_size_based_on_parent_inner_size.rs @@ -0,0 +1,38 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.5f32), + height: taffy::style::Dimension::Percent(0.5f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(400f32), + ..Default::default() + }, + padding: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(20f32), + end: taffy::style::Dimension::Points(20f32), + top: taffy::style::Dimension::Points(20f32), + bottom: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/percentage_size_of_flex_basis.rs b/benches/generated/percentage_size_of_flex_basis.rs new file mode 100644 index 000000000..fa1ce7112 --- /dev/null +++ b/benches/generated/percentage_size_of_flex_basis.rs @@ -0,0 +1,32 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(1f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_basis: taffy::style::Dimension::Points(50f32), ..Default::default() }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/percentage_width_height.rs b/benches/generated/percentage_width_height.rs new file mode 100644 index 000000000..517127b07 --- /dev/null +++ b/benches/generated/percentage_width_height.rs @@ -0,0 +1,30 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.3f32), + height: taffy::style::Dimension::Percent(0.3f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(400f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/percentage_width_height_undefined_parent_size.rs b/benches/generated/percentage_width_height_undefined_parent_size.rs new file mode 100644 index 000000000..b24025866 --- /dev/null +++ b/benches/generated/percentage_width_height_undefined_parent_size.rs @@ -0,0 +1,23 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.5f32), + height: taffy::style::Dimension::Percent(0.5f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/relative_position_should_not_nudge_siblings.rs b/benches/generated/relative_position_should_not_nudge_siblings.rs new file mode 100644 index 000000000..41b1f9cc3 --- /dev/null +++ b/benches/generated/relative_position_should_not_nudge_siblings.rs @@ -0,0 +1,38 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + position: taffy::geometry::Rect { top: taffy::style::Dimension::Points(15f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + position: taffy::geometry::Rect { top: taffy::style::Dimension::Points(15f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/rounding_flex_basis_flex_grow_row_prime_number_width.rs b/benches/generated/rounding_flex_basis_flex_grow_row_prime_number_width.rs new file mode 100644 index 000000000..add6997c4 --- /dev/null +++ b/benches/generated/rounding_flex_basis_flex_grow_row_prime_number_width.rs @@ -0,0 +1,27 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node1 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node2 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node3 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node4 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(113f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/rounding_flex_basis_flex_grow_row_width_of_100.rs b/benches/generated/rounding_flex_basis_flex_grow_row_width_of_100.rs new file mode 100644 index 000000000..17bcbe368 --- /dev/null +++ b/benches/generated/rounding_flex_basis_flex_grow_row_width_of_100.rs @@ -0,0 +1,23 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node1 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node2 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/rounding_flex_basis_flex_shrink_row.rs b/benches/generated/rounding_flex_basis_flex_shrink_row.rs new file mode 100644 index 000000000..3ecf14460 --- /dev/null +++ b/benches/generated/rounding_flex_basis_flex_shrink_row.rs @@ -0,0 +1,39 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_basis: taffy::style::Dimension::Points(25f32), ..Default::default() }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_basis: taffy::style::Dimension::Points(25f32), ..Default::default() }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(101f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/rounding_flex_basis_overrides_main_size.rs b/benches/generated/rounding_flex_basis_overrides_main_size.rs new file mode 100644 index 000000000..f39f5bfdb --- /dev/null +++ b/benches/generated/rounding_flex_basis_overrides_main_size.rs @@ -0,0 +1,49 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(50f32), + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(113f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/rounding_fractial_input_1.rs b/benches/generated/rounding_fractial_input_1.rs new file mode 100644 index 000000000..f8c742c1c --- /dev/null +++ b/benches/generated/rounding_fractial_input_1.rs @@ -0,0 +1,49 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(50f32), + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(113.4f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/rounding_fractial_input_2.rs b/benches/generated/rounding_fractial_input_2.rs new file mode 100644 index 000000000..93d65620c --- /dev/null +++ b/benches/generated/rounding_fractial_input_2.rs @@ -0,0 +1,49 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(50f32), + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(113.6f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/rounding_fractial_input_3.rs b/benches/generated/rounding_fractial_input_3.rs new file mode 100644 index 000000000..f8c742c1c --- /dev/null +++ b/benches/generated/rounding_fractial_input_3.rs @@ -0,0 +1,49 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(50f32), + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(113.4f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/rounding_fractial_input_4.rs b/benches/generated/rounding_fractial_input_4.rs new file mode 100644 index 000000000..f8c742c1c --- /dev/null +++ b/benches/generated/rounding_fractial_input_4.rs @@ -0,0 +1,49 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(50f32), + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(113.4f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/rounding_total_fractial.rs b/benches/generated/rounding_total_fractial.rs new file mode 100644 index 000000000..e11e1b797 --- /dev/null +++ b/benches/generated/rounding_total_fractial.rs @@ -0,0 +1,49 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 0.7f32, + flex_basis: taffy::style::Dimension::Points(50.3f32), + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20.3f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1.6f32, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1.1f32, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10.7f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(87.4f32), + height: taffy::style::Dimension::Points(113.4f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/rounding_total_fractial_nested.rs b/benches/generated/rounding_total_fractial_nested.rs new file mode 100644 index 000000000..af4770683 --- /dev/null +++ b/benches/generated/rounding_total_fractial_nested.rs @@ -0,0 +1,77 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(0.3f32), + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(9.9f32), ..Default::default() }, + position: taffy::geometry::Rect { + bottom: taffy::style::Dimension::Points(13.3f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node01 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 4f32, + flex_basis: taffy::style::Dimension::Points(0.3f32), + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(1.1f32), ..Default::default() }, + position: taffy::geometry::Rect { top: taffy::style::Dimension::Points(13.3f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 0.7f32, + flex_basis: taffy::style::Dimension::Points(50.3f32), + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20.3f32), ..Default::default() }, + ..Default::default() + }, + &[node00, node01], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1.6f32, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1.1f32, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10.7f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(87.4f32), + height: taffy::style::Dimension::Points(113.4f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/size_defined_by_child.rs b/benches/generated/size_defined_by_child.rs new file mode 100644 index 000000000..0f690f346 --- /dev/null +++ b/benches/generated/size_defined_by_child.rs @@ -0,0 +1,18 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[node0]).unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/size_defined_by_child_with_border.rs b/benches/generated/size_defined_by_child_with_border.rs new file mode 100644 index 000000000..1bae9d8aa --- /dev/null +++ b/benches/generated/size_defined_by_child_with_border.rs @@ -0,0 +1,32 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + border: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Points(10f32), + top: taffy::style::Dimension::Points(10f32), + bottom: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/size_defined_by_child_with_padding.rs b/benches/generated/size_defined_by_child_with_padding.rs new file mode 100644 index 000000000..4cb2728e0 --- /dev/null +++ b/benches/generated/size_defined_by_child_with_padding.rs @@ -0,0 +1,32 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + padding: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Points(10f32), + top: taffy::style::Dimension::Points(10f32), + bottom: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/size_defined_by_grand_child.rs b/benches/generated/size_defined_by_grand_child.rs new file mode 100644 index 000000000..de578f019 --- /dev/null +++ b/benches/generated/size_defined_by_grand_child.rs @@ -0,0 +1,19 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[node00]).unwrap(); + let node = taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[node0]).unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/width_smaller_then_content_with_flex_grow_large_size.rs b/benches/generated/width_smaller_then_content_with_flex_grow_large_size.rs new file mode 100644 index 000000000..74da466b4 --- /dev/null +++ b/benches/generated/width_smaller_then_content_with_flex_grow_large_size.rs @@ -0,0 +1,61 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), ..Default::default() }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node10 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), ..Default::default() }, + ..Default::default() + }, + &[node10], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/width_smaller_then_content_with_flex_grow_small_size.rs b/benches/generated/width_smaller_then_content_with_flex_grow_small_size.rs new file mode 100644 index 000000000..d34c5f603 --- /dev/null +++ b/benches/generated/width_smaller_then_content_with_flex_grow_small_size.rs @@ -0,0 +1,61 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), ..Default::default() }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node10 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), ..Default::default() }, + ..Default::default() + }, + &[node10], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/width_smaller_then_content_with_flex_grow_unconstraint_size.rs b/benches/generated/width_smaller_then_content_with_flex_grow_unconstraint_size.rs new file mode 100644 index 000000000..f7fb2e84f --- /dev/null +++ b/benches/generated/width_smaller_then_content_with_flex_grow_unconstraint_size.rs @@ -0,0 +1,53 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), ..Default::default() }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node10 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), ..Default::default() }, + ..Default::default() + }, + &[node10], + ) + .unwrap(); + let node = taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[node0, node1]).unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/width_smaller_then_content_with_flex_grow_very_large_size.rs b/benches/generated/width_smaller_then_content_with_flex_grow_very_large_size.rs new file mode 100644 index 000000000..9a160d82d --- /dev/null +++ b/benches/generated/width_smaller_then_content_with_flex_grow_very_large_size.rs @@ -0,0 +1,61 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), ..Default::default() }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node10 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), ..Default::default() }, + ..Default::default() + }, + &[node10], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/wrap_column.rs b/benches/generated/wrap_column.rs new file mode 100644 index 000000000..38f514406 --- /dev/null +++ b/benches/generated/wrap_column.rs @@ -0,0 +1,71 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(31f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(32f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(33f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node3 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(34f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_wrap: taffy::style::FlexWrap::Wrap, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2, node3], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/wrap_nodes_with_content_sizing_margin_cross.rs b/benches/generated/wrap_nodes_with_content_sizing_margin_cross.rs new file mode 100644 index 000000000..6363fe199 --- /dev/null +++ b/benches/generated/wrap_nodes_with_content_sizing_margin_cross.rs @@ -0,0 +1,70 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node000 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(40f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + &[node000], + ) + .unwrap(); + let node010 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(40f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node01 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + margin: taffy::geometry::Rect { top: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[node010], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_wrap: taffy::style::FlexWrap::Wrap, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(70f32), ..Default::default() }, + ..Default::default() + }, + &[node00, node01], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(500f32), + height: taffy::style::Dimension::Points(500f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/wrap_nodes_with_content_sizing_overflowing_margin.rs b/benches/generated/wrap_nodes_with_content_sizing_overflowing_margin.rs new file mode 100644 index 000000000..b0fbf01e2 --- /dev/null +++ b/benches/generated/wrap_nodes_with_content_sizing_overflowing_margin.rs @@ -0,0 +1,70 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node000 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(40f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + &[node000], + ) + .unwrap(); + let node010 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(40f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node01 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + margin: taffy::geometry::Rect { end: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[node010], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_wrap: taffy::style::FlexWrap::Wrap, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(85f32), ..Default::default() }, + ..Default::default() + }, + &[node00, node01], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(500f32), + height: taffy::style::Dimension::Points(500f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/wrap_reverse_column.rs b/benches/generated/wrap_reverse_column.rs new file mode 100644 index 000000000..ffc4d83cb --- /dev/null +++ b/benches/generated/wrap_reverse_column.rs @@ -0,0 +1,71 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(31f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(32f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(33f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node3 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(34f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_wrap: taffy::style::FlexWrap::WrapReverse, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2, node3], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/wrap_reverse_column_fixed_size.rs b/benches/generated/wrap_reverse_column_fixed_size.rs new file mode 100644 index 000000000..1f91568a7 --- /dev/null +++ b/benches/generated/wrap_reverse_column_fixed_size.rs @@ -0,0 +1,85 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(30f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node3 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node4 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_wrap: taffy::style::FlexWrap::WrapReverse, + align_items: taffy::style::AlignItems::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/wrap_reverse_row.rs b/benches/generated/wrap_reverse_row.rs new file mode 100644 index 000000000..35072aa24 --- /dev/null +++ b/benches/generated/wrap_reverse_row.rs @@ -0,0 +1,66 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(31f32), + height: taffy::style::Dimension::Points(30f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(32f32), + height: taffy::style::Dimension::Points(30f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(33f32), + height: taffy::style::Dimension::Points(30f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node3 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(34f32), + height: taffy::style::Dimension::Points(30f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_wrap: taffy::style::FlexWrap::WrapReverse, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1, node2, node3], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/wrap_reverse_row_align_content_center.rs b/benches/generated/wrap_reverse_row_align_content_center.rs new file mode 100644 index 000000000..09c4b918b --- /dev/null +++ b/benches/generated/wrap_reverse_row_align_content_center.rs @@ -0,0 +1,80 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(30f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node3 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node4 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_wrap: taffy::style::FlexWrap::WrapReverse, + align_content: taffy::style::AlignContent::Center, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/wrap_reverse_row_align_content_flex_start.rs b/benches/generated/wrap_reverse_row_align_content_flex_start.rs new file mode 100644 index 000000000..b7ba75700 --- /dev/null +++ b/benches/generated/wrap_reverse_row_align_content_flex_start.rs @@ -0,0 +1,80 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(30f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node3 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node4 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_wrap: taffy::style::FlexWrap::WrapReverse, + align_content: taffy::style::AlignContent::FlexStart, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/wrap_reverse_row_align_content_space_around.rs b/benches/generated/wrap_reverse_row_align_content_space_around.rs new file mode 100644 index 000000000..28d0f5a5b --- /dev/null +++ b/benches/generated/wrap_reverse_row_align_content_space_around.rs @@ -0,0 +1,80 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(30f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node3 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node4 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_wrap: taffy::style::FlexWrap::WrapReverse, + align_content: taffy::style::AlignContent::SpaceAround, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/wrap_reverse_row_align_content_stretch.rs b/benches/generated/wrap_reverse_row_align_content_stretch.rs new file mode 100644 index 000000000..a63187748 --- /dev/null +++ b/benches/generated/wrap_reverse_row_align_content_stretch.rs @@ -0,0 +1,79 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(30f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node3 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node4 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_wrap: taffy::style::FlexWrap::WrapReverse, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/wrap_reverse_row_single_line_different_size.rs b/benches/generated/wrap_reverse_row_single_line_different_size.rs new file mode 100644 index 000000000..bd7d12f5b --- /dev/null +++ b/benches/generated/wrap_reverse_row_single_line_different_size.rs @@ -0,0 +1,80 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(30f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node3 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node4 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_wrap: taffy::style::FlexWrap::WrapReverse, + align_content: taffy::style::AlignContent::FlexStart, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(300f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/wrap_row.rs b/benches/generated/wrap_row.rs new file mode 100644 index 000000000..7063501c1 --- /dev/null +++ b/benches/generated/wrap_row.rs @@ -0,0 +1,66 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(31f32), + height: taffy::style::Dimension::Points(30f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(32f32), + height: taffy::style::Dimension::Points(30f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(33f32), + height: taffy::style::Dimension::Points(30f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node3 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(34f32), + height: taffy::style::Dimension::Points(30f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_wrap: taffy::style::FlexWrap::Wrap, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1, node2, node3], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/wrap_row_align_items_center.rs b/benches/generated/wrap_row_align_items_center.rs new file mode 100644 index 000000000..eb06703fc --- /dev/null +++ b/benches/generated/wrap_row_align_items_center.rs @@ -0,0 +1,67 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(30f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node3 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(30f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_wrap: taffy::style::FlexWrap::Wrap, + align_items: taffy::style::AlignItems::Center, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1, node2, node3], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/wrap_row_align_items_flex_end.rs b/benches/generated/wrap_row_align_items_flex_end.rs new file mode 100644 index 000000000..53b93dc13 --- /dev/null +++ b/benches/generated/wrap_row_align_items_flex_end.rs @@ -0,0 +1,67 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(30f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node3 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(30f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_wrap: taffy::style::FlexWrap::Wrap, + align_items: taffy::style::AlignItems::FlexEnd, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1, node2, node3], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/wrapped_column_max_height.rs b/benches/generated/wrapped_column_max_height.rs new file mode 100644 index 000000000..f82e73524 --- /dev/null +++ b/benches/generated/wrapped_column_max_height.rs @@ -0,0 +1,72 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(500f32), + ..Default::default() + }, + max_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(20f32), + end: taffy::style::Dimension::Points(20f32), + top: taffy::style::Dimension::Points(20f32), + bottom: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_wrap: taffy::style::FlexWrap::Wrap, + align_items: taffy::style::AlignItems::Center, + align_content: taffy::style::AlignContent::Center, + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(700f32), + height: taffy::style::Dimension::Points(500f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/wrapped_column_max_height_flex.rs b/benches/generated/wrapped_column_max_height_flex.rs new file mode 100644 index 000000000..61ed42532 --- /dev/null +++ b/benches/generated/wrapped_column_max_height_flex.rs @@ -0,0 +1,78 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(500f32), + ..Default::default() + }, + max_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(20f32), + end: taffy::style::Dimension::Points(20f32), + top: taffy::style::Dimension::Points(20f32), + bottom: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_wrap: taffy::style::FlexWrap::Wrap, + align_items: taffy::style::AlignItems::Center, + align_content: taffy::style::AlignContent::Center, + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(700f32), + height: taffy::style::Dimension::Points(500f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/wrapped_row_within_align_items_center.rs b/benches/generated/wrapped_row_within_align_items_center.rs new file mode 100644 index 000000000..7e79d6c47 --- /dev/null +++ b/benches/generated/wrapped_row_within_align_items_center.rs @@ -0,0 +1,51 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(150f32), + height: taffy::style::Dimension::Points(80f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node01 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(80f32), + height: taffy::style::Dimension::Points(80f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_wrap: taffy::style::FlexWrap::Wrap, ..Default::default() }, + &[node00, node01], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + align_items: taffy::style::AlignItems::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/wrapped_row_within_align_items_flex_end.rs b/benches/generated/wrapped_row_within_align_items_flex_end.rs new file mode 100644 index 000000000..aef6576a7 --- /dev/null +++ b/benches/generated/wrapped_row_within_align_items_flex_end.rs @@ -0,0 +1,51 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(150f32), + height: taffy::style::Dimension::Points(80f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node01 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(80f32), + height: taffy::style::Dimension::Points(80f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_wrap: taffy::style::FlexWrap::Wrap, ..Default::default() }, + &[node00, node01], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + align_items: taffy::style::AlignItems::FlexEnd, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/benches/generated/wrapped_row_within_align_items_flex_start.rs b/benches/generated/wrapped_row_within_align_items_flex_start.rs new file mode 100644 index 000000000..924a71057 --- /dev/null +++ b/benches/generated/wrapped_row_within_align_items_flex_start.rs @@ -0,0 +1,51 @@ +pub fn compute() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(150f32), + height: taffy::style::Dimension::Points(80f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node01 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(80f32), + height: taffy::style::Dimension::Points(80f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_wrap: taffy::style::FlexWrap::Wrap, ..Default::default() }, + &[node00, node01], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + align_items: taffy::style::AlignItems::FlexStart, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); +} diff --git a/deny.toml b/deny.toml new file mode 100644 index 000000000..b5926234f --- /dev/null +++ b/deny.toml @@ -0,0 +1,41 @@ +[advisories] +db-path = "~/.cargo/advisory-db" +db-urls = ["https://github.com/rustsec/advisory-db"] +vulnerability = "deny" +unmaintained = "deny" +yanked = "deny" +notice = "deny" +ignore = [ + "RUSTSEC-2021-0127" # from serde_cbor +] + +[licenses] +unlicensed = "deny" +copyleft = "deny" +allow = [ + "MIT", + "MIT-0", + "Apache-2.0", + "BSD-3-Clause", + "ISC", + "Zlib", + "0BSD", + "BSD-2-Clause", + "CC0-1.0", +] +default = "deny" + +[bans] +multiple-versions = "deny" +wildcards = "deny" +highlight = "all" +# Certain crates/versions that will be skipped when doing duplicate detection. +skip = [ + { name = "itoa", version = "1.0.2" } +] + +[sources] +unknown-registry = "deny" +unknown-git = "deny" +allow-registry = ["https://github.com/rust-lang/crates.io-index"] +allow-git = [] diff --git a/examples/basic.rs b/examples/basic.rs index 7289695d7..05e665294 100644 --- a/examples/basic.rs +++ b/examples/basic.rs @@ -1,24 +1,29 @@ -extern crate stretch; +use taffy::prelude::*; -fn main() { - let node = stretch::style::Node { - width: stretch::style::Dimension::Points(100.0), - height: stretch::style::Dimension::Points(100.0), - justify_content: stretch::style::JustifyContent::Center, +fn main() -> Result<(), taffy::error::TaffyError> { + let mut taffy = Taffy::new(); - children: vec![ - stretch::style::Node { - width: stretch::style::Dimension::Percent(0.5), + let child = taffy.new_leaf(FlexboxLayout { + size: Size { width: Dimension::Percent(0.5), height: Dimension::Auto }, + ..Default::default() + })?; - ..Default::default() - }, - ], + let node = taffy.new_with_children( + FlexboxLayout { + size: Size { width: Dimension::Points(100.0), height: Dimension::Points(100.0) }, + justify_content: JustifyContent::Center, + ..Default::default() + }, + &[child], + )?; - ..Default::default() - }; + taffy.compute_layout(node, Size { height: Some(100.0), width: Some(100.0) })?; - let layout = stretch::compute(&node); + // or just use undefined for 100 x 100 + // taffy.compute_layout(node, Size::undefined())?; - println!("{:#?}", layout); -} + println!("node: {:#?}", taffy.layout(node)?); + println!("child: {:#?}", taffy.layout(child)?); + Ok(()) +} diff --git a/examples/nested.rs b/examples/nested.rs new file mode 100644 index 000000000..afbc2adca --- /dev/null +++ b/examples/nested.rs @@ -0,0 +1,55 @@ +use taffy::prelude::*; + +fn main() -> Result<(), taffy::error::TaffyError> { + let mut taffy = Taffy::new(); + + // left + let child_t1 = taffy.new_leaf(FlexboxLayout { + size: Size { width: Dimension::Points(5.0), height: Dimension::Points(5.0) }, + ..Default::default() + })?; + + let div1 = taffy.new_with_children( + FlexboxLayout { + size: Size { width: Dimension::Percent(0.5), height: Dimension::Percent(1.0) }, + // justify_content: JustifyContent::Center, + ..Default::default() + }, + &[child_t1], + )?; + + // right + let child_t2 = taffy.new_leaf(FlexboxLayout { + size: Size { width: Dimension::Points(5.0), height: Dimension::Points(5.0) }, + ..Default::default() + })?; + + let div2 = taffy.new_with_children( + FlexboxLayout { + size: Size { width: Dimension::Percent(0.5), height: Dimension::Percent(1.0) }, + // justify_content: JustifyContent::Center, + ..Default::default() + }, + &[child_t2], + )?; + + let container = taffy.new_with_children( + FlexboxLayout { + size: Size { width: Dimension::Percent(1.0), height: Dimension::Percent(1.0) }, + ..Default::default() + }, + &[div1, div2], + )?; + + taffy.compute_layout(container, Size { height: Some(100.0), width: Some(100.0) })?; + + println!("node: {:#?}", taffy.layout(container)?); + + println!("div1: {:#?}", taffy.layout(div1)?); + println!("div2: {:#?}", taffy.layout(div2)?); + + println!("child1: {:#?}", taffy.layout(child_t1)?); + println!("child2: {:#?}", taffy.layout(child_t2)?); + + Ok(()) +} diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 000000000..53f62a6d9 --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,3 @@ +max_width = 120 +use_field_init_shorthand = true +use_small_heuristics = "Max" \ No newline at end of file diff --git a/scripts/gentest/Cargo.toml b/scripts/gentest/Cargo.toml new file mode 100644 index 000000000..64e086c10 --- /dev/null +++ b/scripts/gentest/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "gentest" +version = "0.1.0" +authors = ["Emil Sjölander "] +edition = "2018" + +[dependencies] +env_logger = "0.9.0" +fantoccini = "0.19.0" +json = "0.12.0" +log = "0.4" +proc-macro2 = "1.0.6" +quote = "1.0.2" +serde_json = "1" +syn = "1.0.7" +tokio = { version = "1.18", features = ["full"] } diff --git a/scripts/gentest/src/main.rs b/scripts/gentest/src/main.rs new file mode 100644 index 000000000..0f3fbba48 --- /dev/null +++ b/scripts/gentest/src/main.rs @@ -0,0 +1,486 @@ +use std::fs; +use std::path::{Path, PathBuf}; +use std::process::Command; + +use fantoccini::{Client, ClientBuilder}; +use json; +use log::*; +use proc_macro2::{Span, TokenStream}; +use quote::quote; +use syn::Ident; + +#[tokio::main] +async fn main() { + env_logger::init(); + // this requires being run by cargo, which is iffy + let root_dir = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap()); + let repo_root = root_dir.parent().and_then(Path::parent).unwrap(); + + let fixtures_root = repo_root.join("test_fixtures"); + let fixtures = fs::read_dir(fixtures_root).unwrap(); + + info!("reading test fixtures from disk"); + let mut fixtures: Vec<_> = fixtures + .into_iter() + .filter_map(|a| a.ok()) + .filter(|f| f.path().is_file() && f.path().extension().map(|p| p == "html").unwrap_or(false)) + .map(|f| { + let fixture_path = f.path().to_path_buf(); + let name = fixture_path.file_stem().unwrap().to_str().unwrap().to_string(); + (name, fixture_path) + }) + .collect(); + fixtures.sort_unstable_by_key(|f| f.0.clone()); + + info!("starting webdriver instance"); + let webdriver_url = "http://localhost:4444"; + let mut webdriver_handle = Command::new("chromedriver") + .arg("--port=4444") + .spawn() + .expect("ChromeDriver not found: Make sure you have it installed and added to your PATH."); + + // this is silly, but it works + std::thread::sleep(std::time::Duration::from_secs(1)); + + let mut caps = serde_json::map::Map::new(); + let chrome_opts = serde_json::json!({ "args": ["--headless", "--disable-gpu"] }); + caps.insert("goog:chromeOptions".to_string(), chrome_opts.clone()); + + info!("spawning webdriver client and collecting test descriptions"); + let client = ClientBuilder::native().capabilities(caps.clone()).connect(webdriver_url).await.unwrap(); + + let mut test_descs = vec![]; + for (name, fixture_path) in fixtures { + test_descs.push(test_root_element(client.clone(), name, fixture_path).await); + } + + info!("killing webdriver instance..."); + webdriver_handle.kill().unwrap(); + + info!("generating test sources and concatenating..."); + + let bench_descs: Vec<_> = test_descs + .iter() + .map(|(name, description)| { + debug!("generating bench contents for {}", &name); + (name.clone(), generate_bench(description)) + }) + .collect(); + + let test_descs: Vec<_> = test_descs + .iter() + .map(|(name, description)| { + debug!("generating test contents for {}", &name); + (name.clone(), generate_test(name, description)) + }) + .collect(); + + let benchmarks: Vec<_> = test_descs + .iter() + .map(|(name, _)| { + let bench_mod = Ident::new(name, Span::call_site()); + quote!(#bench_mod::compute()) + }) + .collect(); + + let test_mods = test_descs + .iter() + .map(|(name, _)| { + let name = Ident::new(name, Span::call_site()); + quote!(mod #name;) + }) + .fold(quote!(), |a, b| quote!(#a #b)); + + for (name, bench_body) in bench_descs { + let mut bench_filename = repo_root.join("benches").join("generated").join(&name); + bench_filename.set_extension("rs"); + debug!("writing {} to disk...", &name); + fs::write(bench_filename, bench_body.to_string()).unwrap(); + } + + for (name, test_body) in test_descs { + let mut test_filename = repo_root.join("tests").join("generated").join(&name); + test_filename.set_extension("rs"); + debug!("writing {} to disk...", &name); + fs::write(test_filename, test_body.to_string()).unwrap(); + } + + let bench_mods = quote!( + use criterion::{criterion_group, criterion_main, Criterion}; + + #test_mods + + fn benchmark(c: &mut Criterion) { + c.bench_function("generated benchmarks", |b| { + b.iter(|| { #(#benchmarks;)* }) + }); + } + + criterion_group!(benches, benchmark); + criterion_main!(benches); + ); + + info!("writing generated test file to disk..."); + fs::write(repo_root.join("benches").join("generated").join("mod.rs"), bench_mods.to_string()).unwrap(); + fs::write(repo_root.join("tests").join("generated").join("mod.rs"), test_mods.to_string()).unwrap(); + + info!("formatting the source directory"); + Command::new("cargo").arg("fmt").current_dir(repo_root).status().unwrap(); +} + +async fn test_root_element(client: Client, name: String, fixture_path: impl AsRef) -> (String, json::JsonValue) { + let fixture_path = fixture_path.as_ref(); + + let url = format!("file://{}", fixture_path.display()); + + client.goto(&url).await.unwrap(); + let description = client + .execute("return JSON.stringify(describeElement(document.getElementById('test-root')))", vec![]) + .await + .unwrap(); + let description_string = description.as_str().unwrap(); + let description = json::parse(description_string).unwrap(); + (name, description) +} + +fn generate_bench(description: &json::JsonValue) -> TokenStream { + let node_description = generate_node("node", &description); + + quote!( + pub fn compute() { + let mut taffy = taffy::Taffy::new(); + #node_description + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + } + ) +} + +fn generate_test(name: impl AsRef, description: &json::JsonValue) -> TokenStream { + let name = name.as_ref(); + let name = Ident::new(name, Span::call_site()); + let node_description = generate_node("node", &description); + let assertions = generate_assertions("node", &description); + + quote!( + #[test] + fn #name() { + let mut taffy = taffy::Taffy::new(); + #node_description + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + #assertions + } + ) +} + +fn generate_assertions(ident: &str, node: &json::JsonValue) -> TokenStream { + let layout = &node["layout"]; + + let read_f32 = |s: &str| layout[s].as_f32().unwrap(); + let width = read_f32("width"); + let height = read_f32("height"); + let x = read_f32("x"); + let y = read_f32("y"); + + let children = { + let mut c = Vec::new(); + match node["children"] { + json::JsonValue::Array(ref value) => { + for i in 0..value.len() { + let child = &value[i]; + c.push(generate_assertions(&format!("{}{}", ident, i), child)); + } + } + _ => (), + }; + c.into_iter().fold(quote!(), |a, b| quote!(#a #b)) + }; + + let ident = Ident::new(ident, Span::call_site()); + + quote!( + assert_eq!(taffy.layout(#ident).unwrap().size.width, #width); + assert_eq!(taffy.layout(#ident).unwrap().size.height, #height); + assert_eq!(taffy.layout(#ident).unwrap().location.x, #x); + assert_eq!(taffy.layout(#ident).unwrap().location.y, #y); + + #children + ) +} + +fn generate_node(ident: &str, node: &json::JsonValue) -> TokenStream { + let style = &node["style"]; + + let display = match style["display"] { + json::JsonValue::Short(ref value) => match value.as_ref() { + "none" => quote!(display: taffy::style::Display::None,), + _ => quote!(), + }, + _ => quote!(), + }; + + let position_type = match style["position_type"] { + json::JsonValue::Short(ref value) => match value.as_ref() { + "absolute" => quote!(position_type: taffy::style::PositionType::Absolute,), + _ => quote!(), + }, + _ => quote!(), + }; + + let direction = match style["direction"] { + json::JsonValue::Short(ref value) => match value.as_ref() { + "rtl" => quote!(direction: taffy::style::Direction::RTL,), + "ltr" => quote!(direction: taffy::style::Direction::LTR,), + _ => quote!(), + }, + _ => quote!(), + }; + + let flex_direction = match style["flexDirection"] { + json::JsonValue::Short(ref value) => match value.as_ref() { + "row-reverse" => quote!(flex_direction: taffy::style::FlexDirection::RowReverse,), + "column" => quote!(flex_direction: taffy::style::FlexDirection::Column,), + "column-reverse" => quote!(flex_direction: taffy::style::FlexDirection::ColumnReverse,), + _ => quote!(), + }, + _ => quote!(), + }; + + let flex_wrap = match style["flexWrap"] { + json::JsonValue::Short(ref value) => match value.as_ref() { + "wrap" => quote!(flex_wrap: taffy::style::FlexWrap::Wrap,), + "wrap-reverse" => quote!(flex_wrap: taffy::style::FlexWrap::WrapReverse,), + _ => quote!(), + }, + _ => quote!(), + }; + + let overflow = match style["overflow"] { + json::JsonValue::Short(ref value) => match value.as_ref() { + "hidden" => quote!(overflow: taffy::style::Overflow::Hidden,), + "scroll" => quote!(overflow: taffy::style::Overflow::Scroll,), + _ => quote!(), + }, + _ => quote!(), + }; + + let align_items = match style["alignItems"] { + json::JsonValue::Short(ref value) => match value.as_ref() { + "flex-start" => quote!(align_items: taffy::style::AlignItems::FlexStart,), + "flex-end" => quote!(align_items: taffy::style::AlignItems::FlexEnd,), + "center" => quote!(align_items: taffy::style::AlignItems::Center,), + "baseline" => quote!(align_items: taffy::style::AlignItems::Baseline,), + _ => quote!(), + }, + _ => quote!(), + }; + + let align_self = match style["alignSelf"] { + json::JsonValue::Short(ref value) => match value.as_ref() { + "flex-start" => quote!(align_self: taffy::style::AlignSelf::FlexStart,), + "flex-end" => quote!(align_self: taffy::style::AlignSelf::FlexEnd,), + "center" => quote!(align_self: taffy::style::AlignSelf::Center,), + "baseline" => quote!(align_self: taffy::style::AlignSelf::Baseline,), + "stretch" => quote!(align_self: taffy::style::AlignSelf::Stretch,), + _ => quote!(), + }, + _ => quote!(), + }; + + let align_content = match style["alignContent"] { + json::JsonValue::Short(ref value) => match value.as_ref() { + "flex-start" => quote!(align_content: taffy::style::AlignContent::FlexStart,), + "flex-end" => quote!(align_content: taffy::style::AlignContent::FlexEnd,), + "center" => quote!(align_content: taffy::style::AlignContent::Center,), + "space-between" => quote!(align_content: taffy::style::AlignContent::SpaceBetween,), + "space-around" => quote!(align_content: taffy::style::AlignContent::SpaceAround,), + _ => quote!(), + }, + _ => quote!(), + }; + + let justify_content = match style["justifyContent"] { + json::JsonValue::Short(ref value) => match value.as_ref() { + "flex-end" => quote!(justify_content: taffy::style::JustifyContent::FlexEnd,), + "center" => quote!(justify_content: taffy::style::JustifyContent::Center,), + "space-between" => quote!(justify_content: taffy::style::JustifyContent::SpaceBetween,), + "space-around" => quote!(justify_content: taffy::style::JustifyContent::SpaceAround,), + "space-evenly" => quote!(justify_content: taffy::style::JustifyContent::SpaceEvenly,), + _ => quote!(), + }, + _ => quote!(), + }; + + let flex_grow = match style["flexGrow"] { + json::JsonValue::Number(value) => { + let value: f32 = value.into(); + quote!(flex_grow: #value,) + } + _ => quote!(), + }; + + let flex_shrink = match style["flexShrink"] { + json::JsonValue::Number(value) => { + let value: f32 = value.into(); + quote!(flex_shrink: #value,) + } + _ => quote!(), + }; + + let flex_basis = match style["flexBasis"] { + json::JsonValue::Object(ref value) => { + let value = generate_dimension(value); + quote!(flex_basis: #value,) + } + _ => quote!(), + }; + + let size = match style["size"] { + json::JsonValue::Object(ref value) => { + let size = generate_size(value); + quote!(size: #size,) + } + _ => quote!(), + }; + + let min_size = match style["min_size"] { + json::JsonValue::Object(ref value) => { + let min_size = generate_size(value); + quote!(min_size: #min_size,) + } + _ => quote!(), + }; + + let max_size = match style["max_size"] { + json::JsonValue::Object(ref value) => { + let max_size = generate_size(value); + quote!(max_size: #max_size,) + } + _ => quote!(), + }; + + macro_rules! edges_quoted { + ($style:ident, $val:ident) => { + let $val = match $style[stringify!($val)] { + json::JsonValue::Object(ref value) => { + let edges = generate_edges(value); + quote!($val: #edges,) + }, + _ => quote!(), + }; + }; + } + + edges_quoted!(style, margin); + edges_quoted!(style, padding); + edges_quoted!(style, position); + edges_quoted!(style, border); + + let (children_body, children) = match node["children"] { + json::JsonValue::Array(ref value) => { + if value.len() > 0 { + let body = value + .iter() + .enumerate() + .map(|(i, child)| generate_node(&format!("{}{}", ident, i), child)) + .collect(); + let idents = value + .iter() + .enumerate() + .map(|(i, _)| Ident::new(&format!("{}{}", ident, i), Span::call_site())) + .collect::>(); + (body, quote!(&[#(#idents),*])) + } else { + (quote!(), quote!(&[])) + } + } + _ => (quote!(), quote!()), + }; + + let ident = Ident::new(&format!("{}", ident), Span::call_site()); + + quote!( + #children_body + let #ident = taffy.new_with_children( + taffy::style::FlexboxLayout { + #display + #direction + #position_type + #flex_direction + #flex_wrap + #overflow + #align_items + #align_self + #align_content + #justify_content + #flex_grow + #flex_shrink + #flex_basis + #size + #min_size + #max_size + #margin + #padding + #position + #border + ..Default::default() + }, + #children + // TODO: Only add children if they exist + ).unwrap();) +} + +macro_rules! dim_quoted { + ($obj:ident, $dim_name:ident) => { + let $dim_name = match $obj.get(stringify!($dim_name)) { + Some(json::JsonValue::Object(ref value)) => { + let dim = generate_dimension(value); + quote!($dim_name: #dim,) + } + _ => quote!(), + }; + }; +} + +fn generate_size(size: &json::object::Object) -> TokenStream { + dim_quoted!(size, width); + dim_quoted!(size, height); + quote!( + taffy::geometry::Size { + #width #height + ..Default::default() + } + ) +} + +fn generate_dimension(dimen: &json::object::Object) -> TokenStream { + let unit = dimen.get("unit").unwrap(); + let value = || dimen.get("value").unwrap().as_f32().unwrap(); + + match unit { + json::JsonValue::Short(ref unit) => match unit.as_ref() { + "auto" => quote!(taffy::style::Dimension::Auto), + "points" => { + let value = value(); + quote!(taffy::style::Dimension::Points(#value)) + } + "percent" => { + let value = value(); + quote!(taffy::style::Dimension::Percent(#value)) + } + _ => unreachable!(), + }, + _ => unreachable!(), + } +} + +fn generate_edges(dimen: &json::object::Object) -> TokenStream { + dim_quoted!(dimen, start); + dim_quoted!(dimen, end); + dim_quoted!(dimen, top); + dim_quoted!(dimen, bottom); + + quote!(taffy::geometry::Rect { + #start #end #top #bottom + ..Default::default() + }) +} diff --git a/scripts/gentest/test_base_style.css b/scripts/gentest/test_base_style.css new file mode 100644 index 000000000..d9c038e3a --- /dev/null +++ b/scripts/gentest/test_base_style.css @@ -0,0 +1,45 @@ +body { + padding: 0; + margin: 0; +} + +div, span, img { + box-sizing: border-box; + position: relative; + border: 0 solid black; + margin: 0; + padding: 0; + display: flex; +} + +body > * { + position: absolute; +} + +div { + background-color: #222; +} + +div > div { + background-color: #444; +} + +div > div > div { + background-color: #666; +} + +div > div > div > div { + background-color: #888; +} + +div > div > div > div > div { + background-color: #aaa; +} + +div > div > div > div > div > div { + background-color: #ccc; +} + +div > div > div > div > div > div > div { + background-color: #eee; +} \ No newline at end of file diff --git a/scripts/gentest/test_helper.js b/scripts/gentest/test_helper.js new file mode 100644 index 000000000..4baf07b1d --- /dev/null +++ b/scripts/gentest/test_helper.js @@ -0,0 +1,143 @@ +function define_element_prop(property, getter) { + if (!(property in Element.prototype)) { + Object.defineProperty(Element.prototype, property, { + get: function() { + return getter(this); + } + }); + } +} + +define_element_prop("__stretch_description__", (e) => { + return JSON.stringify(describeElement(e)); +}); + +function parseDimension(input) { + if (input.endsWith("px")) { + return { + unit: 'points', + value: Number(input.replace('px','')) + }; + } else if (input.endsWith("%")) { + return { + unit: 'percent', + value: Number(input.replace('%','')) / 100 + }; + } else { + return input == "auto" ? {unit: "auto"} : undefined; + } +} + +function parseNumber(input) { + if (input === "" || isNaN(input)) { + return undefined; + } else { + return Number(input); + } +} + +function parseEnum(input) { + if (input) { + return input; + } else { + return undefined; + } +} + +function parseEdges(edges) { + var start = parseDimension(edges.start); + var end = parseDimension(edges.end); + var top = parseDimension(edges.top); + var bottom = parseDimension(edges.bottom); + + if (start === undefined && end === undefined && top === undefined && bottom === undefined) { + return undefined; + } + + return { + start: start, + end: end, + top: top, + bottom: bottom + }; +} + +function parseSize(size) { + var width = parseDimension(size.width); + var height = parseDimension(size.height); + + if (width === undefined && height === undefined) { + return undefined; + } + + return { + width: width, + height: height, + }; +} + +function describeElement(e) { + return { + style: { + display: parseEnum(e.style.display), + + position_type: parseEnum(e.style.position), + direction: parseEnum(e.style.direction), + flexDirection: parseEnum(e.style.flexDirection), + + flexWrap: parseEnum(e.style.flexWrap), + overflow: parseEnum(e.style.overflow), + + alignItems: parseEnum(e.style.alignItems), + alignSelf: parseEnum(e.style.alignSelf), + alignContent: parseEnum(e.style.alignContent), + + justifyContent: parseEnum(e.style.justifyContent), + + flexGrow: parseNumber(e.style.flexGrow), + flexShrink: parseNumber(e.style.flexShrink), + flexBasis: parseDimension(e.style.flexBasis), + + size: parseSize({width: e.style.width, height: e.style.height}), + min_size: parseSize({width: e.style.minWidth, height: e.style.minHeight}), + max_size: parseSize({width: e.style.maxWidth, height: e.style.maxHeight}), + + margin: parseEdges({ + start: e.style.marginLeft, + end: e.style.marginRight, + top: e.style.marginTop, + bottom: e.style.marginBottom, + }), + + padding: parseEdges({ + start: e.style.paddingLeft, + end: e.style.paddingRight, + top: e.style.paddingTop, + bottom: e.style.paddingBottom, + }), + + border: parseEdges({ + start: e.style.borderLeftWidth, + end: e.style.borderRightWidth, + top: e.style.borderTopWidth, + bottom: e.style.borderBottomWidth, + }), + + position: parseEdges({ + start: e.style.left, + end: e.style.right, + top: e.style.top, + bottom: e.style.bottom, + }), + }, + + layout: { + width: e.offsetWidth, + height: e.offsetHeight, + x: e.offsetLeft + e.parentNode.clientLeft, + y: e.offsetTop + e.parentNode.clientTop, + }, + + children: Array.from(e.children).map(c => describeElement(c)), + } +} diff --git a/src/algo.rs b/src/algo.rs deleted file mode 100644 index 4fc059131..000000000 --- a/src/algo.rs +++ /dev/null @@ -1,781 +0,0 @@ -use std::f32; - -use style; -use layout; - -#[derive(Debug, Copy, Clone)] -struct FlexSize { - main: f32, - cross: f32, -} - -#[derive(Debug, Copy, Clone)] -struct SizeConstraint { - min: f32, - max: f32, -} - -impl SizeConstraint { - fn exactly(size: f32) -> SizeConstraint { - SizeConstraint { - min: size, - max: size, - } - } - - fn undefined() -> SizeConstraint { - SizeConstraint { - min: f32::NEG_INFINITY, - max: f32::INFINITY, - } - } - - fn at_least(size: f32) -> SizeConstraint { - SizeConstraint { - min: size, - max: f32::NEG_INFINITY, - } - } - - fn at_most(size: f32) -> SizeConstraint { - SizeConstraint { - min: f32::NEG_INFINITY, - max: size, - } - } - - fn between(min: f32, max: f32) -> SizeConstraint { - SizeConstraint { - min: min, - max: max, - } - } -} - -struct FlexItem<'a> { - node: &'a style::Node, - - // temporary values for main size determination - flex_basis: f32, - hypothetical_inner_main_size: f32, - hypothetical_outer_main_size: f32, - target_main_size: f32, - violation: f32, - frozen: bool, - - // temporary values for cross size determination - hypothetical_inner_cross_size: f32, - hypothetical_outer_cross_size: f32, - target_cross_size: f32, - - main_margin_start: f32, - main_margin_end: f32, - cross_margin_start: f32, - cross_margin_end: f32, - - // temporary values for holding offset in the main / cross direction. - // offset is the relative position from the item's natural flow position based on - // relative position values, alignment, and justification. Does not unclude margin/padding/border. - offset_main: f32, - offset_cross: f32, -} - -struct ComputeResult { - size: FlexSize, - children: Vec, -} - -struct FlexLine<'a> { - items: Vec>, - cross_size: f32, - offset_cross: f32, -} - -pub fn compute(root: &style::Node) -> layout::Node { - let result = compute_internal(root, SizeConstraint::undefined(), SizeConstraint::undefined()); - - layout::Node { - width: if root.flex_direction.is_row() { result.size.main } else { result.size.cross }, - height: if root.flex_direction.is_column() { result.size.main } else { result.size.cross }, - x: 0.0, - y: 0.0, - children: result.children, - } -} - -fn compute_internal(node: &style::Node, main: SizeConstraint, cross: SizeConstraint) -> ComputeResult { - // 9.2. Line Length Determination - - // 1. Generate anonymous flex items as described in §4 Flex Items. - - let mut flex_items: Vec = node.children.iter().map(|child| { - FlexItem { - node: child, - - flex_basis: 0.0, - hypothetical_inner_main_size: 0.0, - hypothetical_outer_main_size: 0.0, - target_main_size: 0.0, - violation: 0.0, - frozen: false, - - hypothetical_inner_cross_size: 0.0, - hypothetical_outer_cross_size: 0.0, - target_cross_size: 0.0, - - main_margin_start: 0.0, - main_margin_end: 0.0, - cross_margin_start: 0.0, - cross_margin_end: 0.0, - - offset_main: 0.0, - offset_cross: 0.0, - } - }).collect(); - - // 2. Determine the available main and cross space for the flex items. - // For each dimension, if that dimension of the flex container’s content box - // is a definite size, use that; if that dimension of the flex container is - // being sized under a min or max-content constraint, the available space in - // that dimension is that constraint; otherwise, subtract the flex container’s - // margin, border, and padding from the space available to the flex container - // in that dimension and use that value. This might result in an infinite value. - - let avaliable_main = node.main_size().resolve(main.max, { - main.max - - node.main_margin_start().resolve(main.max, 0.0) - - node.main_margin_end().resolve(main.max, 0.0) - }) - - node.main_padding_start().resolve(main.max, 0.0) - - node.main_padding_end().resolve(main.max, 0.0) - - node.main_border_start().resolve(main.max, 0.0) - - node.main_border_end().resolve(main.max, 0.0); - - let avaliable_cross = node.cross_size().resolve(cross.max, { - cross.max - - node.cross_margin_start().resolve(cross.max, 0.0) - - node.cross_margin_end().resolve(cross.max, 0.0) - }) - - node.cross_padding_start().resolve(cross.max, 0.0) - - node.cross_padding_end().resolve(cross.max, 0.0) - - node.cross_border_start().resolve(cross.max, 0.0) - - node.cross_border_end().resolve(cross.max, 0.0); - - // 3. Determine the flex base size and hypothetical main size of each item: - for child in &mut flex_items { - // A. If the item has a definite used flex basis, that’s the flex base size. - - let flex_basis = child.node.flex_basis.resolve(avaliable_main, f32::INFINITY); - if flex_basis.is_finite() { - child.flex_basis = flex_basis; - 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.node.aspect_ratio { - let cross_size = node.cross_size().resolve(avaliable_cross, f32::INFINITY); - - if cross_size.is_finite() && child.node.flex_basis == style::Dimension::Auto { - child.flex_basis = ratio * cross_size; - 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 - // constraint (e.g. when performing automatic table layout [CSS21]), - // size the item under that constraint. The flex base size is the item’s - // resulting main size. - - if main.min.is_finite() || main.max.is_finite() { - let size = compute_internal(child.node, main, cross).size; - child.flex_basis = size.main; - continue; - } - - // 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 - // inline axis is parallel to the main axis, lay the item out using the rules - // for a box in an orthogonal flow [CSS3-WRITING-MODES]. The flex base size - // is the item’s max-content main size. - - if avaliable_main.is_infinite() { - let size = compute_internal(child.node, SizeConstraint::undefined(), SizeConstraint::undefined()).size; - child.flex_basis = size.main; - continue; - } - - // 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. - // If a cross size is needed to determine the main size (e.g. when the - // flex item’s main size is in its block axis) and the flex item’s cross size - // is auto and not definite, in this calculation use fit-content as the - // flex item’s cross size. The flex base size is the item’s resulting main size. - - let size = compute_internal(child.node, SizeConstraint::at_most(avaliable_main), SizeConstraint::at_most(avaliable_cross)).size; - child.flex_basis = size.main; - } - - // The hypothetical main size is the item’s flex base size clamped according to its - // used min and max main sizes (and flooring the content box size at zero). - - for child in &mut flex_items { - child.hypothetical_inner_main_size = child.flex_basis - .max(child.node.min_main_size().resolve(avaliable_main, f32::MIN)) - .min(child.node.max_main_size().resolve(avaliable_main, f32::MAX)) - .max(0.0); - - child.hypothetical_outer_main_size = child.hypothetical_inner_main_size - + child.node.main_margin_start().resolve(avaliable_main, 0.0) - + child.node.main_margin_end().resolve(avaliable_main, 0.0); - } - - // 9.3. Main Size Determination - - // 5. Collect flex items into flex lines: - // - If the flex container is single-line, collect all the flex items into - // a single flex line. - // - Otherwise, starting from the first uncollected item, collect consecutive - // items one by one until the first time that the next collected item would - // not fit into the flex container’s inner main size (or until a forced break - // is encountered, see §10 Fragmenting Flex Layout). If the very first - // uncollected item wouldn’t fit, collect just it into the line. - // - // For this step, the size of a flex item is its outer hypothetical main size. (Note: This can be negative.) - // Repeat until all flex items have been collected into flex lines - // - // Note that the "collect as many" line will collect zero-sized flex items onto - // the end of the previous line even if the last non-zero item exactly "filled up" the line. - - let mut flex_lines = { - let mut lines: Vec = vec![]; - let mut line_length = 0.0; - - if node.wrap == style::Wrap::NoWrap { - lines.push(FlexLine { items: flex_items, cross_size: 0.0, offset_cross: 0.0 }); - } else { - let mut line = FlexLine { items: vec![], cross_size: 0.0, offset_cross: 0.0 }; - - for child in flex_items { - line_length += child.hypothetical_outer_main_size; - - if line_length > avaliable_main && line.items.len() > 0 { - line_length = child.hypothetical_outer_main_size; - lines.push(line); - line = FlexLine { items: vec![], cross_size: 0.0, offset_cross: 0.0 }; - } - - line.items.push(child); - } - - lines.push(line); - } - - lines - }; - - // 6. Resolve the flexible lengths of all the flex items to find their used main size. - // See §9.7 Resolving Flexible Lengths. - // - // 9.7. Resolving Flexible Lengths - - for line in &mut flex_lines { - // 1. Determine the used flex factor. Sum the outer hypothetical main sizes of all - // items on the line. If the sum is less than the flex container’s inner main size, - // use the flex grow factor for the rest of this algorithm; otherwise, use the - // flex shrink factor. - - let used_flex_factor: f32 = line.items.iter().map(|child| child.hypothetical_outer_main_size).sum(); - let growing = used_flex_factor < avaliable_main; - let shrinking = !growing; - - // 2. Size inflexible items. Freeze, setting its target main size to its hypothetical main size - // - Any item that has a flex factor of zero - // - If using the flex grow factor: any item that has a flex base size - // greater than its hypothetical main size - // - If using the flex shrink factor: any item that has a flex base size - // smaller than its hypothetical main size - - for child in line.items.iter_mut() { - child.target_main_size = child.hypothetical_inner_main_size; - - if (child.node.flex_grow == 0.0 && child.node.flex_shrink == 0.0) || - (growing && child.flex_basis > child.hypothetical_inner_main_size) || - (shrinking && child.flex_basis < child.hypothetical_inner_main_size) { - child.frozen = true; - } - } - - // 3. Calculate initial free space. Sum the outer sizes of all items on the line, - // and subtract this from the flex container’s inner main size. For frozen items, - // use their outer target main size; for other items, use their outer flex base size. - - let used_space: f32 = line.items.iter().map(|child| { - child.node.main_margin_start().resolve(avaliable_main, 0.0) + - child.node.main_margin_end().resolve(avaliable_main, 0.0) + - if child.frozen { - child.target_main_size - } else { - child.flex_basis - } - }).sum(); - - let initial_free_space = avaliable_main - used_space; - - // 4. Loop - - loop { - // a. Check for flexible items. If all the flex items on the line are frozen, - // free space has been distributed; exit this loop. - - let mut frozen: Vec<&mut FlexItem> = vec![]; - let mut unfrozen: Vec<&mut FlexItem> = vec![]; - - for child in line.items.iter_mut() { - if child.frozen { - frozen.push(child); - } else { - unfrozen.push(child); - } - } - - if unfrozen.len() == 0 { - break; - } - - // b. Calculate the remaining free space as for initial free space, above. - // If the sum of the unfrozen flex items’ flex factors is less than one, - // multiply the initial free space by this sum. If the magnitude of this - // value is less than the magnitude of the remaining free space, use this - // as the remaining free space. - - let used_space: f32 = Iterator::chain(frozen.iter(), unfrozen.iter()).map(|child| { - child.node.main_margin_start().resolve(avaliable_main, 0.0) + - child.node.main_margin_end().resolve(avaliable_main, 0.0) + - if child.frozen { - child.target_main_size - } else { - child.flex_basis - } - }).sum(); - - let sum_flex_grow: f32 = unfrozen.iter().map(|item| { item.node.flex_grow }).sum(); - let sum_flex_shrink: f32 = unfrozen.iter().map(|item| { item.node.flex_shrink }).sum(); - - let free_space = if growing && sum_flex_grow < 1.0 { - (initial_free_space * sum_flex_grow).min(avaliable_main - used_space) - } else if shrinking && sum_flex_shrink < 1.0 { - (initial_free_space * sum_flex_shrink).max(avaliable_main - used_space) - } else { - avaliable_main - used_space - }; - - // c. Distribute free space proportional to the flex factors. - // - If the remaining free space is zero - // Do Nothing - // - If using the flex grow factor - // Find the ratio of the item’s flex grow factor to the sum of the - // flex grow factors of all unfrozen items on the line. Set the item’s - // target main size to its flex base size plus a fraction of the remaining - // free space proportional to the ratio. - // - If using the flex shrink factor - // For every unfrozen item on the line, multiply its flex shrink factor by - // its inner flex base size, and note this as its scaled flex shrink factor. - // Find the ratio of the item’s scaled flex shrink factor to the sum of the - // scaled flex shrink factors of all unfrozen items on the line. Set the item’s - // target main size to its flex base size minus a fraction of the absolute value - // of the remaining free space proportional to the ratio. Note this may result - // in a negative inner main size; it will be corrected in the next step. - // - Otherwise - // Do Nothing - - if free_space > 0.0 && growing { - for child in &mut unfrozen { - child.target_main_size = child.flex_basis + free_space * (child.node.flex_grow / sum_flex_grow); - } - } else if free_space < 0.0 && shrinking { - for child in &mut unfrozen { - child.target_main_size = child.flex_basis + free_space * (child.node.flex_shrink / sum_flex_shrink); - } - } - - // d. Fix min/max violations. Clamp each non-frozen item’s target main size by its - // used min and max main sizes and floor its content-box size at zero. If the - // item’s target main size was made smaller by this, it’s a max violation. - // If the item’s target main size was made larger by this, it’s a min violation. - - let mut total_violation = 0.0; - for child in &mut unfrozen { - let max = child.node.max_main_size().resolve(avaliable_main, f32::MAX); - let min = child.node.min_main_size().resolve(avaliable_main, f32::MIN).max(0.0); - - let clamped = if child.target_main_size > max { - max - } else if child.target_main_size < min { - min - } else { - child.target_main_size - }; - - child.violation = clamped - child.target_main_size; - total_violation += child.violation; - child.target_main_size = clamped; - } - - // e. Freeze over-flexed items. The total violation is the sum of the adjustments - // from the previous step ∑(clamped size - unclamped size). If the total violation is: - // - Zero - // Freeze all items. - // - Positive - // Freeze all the items with min violations. - // - Negative - // Freeze all the items with max violations. - - if total_violation > 0.0 { - for child in &mut unfrozen { - child.frozen = child.violation < 0.0; - } - } else if total_violation < 0.0 { - for child in &mut unfrozen { - child.frozen = child.violation > 0.0; - } - } else { - for child in &mut unfrozen { - child.frozen = true; - } - } - - // f. Return to the start of this loop. - } - } - - // Not part of the spec from what i can see but seems correct - let container_main_size = if avaliable_main.is_finite() { - avaliable_main - } else { - let mut longest_line = f32::MIN; - - for line in &flex_lines { - let length: f32 = line.items.iter().map(|item| { - item.target_main_size - }).sum(); - - longest_line = if length > longest_line { - length - } else { - longest_line - }; - } - - longest_line - }.min(main.max).max(main.min).max(0.0); - - // 9.4. Cross Size Determination - - // 7. Determine the hypothetical cross size of each item by performing layout with the - // used main size and the available space, treating auto as fit-content. - - for line in &mut flex_lines { - for child in &mut line.items { - let size = compute_internal( - child.node, - SizeConstraint::exactly(child.target_main_size), - SizeConstraint::between(cross.min, avaliable_cross), - ).size; - - child.hypothetical_inner_cross_size = size.cross - .max(child.node.min_cross_size().resolve(avaliable_cross, f32::MIN)) - .min(child.node.max_cross_size().resolve(avaliable_cross, f32::MAX)) - .max(0.0); - - child.hypothetical_outer_cross_size = child.hypothetical_inner_cross_size - + node.cross_margin_start().resolve(avaliable_cross, 0.0) - + node.cross_margin_end().resolve(avaliable_cross, 0.0); - } - } - - // 8. Calculate the cross size of each flex line. - // If the flex container is single-line and has a definite cross size, the cross size - // of the flex line is the flex container’s inner cross size. Otherwise, for each flex line: - // - // 1. Collect all the flex items whose inline-axis is parallel to the main-axis, whose - // align-self is baseline, and whose cross-axis margins are both non-auto. Find the - // largest of the distances between each item’s baseline and its hypothetical outer - // cross-start edge, and the largest of the distances between each item’s baseline - // and its hypothetical outer cross-end edge, and sum these two values. - // 2. Among all the items not collected by the previous step, find the largest - // outer hypothetical cross size. - // 3. The used cross-size of the flex line is the largest of the numbers found in the - // previous two steps and zero. - // - // If the flex container is single-line, then clamp the line’s cross-size to be within - // the container’s computed min and max cross sizes. Note that if CSS 2.1’s definition - // of min/max-width/height applied more generally, this behavior would fall out automatically. - - if flex_lines.len() == 1 && avaliable_cross.is_finite() { - flex_lines[0].cross_size = avaliable_cross.min(cross.max).max(cross.min); - } else { - for line in &mut flex_lines { - // TODO handle baseline (1) - - line.cross_size = line.items.iter().map(|child| { - child.hypothetical_outer_cross_size - }).fold(0.0, |acc, x| acc.max(x)); - } - } - - // 9. Handle 'align-content: stretch'. If the flex container has a definite cross size, - // align-content is stretch, and the sum of the flex lines' cross sizes is less than - // the flex container’s inner cross size, increase the cross size of each flex line - // by equal amounts such that the sum of their cross sizes exactly equals the - // flex container’s inner cross size. - - if node.align_content == style::AlignContent::Stretch && avaliable_cross.is_finite() { - let total_cross: f32 = flex_lines.iter().map(|line| line.cross_size).sum(); - - if total_cross < avaliable_cross { - let remaining = avaliable_cross - total_cross; - let addition = remaining / flex_lines.len() as f32; - - for line in &mut flex_lines { - line.cross_size += addition; - } - } - } - - // 10. Collapse visibility:collapse items. If any flex items have visibility: collapse, - // note the cross size of the line they’re in as the item’s strut size, and restart - // layout from the beginning. - // - // In this second layout round, when collecting items into lines, treat the collapsed - // items as having zero main size. For the rest of the algorithm following that step, - // ignore the collapsed items entirely (as if they were display:none) except that after - // calculating the cross size of the lines, if any line’s cross size is less than the - // largest strut size among all the collapsed items in the line, set its cross size to - // that strut size. - // - // Skip this step in the second layout round. - - // TODO implement once (if ever) we support visibility:collapse - - // 11. Determine the used cross size of each flex item. If a flex item has align-self: stretch, - // its computed cross size property is auto, and neither of its cross-axis margins are auto, - // the used outer cross size is the used cross size of its flex line, clamped according to - // the item’s used min and max cross sizes. Otherwise, the used cross size is the item’s - // hypothetical cross size. - // - // If the flex item has align-self: stretch, redo layout for its contents, treating this - // used size as its definite cross size so that percentage-sized children can be resolved. - // - // Note that this step does not affect the main size of the flex item, even if it has an - // intrinsic aspect ratio. - - for line in &mut flex_lines { - for child in &mut line.items { - let is_stretch = child.node.align_self(node) == style::AlignSelf::Stretch; - - if is_stretch && - child.node.cross_margin_start() != style::Dimension::Auto && - child.node.cross_margin_end() != style::Dimension::Auto && - child.node.cross_size() == style::Dimension::Auto { - child.target_cross_size = line.cross_size - .min(child.node.max_cross_size().resolve(avaliable_cross, f32::MAX)) - .max(child.node.min_cross_size().resolve(avaliable_cross, f32::MIN)); - } else { - child.target_cross_size = child.hypothetical_inner_cross_size; - } - - if is_stretch { - // TODO use result somehow - compute_internal(child.node, SizeConstraint::exactly(child.target_main_size), SizeConstraint::exactly(child.target_cross_size)); - } - } - } - - // 9.5. Main-Axis Alignment - - // 12. Distribute any remaining free space. For each flex line: - // 1. If the remaining free space is positive and at least one main-axis margin on this - // line is auto, distribute the free space equally among these margins. Otherwise, - // set all auto margins to zero. - // 2. Align the items along the main-axis per justify-content. - - for line in &mut flex_lines { - let used_space: f32 = line.items.iter().map(|child| child.target_main_size).sum(); - let free_space = avaliable_main - used_space; - - if free_space > 0.0 { - let mut num_auto_margins = 0; - - for child in &mut line.items { - if child.node.main_margin_start() == style::Dimension::Auto { - num_auto_margins += 1; - } - if child.node.main_margin_end() == style::Dimension::Auto { - num_auto_margins += 1; - } - } - - if num_auto_margins > 0 { - let margin = free_space / num_auto_margins as f32; - - for child in &mut line.items { - if child.node.main_margin_start() == style::Dimension::Auto { - child.main_margin_start = margin; - } - if child.node.main_margin_end() == style::Dimension::Auto { - child.main_margin_end = margin; - } - } - } else { - let num_items = line.items.len(); - let mut is_first = true; - - for child in &mut line.items { - child.main_margin_start = child.node.main_margin_start().resolve(container_main_size, 0.0); - child.main_margin_end = child.node.main_margin_end().resolve(container_main_size, 0.0); - - child.offset_main = match node.justify_content { - style::JustifyContent::FlexStart => 0.0, - style::JustifyContent::Center => if is_first { free_space / 2.0 } else { 0.0 }, - style::JustifyContent::FlexEnd => if is_first { free_space } else { 0.0 }, - style::JustifyContent::SpaceBetween => if is_first { 0.0 } else { free_space / (num_items - 1) as f32 }, - style::JustifyContent::SpaceAround => if is_first { (free_space / num_items as f32) / 2.0 } else { free_space / num_items as f32 }, - style::JustifyContent::SpaceEvenly => free_space / (num_items + 1) as f32, - }; - - is_first = false; - } - } - } - } - - // 9.6. Cross-Axis Alignment - - // 13. Resolve cross-axis auto margins. If a flex item has auto cross-axis margins: - // - If its outer cross size (treating those auto margins as zero) is less than the - // cross size of its flex line, distribute the difference in those sizes equally - // to the auto margins. - // - Otherwise, if the block-start or inline-start margin (whichever is in the cross axis) - // is auto, set it to zero. Set the opposite margin so that the outer cross size of the - // item equals the cross size of its flex line. - - for line in &mut flex_lines { - for child in &mut line.items { - if child.target_cross_size < line.cross_size { - let free_space = line.cross_size - child.target_cross_size; - - if child.node.cross_margin_start() == style::Dimension::Auto && child.node.cross_margin_end() == style::Dimension::Auto { - child.cross_margin_start = free_space / 2.0; - child.cross_margin_end = free_space / 2.0; - } else if child.node.cross_margin_start() == style::Dimension::Auto { - child.cross_margin_start = free_space; - } else if child.node.cross_margin_end() == style::Dimension::Auto { - child.cross_margin_end = free_space; - } else { - child.cross_margin_start = child.node.cross_margin_start().resolve(line.cross_size, 0.0); - child.cross_margin_end = child.node.cross_margin_end().resolve(line.cross_size, 0.0); - - // 14. Align all flex items along the cross-axis per align-self, if neither of the item’s - // cross-axis margins are auto. - - child.offset_cross = match child.node.align_self(node) { - style::AlignSelf::Auto => 0.0, // Should never happen - style::AlignSelf::FlexStart => 0.0, - style::AlignSelf::FlexEnd => free_space, - style::AlignSelf::Center => free_space / 2.0, - style::AlignSelf::Baseline => free_space / 2.0, // Treat as center for now until we have baseline support - style::AlignSelf::Stretch => 0.0, - }; - } - } - } - } - - // 15. Determine the flex container’s used cross size: - // - If the cross size property is a definite size, use that, clamped by the used - // min and max cross sizes of the flex container. - // - Otherwise, use the sum of the flex lines' cross sizes, clamped by the used - // min and max cross sizes of the flex container. - - let total_cross_size = flex_lines.iter().map(|line| line.cross_size).sum(); - let container_cross_size = if avaliable_cross.is_finite() { - avaliable_cross - } else { - total_cross_size - }.min(cross.max).max(cross.min);; - - // 16. Align all flex lines per align-content. - - let free_space = container_cross_size - total_cross_size; - let num_lines = flex_lines.len(); - let mut is_first = true; - - for line in &mut flex_lines { - line.offset_cross = match node.align_content { - style::AlignContent::FlexStart => 0.0, - style::AlignContent::FlexEnd => if is_first { free_space } else { 0.0 }, - style::AlignContent::Center => if is_first { free_space / 2.0 } else { 0.0 }, - style::AlignContent::Stretch => 0.0, - style::AlignContent::SpaceBetween => if is_first { 0.0 } else { free_space / (num_lines - 1) as f32 }, - style::AlignContent::SpaceAround => if is_first { (free_space / num_lines as f32) / 2.0 } else { free_space / num_lines as f32 }, - }; - is_first = false; - } - - let mut children: Vec = vec![]; - - let mut total_offset_cross = - node.cross_padding_start().resolve(container_cross_size, 0.0) + - node.cross_border_start().resolve(container_cross_size, 0.0); - - for line in &mut flex_lines { - let mut total_offset_main = - node.main_padding_start().resolve(container_main_size, 0.0) + - node.main_border_start().resolve(container_main_size, 0.0); - - for child in &mut line.items { - let result = compute_internal( - child.node, - SizeConstraint::exactly(child.target_main_size), - SizeConstraint::exactly(child.target_cross_size)); - - let offset_main = { - total_offset_main + - child.offset_main + - child.main_margin_start - }; - - let offset_cross = { - total_offset_cross + - child.offset_cross + - line.offset_cross + - child.cross_margin_start - }; - - children.push(layout::Node { - width: if child.node.flex_direction.is_row() { result.size.main } else { result.size.cross }, - height: if child.node.flex_direction.is_column() { result.size.main } else { result.size.cross }, - x: if child.node.flex_direction.is_row() { offset_main } else {offset_cross }, - y: if child.node.flex_direction.is_column() { offset_main } else {offset_cross }, - children: result.children, - }); - - total_offset_main = offset_main + result.size.main + child.main_margin_end; - } - - total_offset_cross += line.offset_cross + line.cross_size; - } - - ComputeResult { - size: FlexSize { - main: container_main_size, - cross: container_cross_size, - }, - children: children, - } -} diff --git a/src/data.rs b/src/data.rs new file mode 100644 index 000000000..ba9e0b2e1 --- /dev/null +++ b/src/data.rs @@ -0,0 +1,64 @@ +//! Node Data - important layout and styling data for nodes +//! +//! Used to compute layout for Taffy trees +//! +use crate::layout::{Cache, Layout}; +use crate::style::FlexboxLayout; + +/// Layout information for a given [`Node`](crate::node::Node) +/// +/// Stored in a [`Taffy`]. +pub(crate) struct NodeData { + /// The layout strategy used by this node + pub(crate) style: FlexboxLayout, + + /// The results of the layout computation + pub(crate) layout: Layout, + /// The primary cached results of the layout computation + pub(crate) main_size_layout_cache: Option, + /// Secondary cached results of the layout computation + pub(crate) other_layout_cache: Option, + /// Does this node's layout need to be recomputed? + pub(crate) is_dirty: bool, + + /// wether or not the Node has custom measure data attached to it + pub(crate) has_measure: bool, +} + +impl NodeData { + /// Create the data for a new node with a [`MeasureFunc`] + #[must_use] + pub fn new_with_required_measure(style: FlexboxLayout) -> Self { + Self { + style, + main_size_layout_cache: None, + other_layout_cache: None, + layout: Layout::new(), + is_dirty: true, + has_measure: true, + } + } + + /// Create the data for a new node + #[must_use] + pub fn new(style: FlexboxLayout) -> Self { + Self { + style, + main_size_layout_cache: None, + other_layout_cache: None, + layout: Layout::new(), + is_dirty: true, + has_measure: false, + } + } + + /// Marks a node and all of its parents (recursively) as dirty + /// + /// This clears any cached data and signals that the data must be recomputed. + #[inline] + pub fn mark_dirty(&mut self) { + self.main_size_layout_cache = None; + self.other_layout_cache = None; + self.is_dirty = true; + } +} diff --git a/src/error.rs b/src/error.rs new file mode 100644 index 000000000..88cef3bea --- /dev/null +++ b/src/error.rs @@ -0,0 +1,49 @@ +//! The Error types produced by Taffy. +#[cfg(feature = "std")] +use core::fmt::{Display, Formatter, Result}; + +use crate::node::Node; + +/// The error Taffy generates on invalid operations +pub type TaffyResult = core::result::Result; + +/// An error that occurs while trying to access or modify a [`Node`]'s children by index. +#[derive(Debug)] +pub enum TaffyError { + /// The parent [`Node`] does not have a child at `child_index`. It only has `child_count` children + ChildIndexOutOfBounds { + /// The parent node whose child was being looked up + parent: Node, + /// The index that was looked up + child_index: usize, + /// The total number of children the parent has + child_count: usize, + }, + /// The parent [`Node`] was not found in the [`Taffy`](crate::Taffy) instance. + InvalidParentNode(Node), + /// The child [`Node`] was not found in the [`Taffy`](crate::Taffy) instance. + InvalidChildNode(Node), + /// The supplied [`Node`] was not found in the [`Taffy`](crate::Taffy) instance. + InvalidInputNode(Node), +} + +#[cfg(feature = "std")] +impl Display for TaffyError { + fn fmt(&self, f: &mut Formatter) -> Result { + match self { + TaffyError::ChildIndexOutOfBounds { parent, child_index, child_count } => write!( + f, + "Index (is {}) should be < child_count ({}) for parent node {:?}", + child_index, child_count, parent + ), + TaffyError::InvalidParentNode(parent) => { + write!(f, "Parent Node {:?} is not in the Taffy instance", parent) + } + TaffyError::InvalidChildNode(child) => write!(f, "Child Node {:?} is not in the Taffy instance", child), + TaffyError::InvalidInputNode(node) => write!(f, "Supplied Node {:?} is not in the Taffy instance", node), + } + } +} + +#[cfg(feature = "std")] +impl std::error::Error for TaffyError {} diff --git a/src/flexbox.rs b/src/flexbox.rs new file mode 100644 index 000000000..054da8153 --- /dev/null +++ b/src/flexbox.rs @@ -0,0 +1,1823 @@ +//! Computes the [flexbox](https://css-tricks.com/snippets/css/a-guide-to-flexbox/) layout algorithm on [`Taffy`](crate::Taffy) according to the [spec](https://www.w3.org/TR/css-flexbox-1/) +//! +//! Note that some minor steps appear to be missing: see https://github.com/DioxusLabs/taffy/issues for more information. +use core::f32; + +use slotmap::SlotMap; + +use crate::data::NodeData; +use crate::geometry::{Point, Rect, Size}; +use crate::layout::{Cache, Layout}; +use crate::math::MaybeMath; +use crate::node::{Measure, Node, Taffy}; +use crate::resolve::{MaybeResolve, ResolveOrDefault}; +use crate::style::{AlignContent, AlignSelf, Dimension, Display, FlexWrap, JustifyContent, PositionType}; +use crate::style::{FlexDirection, FlexboxLayout}; +use crate::sys::{abs, round, ChildrenVec, Vec}; +// use crate::Taffy; + +/// The intermediate results of a flexbox calculation for a single item +struct FlexItem { + /// The identifier for the associated [`Node`](crate::node::Node) + node: Node, + + /// The base size of this item + size: Size>, + /// The minimum allowable size of this item + min_size: Size>, + /// The maximum allowable size of this item + max_size: Size>, + + /// The final offset of this item + position: Rect>, + /// The margin of this item + margin: Rect, + /// The padding of this item + padding: Rect, + /// The border of this item + border: Rect, + + /// The default size of this item + flex_basis: f32, + /// The default size of this item, minus padding and border + inner_flex_basis: f32, + /// The amount by which this item has deviated from its target size + violation: f32, + /// Is the size of this item locked + frozen: bool, + + /// The proposed inner size of this item + hypothetical_inner_size: Size, + /// The proposed outer size of this item + hypothetical_outer_size: Size, + /// The size that this item wants to be + target_size: Size, + /// The size that this item wants to be, plus any padding and border + outer_target_size: Size, + + /// The position of the bottom edge of this item + baseline: f32, + + /// A temporary value for the main offset + /// + /// Offset is the relative position from the item's natural flow position based on + /// relative position values, alignment, and justification. Does not include margin/padding/border. + offset_main: f32, + /// A temporary value for the cross offset + /// + /// Offset is the relative position from the item's natural flow position based on + /// relative position values, alignment, and justification. Does not include margin/padding/border. + offset_cross: f32, +} + +/// A line of [`FlexItem`] used for intermediate computation +struct FlexLine<'a> { + /// The slice of items to iterate over during computation of this line + items: &'a mut [FlexItem], + /// The dimensions of the cross-axis + cross_size: f32, + /// The relative offset of the cross-axis + offset_cross: f32, +} + +/// Values that can be cached during the flexbox algorithm +struct AlgoConstants { + /// The direction of the current segment being layed out + dir: FlexDirection, + /// Is this segment a row + is_row: bool, + /// Is this segment a column + is_column: bool, + /// Is the wrap direction inverted + is_wrap_reverse: bool, + + /// The margin of this section + margin: Rect, + /// The border of this section + border: Rect, + /// The padding of this section + padding_border: Rect, + + /// The size of the internal node + node_inner_size: Size>, + /// The size of the surrounding container + container_size: Size, + /// The size of the internal container + inner_container_size: Size, +} + +impl Taffy { + /// Computes the layout of [`Taffy`] according to the flexbox algorithm + pub(crate) fn compute(&mut self, root: Node, size: Size>, measure: &impl Measure) { + let style = self.nodes[root].style; + let has_root_min_max = style.min_size.width.is_defined() + || style.min_size.height.is_defined() + || style.max_size.width.is_defined() + || style.max_size.height.is_defined(); + + let preliminary_size = if has_root_min_max { + let first_pass = self.compute_preliminary(root, style.size.maybe_resolve(size), size, measure, false, true); + + self.compute_preliminary( + root, + Size { + width: first_pass + .width + .maybe_max(style.min_size.width.maybe_resolve(size.width)) + .maybe_min(style.max_size.width.maybe_resolve(size.width)) + .into(), + height: first_pass + .height + .maybe_max(style.min_size.height.maybe_resolve(size.height)) + .maybe_min(style.max_size.height.maybe_resolve(size.height)) + .into(), + }, + size, + measure, + true, + true, + ) + } else { + self.compute_preliminary(root, style.size.maybe_resolve(size), size, measure, true, true) + }; + + self.nodes[root].layout = Layout { order: 0, size: preliminary_size, location: Point::ZERO }; + + Self::round_layout(&mut self.nodes, &self.children, root, 0.0, 0.0); + } + + /// Rounds the calculated [`NodeData`] according to the spec + fn round_layout( + nodes: &mut SlotMap, + children: &SlotMap>, + root: Node, + abs_x: f32, + abs_y: f32, + ) { + let layout = &mut nodes[root].layout; + let abs_x = abs_x + layout.location.x; + let abs_y = abs_y + layout.location.y; + + layout.location.x = round(layout.location.x); + layout.location.y = round(layout.location.y); + + layout.size.width = round(layout.size.width); + layout.size.height = round(layout.size.height); + + for child in &children[root] { + Self::round_layout(nodes, children, *child, abs_x, abs_y); + } + } + + /// Saves intermediate results to a [`Cache`] + fn cache(&mut self, node: Node, main_size: bool) -> &mut Option { + if main_size { + &mut self.nodes[node].main_size_layout_cache + } else { + &mut self.nodes[node].other_layout_cache + } + } + + /// Try to get the computation result from the cache. + #[inline] + fn compute_from_cache( + &mut self, + node: Node, + node_size: Size>, + parent_size: Size>, + perform_layout: bool, + main_size: bool, + ) -> Option> { + if let Some(ref cache) = self.cache(node, main_size) { + if cache.perform_layout || !perform_layout { + let width_compatible = if let Some(width) = node_size.width { + abs(width - cache.size.width) < f32::EPSILON + } else { + cache.node_size.width.is_none() + }; + + let height_compatible = if let Some(height) = node_size.height { + abs(height - cache.size.height) < f32::EPSILON + } else { + cache.node_size.height.is_none() + }; + + if width_compatible && height_compatible { + return Some(cache.size); + } + + if cache.node_size == node_size && cache.parent_size == parent_size { + return Some(cache.size); + } + } + } + + None + } + + /// Compute constants that can be reused during the flexbox algorithm. + #[inline] + fn compute_constants( + node: &NodeData, + node_size: Size>, + parent_size: Size>, + ) -> AlgoConstants { + let dir = node.style.flex_direction; + let is_row = dir.is_row(); + let is_column = dir.is_column(); + let is_wrap_reverse = node.style.flex_wrap == FlexWrap::WrapReverse; + + let margin = node.style.margin.resolve_or_default(parent_size.width); + let padding = node.style.padding.resolve_or_default(parent_size.width); + let border = node.style.border.resolve_or_default(parent_size.width); + + let padding_border = Rect { + start: padding.start + border.start, + end: padding.end + border.end, + top: padding.top + border.top, + bottom: padding.bottom + border.bottom, + }; + + let node_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()), + }; + + let container_size = Size::ZERO; + let inner_container_size = Size::ZERO; + + AlgoConstants { + dir, + is_row, + is_column, + is_wrap_reverse, + margin, + border, + padding_border, + node_inner_size, + container_size, + inner_container_size, + } + } + + /// Generate anonymous flex items. + /// + /// # [9.1. Initial Setup](https://www.w3.org/TR/css-flexbox-1/#box-manip) + /// + /// - [**Generate anonymous flex items**](https://www.w3.org/TR/css-flexbox-1/#algo-anon-box) as described in [§4 Flex Items](https://www.w3.org/TR/css-flexbox-1/#flex-items). + #[inline] + fn generate_anonymous_flex_items(&self, node: Node, constants: &AlgoConstants) -> Vec { + self.children[node] + .iter() + .map(|child| (child, &self.nodes[*child].style)) + .filter(|(_, style)| style.position_type != PositionType::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), + + position: child_style.position.zip_size(constants.node_inner_size, |p, s| p.maybe_resolve(s)), + margin: child_style.margin.resolve_or_default(constants.node_inner_size.width), + padding: child_style.padding.resolve_or_default(constants.node_inner_size.width), + border: child_style.border.resolve_or_default(constants.node_inner_size.width), + flex_basis: 0.0, + inner_flex_basis: 0.0, + violation: 0.0, + frozen: false, + + 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() + } + + /// Determine the available main and cross space for the flex items. + /// + /// # [9.2. Line Length Determination](https://www.w3.org/TR/css-flexbox-1/#line-sizing) + /// + /// - [**Determine the available main and cross space for the flex items**](https://www.w3.org/TR/css-flexbox-1/#algo-available). + /// For each dimension, if that dimension of the flex container’s content box is a definite size, use that; + /// if that dimension of the flex container is being sized under a min or max-content constraint, the available space in that dimension is that constraint; + /// otherwise, subtract the flex container’s margin, border, and padding from the space available to the flex container in that dimension and use that value. + /// **This might result in an infinite value**. + #[inline] + #[must_use] + fn determine_available_space( + node_size: Size>, + parent_size: Size>, + constants: &AlgoConstants, + ) -> Size> { + let width = match node_size.width { + Some(node_width) => Some(node_width), + None => parent_size + .width + .maybe_sub(constants.margin.horizontal_axis_sum()) + .maybe_sub(constants.padding_border.horizontal_axis_sum()), + }; + + let height = match node_size.height { + Some(node_height) => Some(node_height), + None => parent_size + .height + .maybe_sub(constants.margin.vertical_axis_sum()) + .maybe_sub(constants.padding_border.vertical_axis_sum()), + }; + + Size { width, height } + } + + /// Determine the flex base size and hypothetical main size of each item. + /// + /// # [9.2. Line Length Determination](https://www.w3.org/TR/css-flexbox-1/#line-sizing) + /// + /// - [**Determine the flex base size and hypothetical main size of each item:**](https://www.w3.org/TR/css-flexbox-1/#algo-main-item) + /// + /// - A. If the item has a definite used flex basis, that’s the flex base size. + /// + /// - 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. + /// + /// - 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 constraint (e.g. when performing automatic table layout \[CSS21\]), size the item under that constraint. + /// The flex base size is the item’s resulting main size. + /// + /// - 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. + /// If a cross size is needed to determine the main size (e.g. when the flex item’s main size is in its block axis) and the flex item’s cross size is auto and not definite, + /// in this calculation use fit-content as the flex item’s cross size. The flex base size is the item’s resulting main size. + /// + /// When determining the flex base size, the item’s min and max main sizes are ignored (no clamping occurs). + /// Furthermore, the sizing calculations that floor the content box size at zero when applying box-sizing are also ignored. + /// (For example, an item with a specified size of zero, positive padding, and box-sizing: border-box will have an outer flex base size of zero—and hence a negative inner flex base size.) + #[inline] + fn determine_flex_base_size( + &mut self, + node: Node, + node_size: Size>, + constants: &AlgoConstants, + available_space: Size>, + flex_items: &mut Vec, + measure: &impl Measure, + ) { + // TODO - this does not follow spec. See the TODOs below + for child in flex_items.iter_mut() { + let child_style = self.nodes[child.node].style; + + // 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; + } + } + } + + // 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 + // constraint (e.g. when performing automatic table layout [CSS21]), + // 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 + + // 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 + // inline axis is parallel to the main axis, lay the item out using the rules + // 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 + + // 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. + // If a cross size is needed to determine the main size (e.g. when the + // flex item’s main size is in its block axis) and the flex item’s cross size + // is auto and not definite, in this calculation use fit-content as the + // flex item’s cross size. The flex base size is the item’s resulting main size. + + let width: Option = if child.size.width.is_none() + && child_style.align_self(&self.nodes[node].style) == AlignSelf::Stretch + && constants.is_column + { + available_space.width + } else { + child.size.width + }; + + let height: Option = if child.size.height.is_none() + && child_style.align_self(&self.nodes[node].style) == AlignSelf::Stretch + && constants.is_row + { + available_space.height + } else { + child.size.height + }; + + child.flex_basis = self + .compute_preliminary( + child.node, + Size { + width: width.maybe_min(child.max_size.width), + height: height.maybe_min(child.max_size.height), + }, + available_space, + measure, + false, + true, + ) + .main(constants.dir) + .maybe_min(child.max_size.main(constants.dir)); + } + + // The hypothetical main size is the item’s flex base size clamped according to its + // used min and max main sizes (and flooring the content box size at zero). + + for child in flex_items { + child.inner_flex_basis = child.flex_basis + - child.padding.main_axis_sum(constants.dir) + - child.border.main_axis_sum(constants.dir); + + // TODO - not really spec abiding but needs to be done somewhere. probably somewhere else though. + // The following logic was developed not from the spec but by trail and error looking into how + // webkit handled various scenarios. Can probably be solved better by passing in + // min-content max-content constraints from the top + let min_main = self + .compute_preliminary(child.node, Size::undefined(), available_space, measure, false, false) + .main(constants.dir) + .maybe_max(child.min_size.main(constants.dir)) + .maybe_min(child.size.main(constants.dir)) + .into(); + + child.hypothetical_inner_size.set_main( + constants.dir, + child.flex_basis.maybe_max(min_main).maybe_min(child.max_size.main(constants.dir)), + ); + + child.hypothetical_outer_size.set_main( + constants.dir, + child.hypothetical_inner_size.main(constants.dir) + child.margin.main_axis_sum(constants.dir), + ); + } + } + + /// Collect flex items into flex lines. + /// + /// # [9.3. Main Size Determination](https://www.w3.org/TR/css-flexbox-1/#main-sizing) + /// + /// - [**Collect flex items into flex lines**](https://www.w3.org/TR/css-flexbox-1/#algo-line-break): + /// + /// - If the flex container is single-line, collect all the flex items into a single flex line. + /// + /// - Otherwise, starting from the first uncollected item, collect consecutive items one by one until the first time that the next collected item would not fit into the flex container’s inner main size + /// (or until a forced break is encountered, see [§10 Fragmenting Flex Layout](https://www.w3.org/TR/css-flexbox-1/#pagination)). + /// If the very first uncollected item wouldn’t fit, collect just it into the line. + /// + /// For this step, the size of a flex item is its outer hypothetical main size. (**Note: This can be negative**.) + /// + /// Repeat until all flex items have been collected into flex lines. + /// + /// **Note that the "collect as many" line will collect zero-sized flex items onto the end of the previous line even if the last non-zero item exactly "filled up" the line**. + #[inline] + fn collect_flex_lines<'a>( + &self, + node: Node, + constants: &AlgoConstants, + available_space: Size>, + flex_items: &'a mut Vec, + ) -> Vec> { + let mut lines = crate::sys::new_vec_with_capacity(1); + + if self.nodes[node].style.flex_wrap == FlexWrap::NoWrap { + lines.push(FlexLine { items: flex_items.as_mut_slice(), cross_size: 0.0, offset_cross: 0.0 }); + } else { + let mut flex_items = &mut flex_items[..]; + + while !flex_items.is_empty() { + let mut line_length = 0.0; + let index = flex_items + .iter() + .enumerate() + .find(|&(idx, child)| { + line_length += child.hypothetical_outer_size.main(constants.dir); + if let Some(main) = available_space.main(constants.dir) { + line_length > main && idx != 0 + } else { + false + } + }) + .map(|(idx, _)| idx) + .unwrap_or(flex_items.len()); + + let (items, rest) = flex_items.split_at_mut(index); + lines.push(FlexLine { items, cross_size: 0.0, offset_cross: 0.0 }); + flex_items = rest; + } + } + + lines + } + + /// Resolve the flexible lengths of the items within a flex line. + /// + /// # [9.7. Resolving Flexible Lengths](https://www.w3.org/TR/css-flexbox-1/#resolve-flexible-lengths) + #[inline] + fn resolve_flexible_lengths( + &mut self, + line: &mut FlexLine, + constants: &AlgoConstants, + available_space: Size>, + measure: &impl Measure, + ) { + // 1. Determine the used flex factor. Sum the outer hypothetical main sizes of all + // items on the line. If the sum is less than the flex container’s inner main size, + // use the flex grow factor for the rest of this algorithm; otherwise, use the + // flex shrink factor. + + let used_flex_factor: f32 = + line.items.iter().map(|child| child.hypothetical_outer_size.main(constants.dir)).sum(); + let growing = used_flex_factor < constants.node_inner_size.main(constants.dir).unwrap_or(0.0); + let shrinking = !growing; + + // 2. Size inflexible items. Freeze, setting its target main size to its hypothetical main size + // - Any item that has a flex factor of zero + // - If using the flex grow factor: any item that has a flex base size + // greater than its hypothetical main size + // - If using the flex shrink factor: any item that has a flex base size + // smaller than its hypothetical main size + + for child in line.items.iter_mut() { + // TODO - This is not found by reading the spec. Maybe this can be done in some other place + // instead. This was found by trail and error fixing tests to align with webkit output. + if constants.node_inner_size.main(constants.dir).is_none() && constants.is_row { + child.target_size.set_main( + constants.dir, + self.compute_preliminary( + child.node, + Size { + width: child.size.width.maybe_max(child.min_size.width).maybe_min(child.max_size.width), + height: child.size.height.maybe_max(child.min_size.height).maybe_min(child.max_size.height), + }, + available_space, + measure, + false, + false, + ) + .main(constants.dir) + .maybe_max(child.min_size.main(constants.dir)) + .maybe_min(child.max_size.main(constants.dir)), + ); + } else { + child.target_size.set_main(constants.dir, child.hypothetical_inner_size.main(constants.dir)); + } + + // 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), + ); + + let child_style = &self.nodes[child.node].style; + if (child_style.flex_grow == 0.0 && child_style.flex_shrink == 0.0) + || (growing && child.flex_basis > child.hypothetical_inner_size.main(constants.dir)) + || (shrinking && child.flex_basis < child.hypothetical_inner_size.main(constants.dir)) + { + child.frozen = true; + } + } + + // 3. Calculate initial free space. Sum the outer sizes of all items on the line, + // and subtract this from the flex container’s inner main size. For frozen items, + // use their outer target main size; for other items, use their outer flex base size. + + let used_space: f32 = line + .items + .iter() + .map(|child| { + child.margin.main_axis_sum(constants.dir) + + if child.frozen { child.target_size.main(constants.dir) } else { child.flex_basis } + }) + .sum(); + + let initial_free_space = constants.node_inner_size.main(constants.dir).maybe_sub(used_space).unwrap_or(0.0); + + // 4. Loop + + loop { + // a. Check for flexible items. If all the flex items on the line are frozen, + // free space has been distributed; exit this loop. + + if line.items.iter().all(|child| child.frozen) { + break; + } + + // b. Calculate the remaining free space as for initial free space, above. + // If the sum of the unfrozen flex items’ flex factors is less than one, + // multiply the initial free space by this sum. If the magnitude of this + // value is less than the magnitude of the remaining free space, use this + // as the remaining free space. + + let used_space: f32 = line + .items + .iter() + .map(|child| { + child.margin.main_axis_sum(constants.dir) + + if child.frozen { child.target_size.main(constants.dir) } else { child.flex_basis } + }) + .sum(); + + let mut unfrozen: Vec<&mut FlexItem> = line.items.iter_mut().filter(|child| !child.frozen).collect(); + + let (sum_flex_grow, sum_flex_shrink): (f32, f32) = + unfrozen.iter().fold((0.0, 0.0), |(flex_grow, flex_shrink), item| { + let style = &self.nodes[item.node].style; + (flex_grow + style.flex_grow, flex_shrink + style.flex_shrink) + }); + + let free_space = if growing && sum_flex_grow < 1.0 { + (initial_free_space * sum_flex_grow) + .maybe_min(constants.node_inner_size.main(constants.dir).maybe_sub(used_space)) + } else if shrinking && sum_flex_shrink < 1.0 { + (initial_free_space * sum_flex_shrink) + .maybe_max(constants.node_inner_size.main(constants.dir).maybe_sub(used_space)) + } else { + (constants.node_inner_size.main(constants.dir).maybe_sub(used_space)).unwrap_or(0.0) + }; + + // c. Distribute free space proportional to the flex factors. + // - If the remaining free space is zero + // Do Nothing + // - If using the flex grow factor + // Find the ratio of the item’s flex grow factor to the sum of the + // flex grow factors of all unfrozen items on the line. Set the item’s + // target main size to its flex base size plus a fraction of the remaining + // free space proportional to the ratio. + // - If using the flex shrink factor + // For every unfrozen item on the line, multiply its flex shrink factor by + // its inner flex base size, and note this as its scaled flex shrink factor. + // Find the ratio of the item’s scaled flex shrink factor to the sum of the + // scaled flex shrink factors of all unfrozen items on the line. Set the item’s + // target main size to its flex base size minus a fraction of the absolute value + // of the remaining free space proportional to the ratio. Note this may result + // in a negative inner main size; it will be corrected in the next step. + // - Otherwise + // Do Nothing + + if free_space.is_normal() { + if growing && sum_flex_grow > 0.0 { + for child in &mut unfrozen { + child.target_size.set_main( + constants.dir, + child.flex_basis + free_space * (self.nodes[child.node].style.flex_grow / sum_flex_grow), + ); + } + } else if shrinking && sum_flex_shrink > 0.0 { + let sum_scaled_shrink_factor: f32 = unfrozen + .iter() + .map(|child| child.inner_flex_basis * self.nodes[child.node].style.flex_shrink) + .sum(); + + if sum_scaled_shrink_factor > 0.0 { + for child in &mut unfrozen { + let scaled_shrink_factor = + child.inner_flex_basis * self.nodes[child.node].style.flex_shrink; + child.target_size.set_main( + constants.dir, + child.flex_basis + free_space * (scaled_shrink_factor / sum_scaled_shrink_factor), + ) + } + } + } + } + + // d. Fix min/max violations. Clamp each non-frozen item’s target main size by its + // used min and max main sizes and floor its content-box size at zero. If the + // item’s target main size was made smaller by this, it’s a max violation. + // If the item’s target main size was made larger by this, it’s a min violation. + + let total_violation = unfrozen.iter_mut().fold(0.0, |acc, child| -> f32 { + // TODO - not really spec abiding but needs to be done somewhere. probably somewhere else though. + // The following logic was developed not from the spec but by trial and error looking into how + // webkit handled various scenarios. Can probably be solved better by passing in + // min-content max-content constraints from the top. Need to figure out correct thing to do here as + // just piling on more conditionals. + let min_main = if constants.is_row && !self.nodes[child.node].has_measure { + self.compute_preliminary(child.node, Size::undefined(), available_space, measure, false, false) + .width + .maybe_min(child.size.width) + .maybe_max(child.min_size.width) + .into() + } else { + child.min_size.main(constants.dir) + }; + + let max_main = child.max_size.main(constants.dir); + let clamped = child.target_size.main(constants.dir).maybe_min(max_main).maybe_max(min_main).max(0.0); + child.violation = clamped - child.target_size.main(constants.dir); + child.target_size.set_main(constants.dir, clamped); + child.outer_target_size.set_main( + constants.dir, + child.target_size.main(constants.dir) + child.margin.main_axis_sum(constants.dir), + ); + + acc + child.violation + }); + + // e. Freeze over-flexed items. The total violation is the sum of the adjustments + // from the previous step ∑(clamped size - unclamped size). If the total violation is: + // - Zero + // Freeze all items. + // - Positive + // Freeze all the items with min violations. + // - Negative + // Freeze all the items with max violations. + + for child in &mut unfrozen { + match total_violation { + v if v > 0.0 => child.frozen = child.violation > 0.0, + v if v < 0.0 => child.frozen = child.violation < 0.0, + _ => child.frozen = true, + } + } + + // f. Return to the start of this loop. + } + } + + /// Determine the hypothetical cross size of each item. + /// + /// # [9.4. Cross Size Determination](https://www.w3.org/TR/css-flexbox-1/#cross-sizing) + /// + /// - [**Determine the hypothetical cross size of each item**](https://www.w3.org/TR/css-flexbox-1/#algo-cross-item) + /// by performing layout with the used main size and the available space, treating auto as fit-content. + #[inline] + fn determine_hypothetical_cross_size( + &mut self, + line: &mut FlexLine, + constants: &AlgoConstants, + available_space: Size>, + measure: &impl Measure, + ) { + for child in line.items.iter_mut() { + let child_cross = child + .size + .cross(constants.dir) + .maybe_max(child.min_size.cross(constants.dir)) + .maybe_min(child.max_size.cross(constants.dir)); + + child.hypothetical_inner_size.set_cross( + constants.dir, + self.compute_preliminary( + child.node, + Size { + width: if constants.is_row { child.target_size.width.into() } else { child_cross }, + height: if constants.is_row { child_cross } else { child.target_size.height.into() }, + }, + Size { + width: if constants.is_row { + constants.container_size.main(constants.dir).into() + } else { + available_space.width + }, + height: if constants.is_row { + available_space.height + } else { + constants.container_size.main(constants.dir).into() + }, + }, + measure, + false, + false, + ) + .cross(constants.dir) + .maybe_max(child.min_size.cross(constants.dir)) + .maybe_min(child.max_size.cross(constants.dir)), + ); + + child.hypothetical_outer_size.set_cross( + constants.dir, + child.hypothetical_inner_size.cross(constants.dir) + child.margin.cross_axis_sum(constants.dir), + ); + } + } + + /// Calculate the base lines of the children. + #[inline] + fn calculate_children_base_lines( + &mut self, + node: Node, + node_size: Size>, + flex_lines: &mut [FlexLine], + constants: &AlgoConstants, + measure: &impl Measure, + ) { + /// Recursively calculates the baseline for children + fn calc_baseline(db: &Taffy, node: Node, layout: &Layout) -> f32 { + if db.children[node].is_empty() { + layout.size.height + } else { + let child = db.children[node][0]; + calc_baseline(db, child, &db.nodes[child].layout) + } + } + + for line in flex_lines { + for child in line.items.iter_mut() { + let preliminary_size = self.compute_preliminary( + child.node, + Size { + width: if constants.is_row { + child.target_size.width.into() + } else { + child.hypothetical_inner_size.width.into() + }, + height: if constants.is_row { + child.hypothetical_inner_size.height.into() + } else { + child.target_size.height.into() + }, + }, + Size { + width: if constants.is_row { constants.container_size.width.into() } else { node_size.width }, + height: if constants.is_row { + node_size.height + } else { + constants.container_size.height.into() + }, + }, + measure, + true, + false, + ); + + child.baseline = calc_baseline( + self, + child.node, + &Layout { + order: self.children[node].iter().position(|n| *n == child.node).unwrap() as u32, + size: preliminary_size, + location: Point::ZERO, + }, + ); + } + } + } + + /// Calculate the cross size of each flex line. + /// + /// # [9.4. Cross Size Determination](https://www.w3.org/TR/css-flexbox-1/#cross-sizing) + /// + /// - [**Calculate the cross size of each flex line**](https://www.w3.org/TR/css-flexbox-1/#algo-cross-line). + /// + /// If the flex container is single-line and has a definite cross size, the cross size of the flex line is the flex container’s inner cross size. + /// + /// Otherwise, for each flex line: + /// + /// 1. Collect all the flex items whose inline-axis is parallel to the main-axis, whose align-self is baseline, and whose cross-axis margins are both non-auto. + /// Find the largest of the distances between each item’s baseline and its hypothetical outer cross-start edge, + /// and the largest of the distances between each item’s baseline and its hypothetical outer cross-end edge, and sum these two values. + /// + /// 2. Among all the items not collected by the previous step, find the largest outer hypothetical cross size. + /// + /// 3. The used cross-size of the flex line is the largest of the numbers found in the previous two steps and zero. + /// + /// If the flex container is single-line, then clamp the line’s cross-size to be within the container’s computed min and max cross sizes. + /// **Note that if CSS 2.1’s definition of min/max-width/height applied more generally, this behavior would fall out automatically**. + #[inline] + fn calculate_cross_size( + &mut self, + flex_lines: &mut [FlexLine], + node: Node, + node_size: Size>, + constants: &AlgoConstants, + ) { + if flex_lines.len() == 1 && node_size.cross(constants.dir).is_some() { + flex_lines[0].cross_size = + (node_size.cross(constants.dir).maybe_sub(constants.padding_border.cross_axis_sum(constants.dir))) + .unwrap_or(0.0); + } else { + for line in flex_lines.iter_mut() { + // 1. Collect all the flex items whose inline-axis is parallel to the main-axis, whose + // align-self is baseline, and whose cross-axis margins are both non-auto. Find the + // largest of the distances between each item’s baseline and its hypothetical outer + // cross-start edge, and the largest of the distances between each item’s baseline + // and its hypothetical outer cross-end edge, and sum these two values. + + // 2. Among all the items not collected by the previous step, find the largest + // outer hypothetical cross size. + + // 3. The used cross-size of the flex line is the largest of the numbers found in the + // previous two steps and zero. + + let max_baseline: f32 = line.items.iter().map(|child| child.baseline).fold(0.0, |acc, x| acc.max(x)); + line.cross_size = line + .items + .iter() + .map(|child| { + let child_style = &self.nodes[child.node].style; + if child_style.align_self(&self.nodes[node].style) == AlignSelf::Baseline + && child_style.cross_margin_start(constants.dir) != Dimension::Auto + && child_style.cross_margin_end(constants.dir) != Dimension::Auto + && child_style.cross_size(constants.dir) == Dimension::Auto + { + max_baseline - child.baseline + child.hypothetical_outer_size.cross(constants.dir) + } else { + child.hypothetical_outer_size.cross(constants.dir) + } + }) + .fold(0.0, |acc, x| acc.max(x)); + } + } + } + + /// Handle 'align-content: stretch'. + /// + /// # [9.4. Cross Size Determination](https://www.w3.org/TR/css-flexbox-1/#cross-sizing) + /// + /// - [**Handle 'align-content: stretch'**](https://www.w3.org/TR/css-flexbox-1/#algo-line-stretch). If the flex container has a definite cross size, align-content is stretch, + /// and the sum of the flex lines' cross sizes is less than the flex container’s inner cross size, + /// increase the cross size of each flex line by equal amounts such that the sum of their cross sizes exactly equals the flex container’s inner cross size. + #[inline] + fn handle_align_content_stretch( + &mut self, + flex_lines: &mut [FlexLine], + node: Node, + node_size: Size>, + constants: &AlgoConstants, + ) { + if self.nodes[node].style.align_content == AlignContent::Stretch && node_size.cross(constants.dir).is_some() { + let total_cross: f32 = flex_lines.iter().map(|line| line.cross_size).sum(); + let inner_cross = + (node_size.cross(constants.dir).maybe_sub(constants.padding_border.cross_axis_sum(constants.dir))) + .unwrap_or(0.0); + + if total_cross < inner_cross { + let remaining = inner_cross - total_cross; + let addition = remaining / flex_lines.len() as f32; + flex_lines.iter_mut().for_each(|line| line.cross_size += addition); + } + } + } + + /// Determine the used cross size of each flex item. + /// + /// # [9.4. Cross Size Determination](https://www.w3.org/TR/css-flexbox-1/#cross-sizing) + /// + /// - [**Determine the used cross size of each flex item**](https://www.w3.org/TR/css-flexbox-1/#algo-stretch). If a flex item has align-self: stretch, its computed cross size property is auto, + /// and neither of its cross-axis margins are auto, the used outer cross size is the used cross size of its flex line, clamped according to the item’s used min and max cross sizes. + /// Otherwise, the used cross size is the item’s hypothetical cross size. + /// + /// If the flex item has align-self: stretch, redo layout for its contents, treating this used size as its definite cross size so that percentage-sized children can be resolved. + /// + /// **Note that this step does not affect the main size of the flex item, even if it has an intrinsic aspect ratio**. + #[inline] + fn determine_used_cross_size(&mut self, flex_lines: &mut [FlexLine], node: Node, constants: &AlgoConstants) { + for line in flex_lines { + let line_cross_size = line.cross_size; + + for child in line.items.iter_mut() { + let child_style = &self.nodes[child.node].style; + child.target_size.set_cross( + constants.dir, + if child_style.align_self(&self.nodes[node].style) == AlignSelf::Stretch + && child_style.cross_margin_start(constants.dir) != Dimension::Auto + && child_style.cross_margin_end(constants.dir) != Dimension::Auto + && child_style.cross_size(constants.dir) == Dimension::Auto + { + (line_cross_size - child.margin.cross_axis_sum(constants.dir)) + .maybe_max(child.min_size.cross(constants.dir)) + .maybe_min(child.max_size.cross(constants.dir)) + } else { + child.hypothetical_inner_size.cross(constants.dir) + }, + ); + + child.outer_target_size.set_cross( + constants.dir, + child.target_size.cross(constants.dir) + child.margin.cross_axis_sum(constants.dir), + ); + } + } + } + + /// Distribute any remaining free space. + /// + /// # [9.5. Main-Axis Alignment](https://www.w3.org/TR/css-flexbox-1/#main-alignment) + /// + /// - [**Distribute any remaining free space**](https://www.w3.org/TR/css-flexbox-1/#algo-main-align). For each flex line: + /// + /// 1. If the remaining free space is positive and at least one main-axis margin on this line is `auto`, distribute the free space equally among these margins. + /// Otherwise, set all `auto` margins to zero. + /// + /// 2. Align the items along the main-axis per `justify-content`. + #[inline] + fn distribute_remaining_free_space(&mut self, flex_lines: &mut [FlexLine], node: Node, constants: &AlgoConstants) { + for line in flex_lines { + let used_space: f32 = line.items.iter().map(|child| child.outer_target_size.main(constants.dir)).sum(); + let free_space = constants.inner_container_size.main(constants.dir) - used_space; + let mut num_auto_margins = 0; + + for child in line.items.iter_mut() { + let child_style = &self.nodes[child.node].style; + if child_style.main_margin_start(constants.dir) == Dimension::Auto { + num_auto_margins += 1; + } + if child_style.main_margin_end(constants.dir) == Dimension::Auto { + num_auto_margins += 1; + } + } + + if free_space > 0.0 && num_auto_margins > 0 { + let margin = free_space / num_auto_margins as f32; + + for child in line.items.iter_mut() { + let child_style = &self.nodes[child.node].style; + if child_style.main_margin_start(constants.dir) == Dimension::Auto { + if constants.is_row { + child.margin.start = margin; + } else { + child.margin.top = margin; + } + } + if child_style.main_margin_end(constants.dir) == Dimension::Auto { + if constants.is_row { + child.margin.end = margin; + } else { + child.margin.bottom = margin; + } + } + } + } else { + let num_items = line.items.len(); + let layout_reverse = constants.dir.is_reverse(); + + let justify_item = |(i, child): (usize, &mut FlexItem)| { + let is_first = i == 0; + + child.offset_main = match self.nodes[node].style.justify_content { + JustifyContent::FlexStart => { + if layout_reverse && is_first { + free_space + } else { + 0.0 + } + } + JustifyContent::Center => { + if is_first { + free_space / 2.0 + } else { + 0.0 + } + } + JustifyContent::FlexEnd => { + if is_first && !layout_reverse { + free_space + } else { + 0.0 + } + } + JustifyContent::SpaceBetween => { + if is_first { + 0.0 + } else { + free_space / (num_items - 1) as f32 + } + } + JustifyContent::SpaceAround => { + if is_first { + (free_space / num_items as f32) / 2.0 + } else { + free_space / num_items as f32 + } + } + JustifyContent::SpaceEvenly => free_space / (num_items + 1) as f32, + }; + }; + + if layout_reverse { + line.items.iter_mut().rev().enumerate().for_each(justify_item); + } else { + line.items.iter_mut().enumerate().for_each(justify_item); + } + } + } + } + + /// Resolve cross-axis `auto` margins. + /// + /// # [9.6. Cross-Axis Alignment](https://www.w3.org/TR/css-flexbox-1/#cross-alignment) + /// + /// - [**Resolve cross-axis `auto` margins**](https://www.w3.org/TR/css-flexbox-1/#algo-cross-margins). + /// If a flex item has auto cross-axis margins: + /// + /// - If its outer cross size (treating those auto margins as zero) is less than the cross size of its flex line, + /// distribute the difference in those sizes equally to the auto margins. + /// + /// - Otherwise, if the block-start or inline-start margin (whichever is in the cross axis) is auto, set it to zero. + /// Set the opposite margin so that the outer cross size of the item equals the cross size of its flex line. + #[inline] + fn resolve_cross_axis_auto_margins(&mut self, flex_lines: &mut [FlexLine], node: Node, constants: &AlgoConstants) { + for line in flex_lines { + let line_cross_size = line.cross_size; + let max_baseline: f32 = line.items.iter_mut().map(|child| child.baseline).fold(0.0, |acc, x| acc.max(x)); + + for child in line.items.iter_mut() { + let free_space = line_cross_size - child.outer_target_size.cross(constants.dir); + let child_style = &self.nodes[child.node].style; + + if child_style.cross_margin_start(constants.dir) == Dimension::Auto + && child_style.cross_margin_end(constants.dir) == Dimension::Auto + { + if constants.is_row { + child.margin.top = free_space / 2.0; + child.margin.bottom = free_space / 2.0; + } else { + child.margin.start = free_space / 2.0; + child.margin.end = free_space / 2.0; + } + } else if child_style.cross_margin_start(constants.dir) == Dimension::Auto { + if constants.is_row { + child.margin.top = free_space; + } else { + child.margin.start = free_space; + } + } else if child_style.cross_margin_end(constants.dir) == Dimension::Auto { + if constants.is_row { + child.margin.bottom = free_space; + } else { + child.margin.end = free_space; + } + } else { + // 14. Align all flex items along the cross-axis. + child.offset_cross = self.align_flex_items_along_cross_axis( + node, + child, + child_style, + free_space, + max_baseline, + constants, + ); + } + } + } + } + + /// Align all flex items along the cross-axis. + /// + /// # [9.6. Cross-Axis Alignment](https://www.w3.org/TR/css-flexbox-1/#cross-alignment) + /// + /// - [**Align all flex items along the cross-axis**](https://www.w3.org/TR/css-flexbox-1/#algo-cross-align) per `align-self`, + /// if neither of the item's cross-axis margins are `auto`. + #[inline] + fn align_flex_items_along_cross_axis( + &self, + node: Node, + child: &mut FlexItem, + child_style: &FlexboxLayout, + free_space: f32, + max_baseline: f32, + constants: &AlgoConstants, + ) -> f32 { + match child_style.align_self(&self.nodes[node].style) { + AlignSelf::Auto => unreachable!(), + AlignSelf::FlexStart => { + if constants.is_wrap_reverse { + free_space + } else { + 0.0 + } + } + AlignSelf::FlexEnd => { + if constants.is_wrap_reverse { + 0.0 + } else { + free_space + } + } + AlignSelf::Center => free_space / 2.0, + AlignSelf::Baseline => { + if constants.is_row { + max_baseline - child.baseline + } else { + // baseline alignment only makes sense if the constants.direction is row + // we treat it as flex-start alignment in columns. + if constants.is_wrap_reverse { + free_space + } else { + 0.0 + } + } + } + AlignSelf::Stretch => { + if constants.is_wrap_reverse { + free_space + } else { + 0.0 + } + } + } + } + + /// Determine the flex container’s used cross size. + /// + /// # [9.6. Cross-Axis Alignment](https://www.w3.org/TR/css-flexbox-1/#cross-alignment) + /// + /// - [**Determine the flex container’s used cross size**](https://www.w3.org/TR/css-flexbox-1/#algo-cross-container): + /// + /// - If the cross size property is a definite size, use that, clamped by the used min and max cross sizes of the flex container. + /// + /// - Otherwise, use the sum of the flex lines' cross sizes, clamped by the used min and max cross sizes of the flex container. + #[inline] + #[must_use] + fn determine_container_cross_size( + flex_lines: &mut [FlexLine], + node_size: Size>, + constants: &mut AlgoConstants, + ) -> f32 { + let total_cross_size: f32 = flex_lines.iter().map(|line| line.cross_size).sum(); + + constants.container_size.set_cross( + constants.dir, + node_size + .cross(constants.dir) + .unwrap_or(total_cross_size + constants.padding_border.cross_axis_sum(constants.dir)), + ); + + constants.inner_container_size.set_cross( + constants.dir, + constants.container_size.cross(constants.dir) - constants.padding_border.cross_axis_sum(constants.dir), + ); + + total_cross_size + } + + /// Align all flex lines per `align-content`. + /// + /// # [9.6. Cross-Axis Alignment](https://www.w3.org/TR/css-flexbox-1/#cross-alignment) + /// + /// - [**Align all flex lines**](https://www.w3.org/TR/css-flexbox-1/#algo-line-align) per `align-content`. + #[inline] + fn align_flex_lines_per_align_content( + &self, + flex_lines: &mut [FlexLine], + node: Node, + constants: &AlgoConstants, + total_cross_size: f32, + ) { + let free_space = constants.inner_container_size.cross(constants.dir) - total_cross_size; + let num_lines = flex_lines.len(); + + let align_line = |(i, line): (usize, &mut FlexLine)| { + let is_first = i == 0; + + line.offset_cross = match self.nodes[node].style.align_content { + AlignContent::FlexStart => { + if is_first && constants.is_wrap_reverse { + free_space + } else { + 0.0 + } + } + AlignContent::FlexEnd => { + if is_first && !constants.is_wrap_reverse { + free_space + } else { + 0.0 + } + } + AlignContent::Center => { + if is_first { + free_space / 2.0 + } else { + 0.0 + } + } + AlignContent::Stretch => 0.0, + AlignContent::SpaceBetween => { + if is_first { + 0.0 + } else { + free_space / (num_lines - 1) as f32 + } + } + AlignContent::SpaceAround => { + if is_first { + (free_space / num_lines as f32) / 2.0 + } else { + free_space / num_lines as f32 + } + } + }; + }; + + if constants.is_wrap_reverse { + flex_lines.iter_mut().rev().enumerate().for_each(align_line); + } else { + flex_lines.iter_mut().enumerate().for_each(align_line); + } + } + + /// Do a final layout pass and collect the resulting layouts. + #[inline] + fn final_layout_pass( + &mut self, + node: Node, + flex_lines: &mut [FlexLine], + constants: &AlgoConstants, + measure: &impl Measure, + ) { + let mut total_offset_cross = constants.padding_border.cross_start(constants.dir); + + let layout_line = |line: &mut FlexLine| { + let mut total_offset_main = constants.padding_border.main_start(constants.dir); + let line_offset_cross = line.offset_cross; + + let layout_item = |child: &mut FlexItem| { + let preliminary_size = self.compute_preliminary( + child.node, + child.target_size.map(|s| s.into()), + constants.container_size.map(|s| s.into()), + measure, + true, + false, + ); + + let offset_main = total_offset_main + + child.offset_main + + child.margin.main_start(constants.dir) + + (child.position.main_start(constants.dir).unwrap_or(0.0) + - child.position.main_end(constants.dir).unwrap_or(0.0)); + + let offset_cross = total_offset_cross + + child.offset_cross + + line_offset_cross + + child.margin.cross_start(constants.dir) + + (child.position.cross_start(constants.dir).unwrap_or(0.0) + - child.position.cross_end(constants.dir).unwrap_or(0.0)); + + self.nodes[child.node].layout = Layout { + order: self.children[node].iter().position(|n| *n == child.node).unwrap() as u32, + size: preliminary_size, + location: Point { + x: if constants.is_row { offset_main } else { offset_cross }, + y: if constants.is_column { offset_main } else { offset_cross }, + }, + }; + + total_offset_main += child.offset_main + + child.margin.main_axis_sum(constants.dir) + + preliminary_size.main(constants.dir); + }; + + if constants.dir.is_reverse() { + line.items.iter_mut().rev().for_each(layout_item); + } else { + line.items.iter_mut().for_each(layout_item); + } + + total_offset_cross += line_offset_cross + line.cross_size; + }; + + if constants.is_wrap_reverse { + flex_lines.iter_mut().rev().for_each(layout_line); + } else { + flex_lines.iter_mut().for_each(layout_line); + } + } + + /// Perform absolute layout on all absolutely positioned children. + #[inline] + fn perform_absolute_layout_on_absolute_children( + &mut self, + node: Node, + constants: &AlgoConstants, + measure: &impl Measure, + ) { + // TODO: remove number of Vec<_> generated + let candidates = self.children[node] + .iter() + .cloned() + .enumerate() + .filter(|(_, child)| self.nodes[*child].style.position_type == PositionType::Absolute) + .collect::>(); + + for (order, child) in candidates { + let container_width = constants.container_size.width.into(); + let container_height = constants.container_size.height.into(); + + let child_style = self.nodes[child].style; + + // X-axis + let child_position_start = child_style.position.start.maybe_resolve(container_width); + let child_margin_start = child_style.margin.start.maybe_resolve(container_width); + let start = child_position_start.maybe_add(child_margin_start); + + let child_position_end = child_style.position.end.maybe_resolve(container_width); + let child_margin_end = child_style.margin.end.maybe_resolve(container_width); + let end = child_position_end.maybe_add(child_margin_end); + + // Y-axis + let child_position_top = child_style.position.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); + + let child_position_bottom = child_style.position.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 (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) }; + + let mut width = child_style + .size + .width + .maybe_resolve(container_width) + .maybe_max(child_style.min_size.width.maybe_resolve(container_width)) + .maybe_min(child_style.max_size.width.maybe_resolve(container_width)); + + if width.is_none() && start.is_some() && end.is_some() { + width = container_width.maybe_sub(start).maybe_sub(end); + } + + let mut height: Option = child_style + .size + .height + .maybe_resolve(container_height) + .maybe_max(child_style.min_size.height.maybe_resolve(container_height)) + .maybe_min(child_style.max_size.height.maybe_resolve(container_height)); + + if height.is_none() && top.is_some() && bottom.is_some() { + height = container_height.maybe_sub(top).maybe_sub(bottom); + } + + let preliminary_size = self.compute_preliminary( + child, + Size { width, height }, + Size { width: container_width, height: container_height }, + measure, + true, + false, + ); + + let free_main_space = constants.container_size.main(constants.dir) + - preliminary_size + .main(constants.dir) + .maybe_max( + child_style + .min_main_size(constants.dir) + .maybe_resolve(constants.node_inner_size.main(constants.dir)), + ) + .maybe_min( + child_style + .max_main_size(constants.dir) + .maybe_resolve(constants.node_inner_size.main(constants.dir)), + ); + + let free_cross_space = constants.container_size.cross(constants.dir) + - preliminary_size + .cross(constants.dir) + .maybe_max( + child_style + .min_cross_size(constants.dir) + .maybe_resolve(constants.node_inner_size.cross(constants.dir)), + ) + .maybe_min( + child_style + .max_cross_size(constants.dir) + .maybe_resolve(constants.node_inner_size.cross(constants.dir)), + ); + + 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) + } else { + match self.nodes[node].style.justify_content { + JustifyContent::SpaceBetween | JustifyContent::FlexStart => { + constants.padding_border.main_start(constants.dir) + } + JustifyContent::FlexEnd => free_main_space - constants.padding_border.main_end(constants.dir), + JustifyContent::SpaceEvenly | JustifyContent::SpaceAround | JustifyContent::Center => { + free_main_space / 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) + } else { + match child_style.align_self(&self.nodes[node].style) { + AlignSelf::Auto => unreachable!(), + AlignSelf::FlexStart => { + if constants.is_wrap_reverse { + free_cross_space - constants.padding_border.cross_end(constants.dir) + } else { + constants.padding_border.cross_start(constants.dir) + } + } + AlignSelf::FlexEnd => { + if constants.is_wrap_reverse { + constants.padding_border.cross_start(constants.dir) + } else { + free_cross_space - constants.padding_border.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) + } + } + } + }; + + self.nodes[child].layout = Layout { + order: order as u32, + size: preliminary_size, + location: Point { + x: if constants.is_row { offset_main } else { offset_cross }, + y: if constants.is_column { offset_main } else { offset_cross }, + }, + }; + } + } + + /// Compute a preliminary size for an item + fn compute_preliminary( + &mut self, + node: Node, + node_size: Size>, + parent_size: Size>, + measure: &impl Measure, + perform_layout: bool, + main_size: bool, + ) -> Size { + self.nodes[node].is_dirty = false; + + // First we check if we have a result for the given input + if let Some(cached_size) = self.compute_from_cache(node, node_size, parent_size, perform_layout, main_size) { + return cached_size; + } + + // Define some general constants we will need for the remainder of the algorithm. + let mut constants = Taffy::compute_constants(&self.nodes[node], node_size, parent_size); + + // If this is a leaf node we can skip a lot of this function in some cases + if self.children[node].is_empty() { + if node_size.width.is_some() && node_size.height.is_some() { + return node_size.map(|s| s.unwrap_or(0.0)); + } + + if self.nodes[node].has_measure { + let converted_size = measure.measure(node, node_size); + + *self.cache(node, main_size) = + Some(Cache { node_size, parent_size, perform_layout, size: converted_size }); + + return converted_size; + } + + return Size { + width: node_size.width.unwrap_or(0.0) + constants.padding_border.horizontal_axis_sum(), + height: node_size.height.unwrap_or(0.0) + constants.padding_border.vertical_axis_sum(), + }; + } + + // 9. Flex Layout Algorithm + + // 9.1. Initial Setup + + // 1. Generate anonymous flex items as described in §4 Flex Items. + let mut flex_items = self.generate_anonymous_flex_items(node, &constants); + + // 9.2. Line Length Determination + + // 2. Determine the available main and cross space for the flex items. + let available_space = Self::determine_available_space(node_size, parent_size, &constants); + + let has_baseline_child = flex_items + .iter() + .any(|child| self.nodes[child.node].style.align_self(&self.nodes[node].style) == AlignSelf::Baseline); + + // 3. Determine the flex base size and hypothetical main size of each item. + self.determine_flex_base_size(node, node_size, &constants, available_space, &mut flex_items, measure); + + // TODO: Add step 4 according to spec: https://www.w3.org/TR/css-flexbox-1/#algo-main-container + // 9.3. Main Size Determination + + // 5. Collect flex items into flex lines. + let mut flex_lines = self.collect_flex_lines(node, &constants, available_space, &mut flex_items); + + // 6. Resolve the flexible lengths of all the flex items to find their used main size. + for line in &mut flex_lines { + self.resolve_flexible_lengths(line, &constants, available_space, measure); + } + + // TODO: Cleanup and make according to spec + // Not part of the spec from what i can see but seems correct + constants.container_size.set_main( + constants.dir, + node_size.main(constants.dir).unwrap_or({ + let longest_line = flex_lines.iter().fold(f32::MIN, |acc, line| { + let length: f32 = line.items.iter().map(|item| item.outer_target_size.main(constants.dir)).sum(); + acc.max(length) + }); + + let size = longest_line + constants.padding_border.main_axis_sum(constants.dir); + match available_space.main(constants.dir) { + Some(val) if flex_lines.len() > 1 && size < val => val, + _ => size, + } + }), + ); + + constants.inner_container_size.set_main( + constants.dir, + constants.container_size.main(constants.dir) - constants.padding_border.main_axis_sum(constants.dir), + ); + + // 9.4. Cross Size Determination + + // 7. Determine the hypothetical cross size of each item. + for line in &mut flex_lines { + self.determine_hypothetical_cross_size(line, &constants, available_space, measure); + } + + // TODO - probably should move this somewhere else as it doesn't make a ton of sense here but we need it below + // TODO - This is expensive and should only be done if we really require a baseline. aka, make it lazy + if has_baseline_child { + self.calculate_children_base_lines(node, node_size, &mut flex_lines, &constants, measure); + } + + // 8. Calculate the cross size of each flex line. + self.calculate_cross_size(&mut flex_lines, node, node_size, &constants); + + // 9. Handle 'align-content: stretch'. + self.handle_align_content_stretch(&mut flex_lines, node, node_size, &constants); + + // 10. Collapse visibility:collapse items. If any flex items have visibility: collapse, + // note the cross size of the line they’re in as the item’s strut size, and restart + // layout from the beginning. + // + // In this second layout round, when collecting items into lines, treat the collapsed + // items as having zero main size. For the rest of the algorithm following that step, + // ignore the collapsed items entirely (as if they were display:none) except that after + // calculating the cross size of the lines, if any line’s cross size is less than the + // largest strut size among all the collapsed items in the line, set its cross size to + // that strut size. + // + // Skip this step in the second layout round. + + // TODO implement once (if ever) we support visibility:collapse + + // 11. Determine the used cross size of each flex item. + self.determine_used_cross_size(&mut flex_lines, node, &constants); + + // 9.5. Main-Axis Alignment + + // 12. Distribute any remaining free space. + self.distribute_remaining_free_space(&mut flex_lines, node, &constants); + + // 9.6. Cross-Axis Alignment + + // 13. Resolve cross-axis auto margins (also includes 14). + self.resolve_cross_axis_auto_margins(&mut flex_lines, node, &constants); + + // 15. Determine the flex container’s used cross size. + let total_cross_size = Self::determine_container_cross_size(&mut flex_lines, node_size, &mut constants); + + // We have the container size. + // If our caller does not care about performing layout we are done now. + if !perform_layout { + let container_size = constants.container_size; + *self.cache(node, main_size) = Some(Cache { node_size, parent_size, perform_layout, size: container_size }); + return container_size; + } + + // 16. Align all flex lines per align-content. + self.align_flex_lines_per_align_content(&mut flex_lines, node, &constants, total_cross_size); + + // Do a final layout pass and gather the resulting layouts + self.final_layout_pass(node, &mut flex_lines, &constants, measure); + + // Before returning we perform absolute layout on all absolutely positioned children + self.perform_absolute_layout_on_absolute_children(node, &constants, measure); + + /// Lay out all hidden nodes recursively + /// + /// Each hidden node has zero size and is placed at the origin + fn hidden_layout( + nodes: &mut SlotMap, + children: &SlotMap>, + node: Node, + order: u32, + ) { + nodes[node].layout = Layout { order, size: Size::ZERO, location: Point::ZERO }; + + for (order, child) in children[node].iter().enumerate() { + hidden_layout(nodes, children, *child, order as _); + } + } + + for (order, child) in self.children[node].iter().enumerate() { + if self.nodes[*child].style.display == Display::None { + hidden_layout(&mut self.nodes, &self.children, *child, order as _); + } + } + + let container_size = constants.container_size; + *self.cache(node, main_size) = Some(Cache { node_size, parent_size, perform_layout, size: container_size }); + + container_size + } +} + +#[cfg(test)] +mod tests { + use crate::{ + math::MaybeMath, + node::Taffy, + prelude::{Rect, Size}, + resolve::ResolveOrDefault, + style::{FlexWrap, FlexboxLayout}, + }; + + // Make sure we get correct constants + #[test] + fn correct_constants() { + let mut tree = Taffy::with_capacity(16); + + let style = FlexboxLayout::default(); + let node_id = tree.new_leaf(style).unwrap(); + + let node_size = Size::undefined(); + let parent_size = Size::undefined(); + + let constants = Taffy::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()); + assert!(constants.is_column == style.flex_direction.is_column()); + assert!(constants.is_wrap_reverse == (style.flex_wrap == FlexWrap::WrapReverse)); + + let margin = style.margin.resolve_or_default(parent_size); + assert_eq!(constants.margin, margin); + + let border = style.border.resolve_or_default(parent_size); + assert_eq!(constants.border, border); + + let padding = style.padding.resolve_or_default(parent_size); + + // TODO: Replace with something less hardcoded? + let padding_border = Rect { + start: padding.start + border.start, + end: padding.end + border.end, + top: padding.top + border.top, + bottom: padding.bottom + border.bottom, + }; + + 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()), + }; + assert_eq!(constants.node_inner_size, inner_size); + + assert_eq!(constants.container_size, Size::ZERO); + assert_eq!(constants.inner_container_size, Size::ZERO); + } +} diff --git a/src/geometry.rs b/src/geometry.rs new file mode 100644 index 000000000..c976d667a --- /dev/null +++ b/src/geometry.rs @@ -0,0 +1,277 @@ +//! Geometric primitives useful for layout + +use crate::style::{Dimension, FlexDirection}; +use core::ops::Add; + +/// An axis-aligned UI rectangle +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serde", serde(default))] +pub struct Rect { + /// This can represent either the x-coordinate of the starting edge, + /// or the amount of padding on the starting side. + /// + /// The starting edge is the left edge when working with LTR text, + /// and the right edge when working with RTL text. + pub start: T, + /// This can represent either the x-coordinate of the ending edge, + /// or the amount of padding on the ending side. + /// + /// The ending edge is the right edge when working with LTR text, + /// and the left edge when working with RTL text. + pub end: T, + /// This can represent either the y-coordinate of the top edge, + /// or the amount of padding on the top side. + pub top: T, + /// This can represent either the y-coordinate of the bottom edge, + /// or the amount of padding on the bottom side. + pub bottom: T, +} + +impl Rect { + /// Applies the function `f` to all four sides of the rect + /// + /// When applied to the left and right sides, the width is used + /// as the second parameter of `f`. + /// When applied to the top or bottom sides, the height is used instead. + pub(crate) fn zip_size(self, size: Size, f: F) -> Rect + where + F: Fn(T, U) -> R, + U: Copy, + { + Rect { + start: f(self.start, size.width), + end: f(self.end, size.width), + top: f(self.top, size.height), + bottom: f(self.bottom, size.height), + } + } +} + +impl Rect +where + T: Add + Copy + Clone, +{ + /// The sum of [`Rect.start`](Rect) and [`Rect.end`](Rect) + /// + /// This is typically used when computing total padding. + /// + /// **NOTE:** this is *not* the width of the rectangle. + pub(crate) fn horizontal_axis_sum(&self) -> T { + self.start + self.end + } + + /// The sum of [`Rect.top`](Rect) and [`Rect.bottom`](Rect) + /// + /// This is typically used when computing total padding. + /// + /// **NOTE:** this is *not* the height of the rectangle. + pub(crate) fn vertical_axis_sum(&self) -> T { + self.top + self.bottom + } + + /// The sum of the two fields of the [`Rect`] representing the main axis. + /// + /// This is typically used when computing total padding. + /// + /// If the [`FlexDirection`] is [`FlexDirection::Row`] or [`FlexDirection::RowReverse`], this is [`Rect::horizontal`]. + /// Otherwise, this is [`Rect::vertical`]. + pub(crate) fn main_axis_sum(&self, direction: FlexDirection) -> T { + if direction.is_row() { + self.horizontal_axis_sum() + } else { + self.vertical_axis_sum() + } + } + + /// The sum of the two fields of the [`Rect`] representing the cross axis. + /// + /// If the [`FlexDirection`] is [`FlexDirection::Row`] or [`FlexDirection::RowReverse`], this is [`Rect::vertical`]. + /// Otherwise, this is [`Rect::horizontal`]. + pub(crate) fn cross_axis_sum(&self, direction: FlexDirection) -> T { + if direction.is_row() { + self.vertical_axis_sum() + } else { + self.horizontal_axis_sum() + } + } +} + +impl Rect +where + T: Copy + Clone, +{ + /// The `start` or `top` value of the [`Rect`], from the perspective of the main layout axis + pub(crate) fn main_start(&self, direction: FlexDirection) -> T { + if direction.is_row() { + self.start + } else { + self.top + } + } + + /// The `end` or `bottom` value of the [`Rect`], from the perspective of the main layout axis + pub(crate) fn main_end(&self, direction: FlexDirection) -> T { + if direction.is_row() { + self.end + } else { + self.bottom + } + } + + /// The `start` or `top` value of the [`Rect`], from the perspective of the cross layout axis + pub(crate) fn cross_start(&self, direction: FlexDirection) -> T { + if direction.is_row() { + self.top + } else { + self.start + } + } + + /// The `end` or `bottom` value of the [`Rect`], from the perspective of the main layout axis + pub(crate) fn cross_end(&self, direction: FlexDirection) -> T { + if direction.is_row() { + self.bottom + } else { + self.end + } + } +} + +impl Rect { + /// Creates a new Rect with `0.0` as all parameters + pub const ZERO: Rect = Self { start: 0.0, end: 0.0, top: 0.0, bottom: 0.0 }; + + /// Creates a new Rect + #[must_use] + pub fn new(start: f32, end: f32, top: f32, bottom: f32) -> Self { + Self { start, end, top, bottom } + } +} + +/// The width and height of a [`Rect`] +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serde", serde(default))] +pub struct Size { + /// The x extent of the rectangle + pub width: T, + /// The y extent of the rectangle + pub height: T, +} + +impl Size<()> { + /// Generates a `Size>` with undefined width and height + #[must_use] + pub fn undefined() -> Size> { + Size { width: None, height: None } + } +} + +impl Size { + /// Applies the function `f` to both the width and height + /// + /// This is used to transform a `Rect` into a `Rect`. + pub fn map(self, f: F) -> Size + where + F: Fn(T) -> R, + { + Size { width: f(self.width), height: f(self.height) } + } + + /// Sets the extent of the main layout axis + /// + /// Whether this is the width or height depends on the `direction` provided + pub(crate) fn set_main(&mut self, direction: FlexDirection, value: T) { + if direction.is_row() { + self.width = value + } else { + self.height = value + } + } + + /// Sets the extent of the cross layout axis + /// + /// Whether this is the width or height depends on the `direction` provided + pub(crate) fn set_cross(&mut self, direction: FlexDirection, value: T) { + if direction.is_row() { + self.height = value + } else { + self.width = value + } + } + + /// Gets the extent of the main layout axis + /// + /// Whether this is the width or height depends on the `direction` provided + pub(crate) fn main(self, direction: FlexDirection) -> T { + if direction.is_row() { + self.width + } else { + self.height + } + } + + /// Gets the extent of the cross layout axis + /// + /// Whether this is the width or height depends on the `direction` provided + pub(crate) fn cross(self, direction: FlexDirection) -> T { + if direction.is_row() { + self.height + } else { + self.width + } + } +} + +impl Size { + /// A [`Size`] with zero width and height + pub const ZERO: Size = Self { width: 0.0, height: 0.0 }; +} + +impl Size> { + /// A [`Size`] with `None` width and height + pub const NONE: Size> = Self { width: None, height: None }; + + /// A [`Size>`] with `Some(width)` and `Some(height)` as parameters + #[must_use] + pub fn new(width: f32, height: f32) -> Self { + Size { width: Some(width), height: Some(height) } + } +} + +impl Size { + /// Generates a [`Size`] using [`Dimension::Points`] values + #[must_use] + pub fn from_points(width: f32, height: f32) -> Self { + Size { width: Dimension::Points(width), height: Dimension::Points(height) } + } + + /// Generates a [`Size`] using [`Dimension::Percent`] values + #[must_use] + pub fn from_percent(width: f32, height: f32) -> Self { + Size { width: Dimension::Percent(width), height: Dimension::Percent(height) } + } + + /// Generates a [`Size`] using [`Dimension::Auto`] in both width and height + pub const AUTO: Size = Self { width: Dimension::Auto, height: Dimension::Auto }; + + /// Generates a [`Size`] using [`Dimension::Undefined`] in both width and height + pub const UNDEFINED: Size = Self { width: Dimension::Undefined, height: Dimension::Undefined }; +} + +/// A 2-dimensional coordinate. +/// +/// When used in association with a [`Rect`], represents the bottom-left corner. +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub struct Point { + /// The x-coordinate + pub x: T, + /// The y-coordinate + pub y: T, +} + +impl Point { + /// A [`Point`] with values (0,0), representing the origin + pub const ZERO: Point = Self { x: 0.0, y: 0.0 }; +} diff --git a/src/layout.rs b/src/layout.rs index c9906be2c..397a7d434 100644 --- a/src/layout.rs +++ b/src/layout.rs @@ -1,16 +1,39 @@ -#[derive(Debug)] -pub struct Edges { - pub left: f32, - pub right: f32, - pub top: f32, - pub bottom: f32, +//! Final and cached data structures that represent the high-level UI layout + +use crate::geometry::{Point, Size}; + +/// The final result of a layout algorithm for a single [`Node`](crate::node::Node). +#[derive(Copy, Debug, Clone)] +pub struct Layout { + /// The relative ordering of the node + /// + /// Nodes with a higher order should be rendered on top of those with a lower order. + /// This is effectively a topological sort of each tree. + pub order: u32, + /// The width and height of the node + pub size: Size, + /// The bottom-left corner of the node + pub location: Point, +} + +impl Layout { + /// Creates a new [`Layout`] struct with zero size positioned at the origin + #[must_use] + pub(crate) fn new() -> Self { + Self { order: 0, size: Size::ZERO, location: Point::ZERO } + } } -#[derive(Debug)] -pub struct Node { - pub width: f32, - pub height: f32, - pub x: f32, - pub y: f32, - pub children: Vec, -} \ No newline at end of file +/// Cached intermediate layout results +#[derive(Debug, Clone)] +pub(crate) struct Cache { + /// The initial cached size of the node itself + pub(crate) node_size: Size>, + /// The initial cached size of the parent's node + pub(crate) parent_size: Size>, + /// Whether or not layout should be recomputed + pub(crate) perform_layout: bool, + + /// The cached size of the item + pub(crate) size: Size, +} diff --git a/src/lib.rs b/src/lib.rs index 87fba59fa..3e43875fa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,34 @@ -pub mod style; +#![doc = include_str!("../README.md")] +#![cfg_attr(not(feature = "std"), no_std)] +#![deny(unsafe_code)] +#![warn(missing_docs)] +#![warn(clippy::missing_docs_in_private_items)] +#![forbid(unsafe_code)] + +// We always need std for the tests +// See +#[cfg(all(test, not(feature = "std")))] +#[macro_use] +extern crate std; + +#[cfg(all(not(feature = "std"), feature = "alloc"))] +extern crate alloc; + +#[cfg_attr(feature = "serde", macro_use)] +#[cfg(feature = "serde")] +extern crate serde; + +pub mod error; +pub mod geometry; pub mod layout; +pub mod math; +pub mod node; +pub mod prelude; +pub mod style; + +mod data; +mod flexbox; +mod resolve; +mod sys; -mod algo; -pub use algo::compute; \ No newline at end of file +pub use crate::node::Taffy; diff --git a/src/math.rs b/src/math.rs new file mode 100644 index 000000000..cd9ad6512 --- /dev/null +++ b/src/math.rs @@ -0,0 +1,230 @@ +//! Contains numerical helper traits and functions + +/// A trait to conveniently calculate minimums and maximums when some data may not be defined +/// +/// If the left-hand value is [`None`], these operations return [`None`]. +/// If the right-hand value is [`None`], it is treated as zero. +pub(crate) trait MaybeMath { + /// Returns the minimum of `self` and `rhs` + fn maybe_min(self, rhs: In) -> Out; + + /// Returns the maximum of `self` and `rhs` + fn maybe_max(self, rhs: In) -> Out; + + /// Adds `self` and `rhs`. + fn maybe_add(self, rhs: In) -> Out; + + /// Subtracts rhs from `self`, treating [`None`] values as default + fn maybe_sub(self, rhs: In) -> Out; +} + +impl MaybeMath, Option> for Option { + fn maybe_min(self, rhs: Option) -> Option { + match (self, rhs) { + (Some(l), Some(r)) => Some(l.min(r)), + (Some(_l), None) => self, + (None, Some(_r)) => None, + (None, None) => None, + } + } + + fn maybe_max(self, rhs: Option) -> Option { + match (self, rhs) { + (Some(l), Some(r)) => Some(l.max(r)), + (Some(_l), None) => self, + (None, Some(_r)) => None, + (None, None) => None, + } + } + + fn maybe_add(self, rhs: Option) -> Option { + match (self, rhs) { + (Some(l), Some(r)) => Some(l + r), + (Some(_l), None) => self, + (None, Some(_r)) => None, + (None, None) => None, + } + } + + fn maybe_sub(self, rhs: Option) -> Option { + match (self, rhs) { + (Some(l), Some(r)) => Some(l - r), + (Some(_l), None) => self, + (None, Some(_r)) => None, + (None, None) => None, + } + } +} + +impl MaybeMath> for Option { + fn maybe_min(self, rhs: f32) -> Option { + self.map(|val| val.min(rhs)) + } + + fn maybe_max(self, rhs: f32) -> Option { + self.map(|val| val.max(rhs)) + } + + fn maybe_add(self, rhs: f32) -> Option { + self.map(|val| val + rhs) + } + + fn maybe_sub(self, rhs: f32) -> Option { + self.map(|val| val - rhs) + } +} + +impl MaybeMath, f32> for f32 { + fn maybe_min(self, rhs: Option) -> f32 { + match rhs { + Some(val) => self.min(val), + None => self, + } + } + + fn maybe_max(self, rhs: Option) -> f32 { + match rhs { + Some(val) => self.max(val), + None => self, + } + } + + fn maybe_add(self, rhs: Option) -> f32 { + match rhs { + Some(val) => self + val, + None => self, + } + } + + fn maybe_sub(self, rhs: Option) -> f32 { + match rhs { + Some(val) => self - val, + None => self, + } + } +} + +#[cfg(test)] +mod tests { + mod lhs_option_f32_rhs_option_f32 { + + use crate::math::MaybeMath; + use rstest::rstest; + + #[rstest] + #[case(Some(3.0), Some(5.0), Some(3.0))] + #[case(Some(5.0), Some(3.0), Some(3.0))] + #[case(Some(3.0), None, Some(3.0))] + #[case(None, Some(3.0), None)] + #[case(None, None, None)] + fn test_maybe_min(#[case] lhs: Option, #[case] rhs: Option, #[case] expected: Option) { + assert_eq!(lhs.maybe_min(rhs), expected); + } + + #[rstest] + #[case(Some(3.0), Some(5.0), Some(5.0))] + #[case(Some(5.0), Some(3.0), Some(5.0))] + #[case(Some(3.0), None, Some(3.0))] + #[case(None, Some(3.0), None)] + #[case(None, None, None)] + fn test_maybe_max(#[case] lhs: Option, #[case] rhs: Option, #[case] expected: Option) { + assert_eq!(lhs.maybe_max(rhs), expected); + } + + #[rstest] + #[case(Some(3.0), Some(5.0), Some(8.0))] + #[case(Some(5.0), Some(3.0), Some(8.0))] + #[case(Some(3.0), None, Some(3.0))] + #[case(None, Some(3.0), None)] + #[case(None, None, None)] + fn test_maybe_add(#[case] lhs: Option, #[case] rhs: Option, #[case] expected: Option) { + assert_eq!(lhs.maybe_add(rhs), expected); + } + + #[rstest] + #[case(Some(3.0), Some(5.0), Some(-2.0))] + #[case(Some(5.0), Some(3.0), Some(2.0))] + #[case(Some(3.0), None, Some(3.0))] + #[case(None, Some(3.0), None)] + #[case(None, None, None)] + fn test_maybe_sub(#[case] lhs: Option, #[case] rhs: Option, #[case] expected: Option) { + assert_eq!(lhs.maybe_sub(rhs), expected); + } + } + + mod lhs_option_f32_rhs_f32 { + + use crate::math::MaybeMath; + use rstest::rstest; + + #[rstest] + #[case(Some(3.0), 5.0, Some(3.0))] + #[case(Some(5.0), 3.0, Some(3.0))] + #[case(None, 3.0, None)] + fn test_maybe_min(#[case] lhs: Option, #[case] rhs: f32, #[case] expected: Option) { + assert_eq!(lhs.maybe_min(rhs), expected); + } + + #[rstest] + #[case(Some(3.0), 5.0, Some(5.0))] + #[case(Some(5.0), 3.0, Some(5.0))] + #[case(None, 3.0, None)] + fn test_maybe_max(#[case] lhs: Option, #[case] rhs: f32, #[case] expected: Option) { + assert_eq!(lhs.maybe_max(rhs), expected); + } + + #[rstest] + #[case(Some(3.0), 5.0, Some(8.0))] + #[case(Some(5.0), 3.0, Some(8.0))] + #[case(None, 3.0, None)] + fn test_maybe_add(#[case] lhs: Option, #[case] rhs: f32, #[case] expected: Option) { + assert_eq!(lhs.maybe_add(rhs), expected); + } + + #[rstest] + #[case(Some(3.0), 5.0, Some(-2.0))] + #[case(Some(5.0), 3.0, Some(2.0))] + #[case(None, 3.0, None)] + fn test_maybe_sub(#[case] lhs: Option, #[case] rhs: f32, #[case] expected: Option) { + assert_eq!(lhs.maybe_sub(rhs), expected); + } + } + + mod lhs_f32_rhs_option_f32 { + + use crate::math::MaybeMath; + use rstest::rstest; + + #[rstest] + #[case(3.0, Some(5.0), 3.0)] + #[case(5.0, Some(3.0), 3.0)] + #[case(3.0, None, 3.0)] + fn test_maybe_min(#[case] lhs: f32, #[case] rhs: Option, #[case] expected: f32) { + assert_eq!(lhs.maybe_min(rhs), expected); + } + + #[rstest] + #[case(3.0, Some(5.0), 5.0)] + #[case(5.0, Some(3.0), 5.0)] + #[case(3.0, None, 3.0)] + fn test_maybe_max(#[case] lhs: f32, #[case] rhs: Option, #[case] expected: f32) { + assert_eq!(lhs.maybe_max(rhs), expected); + } + + #[rstest] + #[case(3.0, Some(5.0), 8.0)] + #[case(5.0, Some(3.0), 8.0)] + #[case(3.0, None, 3.0)] + fn test_maybe_add(#[case] lhs: f32, #[case] rhs: Option, #[case] expected: f32) { + assert_eq!(lhs.maybe_add(rhs), expected); + } + + #[rstest] + #[case(3.0, Some(5.0), -2.0)] + #[case(5.0, Some(3.0), 2.0)] + #[case(3.0, None, 3.0)] + fn test_maybe_sub(#[case] lhs: f32, #[case] rhs: Option, #[case] expected: f32) { + assert_eq!(lhs.maybe_sub(rhs), expected); + } + } +} diff --git a/src/node.rs b/src/node.rs new file mode 100644 index 000000000..230302389 --- /dev/null +++ b/src/node.rs @@ -0,0 +1,627 @@ +//! UI [`Node`] types and related data structures. +//! +//! Layouts are composed of multiple nodes, which live in a tree-like data structure. +use core::marker::PhantomData; + +use slotmap::{SlotMap, SparseSecondaryMap}; + +/// A node in a layout. +pub type Node = slotmap::DefaultKey; + +use crate::error::{TaffyError, TaffyResult}; +use crate::geometry::Size; +use crate::layout::Layout; +use crate::style::FlexboxLayout; +use crate::sys::{new_vec_with_capacity, ChildrenVec, Vec}; +use crate::{data::NodeData, error}; + +/// Trait that can measure nodes using previously stored associated data +pub trait Measure { + fn measure(&self, node: Node, constraint: Size>) -> Size; +} + +pub struct NoMeasure { + phantom: PhantomData<()>, +} + +// pub type Taffy = Taffy; + +/// A tree of UI [`Nodes`](`Node`), suitable for UI layout +pub struct Taffy { + /// The [`NodeData`] for each node stored in this tree + pub(crate) nodes: SlotMap, + + /// The children of each node + /// + /// The indexes in the outer vector correspond to the position of the parent [`NodeData`] + pub(crate) children: SlotMap>, + + /// The parents of each node + /// + /// The indexes in the outer vector correspond to the position of the child [`NodeData`] + pub(crate) parents: SlotMap>, +} + +impl Default for Taffy { + fn default() -> Self { + Self::with_capacity(16) + } +} + +#[allow(clippy::iter_cloned_collect)] // due to no-std support, we need to use `iter_cloned` instead of `collect` +impl Taffy { + /// Creates a new [`Taffy`] + /// + /// The default capacity of a [`Taffy`] is 16 nodes. + #[must_use] + pub fn new() -> Self { + Taffy::default() + } + + /// Creates a new [`Taffy`] that can store `capacity` nodes before reallocation + #[must_use] + pub fn with_capacity(capacity: usize) -> Self { + Self { + nodes: SlotMap::with_capacity(capacity), + children: SlotMap::with_capacity(capacity), + parents: SlotMap::with_capacity(capacity), + } + } + + /// Creates and adds a new unattached leaf node to the tree, and returns the [`NodeId`] of the new node + pub fn new_leaf(&mut self, layout: FlexboxLayout) -> TaffyResult { + let id = self.nodes.insert(NodeData::new(layout)); + let _ = self.children.insert(new_vec_with_capacity(0)); + let _ = self.parents.insert(None); + + Ok(id) + } + + /// Creates and adds a new unattached leaf node to the tree, and returns the [`NodeId`] of the new node + /// + /// Creates and adds a new leaf node with a supplied [`MeasureFunc`] + pub fn new_leaf_with_required_measure(&mut self, layout: FlexboxLayout) -> TaffyResult { + let id = self.nodes.insert(NodeData::new_with_required_measure(layout)); + let _ = self.children.insert(new_vec_with_capacity(0)); + let _ = self.parents.insert(None); + + Ok(id) + } + + /// Creates and adds a new node, which may have any number of `children` + pub fn new_with_children(&mut self, layout: FlexboxLayout, children: &[Node]) -> TaffyResult { + let id = self.nodes.insert(NodeData::new(layout)); + + for child in children { + self.parents[*child] = Some(id); + } + + let _ = self.children.insert(children.iter().copied().collect::<_>()); + let _ = self.parents.insert(None); + + Ok(id) + } + + /// Removes all nodes + /// + /// All associated [`Id`] will be rendered invalid. + pub fn clear(&mut self) { + self.nodes.clear(); + self.children.clear(); + self.parents.clear(); + } + + /// Remove a specific [`Node`] from the tree + /// + /// Its [`Id`] is marked as invalid. Returns the id of the node removed. + pub fn remove(&mut self, node: Node) -> TaffyResult { + if let Some(parent) = self.parents[node] { + if let Some(children) = self.children.get_mut(parent) { + children.retain(|f| *f != node); + } + } + + let _ = self.children.remove(node); + let _ = self.parents.remove(node); + let _ = self.nodes.remove(node); + + Ok(node) + } + + /// Adds a `child` [`Node`] under the supplied `parent` + pub fn add_child(&mut self, parent: Node, child: Node) -> TaffyResult<()> { + self.parents[child] = Some(parent); + self.children[parent].push(child); + self.mark_dirty(parent)?; + + Ok(()) + } + + /// Directly sets the `children` of the supplied `parent` + pub fn set_children(&mut self, parent: Node, children: &[Node]) -> TaffyResult<()> { + // Remove node as parent from all its current children. + for child in &self.children[parent] { + self.parents[*child] = None; + } + + // Build up relation node <-> child + for child in children { + self.parents[*child] = Some(parent); + } + + self.children[parent] = children.iter().copied().collect::<_>(); + + self.mark_dirty(parent)?; + + Ok(()) + } + + /// Removes the `child` of the parent `node` + /// + /// The child is not removed from the tree entirely, it is simply no longer attached to its previous parent. + pub fn remove_child(&mut self, parent: Node, child: Node) -> TaffyResult { + let index = self.children[parent].iter().position(|n| *n == child).unwrap(); + self.remove_child_at_index(parent, index) + } + + /// Removes the child at the given `index` from the `parent` + /// + /// The child is not removed from the tree entirely, it is simply no longer attached to its previous parent. + pub fn remove_child_at_index(&mut self, parent: Node, child_index: usize) -> TaffyResult { + let child_count = self.children[parent].len(); + if child_index >= child_count { + return Err(error::TaffyError::ChildIndexOutOfBounds { parent, child_index, child_count }); + } + + let child = self.children[parent].remove(child_index); + self.parents[child] = None; + + self.mark_dirty(parent)?; + + Ok(child) + } + + /// Replaces the child at the given `child_index` from the `parent` node with the new `child` node + /// + /// The child is not removed from the tree entirely, it is simply no longer attached to its previous parent. + pub fn replace_child_at_index(&mut self, parent: Node, child_index: usize, new_child: Node) -> TaffyResult { + let child_count = self.children[parent].len(); + if child_index >= child_count { + return Err(error::TaffyError::ChildIndexOutOfBounds { parent, child_index, child_count }); + } + + self.parents[new_child] = Some(parent); + let old_child = core::mem::replace(&mut self.children[parent][child_index], new_child); + self.parents[old_child] = None; + + self.mark_dirty(parent)?; + + Ok(old_child) + } + + /// Returns the child [`Node`] of the parent `node` at the provided `child_index` + pub fn child_at_index(&self, parent: Node, child_index: usize) -> TaffyResult { + let child_count = self.children[parent].len(); + if child_index >= child_count { + return Err(error::TaffyError::ChildIndexOutOfBounds { parent, child_index, child_count }); + } + + Ok(self.children[parent][child_index]) + } + + /// Returns the number of children of the `parent` [`Node`] + pub fn child_count(&self, parent: Node) -> TaffyResult { + Ok(self.children[parent].len()) + } + + /// Returns a list of children that belong to the [`Parent`] + pub fn children(&self, parent: Node) -> TaffyResult> { + Ok(self.children[parent].iter().copied().collect::<_>()) + } + + /// Sets the [`Style`] of the provided `node` + pub fn set_style(&mut self, node: Node, style: FlexboxLayout) -> TaffyResult<()> { + self.nodes[node].style = style; + self.mark_dirty(node)?; + Ok(()) + } + + /// Gets the [`Style`] of the provided `node` + pub fn style(&self, node: Node) -> TaffyResult<&FlexboxLayout> { + Ok(&self.nodes[node].style) + } + + /// Return this node layout relative to its parent + pub fn layout(&self, node: Node) -> TaffyResult<&Layout> { + Ok(&self.nodes[node].layout) + } + + /// Marks the layout computation of this node and its children as outdated + /// + /// Performs a recursive depth-first search up the tree until the root node is reached + /// + /// WARNING: this will stack-overflow if the tree contains a cycle + pub fn mark_dirty(&mut self, node: Node) -> TaffyResult<()> { + /// WARNING: this will stack-overflow if the tree contains a cycle + fn mark_dirty_recursive( + nodes: &mut SlotMap, + parents: &SlotMap>, + node_id: Node, + ) { + nodes[node_id].mark_dirty(); + + if let Some(Some(node)) = parents.get(node_id) { + mark_dirty_recursive(nodes, parents, *node); + } + } + + mark_dirty_recursive(&mut self.nodes, &self.parents, node); + + Ok(()) + } + + /// Indicates whether the layout of this node (and its children) need to be recomputed + pub fn dirty(&self, node: Node) -> TaffyResult { + Ok(self.nodes[node].is_dirty) + } + + /// Updates the stored layout of the provided `node` and its children with measure + pub fn compute_measured_layout( + &mut self, + node: Node, + measure: &impl Measure, + size: Size>, + ) -> Result<(), TaffyError> { + self.compute(node, size, measure); + Ok(()) + } +} + +struct NoopMeasure(); + +impl Measure for NoopMeasure { + fn measure(&self, _node: Node, _size: Size>) -> Size { + Size::ZERO + } +} + +impl Taffy { + /// Updates the stored layout of the provided `node` and its children with no measurements + pub fn compute_layout(&mut self, node: Node, size: Size>) -> Result<(), TaffyError> { + let noop = NoopMeasure(); + self.compute(node, size, &noop); + Ok(()) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::{ + style::{Dimension, Display, FlexDirection}, + sys, + }; + + #[test] + fn new_should_allocate_default_capacity() { + const DEFAULT_CAPACITY: usize = 16; // This is the capacity defined in the `impl Default` + let taffy = Taffy::new(); + + assert!(taffy.children.capacity() >= DEFAULT_CAPACITY); + assert!(taffy.parents.capacity() >= DEFAULT_CAPACITY); + assert!(taffy.nodes.capacity() >= DEFAULT_CAPACITY); + } + + #[test] + fn test_with_capacity() { + const CAPACITY: usize = 8; + let taffy = Taffy::with_capacity(CAPACITY); + + assert!(taffy.children.capacity() >= CAPACITY); + assert!(taffy.parents.capacity() >= CAPACITY); + assert!(taffy.nodes.capacity() >= CAPACITY); + } + + #[test] + fn test_new_leaf() { + let mut taffy = Taffy::new(); + + let res = taffy.new_leaf(FlexboxLayout::default()); + assert!(res.is_ok()); + let node = res.unwrap(); + + // node should be in the taffy tree and have no children + assert!(taffy.child_count(node).unwrap() == 0); + } + + #[test] + fn new_leaf_with_measure() { + let mut taffy: Taffy = Taffy::new(); + + let res = taffy.new_leaf_with_required_measure(FlexboxLayout::default()); + assert!(res.is_ok()); + let node = res.unwrap(); + + // node should be in the taffy tree and have no children + assert!(taffy.child_count(node).unwrap() == 0); + } + + /// Test that new_with_children works as expected + #[test] + fn test_new_with_children() { + let mut taffy = Taffy::new(); + let child0 = taffy.new_leaf(FlexboxLayout::default()).unwrap(); + let child1 = taffy.new_leaf(FlexboxLayout::default()).unwrap(); + let node = taffy.new_with_children(FlexboxLayout::default(), &[child0, child1]).unwrap(); + + // node should have two children + assert_eq!(taffy.child_count(node).unwrap(), 2); + assert_eq!(taffy.children(node).unwrap()[0], child0); + assert_eq!(taffy.children(node).unwrap()[1], child1); + } + + #[test] + fn remove_node_should_remove() { + let mut taffy = Taffy::new(); + + let node = taffy.new_leaf(FlexboxLayout::default()).unwrap(); + + let _ = taffy.remove(node).unwrap(); + } + + #[test] + fn remove_node_should_detach_herarchy() { + let mut taffy = Taffy::new(); + + // Build a linear tree layout: <0> <- <1> <- <2> + let node2 = taffy.new_leaf(FlexboxLayout::default()).unwrap(); + let node1 = taffy.new_with_children(FlexboxLayout::default(), &[node2]).unwrap(); + let node0 = taffy.new_with_children(FlexboxLayout::default(), &[node1]).unwrap(); + + // Both node0 and node1 should have 1 child nodes + assert_eq!(taffy.children(node0).unwrap().as_slice(), &[node1]); + assert_eq!(taffy.children(node1).unwrap().as_slice(), &[node2]); + + // Disconnect the tree: <0> <2> + let _ = taffy.remove(node1).unwrap(); + + // Both remaining nodes should have no child nodes + assert!(taffy.children(node0).unwrap().is_empty()); + assert!(taffy.children(node2).unwrap().is_empty()); + } + + #[test] + fn remove_last_node() { + let mut taffy = Taffy::new(); + + let parent = taffy.new_leaf(FlexboxLayout::default()).unwrap(); + let child = taffy.new_leaf(FlexboxLayout::default()).unwrap(); + taffy.add_child(parent, child).unwrap(); + + taffy.remove(child).unwrap(); + taffy.remove(parent).unwrap(); + } + + #[test] + fn set_measure() { + struct ReturnStoredSize { + size: f32, + } + + impl Measure for ReturnStoredSize { + fn measure(&self, _node: Node, _size: Size>) -> Size { + let ReturnStoredSize { size } = self; + Size { width: *size, height: *size } + } + } + + let mut taffy = Taffy::new(); + let node = taffy.new_leaf_with_required_measure(FlexboxLayout::default()).unwrap(); + + let mut measure = ReturnStoredSize { size: 200. }; + taffy.compute_measured_layout(node, &measure, Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200.0); + + measure.size = 100.; + taffy.mark_dirty(node).unwrap(); + taffy.compute_measured_layout(node, &measure, Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100.0); + } + + /// Test that adding `add_child()` works + #[test] + fn add_child() { + let mut taffy = Taffy::new(); + let node = taffy.new_leaf(FlexboxLayout::default()).unwrap(); + assert_eq!(taffy.child_count(node).unwrap(), 0); + + let child0 = taffy.new_leaf(FlexboxLayout::default()).unwrap(); + taffy.add_child(node, child0).unwrap(); + assert_eq!(taffy.child_count(node).unwrap(), 1); + + let child1 = taffy.new_leaf(FlexboxLayout::default()).unwrap(); + taffy.add_child(node, child1).unwrap(); + assert_eq!(taffy.child_count(node).unwrap(), 2); + } + + #[test] + fn set_children() { + let mut taffy = Taffy::new(); + + let child0 = taffy.new_leaf(FlexboxLayout::default()).unwrap(); + let child1 = taffy.new_leaf(FlexboxLayout::default()).unwrap(); + let node = taffy.new_with_children(FlexboxLayout::default(), &[child0, child1]).unwrap(); + + assert_eq!(taffy.child_count(node).unwrap(), 2); + assert_eq!(taffy.children(node).unwrap()[0], child0); + assert_eq!(taffy.children(node).unwrap()[1], child1); + + let child2 = taffy.new_leaf(FlexboxLayout::default()).unwrap(); + let child3 = taffy.new_leaf(FlexboxLayout::default()).unwrap(); + taffy.set_children(node, &[child2, child3]).unwrap(); + + assert_eq!(taffy.child_count(node).unwrap(), 2); + assert_eq!(taffy.children(node).unwrap()[0], child2); + assert_eq!(taffy.children(node).unwrap()[1], child3); + } + + /// Test that removing a child works + #[test] + fn remove_child() { + let mut taffy = Taffy::new(); + let child0 = taffy.new_leaf(FlexboxLayout::default()).unwrap(); + let child1 = taffy.new_leaf(FlexboxLayout::default()).unwrap(); + let node = taffy.new_with_children(FlexboxLayout::default(), &[child0, child1]).unwrap(); + + assert_eq!(taffy.child_count(node).unwrap(), 2); + + taffy.remove_child(node, child0).unwrap(); + assert_eq!(taffy.child_count(node).unwrap(), 1); + assert_eq!(taffy.children(node).unwrap()[0], child1); + + taffy.remove_child(node, child1).unwrap(); + assert_eq!(taffy.child_count(node).unwrap(), 0); + } + + #[test] + fn remove_child_at_index() { + let mut taffy = Taffy::new(); + let child0 = taffy.new_leaf(FlexboxLayout::default()).unwrap(); + let child1 = taffy.new_leaf(FlexboxLayout::default()).unwrap(); + let node = taffy.new_with_children(FlexboxLayout::default(), &[child0, child1]).unwrap(); + + assert_eq!(taffy.child_count(node).unwrap(), 2); + + taffy.remove_child_at_index(node, 0).unwrap(); + assert_eq!(taffy.child_count(node).unwrap(), 1); + assert_eq!(taffy.children(node).unwrap()[0], child1); + + taffy.remove_child_at_index(node, 0).unwrap(); + assert_eq!(taffy.child_count(node).unwrap(), 0); + } + + #[test] + fn replace_child_at_index() { + let mut taffy = Taffy::new(); + + let child0 = taffy.new_leaf(FlexboxLayout::default()).unwrap(); + let child1 = taffy.new_leaf(FlexboxLayout::default()).unwrap(); + + let node = taffy.new_with_children(FlexboxLayout::default(), &[child0]).unwrap(); + assert_eq!(taffy.child_count(node).unwrap(), 1); + assert_eq!(taffy.children(node).unwrap()[0], child0); + + taffy.replace_child_at_index(node, 0, child1).unwrap(); + assert_eq!(taffy.child_count(node).unwrap(), 1); + assert_eq!(taffy.children(node).unwrap()[0], child1); + } + #[test] + fn test_child_at_index() { + let mut taffy = Taffy::new(); + let child0 = taffy.new_leaf(FlexboxLayout::default()).unwrap(); + let child1 = taffy.new_leaf(FlexboxLayout::default()).unwrap(); + let child2 = taffy.new_leaf(FlexboxLayout::default()).unwrap(); + let node = taffy.new_with_children(FlexboxLayout::default(), &[child0, child1, child2]).unwrap(); + + assert!(if let Ok(result) = taffy.child_at_index(node, 0) { result == child0 } else { false }); + assert!(if let Ok(result) = taffy.child_at_index(node, 1) { result == child1 } else { false }); + assert!(if let Ok(result) = taffy.child_at_index(node, 2) { result == child2 } else { false }); + } + #[test] + fn test_child_count() { + let mut taffy = Taffy::new(); + let child0 = taffy.new_leaf(FlexboxLayout::default()).unwrap(); + let child1 = taffy.new_leaf(FlexboxLayout::default()).unwrap(); + let node = taffy.new_with_children(FlexboxLayout::default(), &[child0, child1]).unwrap(); + + assert!(if let Ok(count) = taffy.child_count(node) { count == 2 } else { false }); + assert!(if let Ok(count) = taffy.child_count(child0) { count == 0 } else { false }); + assert!(if let Ok(count) = taffy.child_count(child1) { count == 0 } else { false }); + } + #[test] + fn test_children() { + let mut taffy = Taffy::new(); + let child0 = taffy.new_leaf(FlexboxLayout::default()).unwrap(); + let child1 = taffy.new_leaf(FlexboxLayout::default()).unwrap(); + let node = taffy.new_with_children(FlexboxLayout::default(), &[child0, child1]).unwrap(); + + let mut children: sys::Vec = sys::Vec::new(); + children.push(child0); + children.push(child1); + + let children_result = taffy.children(node).unwrap(); + assert_eq!(children_result, children); + + assert!(taffy.children(child0).unwrap().len() == 0); + } + #[test] + fn test_set_style() { + let mut taffy = Taffy::new(); + + let node = taffy.new_leaf(FlexboxLayout::default()).unwrap(); + assert_eq!(taffy.style(node).unwrap().display, Display::Flex); + + taffy.set_style(node, FlexboxLayout { display: Display::None, ..FlexboxLayout::default() }).unwrap(); + assert_eq!(taffy.style(node).unwrap().display, Display::None); + } + #[test] + fn test_style() { + let mut taffy = Taffy::new(); + + let style = + FlexboxLayout { display: Display::None, flex_direction: FlexDirection::RowReverse, ..Default::default() }; + + let node = taffy.new_leaf(style).unwrap(); + + let res = taffy.style(node); + assert!(res.is_ok()); + assert!(res.unwrap() == &style); + } + #[test] + fn test_layout() { + let mut taffy = Taffy::new(); + let node = taffy.new_leaf(FlexboxLayout::default()).unwrap(); + + // TODO: Improve this test? + let res = taffy.layout(node); + assert!(res.is_ok()); + } + + #[test] + fn test_mark_dirty() { + let mut taffy = Taffy::new(); + let child0 = taffy.new_leaf(FlexboxLayout::default()).unwrap(); + let child1 = taffy.new_leaf(FlexboxLayout::default()).unwrap(); + let node = taffy.new_with_children(FlexboxLayout::default(), &[child0, child1]).unwrap(); + + taffy.compute_layout(node, Size::undefined()).unwrap(); + + assert_eq!(taffy.dirty(child0).unwrap(), false); + assert_eq!(taffy.dirty(child1).unwrap(), false); + assert_eq!(taffy.dirty(node).unwrap(), false); + + taffy.mark_dirty(node).unwrap(); + assert_eq!(taffy.dirty(child0).unwrap(), false); + assert_eq!(taffy.dirty(child1).unwrap(), false); + assert_eq!(taffy.dirty(node).unwrap(), true); + + taffy.compute_layout(node, Size::undefined()).unwrap(); + taffy.mark_dirty(child0).unwrap(); + assert_eq!(taffy.dirty(child0).unwrap(), true); + assert_eq!(taffy.dirty(child1).unwrap(), false); + assert_eq!(taffy.dirty(node).unwrap(), true); + } + + #[test] + fn compute_layout_should_produce_valid_result() { + let mut taffy = Taffy::new(); + let node_result = taffy.new_leaf(FlexboxLayout { + size: Size { width: Dimension::Points(10f32), height: Dimension::Points(10f32) }, + ..Default::default() + }); + assert!(node_result.is_ok()); + let node = node_result.unwrap(); + let layout_result = taffy.compute_layout(node, Size { width: Some(100.), height: Some(100.) }); + assert!(layout_result.is_ok()); + } +} diff --git a/src/prelude.rs b/src/prelude.rs new file mode 100644 index 000000000..0cbe7df3b --- /dev/null +++ b/src/prelude.rs @@ -0,0 +1,11 @@ +//! Commonly used types + +pub use crate::{ + geometry::{Rect, Size}, + layout::Layout, + node::{Node, Taffy}, + style::{ + AlignContent, AlignItems, AlignSelf, Dimension, Display, FlexDirection, FlexWrap, FlexboxLayout, + JustifyContent, PositionType, + }, +}; diff --git a/src/resolve.rs b/src/resolve.rs new file mode 100644 index 000000000..bfe62d682 --- /dev/null +++ b/src/resolve.rs @@ -0,0 +1,363 @@ +//! Helper trait to calculate dimensions during layout resolution + +use crate::prelude::{Dimension, Rect, Size}; + +/// Trait to encapsulate behaviour where we need to resolve from a +/// potentially context-dependent size or dimension into +/// a context-independent size or dimension. +/// +/// Will return a default value if it unable to resolve. +pub(crate) trait ResolveOrDefault { + /// Resolve a dimension that might be dependent on a context, with a default fallback value + fn resolve_or_default(self, context: TContext) -> TOutput; +} + +/// Trait to encapsulate behaviour where we need to resolve from a +/// potentially context-dependent size or dimension into +/// a context-independent size or dimension. +/// +/// Will return a `None` if it unable to resolve. +pub(crate) trait MaybeResolve { + /// Resolve a dimension that might be dependent on a context, with `None` as fallback value + fn maybe_resolve(self, context: T) -> T; +} + +impl MaybeResolve> for Dimension { + /// Converts the given [`Dimension`] into a concrete value of points + /// + /// Can return `None` + fn maybe_resolve(self, context: Option) -> Option { + match self { + Dimension::Points(points) => Some(points), + // parent_dim * percent + Dimension::Percent(percent) => context.map(|dim| dim * percent), + _ => None, + } + } +} + +impl MaybeResolve>> for Size { + /// Converts any `parent`-relative values for size into an absolute size + fn maybe_resolve(self, context: Size>) -> Size> { + Size { width: self.width.maybe_resolve(context.width), height: self.height.maybe_resolve(context.height) } + } +} + +impl ResolveOrDefault, f32> for Dimension { + /// Will return a default value of result is evaluated to `None` + fn resolve_or_default(self, context: Option) -> f32 { + self.maybe_resolve(context).unwrap_or(0.0) + } +} + +impl ResolveOrDefault>, Rect> for Rect { + fn resolve_or_default(self, context: Size>) -> Rect { + Rect { + start: self.start.resolve_or_default(context.width), + end: self.end.resolve_or_default(context.width), + top: self.top.resolve_or_default(context.height), + bottom: self.bottom.resolve_or_default(context.height), + } + } +} + +impl ResolveOrDefault, Rect> for Rect { + fn resolve_or_default(self, context: Option) -> Rect { + Rect { + start: self.start.resolve_or_default(context), + end: self.end.resolve_or_default(context), + top: self.top.resolve_or_default(context), + bottom: self.bottom.resolve_or_default(context), + } + } +} + +#[cfg(test)] +mod tests { + mod maybe_resolve_dimension { + + use crate::resolve::MaybeResolve; + use crate::style::Dimension; + use rstest::rstest; + + /// `Dimension::Undefined` should always return `None` + /// + /// The parent / context should not affect the outcome. + #[rstest] + #[case(Dimension::Undefined, None, None)] + #[case(Dimension::Undefined, Some(5.0), None)] + #[case(Dimension::Undefined, Some(-5.0), None)] + #[case(Dimension::Undefined, Some(0.), None)] + fn resolve_undefined(#[case] input: Dimension, #[case] context: Option, #[case] expected: Option) { + assert_eq!(input.maybe_resolve(context), expected); + } + + /// `Dimension::Auto` should always return `None` + /// + /// The parent / context should not affect the outcome. + #[rstest] + #[case(Dimension::Auto, None, None)] + #[case(Dimension::Auto, Some(5.0), None)] + #[case(Dimension::Auto, Some(-5.0), None)] + #[case(Dimension::Auto, Some(0.), None)] + fn resolve_auto(#[case] input: Dimension, #[case] context: Option, #[case] expected: Option) { + assert_eq!(input.maybe_resolve(context), expected); + } + + /// `Dimension::Points` should always return `Some(f32)` + /// where the f32 value is the inner value of the points. + /// + /// The parent / context should not affect the outcome. + #[rstest] + #[case(Dimension::Points(1.0), None, Some(1.0))] + #[case(Dimension::Points(1.0), Some(5.0), Some(1.0))] + #[case(Dimension::Points(1.0), Some(-5.0), Some(1.0))] + #[case(Dimension::Points(1.0), Some(0.), Some(1.0))] + fn resolve_points(#[case] input: Dimension, #[case] context: Option, #[case] expected: Option) { + assert_eq!(input.maybe_resolve(context), expected); + } + + /// `Dimension::Percent` should return `None` if context is `None`. + /// Otherwise it should return `Some(f32)` + /// where the f32 value is the inner value of the percent * context value. + /// + /// The parent / context __should__ affect the outcome. + #[rstest] + #[case(Dimension::Percent(1.0), None, None)] + #[case(Dimension::Percent(1.0), Some(5.0), Some(5.0))] + #[case(Dimension::Percent(1.0), Some(-5.0), Some(-5.0))] + #[case(Dimension::Percent(1.0), Some(50.0), Some(50.0))] + fn resolve_percent(#[case] input: Dimension, #[case] context: Option, #[case] expected: Option) { + assert_eq!(input.maybe_resolve(context), expected); + } + } + + mod maybe_resolve_size_dimension { + use crate::{prelude::Size, resolve::MaybeResolve, style::Dimension}; + use rstest::rstest; + + /// Size should always return Size + /// + /// The parent / context should not affect the outcome. + #[rstest] + #[case(Size::UNDEFINED, Size::NONE, Size::NONE)] + #[case(Size::UNDEFINED, Size::new(5.0, 5.0), Size::NONE)] + #[case(Size::UNDEFINED, Size::new(-5.0, -5.0), Size::NONE)] + #[case(Size::UNDEFINED, Size::new(0.0, 0.0), Size::NONE)] + fn maybe_resolve_undefined( + #[case] input: Size, + #[case] context: Size>, + #[case] expected: Size>, + ) { + assert_eq!(input.maybe_resolve(context), expected); + } + + /// Size should always return Size + /// + /// The parent / context should not affect the outcome. + #[rstest] + #[case(Size::AUTO, Size::NONE, Size::NONE)] + #[case(Size::AUTO, Size::new(5.0, 5.0), Size::NONE)] + #[case(Size::AUTO, Size::new(-5.0, -5.0), Size::NONE)] + #[case(Size::AUTO, Size::new(0.0, 0.0), Size::NONE)] + fn maybe_resolve_auto( + #[case] input: Size, + #[case] context: Size>, + #[case] expected: Size>, + ) { + assert_eq!(input.maybe_resolve(context), expected); + } + + /// Size should always return a Size + /// where the f32 values are the inner value of the points. + /// + /// The parent / context should not affect the outcome. + #[rstest] + #[case(Size::from_points(5.0, 5.0), Size::NONE, Size::new(5.0, 5.0))] + #[case(Size::from_points(5.0, 5.0), Size::new(5.0, 5.0), Size::new(5.0, 5.0))] + #[case(Size::from_points(5.0, 5.0), Size::new(-5.0, -5.0), Size::new(5.0, 5.0))] + #[case(Size::from_points(5.0, 5.0), Size::new(0.0, 0.0), Size::new(5.0, 5.0))] + fn maybe_resolve_points( + #[case] input: Size, + #[case] context: Size>, + #[case] expected: Size>, + ) { + assert_eq!(input.maybe_resolve(context), expected); + } + + /// `Size` should return `Size` if context is `Size`. + /// Otherwise it should return `Size` + /// where the f32 value is the inner value of the percent * context value. + /// + /// The context __should__ affect the outcome. + #[rstest] + #[case(Size::from_percent(5.0, 5.0), Size::NONE, Size::NONE)] + #[case(Size::from_percent(5.0, 5.0), Size::new(5.0, 5.0), Size::new(25.0, 25.0))] + #[case(Size::from_percent(5.0, 5.0), Size::new(-5.0, -5.0), Size::new(-25.0, -25.0))] + #[case(Size::from_percent(5.0, 5.0), Size::new(0.0, 0.0), Size::new(0.0, 0.0))] + fn maybe_resolve_percent( + #[case] input: Size, + #[case] context: Size>, + #[case] expected: Size>, + ) { + assert_eq!(input.maybe_resolve(context), expected); + } + } + + mod resolve_or_default_dimension_to_option_f32 { + use crate::resolve::ResolveOrDefault; + use crate::style::Dimension; + use rstest::rstest; + + #[rstest] + #[case(Dimension::Undefined, None, 0.0)] + #[case(Dimension::Undefined, Some(5.0), 0.0)] + #[case(Dimension::Undefined, Some(-5.0), 0.0)] + #[case(Dimension::Undefined, Some(0.0), 0.0)] + fn resolve_or_default_undefined(#[case] input: Dimension, #[case] context: Option, #[case] expected: f32) { + assert_eq!(input.resolve_or_default(context), expected); + } + #[rstest] + #[case(Dimension::Auto, None, 0.0)] + #[case(Dimension::Auto, Some(5.0), 0.0)] + #[case(Dimension::Auto, Some(-5.0), 0.0)] + #[case(Dimension::Auto, Some(0.0), 0.0)] + fn resolve_or_default_auto(#[case] input: Dimension, #[case] context: Option, #[case] expected: f32) { + assert_eq!(input.resolve_or_default(context), expected); + } + #[rstest] + #[case(Dimension::Points(5.0), None, 5.0)] + #[case(Dimension::Points(5.0), Some(5.0), 5.0)] + #[case(Dimension::Points(5.0), Some(-5.0), 5.0)] + #[case(Dimension::Points(5.0), Some(0.0), 5.0)] + fn resolve_or_default_points(#[case] input: Dimension, #[case] context: Option, #[case] expected: f32) { + assert_eq!(input.resolve_or_default(context), expected); + } + #[rstest] + #[case(Dimension::Percent(5.0), None, 0.0)] + #[case(Dimension::Percent(5.0), Some(5.0), 25.0)] + #[case(Dimension::Percent(5.0), Some(-5.0), -25.0)] + #[case(Dimension::Percent(5.0), Some(0.0), 0.0)] + fn resolve_or_default_percent(#[case] input: Dimension, #[case] context: Option, #[case] expected: f32) { + assert_eq!(input.resolve_or_default(context), expected); + } + } + + mod resolve_or_default_rect_dimension_to_rect { + use crate::geometry::{Rect, Size}; + use crate::resolve::ResolveOrDefault; + use crate::style::Dimension; + use rstest::rstest; + + #[rstest] + #[case(Rect::UNDEFINED, Size::NONE, Rect::ZERO)] + #[case(Rect::UNDEFINED, Size::new(5.0, 5.0), Rect::ZERO)] + #[case(Rect::UNDEFINED, Size::new(-5.0, -5.0), Rect::ZERO)] + #[case(Rect::UNDEFINED, Size::new(0.0, 0.0), Rect::ZERO)] + fn resolve_or_default_undefined( + #[case] input: Rect, + #[case] context: Size>, + #[case] expected: Rect, + ) { + assert_eq!(input.resolve_or_default(context), expected); + } + + #[rstest] + #[case(Rect::AUTO, Size::NONE, Rect::ZERO)] + #[case(Rect::AUTO, Size::new(5.0, 5.0), Rect::ZERO)] + #[case(Rect::AUTO, Size::new(-5.0, -5.0), Rect::ZERO)] + #[case(Rect::AUTO, Size::new(0.0, 0.0), Rect::ZERO)] + fn resolve_or_default_auto( + #[case] input: Rect, + #[case] context: Size>, + #[case] expected: Rect, + ) { + assert_eq!(input.resolve_or_default(context), expected); + } + + #[rstest] + #[case(Rect::from_points(5.0, 5.0, 5.0, 5.0), Size::NONE, Rect::new(5.0, 5.0, 5.0, 5.0))] + #[case(Rect::from_points(5.0, 5.0, 5.0, 5.0), Size::new(5.0, 5.0), Rect::new(5.0, 5.0, 5.0, 5.0))] + #[case(Rect::from_points(5.0, 5.0, 5.0, 5.0), Size::new(-5.0, -5.0), Rect::new(5.0, 5.0, 5.0, 5.0))] + #[case(Rect::from_points(5.0, 5.0, 5.0, 5.0), Size::new(0.0, 0.0), Rect::new(5.0, 5.0, 5.0, 5.0))] + fn resolve_or_default_points( + #[case] input: Rect, + #[case] context: Size>, + #[case] expected: Rect, + ) { + assert_eq!(input.resolve_or_default(context), expected); + } + + #[rstest] + #[case(Rect::from_percent(5.0, 5.0, 5.0, 5.0), Size::NONE, Rect::ZERO)] + #[case(Rect::from_percent(5.0, 5.0, 5.0, 5.0), Size::new(5.0, 5.0), Rect::new(25.0, 25.0, 25.0, 25.0))] + #[case(Rect::from_percent(5.0, 5.0, 5.0, 5.0), Size::new(-5.0, -5.0), Rect::new(-25.0, -25.0, -25.0, -25.0))] + #[case(Rect::from_percent(5.0, 5.0, 5.0, 5.0), Size::new(0.0, 0.0), Rect::ZERO)] + fn resolve_or_default_percent( + #[case] input: Rect, + #[case] context: Size>, + #[case] expected: Rect, + ) { + assert_eq!(input.resolve_or_default(context), expected); + } + } + + mod resolve_or_default_rect_dimension_to_rect_f32_via_option { + use crate::geometry::Rect; + use crate::resolve::ResolveOrDefault; + use crate::style::Dimension; + use rstest::rstest; + + #[rstest] + #[case(Rect::UNDEFINED, None, Rect::ZERO)] + #[case(Rect::UNDEFINED, Some(5.0), Rect::ZERO)] + #[case(Rect::UNDEFINED, Some(-5.0), Rect::ZERO)] + #[case(Rect::UNDEFINED, Some(0.0), Rect::ZERO)] + fn resolve_or_default_undefined( + #[case] input: Rect, + #[case] context: Option, + #[case] expected: Rect, + ) { + assert_eq!(input.resolve_or_default(context), expected); + } + + #[rstest] + #[case(Rect::AUTO, None, Rect::ZERO)] + #[case(Rect::AUTO, Some(5.0), Rect::ZERO)] + #[case(Rect::AUTO, Some(-5.0), Rect::ZERO)] + #[case(Rect::AUTO, Some(0.0), Rect::ZERO)] + fn resolve_or_default_auto( + #[case] input: Rect, + #[case] context: Option, + #[case] expected: Rect, + ) { + assert_eq!(input.resolve_or_default(context), expected); + } + + #[rstest] + #[case(Rect::from_points(5.0, 5.0, 5.0, 5.0), None, Rect::new(5.0, 5.0, 5.0, 5.0))] + #[case(Rect::from_points(5.0, 5.0, 5.0, 5.0), Some(5.0), Rect::new(5.0, 5.0, 5.0, 5.0))] + #[case(Rect::from_points(5.0, 5.0, 5.0, 5.0), Some(-5.0), Rect::new(5.0, 5.0, 5.0, 5.0))] + #[case(Rect::from_points(5.0, 5.0, 5.0, 5.0), Some(0.0), Rect::new(5.0, 5.0, 5.0, 5.0))] + fn resolve_or_default_points( + #[case] input: Rect, + #[case] context: Option, + #[case] expected: Rect, + ) { + assert_eq!(input.resolve_or_default(context), expected); + } + + #[rstest] + #[case(Rect::from_percent(5.0, 5.0, 5.0, 5.0), None, Rect::ZERO)] + #[case(Rect::from_percent(5.0, 5.0, 5.0, 5.0), Some(5.0), Rect::new(25.0, 25.0, 25.0, 25.0))] + #[case(Rect::from_percent(5.0, 5.0, 5.0, 5.0), Some(-5.0), Rect::new(-25.0, -25.0, -25.0, -25.0))] + #[case(Rect::from_percent(5.0, 5.0, 5.0, 5.0), Some(0.0), Rect::ZERO)] + fn resolve_or_default_percent( + #[case] input: Rect, + #[case] context: Option, + #[case] expected: Rect, + ) { + assert_eq!(input.resolve_or_default(context), expected); + } + } +} diff --git a/src/style.rs b/src/style.rs index a48822566..a11d33ba8 100644 --- a/src/style.rs +++ b/src/style.rs @@ -1,396 +1,694 @@ -#[derive(Copy, Clone, PartialEq, Debug)] +//! A representation of [CSS layout properties](https://css-tricks.com/snippets/css/a-guide-to-flexbox/) in Rust, used for flexbox layout + +use crate::geometry::{Rect, Size}; + +/// How [`Nodes`](crate::node::Node) are aligned relative to the cross axis +/// +/// The default behavior is [`AlignItems::Stretch`]. +/// +/// [Specification](https://www.w3.org/TR/css-flexbox-1/#align-items-property) +#[derive(Copy, Clone, PartialEq, Eq, Debug)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub enum AlignItems { - FlexStart, - FlexEnd, - Center, - Baseline, - Stretch, + /// Items are packed toward the start of the cross axis + FlexStart, + /// Items are packed toward the end of the cross axis + FlexEnd, + /// Items are packed along the center of the cross axis + Center, + /// Items are aligned such as their baselines align + Baseline, + /// Stretch to fill the container + Stretch, } impl Default for AlignItems { - fn default() -> AlignItems { AlignItems::Stretch } + fn default() -> Self { + Self::Stretch + } } -#[derive(Copy, Clone, PartialEq, Debug)] +/// Overrides the inherited [`AlignItems`] behavior for this node. +/// +/// The behavior of any child nodes will be controlled by this node's [`AlignItems`] value. +/// +/// The default behavior is [`AlignSelf::Auto`]. +/// +/// [Specification](https://www.w3.org/TR/css-flexbox-1/#align-items-property) +#[derive(Copy, Clone, PartialEq, Eq, Debug)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub enum AlignSelf { - Auto, - FlexStart, - FlexEnd, - Center, - Baseline, - Stretch, + /// Inherits the [`AlignItems`] behavior of the parent + Auto, + /// Items are packed toward the start of the cross axis + FlexStart, + /// Items are packed toward the end of the cross axis + FlexEnd, + /// Items are packed along the center of the cross axis + Center, + /// Items are aligned such as their baselines align + Baseline, + /// Distribute items evenly, but stretch them to fill the container + Stretch, } impl Default for AlignSelf { - fn default() -> AlignSelf { AlignSelf::Auto } + fn default() -> Self { + Self::Auto + } } -#[derive(Copy, Clone, PartialEq, Debug)] +/// Sets the distribution of space between and around content items along the cross-axis +/// +/// The default value is [`AlignContent::Stretch`]. +/// +/// [Specification](https://www.w3.org/TR/css-flexbox-1/#align-content-property) +#[derive(Copy, Clone, PartialEq, Eq, Debug)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub enum AlignContent { - FlexStart, - FlexEnd, - Center, - Stretch, - SpaceBetween, - SpaceAround, + /// Items are packed toward the start of the cross axis + FlexStart, + /// Items are packed toward the end of the cross axis + FlexEnd, + /// Items are packed along the center of the cross axis + Center, + /// Distribute items evenly, but stretch them to fill the container + Stretch, + /// Distribute items evenly, such that the first and last item are aligned with the edges + SpaceBetween, + /// Distribute items evenly, + /// such that the space between items is the same as the space between the first and last item and the edges + SpaceAround, } impl Default for AlignContent { - fn default() -> AlignContent { AlignContent::Stretch } -} - -#[derive(Copy, Clone, PartialEq, Debug)] -pub enum Direction { - Inherit, - LTR, - RTL, -} - -impl Default for Direction { - fn default() -> Direction { Direction::Inherit } + fn default() -> Self { + Self::Stretch + } } -#[derive(Copy, Clone, PartialEq, Debug)] +/// Sets the layout used for the children of this node +/// +/// [`Display::Flex`] is the default value. +#[derive(Copy, Clone, PartialEq, Eq, Debug)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub enum Display { - Flex, - None, + /// The children will follow the flexbox layout algorithm + Flex, + /// The children will not be laid out, and will follow absolute positioning + None, } impl Default for Display { - fn default() -> Display { Display::Flex } + fn default() -> Self { + Self::Flex + } } -#[derive(Copy, Clone, PartialEq, Debug)] +/// The direction of the flexbox layout main axis. +/// +/// There are always two perpendicular layout axes: main (or primary) and cross (or secondary). +/// Adding items will cause them to be positioned adjacent to each other along the main axis. +/// By varying this value throughout your tree, you can create complex axis-aligned layouts. +/// +/// Items are always aligned relative to the cross axis, and justified relative to the main axis. +/// +/// The default behavior is [`FlexDirection::Row`]. +/// +/// [Specification](https://www.w3.org/TR/css-flexbox-1/#flex-direction-property) +#[derive(Copy, Clone, PartialEq, Eq, Debug)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub enum FlexDirection { - Row, - Column, - RowReverse, - ColumnReverse, + /// Defines +x as the main axis + /// + /// Items will be added from left to right in a row. + Row, + /// Defines +y as the main axis + /// + /// Items will be added from top to bottom in a column. + Column, + /// Defines -x as the main axis + /// + /// Items will be added from right to left in a row. + RowReverse, + /// Defines -y as the main axis + /// + /// Items will be added from bottom to top in a column. + ColumnReverse, } impl Default for FlexDirection { - fn default() -> FlexDirection { FlexDirection::Row } + fn default() -> Self { + Self::Row + } } impl FlexDirection { - pub(crate) fn is_row(self) -> bool { - self == FlexDirection::Row || self == FlexDirection::RowReverse - } + #[inline] + /// Is the direction [`FlexDirection::Row`] or [`FlexDirection::RowReverse`]? + pub(crate) fn is_row(self) -> bool { + matches!(self, Self::Row | Self::RowReverse) + } - pub(crate) fn is_column(self) -> bool { - self == FlexDirection::Column || self == FlexDirection::ColumnReverse - } + #[inline] + /// Is the direction [`FlexDirection::Column`] or [`FlexDirection::ColumnReverse`]? + pub(crate) fn is_column(self) -> bool { + matches!(self, Self::Column | Self::ColumnReverse) + } + + #[inline] + /// Is the direction [`FlexDirection::RowReverse`] or [`FlexDirection::ColumnReverse`]? + pub(crate) fn is_reverse(self) -> bool { + matches!(self, Self::RowReverse | Self::ColumnReverse) + } } -#[derive(Copy, Clone, PartialEq, Debug)] +/// Sets the distribution of space between and around content items along the main-axis +/// +/// The default value is [`JustifyContent::FlexStart`]. +/// +/// [Specification](https://www.w3.org/TR/css-flexbox-1/#justify-content-property) +#[derive(Copy, Clone, PartialEq, Eq, Debug)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub enum JustifyContent { - FlexStart, - Center, - FlexEnd, - SpaceBetween, - SpaceAround, - SpaceEvenly, + /// Items are packed toward the start of the main axis + FlexStart, + /// Items are packed toward the end of the main axis + FlexEnd, + /// Items are packed along the center of the main axis + Center, + /// Distribute items evenly, such that the first and last item are aligned with the edges + SpaceBetween, + /// Distribute items evenly, + /// such that the space between items is twice same as the space between the first and last item and the edges + SpaceAround, + /// Distribute items evenly, + /// such that the space between items is the same as the space between the first and last item and the edges + SpaceEvenly, } impl Default for JustifyContent { - fn default() -> JustifyContent { JustifyContent::FlexStart } -} - -#[derive(Copy, Clone, PartialEq, Debug)] -pub enum Overflow { - Visible, - Hidden, - Scroll, + fn default() -> Self { + Self::FlexStart + } } -impl Default for Overflow { - fn default() -> Overflow { Overflow::Visible } +/// The positioning strategy for this item. +/// +/// This controls both how the origin is determined for the [`Style::position`] field, +/// and whether or not the item will be controlled by flexbox's layout algorithm. +/// +/// WARNING: this enum follows the behavior of [CSS's `position` property](https://developer.mozilla.org/en-US/docs/Web/CSS/position), +/// which can be unintuitive. +/// +/// [`PositionType::Relative`] is the default value, in contrast to the default behavior in CSS. +#[derive(Copy, Clone, PartialEq, Eq, Debug)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +pub enum PositionType { + /// The offset is computed relative to the final position given by the layout algorithm. + /// Offsets do not affect the position of any other items; they are effectively a correction factor applied at the end. + Relative, + /// The offset is computed relative to this item's closest positioned ancestor, if any. + /// Otherwise, it is placed relative to the origin. + /// No space is created for the item in the page layout, and its size will not be altered. + /// + /// WARNING: to opt-out of layouting entirely, you must use [`Display::None`] instead on your [`Style`] object. + Absolute, } -#[derive(Copy, Clone, PartialEq, Debug)] -pub enum Position { - Relative, - Absolute, -} - -impl Default for Position { - fn default() -> Position { Position::Relative } +impl Default for PositionType { + fn default() -> Self { + Self::Relative + } } -#[derive(Copy, Clone, PartialEq, Debug)] -pub enum Wrap { - NoWrap, - Wrap, - WrapReverse, +/// Controls whether flex items are forced onto one line or can wrap onto multiple lines. +/// +/// Defaults to [`FlexWrap::NoWrap`] +/// +/// [Specification](https://www.w3.org/TR/css-flexbox-1/#flex-wrap-property) +#[derive(Copy, Clone, PartialEq, Eq, Debug)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +pub enum FlexWrap { + /// Items will not wrap and stay on a single line + NoWrap, + /// Items will wrap according to this item's [`FlexDirection`] + Wrap, + /// Items will wrap in the opposite direction to this item's [`FlexDirection`] + WrapReverse, } -impl Default for Wrap { - fn default() -> Wrap { Wrap::NoWrap } +impl Default for FlexWrap { + fn default() -> Self { + Self::NoWrap + } } +/// A unit of linear measurement +/// +/// This is commonly combined with [`Rect`], [`Point`](crate::geometry::Point) and [`Size`]. +/// The default value is [`Dimension::Undefined`]. #[derive(Copy, Clone, PartialEq, Debug)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub enum Dimension { - Auto, - Points(f32), - Percent(f32), + /// The dimension is not given + Undefined, + /// The dimension should be automatically computed + Auto, + /// The dimension is stored in [points](https://en.wikipedia.org/wiki/Point_(typography)) + /// + /// Each point is about 0.353 mm in size. + Points(f32), + /// The dimension is stored in percentage relative to the parent item. + Percent(f32), } impl Default for Dimension { - fn default() -> Dimension { Dimension::Auto } + fn default() -> Self { + Self::Undefined + } } impl Dimension { - pub(crate) fn resolve(&self, parent_size: f32, auto_size: f32) -> f32 { - match self { - Dimension::Points(points) => *points, - Dimension::Percent(percent) if parent_size.is_finite() => percent * parent_size, - _ => auto_size, + /// Is this value defined? + pub(crate) fn is_defined(self) -> bool { + matches!(self, Dimension::Points(_) | Dimension::Percent(_)) } - } -} - -#[derive(Debug)] -pub struct Edges { - pub start: Dimension, - pub end: Dimension, - pub top: Dimension, - pub bottom: Dimension, } -impl Default for Edges { - fn default() -> Edges { - Edges { - start: Dimension::Points(0.0), - end: Dimension::Points(0.0), - top: Dimension::Points(0.0), - bottom: Dimension::Points(0.0), +impl Default for Rect { + fn default() -> Self { + Self { start: Default::default(), end: Default::default(), top: Default::default(), bottom: Default::default() } } - } } -#[derive(Debug)] -pub struct Node { - pub position: Position, - pub direction: Direction, - pub flex_direction: FlexDirection, - - pub wrap: Wrap, - pub overflow: Overflow, - - pub align_items: AlignItems, - pub align_self: AlignSelf, - pub align_content: AlignContent, - - pub justify_content: JustifyContent, - - pub margin: Edges, - pub padding: Edges, - pub border: Edges, - - pub flex_grow: f32, - pub flex_shrink: f32, - pub flex_basis: Dimension, - - pub left: Dimension, - pub right: Dimension, - pub top: Dimension, - pub bottom: Dimension, - - pub width: Dimension, - pub min_width: Dimension, - pub max_width: Dimension, - - pub height: Dimension, - pub min_height: Dimension, - pub max_height: Dimension, - - pub aspect_ratio: Option, - - pub children: Vec, -} - -impl Default for Node { - fn default() -> Node { - Node { - position: Default::default(), - direction: Default::default(), - flex_direction: Default::default(), - - wrap: Default::default(), - overflow: Default::default(), - - align_items: Default::default(), - align_self: Default::default(), - align_content: Default::default(), - - justify_content: Default::default(), - - margin: Default::default(), - padding: Default::default(), - border: Default::default(), - - flex_grow: 0.0, - flex_shrink: 1.0, - flex_basis: Default::default(), - - left: Default::default(), - right: Default::default(), - top: Default::default(), - bottom: Default::default(), - - width: Default::default(), - min_width: Default::default(), - max_width: Default::default(), - - height: Default::default(), - min_height: Default::default(), - max_height: Default::default(), - - aspect_ratio: Default::default(), - - children: vec![], +impl Rect { + /// Generates a [`Rect`] using [`Dimension::Points`] values for `start` and `top` + #[must_use] + pub fn top_from_points(start: f32, top: f32) -> Rect { + Rect { start: Dimension::Points(start), top: Dimension::Points(top), ..Default::default() } } - } -} -impl Node { - pub(crate) fn main_size(&self) -> Dimension { - match self.flex_direction { - FlexDirection::Row | FlexDirection::RowReverse => self.width, - FlexDirection::Column | FlexDirection::ColumnReverse => self.height, + /// Generates a [`Rect`] using [`Dimension::Points`] values for `end` and `bottom` + #[must_use] + pub fn bot_from_points(end: f32, bottom: f32) -> Rect { + Rect { end: Dimension::Points(end), bottom: Dimension::Points(bottom), ..Default::default() } } - } - pub(crate) fn min_main_size(&self) -> Dimension { - match self.flex_direction { - FlexDirection::Row | FlexDirection::RowReverse => self.min_width, - FlexDirection::Column | FlexDirection::ColumnReverse => self.min_height, + /// Generates a [`Rect`] using [`Dimension::Percent`] values for `start` and `top` + #[must_use] + pub fn top_from_percent(start: f32, top: f32) -> Rect { + Rect { start: Dimension::Percent(start), top: Dimension::Percent(top), ..Default::default() } } - } - pub(crate) fn max_main_size(&self) -> Dimension { - match self.flex_direction { - FlexDirection::Row | FlexDirection::RowReverse => self.max_width, - FlexDirection::Column | FlexDirection::ColumnReverse => self.max_height, + /// Generates a [`Rect`] using [`Dimension::Percent`] values for `end` and `bottom` + #[must_use] + pub fn bot_from_percent(end: f32, bottom: f32) -> Rect { + Rect { end: Dimension::Percent(end), bottom: Dimension::Percent(bottom), ..Default::default() } } - } - pub(crate) fn main_margin_start(&self) -> Dimension { - match self.flex_direction { - FlexDirection::Row | FlexDirection::RowReverse => self.margin.start, - FlexDirection::Column | FlexDirection::ColumnReverse => self.margin.top, + /// Generates a [`Rect`] using [`Dimension::Undefined`] for all values + pub const UNDEFINED: Rect = Self { + start: Dimension::Undefined, + end: Dimension::Undefined, + top: Dimension::Undefined, + bottom: Dimension::Undefined, + }; + + /// Generates a [`Rect`] using [`Dimension::Auto`] for all values + pub const AUTO: Rect = + Self { start: Dimension::Auto, end: Dimension::Auto, top: Dimension::Auto, bottom: Dimension::Auto }; + + /// Create a new Rect with [`Dimension::Points`] + #[must_use] + pub fn from_points(start: f32, end: f32, top: f32, bottom: f32) -> Self { + Rect { + start: Dimension::Points(start), + end: Dimension::Points(end), + top: Dimension::Points(top), + bottom: Dimension::Points(bottom), + } } - } - pub(crate) fn main_margin_end(&self) -> Dimension { - match self.flex_direction { - FlexDirection::Row | FlexDirection::RowReverse => self.margin.end, - FlexDirection::Column | FlexDirection::ColumnReverse => self.margin.bottom, + /// Create a new Rect with [`Dimension::Percent`] + #[must_use] + pub fn from_percent(start: f32, end: f32, top: f32, bottom: f32) -> Self { + Rect { + start: Dimension::Percent(start), + end: Dimension::Percent(end), + top: Dimension::Percent(top), + bottom: Dimension::Percent(bottom), + } } - } +} - pub(crate) fn main_padding_start(&self) -> Dimension { - match self.flex_direction { - FlexDirection::Row | FlexDirection::RowReverse => self.padding.start, - FlexDirection::Column | FlexDirection::ColumnReverse => self.padding.top, +impl Default for Size { + fn default() -> Self { + Self { width: Dimension::Auto, height: Dimension::Auto } } - } +} + +/// The flexbox layout information for a single [`Node`](crate::node::Node). +/// +/// The most important idea in flexbox is the notion of a "main" and "cross" axis, which are always perpendicular to each other. +/// The orientation of these axes are controlled via the [`FlexDirection`] field of this struct. +/// +/// This struct follows the [CSS equivalent](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Basic_Concepts_of_Flexbox) directly; +/// information about the behavior on the web should transfer directly. +/// +/// Detailed information about the exact behavior of each of these fields +/// can be found on [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS) by searching for the field name. +/// The distinction between margin, padding and border is explained well in +/// this [introduction to the box model](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Box_Model/Introduction_to_the_CSS_box_model). +/// +/// If the behavior does not match the flexbox layout algorithm on the web, please file a bug! +#[derive(Copy, Clone, PartialEq, Debug)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serde", serde(default))] +pub struct FlexboxLayout { + /// What layout strategy should be used? + pub display: Display, + /// What should the `position` value of this struct use as a base offset? + pub position_type: PositionType, + /// Which direction does the main axis flow in? + pub flex_direction: FlexDirection, + /// Should elements wrap, or stay in a single line? + pub flex_wrap: FlexWrap, + /// How should items be aligned relative to the cross axis? + pub align_items: AlignItems, + /// Should this item violate the cross axis alignment specified by its parent's [`AlignItems`]? + pub align_self: AlignSelf, + /// How should content contained within this item be aligned relative to the cross axis? + pub align_content: AlignContent, + /// How should items be aligned relative to the main axis? + pub justify_content: JustifyContent, + /// How should the position of this element be tweaked relative to the layout defined? + pub position: Rect, + /// How large should the margin be on each side? + pub margin: Rect, + /// How large should the padding be on each side? + pub padding: Rect, + /// How large should the border be on each side? + pub border: Rect, + /// The relative rate at which this item grows when it is expanding to fill space + /// + /// 0.0 is the default value, and this value must be positive. + pub flex_grow: f32, + /// The relative rate at which this item shrinks when it is contracting to fit into space + /// + /// 1.0 is the default value, and this value must be positive. + pub flex_shrink: f32, + /// Sets the initial main axis size of the item + pub flex_basis: Dimension, + /// Sets the initial size of the item + // TODO: why does this exist as distinct from flex_basis? How do they interact? + pub size: Size, + /// Controls the minimum size of the item + pub min_size: Size, + /// Controls the maximum size of the item + pub max_size: Size, + /// Sets the preferred aspect ratio for the item + /// + /// The ratio is calculated as width divided by height. + pub aspect_ratio: Option, +} - pub(crate) fn main_padding_end(&self) -> Dimension { - match self.flex_direction { - FlexDirection::Row | FlexDirection::RowReverse => self.padding.end, - FlexDirection::Column | FlexDirection::ColumnReverse => self.padding.bottom, +impl Default for FlexboxLayout { + fn default() -> Self { + Self { + display: Default::default(), + position_type: Default::default(), + flex_direction: Default::default(), + flex_wrap: Default::default(), + align_items: Default::default(), + align_self: Default::default(), + align_content: Default::default(), + justify_content: Default::default(), + position: Default::default(), + margin: Default::default(), + padding: Default::default(), + border: Default::default(), + flex_grow: 0.0, + flex_shrink: 1.0, + flex_basis: Dimension::Auto, + size: Default::default(), + min_size: Default::default(), + max_size: Default::default(), + aspect_ratio: Default::default(), + } } - } +} - pub(crate) fn main_border_start(&self) -> Dimension { - match self.flex_direction { - FlexDirection::Row | FlexDirection::RowReverse => self.border.start, - FlexDirection::Column | FlexDirection::ColumnReverse => self.border.top, +impl FlexboxLayout { + /// If the `direction` is row-oriented, the min width. Otherwise the min height + pub(crate) fn min_main_size(&self, direction: FlexDirection) -> Dimension { + if direction.is_row() { + self.min_size.width + } else { + self.min_size.height + } } - } - pub(crate) fn main_border_end(&self) -> Dimension { - match self.flex_direction { - FlexDirection::Row | FlexDirection::RowReverse => self.border.end, - FlexDirection::Column | FlexDirection::ColumnReverse => self.border.bottom, + /// If the `direction` is row-oriented, the max width. Otherwise the max height + pub(crate) fn max_main_size(&self, direction: FlexDirection) -> Dimension { + if direction.is_row() { + self.max_size.width + } else { + self.max_size.height + } } - } - pub(crate) fn cross_size(&self) -> Dimension { - match self.flex_direction { - FlexDirection::Row | FlexDirection::RowReverse => self.height, - FlexDirection::Column | FlexDirection::ColumnReverse => self.width, + /// If the `direction` is row-oriented, the margin start. Otherwise the margin top + pub(crate) fn main_margin_start(&self, direction: FlexDirection) -> Dimension { + if direction.is_row() { + self.margin.start + } else { + self.margin.top + } } - } - pub(crate) fn min_cross_size(&self) -> Dimension { - match self.flex_direction { - FlexDirection::Row | FlexDirection::RowReverse => self.min_height, - FlexDirection::Column | FlexDirection::ColumnReverse => self.min_width, + /// If the `direction` is row-oriented, the margin end. Otherwise the margin bottom + pub(crate) fn main_margin_end(&self, direction: FlexDirection) -> Dimension { + if direction.is_row() { + self.margin.end + } else { + self.margin.bottom + } } - } - pub(crate) fn max_cross_size(&self) -> Dimension { - match self.flex_direction { - FlexDirection::Row | FlexDirection::RowReverse => self.max_height, - FlexDirection::Column | FlexDirection::ColumnReverse => self.max_width, + /// If the `direction` is row-oriented, the height. Otherwise the width + pub(crate) fn cross_size(&self, direction: FlexDirection) -> Dimension { + if direction.is_row() { + self.size.height + } else { + self.size.width + } } - } - pub(crate) fn cross_margin_start(&self) -> Dimension { - match self.flex_direction { - FlexDirection::Row | FlexDirection::RowReverse => self.margin.top, - FlexDirection::Column | FlexDirection::ColumnReverse => self.margin.start, + /// If the `direction` is row-oriented, the min height. Otherwise the min width + pub(crate) fn min_cross_size(&self, direction: FlexDirection) -> Dimension { + if direction.is_row() { + self.min_size.height + } else { + self.min_size.width + } } - } - pub(crate) fn cross_margin_end(&self) -> Dimension { - match self.flex_direction { - FlexDirection::Row | FlexDirection::RowReverse => self.margin.bottom, - FlexDirection::Column | FlexDirection::ColumnReverse => self.margin.end, + /// If the `direction` is row-oriented, the max height. Otherwise the max width + pub(crate) fn max_cross_size(&self, direction: FlexDirection) -> Dimension { + if direction.is_row() { + self.max_size.height + } else { + self.max_size.width + } } - } - pub(crate) fn cross_padding_start(&self) -> Dimension { - match self.flex_direction { - FlexDirection::Row | FlexDirection::RowReverse => self.padding.top, - FlexDirection::Column | FlexDirection::ColumnReverse => self.padding.start, + /// If the `direction` is row-oriented, the margin top. Otherwise the margin start + pub(crate) fn cross_margin_start(&self, direction: FlexDirection) -> Dimension { + if direction.is_row() { + self.margin.top + } else { + self.margin.start + } } - } - pub(crate) fn cross_padding_end(&self) -> Dimension { - match self.flex_direction { - FlexDirection::Row | FlexDirection::RowReverse => self.padding.bottom, - FlexDirection::Column | FlexDirection::ColumnReverse => self.padding.end, + /// If the `direction` is row-oriented, the margin bottom. Otherwise the margin end + pub(crate) fn cross_margin_end(&self, direction: FlexDirection) -> Dimension { + if direction.is_row() { + self.margin.bottom + } else { + self.margin.end + } } - } - pub(crate) fn cross_border_start(&self) -> Dimension { - match self.flex_direction { - FlexDirection::Row | FlexDirection::RowReverse => self.border.top, - FlexDirection::Column | FlexDirection::ColumnReverse => self.border.start, + /// Computes the final alignment of this item based on the parent's [`AlignItems`] and this item's [`AlignSelf`] + pub(crate) fn align_self(&self, parent: &FlexboxLayout) -> AlignSelf { + // FUTURE WARNING: This function should never return AlignSelf::Auto + // See #169 https://github.com/DioxusLabs/taffy/pull/169#issuecomment-1157698840 + + if self.align_self == AlignSelf::Auto { + match parent.align_items { + AlignItems::FlexStart => AlignSelf::FlexStart, + AlignItems::FlexEnd => AlignSelf::FlexEnd, + AlignItems::Center => AlignSelf::Center, + AlignItems::Baseline => AlignSelf::Baseline, + AlignItems::Stretch => AlignSelf::Stretch, + } + } else { + self.align_self + } } - } +} - pub(crate) fn cross_border_end(&self) -> Dimension { - match self.flex_direction { - FlexDirection::Row | FlexDirection::RowReverse => self.border.bottom, - FlexDirection::Column | FlexDirection::ColumnReverse => self.border.end, +#[allow(clippy::bool_assert_comparison)] +#[cfg(test)] +mod tests { + mod test_flex_direction { + use crate::style::*; + + #[test] + fn flex_direction_is_row() { + assert_eq!(FlexDirection::Row.is_row(), true); + assert_eq!(FlexDirection::RowReverse.is_row(), true); + assert_eq!(FlexDirection::Column.is_row(), false); + assert_eq!(FlexDirection::ColumnReverse.is_row(), false); + } + + #[test] + fn flex_direction_is_column() { + assert_eq!(FlexDirection::Row.is_column(), false); + assert_eq!(FlexDirection::RowReverse.is_column(), false); + assert_eq!(FlexDirection::Column.is_column(), true); + assert_eq!(FlexDirection::ColumnReverse.is_column(), true); + } + + #[test] + fn flex_direction_is_reverse() { + assert_eq!(FlexDirection::Row.is_reverse(), false); + assert_eq!(FlexDirection::RowReverse.is_reverse(), true); + assert_eq!(FlexDirection::Column.is_reverse(), false); + assert_eq!(FlexDirection::ColumnReverse.is_reverse(), true); + } } - } - pub(crate) fn align_self(&self, parent: &Node) -> AlignSelf { - if self.align_self == AlignSelf::Auto { - match parent.align_items { - AlignItems::FlexStart => AlignSelf::FlexStart, - AlignItems::FlexEnd => AlignSelf::FlexEnd, - AlignItems::Center => AlignSelf::Center, - AlignItems::Baseline => AlignSelf::Baseline, - AlignItems::Stretch => AlignSelf::Stretch, - } - } else { - self.align_self + mod test_flexbox_layout { + use crate::style::*; + + fn layout_from_align_items(align: AlignItems) -> FlexboxLayout { + FlexboxLayout { align_items: align, ..Default::default() } + } + + fn layout_from_align_self(align: AlignSelf) -> FlexboxLayout { + FlexboxLayout { align_self: align, ..Default::default() } + } + + #[test] + fn flexbox_layout_min_main_size() { + let layout = FlexboxLayout { min_size: Size::from_points(1.0, 2.0), ..Default::default() }; + assert_eq!(layout.min_main_size(FlexDirection::Row), Dimension::Points(1.0)); + assert_eq!(layout.min_main_size(FlexDirection::Column), Dimension::Points(2.0)); + } + + #[test] + fn flexbox_layout_max_main_size() { + let layout = FlexboxLayout { max_size: Size::from_points(1.0, 2.0), ..Default::default() }; + assert_eq!(layout.max_main_size(FlexDirection::Row), Dimension::Points(1.0)); + assert_eq!(layout.max_main_size(FlexDirection::Column), Dimension::Points(2.0)); + } + + #[test] + fn flexbox_layout_main_margin_start() { + let layout = FlexboxLayout { margin: Rect::top_from_points(2.0, 1.0), ..Default::default() }; + assert_eq!(layout.main_margin_start(FlexDirection::Row), Dimension::Points(2.0)); + assert_eq!(layout.main_margin_start(FlexDirection::Column), Dimension::Points(1.0)); + } + + #[test] + fn flexbox_layout_main_margin_end() { + let layout = FlexboxLayout { margin: Rect::bot_from_points(2.0, 1.0), ..Default::default() }; + assert_eq!(layout.main_margin_end(FlexDirection::Row), Dimension::Points(2.0)); + assert_eq!(layout.main_margin_end(FlexDirection::Column), Dimension::Points(1.0)); + } + + #[test] + fn flexbox_layout_cross_size() { + let layout = FlexboxLayout { size: Size::from_points(1.0, 2.0), ..Default::default() }; + assert_eq!(layout.cross_size(FlexDirection::Row), Dimension::Points(2.0)); + assert_eq!(layout.cross_size(FlexDirection::Column), Dimension::Points(1.0)); + } + + #[test] + fn flexbox_layout_min_cross_size() { + let layout = FlexboxLayout { min_size: Size::from_points(1.0, 2.0), ..Default::default() }; + assert_eq!(layout.min_cross_size(FlexDirection::Row), Dimension::Points(2.0)); + assert_eq!(layout.min_cross_size(FlexDirection::Column), Dimension::Points(1.0)); + } + + #[test] + fn flexbox_layout_max_cross_size() { + let layout = FlexboxLayout { max_size: Size::from_points(1.0, 2.0), ..Default::default() }; + assert_eq!(layout.max_cross_size(FlexDirection::Row), Dimension::Points(2.0)); + assert_eq!(layout.max_cross_size(FlexDirection::Column), Dimension::Points(1.0)); + } + + #[test] + fn flexbox_layout_cross_margin_start() { + let layout = FlexboxLayout { margin: Rect::top_from_points(2.0, 1.0), ..Default::default() }; + assert_eq!(layout.cross_margin_start(FlexDirection::Row), Dimension::Points(1.0)); + assert_eq!(layout.cross_margin_start(FlexDirection::Column), Dimension::Points(2.0)); + } + + #[test] + fn flexbox_layout_cross_margin_end() { + let layout = FlexboxLayout { margin: Rect::bot_from_points(2.0, 1.0), ..Default::default() }; + assert_eq!(layout.cross_margin_end(FlexDirection::Row), Dimension::Points(1.0)); + assert_eq!(layout.cross_margin_end(FlexDirection::Column), Dimension::Points(2.0)); + } + + #[test] + fn flexbox_layout_align_self_auto() { + let parent = layout_from_align_items(AlignItems::FlexStart); + let layout = layout_from_align_self(AlignSelf::Auto); + assert_eq!(layout.align_self(&parent), AlignSelf::FlexStart); + + let parent = layout_from_align_items(AlignItems::FlexEnd); + let layout = layout_from_align_self(AlignSelf::Auto); + assert_eq!(layout.align_self(&parent), AlignSelf::FlexEnd); + + let parent = layout_from_align_items(AlignItems::Center); + let layout = layout_from_align_self(AlignSelf::Auto); + assert_eq!(layout.align_self(&parent), AlignSelf::Center); + + let parent = layout_from_align_items(AlignItems::Baseline); + let layout = layout_from_align_self(AlignSelf::Auto); + assert_eq!(layout.align_self(&parent), AlignSelf::Baseline); + + let parent = layout_from_align_items(AlignItems::Stretch); + let layout = layout_from_align_self(AlignSelf::Auto); + assert_eq!(layout.align_self(&parent), AlignSelf::Stretch); + } + + #[test] + fn align_self() { + let parent = layout_from_align_items(AlignItems::FlexEnd); + let layout = layout_from_align_self(AlignSelf::FlexStart); + assert_eq!(layout.align_self(&parent), AlignSelf::FlexStart); + + let parent = layout_from_align_items(AlignItems::FlexStart); + let layout = layout_from_align_self(AlignSelf::FlexEnd); + assert_eq!(layout.align_self(&parent), AlignSelf::FlexEnd); + + let parent = layout_from_align_items(AlignItems::FlexStart); + let layout = layout_from_align_self(AlignSelf::Center); + assert_eq!(layout.align_self(&parent), AlignSelf::Center); + + let parent = layout_from_align_items(AlignItems::FlexStart); + let layout = layout_from_align_self(AlignSelf::Baseline); + assert_eq!(layout.align_self(&parent), AlignSelf::Baseline); + + let parent = layout_from_align_items(AlignItems::FlexStart); + let layout = layout_from_align_self(AlignSelf::Stretch); + assert_eq!(layout.align_self(&parent), AlignSelf::Stretch); + } } - } } diff --git a/src/sys.rs b/src/sys.rs new file mode 100644 index 000000000..dd4a3426a --- /dev/null +++ b/src/sys.rs @@ -0,0 +1,107 @@ +//! Allocator-flexible data types + +// When std is enabled, prefer those types +#[cfg(feature = "std")] +pub(crate) use self::std::*; + +// When alloc but not std is enabled, use those types +#[cfg(all(feature = "alloc", not(feature = "std")))] +pub(crate) use self::alloc::*; + +// When neither alloc or std is enabled, use a heapless fallback +#[cfg(all(not(feature = "alloc"), not(feature = "std")))] +pub(crate) use self::core::*; + +/// For when `std` is enabled +#[cfg(feature = "std")] +mod std { + /// An allocation-backend agnostic vector type + pub(crate) type Vec = std::vec::Vec; + /// A vector of child nodes + pub(crate) type ChildrenVec = std::vec::Vec; + + /// Creates a new vector with the capacity for the specified number of items before it must be resized + #[must_use] + pub(crate) fn new_vec_with_capacity(capacity: usize) -> Vec { + Vec::with_capacity(capacity) + } + + /// Rounds to the nearest whole number + #[must_use] + pub(crate) fn round(value: f32) -> f32 { + value.round() + } + + /// Computes the absolute value + #[must_use] + pub(crate) fn abs(value: f32) -> f32 { + value.abs() + } +} + +/// For when `alloc` but not `std` is enabled +#[cfg(all(feature = "alloc", not(feature = "std")))] +mod alloc { + extern crate alloc; + + /// An allocation-backend agnostic `Box` type + pub(crate) type Box = alloc::boxed::Box; + /// An allocation-backend agnostic vector type + pub(crate) type Vec = alloc::vec::Vec; + /// A vector of child nodes + pub(crate) type ChildrenVec = alloc::vec::Vec; + + /// Creates a new vector with the capacity for the specified number of items before it must be resized + #[must_use] + pub(crate) fn new_vec_with_capacity(capacity: usize) -> Vec { + Vec::with_capacity(capacity) + } + + /// Rounds to the nearest whole number + #[must_use] + pub(crate) fn round(value: f32) -> f32 { + num_traits::float::FloatCore::round(value) + } + + /// Computes the absolute value + #[must_use] + pub(crate) fn abs(value: f32) -> f32 { + num_traits::float::FloatCore::abs(value) + } +} + +/// For when neither `alloc` nor `std` is enabled +#[cfg(all(not(feature = "alloc"), not(feature = "std")))] +mod core { + /// The maximum number of nodes in the tree + pub const MAX_NODE_COUNT: usize = 256; + /// The maximum number of children of any given node + pub const MAX_CHILD_COUNT: usize = 16; + + /// An allocation-backend agnostic vector type + pub(crate) type Vec = arrayvec::ArrayVec; + /// A vector of child nodes, whose length cannot exceed [`MAX_CHILD_COUNT`] + pub(crate) type ChildrenVec = arrayvec::ArrayVec; + + /// Creates a new map with the capacity for the specified number of items before it must be resized + /// + /// This vector cannot be resized. + #[must_use] + pub(crate) fn new_vec_with_capacity(_capacity: usize) -> arrayvec::ArrayVec { + arrayvec::ArrayVec::new() + } + + /// Rounds to the nearest whole number + #[inline] + #[must_use] + pub(crate) fn round(value: f32) -> f32 { + num_traits::float::FloatCore::round(value) + } + + /// Computes the absolute value + #[inline] + #[must_use] + pub(crate) fn abs(value: f32) -> f32 { + num_traits::float::FloatCore::abs(value) + } +} diff --git a/test_fixtures/absolute_layout_align_items_and_justify_content_center.html b/test_fixtures/absolute_layout_align_items_and_justify_content_center.html new file mode 100644 index 000000000..b93fb9f5b --- /dev/null +++ b/test_fixtures/absolute_layout_align_items_and_justify_content_center.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/absolute_layout_align_items_and_justify_content_center_and_bottom_position.html b/test_fixtures/absolute_layout_align_items_and_justify_content_center_and_bottom_position.html new file mode 100644 index 000000000..e295605f5 --- /dev/null +++ b/test_fixtures/absolute_layout_align_items_and_justify_content_center_and_bottom_position.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/absolute_layout_align_items_and_justify_content_center_and_left_position.html b/test_fixtures/absolute_layout_align_items_and_justify_content_center_and_left_position.html new file mode 100644 index 000000000..bad6a11ae --- /dev/null +++ b/test_fixtures/absolute_layout_align_items_and_justify_content_center_and_left_position.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/absolute_layout_align_items_and_justify_content_center_and_right_position.html b/test_fixtures/absolute_layout_align_items_and_justify_content_center_and_right_position.html new file mode 100644 index 000000000..ec52877ed --- /dev/null +++ b/test_fixtures/absolute_layout_align_items_and_justify_content_center_and_right_position.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/absolute_layout_align_items_and_justify_content_center_and_top_position.html b/test_fixtures/absolute_layout_align_items_and_justify_content_center_and_top_position.html new file mode 100644 index 000000000..85208b879 --- /dev/null +++ b/test_fixtures/absolute_layout_align_items_and_justify_content_center_and_top_position.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/absolute_layout_align_items_and_justify_content_flex_end.html b/test_fixtures/absolute_layout_align_items_and_justify_content_flex_end.html new file mode 100644 index 000000000..94574adbf --- /dev/null +++ b/test_fixtures/absolute_layout_align_items_and_justify_content_flex_end.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/absolute_layout_align_items_center.html b/test_fixtures/absolute_layout_align_items_center.html new file mode 100644 index 000000000..eac2bf66e --- /dev/null +++ b/test_fixtures/absolute_layout_align_items_center.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/absolute_layout_align_items_center_on_child_only.html b/test_fixtures/absolute_layout_align_items_center_on_child_only.html new file mode 100644 index 000000000..1693318bf --- /dev/null +++ b/test_fixtures/absolute_layout_align_items_center_on_child_only.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/absolute_layout_child_order.html b/test_fixtures/absolute_layout_child_order.html new file mode 100644 index 000000000..d0d735c82 --- /dev/null +++ b/test_fixtures/absolute_layout_child_order.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/absolute_layout_in_wrap_reverse_column_container.html b/test_fixtures/absolute_layout_in_wrap_reverse_column_container.html new file mode 100644 index 000000000..57678d2fd --- /dev/null +++ b/test_fixtures/absolute_layout_in_wrap_reverse_column_container.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/absolute_layout_in_wrap_reverse_column_container_flex_end.html b/test_fixtures/absolute_layout_in_wrap_reverse_column_container_flex_end.html new file mode 100644 index 000000000..aac24c8f7 --- /dev/null +++ b/test_fixtures/absolute_layout_in_wrap_reverse_column_container_flex_end.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/absolute_layout_in_wrap_reverse_row_container.html b/test_fixtures/absolute_layout_in_wrap_reverse_row_container.html new file mode 100644 index 000000000..94ec3b9e0 --- /dev/null +++ b/test_fixtures/absolute_layout_in_wrap_reverse_row_container.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/absolute_layout_in_wrap_reverse_row_container_flex_end.html b/test_fixtures/absolute_layout_in_wrap_reverse_row_container_flex_end.html new file mode 100644 index 000000000..8337400d9 --- /dev/null +++ b/test_fixtures/absolute_layout_in_wrap_reverse_row_container_flex_end.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/absolute_layout_justify_content_center.html b/test_fixtures/absolute_layout_justify_content_center.html new file mode 100644 index 000000000..7870779d7 --- /dev/null +++ b/test_fixtures/absolute_layout_justify_content_center.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/absolute_layout_no_size.html b/test_fixtures/absolute_layout_no_size.html new file mode 100644 index 000000000..3be0fc8e2 --- /dev/null +++ b/test_fixtures/absolute_layout_no_size.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/absolute_layout_percentage_bottom_based_on_parent_height.html b/test_fixtures/absolute_layout_percentage_bottom_based_on_parent_height.html new file mode 100644 index 000000000..b00b10636 --- /dev/null +++ b/test_fixtures/absolute_layout_percentage_bottom_based_on_parent_height.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/absolute_layout_start_top_end_bottom.html b/test_fixtures/absolute_layout_start_top_end_bottom.html new file mode 100644 index 000000000..79e1cd526 --- /dev/null +++ b/test_fixtures/absolute_layout_start_top_end_bottom.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/absolute_layout_width_height_end_bottom.html b/test_fixtures/absolute_layout_width_height_end_bottom.html new file mode 100644 index 000000000..7784dff9e --- /dev/null +++ b/test_fixtures/absolute_layout_width_height_end_bottom.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/absolute_layout_width_height_start_top.html b/test_fixtures/absolute_layout_width_height_start_top.html new file mode 100644 index 000000000..996dbdd07 --- /dev/null +++ b/test_fixtures/absolute_layout_width_height_start_top.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/absolute_layout_width_height_start_top_end_bottom.html b/test_fixtures/absolute_layout_width_height_start_top_end_bottom.html new file mode 100644 index 000000000..5853c1231 --- /dev/null +++ b/test_fixtures/absolute_layout_width_height_start_top_end_bottom.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/absolute_layout_within_border.html b/test_fixtures/absolute_layout_within_border.html new file mode 100644 index 000000000..f53e70716 --- /dev/null +++ b/test_fixtures/absolute_layout_within_border.html @@ -0,0 +1,20 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/align_baseline.html b/test_fixtures/align_baseline.html new file mode 100644 index 000000000..3308b8a5a --- /dev/null +++ b/test_fixtures/align_baseline.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/align_baseline_child_multiline.html b/test_fixtures/align_baseline_child_multiline.html new file mode 100644 index 000000000..b20c34077 --- /dev/null +++ b/test_fixtures/align_baseline_child_multiline.html @@ -0,0 +1,23 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/align_baseline_nested_child.html b/test_fixtures/align_baseline_nested_child.html new file mode 100644 index 000000000..33a7d8bad --- /dev/null +++ b/test_fixtures/align_baseline_nested_child.html @@ -0,0 +1,20 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/align_center_should_size_based_on_content.html b/test_fixtures/align_center_should_size_based_on_content.html new file mode 100644 index 000000000..da36201dc --- /dev/null +++ b/test_fixtures/align_center_should_size_based_on_content.html @@ -0,0 +1,21 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/align_flex_start_with_shrinking_children.html b/test_fixtures/align_flex_start_with_shrinking_children.html new file mode 100644 index 000000000..3588ea310 --- /dev/null +++ b/test_fixtures/align_flex_start_with_shrinking_children.html @@ -0,0 +1,21 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/align_flex_start_with_shrinking_children_with_stretch.html b/test_fixtures/align_flex_start_with_shrinking_children_with_stretch.html new file mode 100644 index 000000000..e7d34bec4 --- /dev/null +++ b/test_fixtures/align_flex_start_with_shrinking_children_with_stretch.html @@ -0,0 +1,21 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/align_flex_start_with_stretching_children.html b/test_fixtures/align_flex_start_with_stretching_children.html new file mode 100644 index 000000000..d6b8a05c7 --- /dev/null +++ b/test_fixtures/align_flex_start_with_stretching_children.html @@ -0,0 +1,21 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/align_items_center.html b/test_fixtures/align_items_center.html new file mode 100644 index 000000000..b1a95dfde --- /dev/null +++ b/test_fixtures/align_items_center.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/align_items_center_child_with_margin_bigger_than_parent.html b/test_fixtures/align_items_center_child_with_margin_bigger_than_parent.html new file mode 100644 index 000000000..c4df92a8b --- /dev/null +++ b/test_fixtures/align_items_center_child_with_margin_bigger_than_parent.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/align_items_center_child_without_margin_bigger_than_parent.html b/test_fixtures/align_items_center_child_without_margin_bigger_than_parent.html new file mode 100644 index 000000000..d938cff9d --- /dev/null +++ b/test_fixtures/align_items_center_child_without_margin_bigger_than_parent.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/align_items_center_with_child_margin.html b/test_fixtures/align_items_center_with_child_margin.html new file mode 100644 index 000000000..165ea9940 --- /dev/null +++ b/test_fixtures/align_items_center_with_child_margin.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/align_items_center_with_child_top.html b/test_fixtures/align_items_center_with_child_top.html new file mode 100644 index 000000000..03b049276 --- /dev/null +++ b/test_fixtures/align_items_center_with_child_top.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/align_items_flex_end.html b/test_fixtures/align_items_flex_end.html new file mode 100644 index 000000000..fd5405b5c --- /dev/null +++ b/test_fixtures/align_items_flex_end.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/align_items_flex_end_child_with_margin_bigger_than_parent.html b/test_fixtures/align_items_flex_end_child_with_margin_bigger_than_parent.html new file mode 100644 index 000000000..9fde8bbd3 --- /dev/null +++ b/test_fixtures/align_items_flex_end_child_with_margin_bigger_than_parent.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/align_items_flex_end_child_without_margin_bigger_than_parent.html b/test_fixtures/align_items_flex_end_child_without_margin_bigger_than_parent.html new file mode 100644 index 000000000..4a77ecadc --- /dev/null +++ b/test_fixtures/align_items_flex_end_child_without_margin_bigger_than_parent.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/align_items_flex_start.html b/test_fixtures/align_items_flex_start.html new file mode 100644 index 000000000..2b9075bad --- /dev/null +++ b/test_fixtures/align_items_flex_start.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/align_items_min_max.html b/test_fixtures/align_items_min_max.html new file mode 100644 index 000000000..d0b840b4c --- /dev/null +++ b/test_fixtures/align_items_min_max.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/align_items_stretch.html b/test_fixtures/align_items_stretch.html new file mode 100644 index 000000000..04b2c3e9f --- /dev/null +++ b/test_fixtures/align_items_stretch.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/align_self_baseline.html b/test_fixtures/align_self_baseline.html new file mode 100644 index 000000000..6b1df161c --- /dev/null +++ b/test_fixtures/align_self_baseline.html @@ -0,0 +1,20 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/align_self_center.html b/test_fixtures/align_self_center.html new file mode 100644 index 000000000..c3b62cc81 --- /dev/null +++ b/test_fixtures/align_self_center.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/align_self_flex_end.html b/test_fixtures/align_self_flex_end.html new file mode 100644 index 000000000..c0ec10027 --- /dev/null +++ b/test_fixtures/align_self_flex_end.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/align_self_flex_end_override_flex_start.html b/test_fixtures/align_self_flex_end_override_flex_start.html new file mode 100644 index 000000000..9b40eb318 --- /dev/null +++ b/test_fixtures/align_self_flex_end_override_flex_start.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/align_self_flex_start.html b/test_fixtures/align_self_flex_start.html new file mode 100644 index 000000000..4b33499a9 --- /dev/null +++ b/test_fixtures/align_self_flex_start.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/align_strech_should_size_based_on_parent.html b/test_fixtures/align_strech_should_size_based_on_parent.html new file mode 100644 index 000000000..7d0a4819b --- /dev/null +++ b/test_fixtures/align_strech_should_size_based_on_parent.html @@ -0,0 +1,21 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/border_center_child.html b/test_fixtures/border_center_child.html new file mode 100644 index 000000000..fd269d7c2 --- /dev/null +++ b/test_fixtures/border_center_child.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/border_flex_child.html b/test_fixtures/border_flex_child.html new file mode 100644 index 000000000..aee79db6f --- /dev/null +++ b/test_fixtures/border_flex_child.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/border_no_child.html b/test_fixtures/border_no_child.html new file mode 100644 index 000000000..23e481766 --- /dev/null +++ b/test_fixtures/border_no_child.html @@ -0,0 +1,16 @@ + + + + + + + Test description + + + + +
+
+ + + \ No newline at end of file diff --git a/test_fixtures/border_stretch_child.html b/test_fixtures/border_stretch_child.html new file mode 100644 index 000000000..b36434cd5 --- /dev/null +++ b/test_fixtures/border_stretch_child.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/child_min_max_width_flexing.html b/test_fixtures/child_min_max_width_flexing.html new file mode 100644 index 000000000..d7dea0591 --- /dev/null +++ b/test_fixtures/child_min_max_width_flexing.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/container_with_unsized_child.html b/test_fixtures/container_with_unsized_child.html new file mode 100644 index 000000000..f2a493586 --- /dev/null +++ b/test_fixtures/container_with_unsized_child.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/display_none.html b/test_fixtures/display_none.html new file mode 100644 index 000000000..9fc43aec5 --- /dev/null +++ b/test_fixtures/display_none.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/display_none_fixed_size.html b/test_fixtures/display_none_fixed_size.html new file mode 100644 index 000000000..a227378ba --- /dev/null +++ b/test_fixtures/display_none_fixed_size.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/display_none_with_child.html b/test_fixtures/display_none_with_child.html new file mode 100644 index 000000000..48e0d2950 --- /dev/null +++ b/test_fixtures/display_none_with_child.html @@ -0,0 +1,21 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/display_none_with_margin.html b/test_fixtures/display_none_with_margin.html new file mode 100644 index 000000000..699dd4f75 --- /dev/null +++ b/test_fixtures/display_none_with_margin.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/display_none_with_position.html b/test_fixtures/display_none_with_position.html new file mode 100644 index 000000000..540dcfd1e --- /dev/null +++ b/test_fixtures/display_none_with_position.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_basis_and_main_dimen_set_when_flexing.html b/test_fixtures/flex_basis_and_main_dimen_set_when_flexing.html new file mode 100644 index 000000000..54da94f54 --- /dev/null +++ b/test_fixtures/flex_basis_and_main_dimen_set_when_flexing.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_basis_flex_grow_column.html b/test_fixtures/flex_basis_flex_grow_column.html new file mode 100644 index 000000000..e9ba7daae --- /dev/null +++ b/test_fixtures/flex_basis_flex_grow_column.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_basis_flex_grow_row.html b/test_fixtures/flex_basis_flex_grow_row.html new file mode 100644 index 000000000..402be1961 --- /dev/null +++ b/test_fixtures/flex_basis_flex_grow_row.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_basis_flex_shrink_column.html b/test_fixtures/flex_basis_flex_shrink_column.html new file mode 100644 index 000000000..d93e3a877 --- /dev/null +++ b/test_fixtures/flex_basis_flex_shrink_column.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_basis_flex_shrink_row.html b/test_fixtures/flex_basis_flex_shrink_row.html new file mode 100644 index 000000000..12b2efc0a --- /dev/null +++ b/test_fixtures/flex_basis_flex_shrink_row.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_basis_larger_than_content_column.html b/test_fixtures/flex_basis_larger_than_content_column.html new file mode 100644 index 000000000..a1d236209 --- /dev/null +++ b/test_fixtures/flex_basis_larger_than_content_column.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_basis_larger_than_content_row.html b/test_fixtures/flex_basis_larger_than_content_row.html new file mode 100644 index 000000000..056bc11f5 --- /dev/null +++ b/test_fixtures/flex_basis_larger_than_content_row.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_basis_overrides_main_size.html b/test_fixtures/flex_basis_overrides_main_size.html new file mode 100644 index 000000000..3cfe2cb80 --- /dev/null +++ b/test_fixtures/flex_basis_overrides_main_size.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_basis_slightly_smaller_then_content_with_flex_grow_large_size.html b/test_fixtures/flex_basis_slightly_smaller_then_content_with_flex_grow_large_size.html new file mode 100644 index 000000000..087d3f897 --- /dev/null +++ b/test_fixtures/flex_basis_slightly_smaller_then_content_with_flex_grow_large_size.html @@ -0,0 +1,22 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_basis_smaller_than_content_column.html b/test_fixtures/flex_basis_smaller_than_content_column.html new file mode 100644 index 000000000..d8d3501ed --- /dev/null +++ b/test_fixtures/flex_basis_smaller_than_content_column.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_basis_smaller_than_content_row.html b/test_fixtures/flex_basis_smaller_than_content_row.html new file mode 100644 index 000000000..26a6ae0ad --- /dev/null +++ b/test_fixtures/flex_basis_smaller_than_content_row.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_basis_smaller_than_main_dimen_column.html b/test_fixtures/flex_basis_smaller_than_main_dimen_column.html new file mode 100644 index 000000000..e42461e3d --- /dev/null +++ b/test_fixtures/flex_basis_smaller_than_main_dimen_column.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_basis_smaller_than_main_dimen_row.html b/test_fixtures/flex_basis_smaller_than_main_dimen_row.html new file mode 100644 index 000000000..316016ffe --- /dev/null +++ b/test_fixtures/flex_basis_smaller_than_main_dimen_row.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_basis_smaller_then_content_with_flex_grow_large_size.html b/test_fixtures/flex_basis_smaller_then_content_with_flex_grow_large_size.html new file mode 100644 index 000000000..967de1fc8 --- /dev/null +++ b/test_fixtures/flex_basis_smaller_then_content_with_flex_grow_large_size.html @@ -0,0 +1,22 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_basis_smaller_then_content_with_flex_grow_small_size.html b/test_fixtures/flex_basis_smaller_then_content_with_flex_grow_small_size.html new file mode 100644 index 000000000..ef2764878 --- /dev/null +++ b/test_fixtures/flex_basis_smaller_then_content_with_flex_grow_small_size.html @@ -0,0 +1,22 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_basis_smaller_then_content_with_flex_grow_unconstraint_size.html b/test_fixtures/flex_basis_smaller_then_content_with_flex_grow_unconstraint_size.html new file mode 100644 index 000000000..7239bee0e --- /dev/null +++ b/test_fixtures/flex_basis_smaller_then_content_with_flex_grow_unconstraint_size.html @@ -0,0 +1,22 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_basis_smaller_then_content_with_flex_grow_very_large_size.html b/test_fixtures/flex_basis_smaller_then_content_with_flex_grow_very_large_size.html new file mode 100644 index 000000000..aa6601170 --- /dev/null +++ b/test_fixtures/flex_basis_smaller_then_content_with_flex_grow_very_large_size.html @@ -0,0 +1,22 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_basis_unconstraint_column.html b/test_fixtures/flex_basis_unconstraint_column.html new file mode 100644 index 000000000..bd640d255 --- /dev/null +++ b/test_fixtures/flex_basis_unconstraint_column.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_basis_unconstraint_row.html b/test_fixtures/flex_basis_unconstraint_row.html new file mode 100644 index 000000000..611f4b2fd --- /dev/null +++ b/test_fixtures/flex_basis_unconstraint_row.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_direction_column.html b/test_fixtures/flex_direction_column.html new file mode 100644 index 000000000..08ecce88d --- /dev/null +++ b/test_fixtures/flex_direction_column.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_direction_column_no_height.html b/test_fixtures/flex_direction_column_no_height.html new file mode 100644 index 000000000..c66bcdeab --- /dev/null +++ b/test_fixtures/flex_direction_column_no_height.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_direction_column_reverse.html b/test_fixtures/flex_direction_column_reverse.html new file mode 100644 index 000000000..e632d5e45 --- /dev/null +++ b/test_fixtures/flex_direction_column_reverse.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_direction_row.html b/test_fixtures/flex_direction_row.html new file mode 100644 index 000000000..dd146bc6b --- /dev/null +++ b/test_fixtures/flex_direction_row.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_direction_row_no_width.html b/test_fixtures/flex_direction_row_no_width.html new file mode 100644 index 000000000..5fd1ec9bd --- /dev/null +++ b/test_fixtures/flex_direction_row_no_width.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_direction_row_reverse.html b/test_fixtures/flex_direction_row_reverse.html new file mode 100644 index 000000000..65736b7c9 --- /dev/null +++ b/test_fixtures/flex_direction_row_reverse.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_grow_child.html b/test_fixtures/flex_grow_child.html new file mode 100644 index 000000000..b13992e67 --- /dev/null +++ b/test_fixtures/flex_grow_child.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_grow_flex_basis_percent_min_max.html b/test_fixtures/flex_grow_flex_basis_percent_min_max.html new file mode 100644 index 000000000..969a78823 --- /dev/null +++ b/test_fixtures/flex_grow_flex_basis_percent_min_max.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_grow_height_maximized.html b/test_fixtures/flex_grow_height_maximized.html new file mode 100644 index 000000000..fd9252743 --- /dev/null +++ b/test_fixtures/flex_grow_height_maximized.html @@ -0,0 +1,20 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_grow_in_at_most_container.html b/test_fixtures/flex_grow_in_at_most_container.html new file mode 100644 index 000000000..b89a29651 --- /dev/null +++ b/test_fixtures/flex_grow_in_at_most_container.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_grow_less_than_factor_one.html b/test_fixtures/flex_grow_less_than_factor_one.html new file mode 100644 index 000000000..4c14871d1 --- /dev/null +++ b/test_fixtures/flex_grow_less_than_factor_one.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_grow_root_minimized.html b/test_fixtures/flex_grow_root_minimized.html new file mode 100644 index 000000000..eb98b3dc8 --- /dev/null +++ b/test_fixtures/flex_grow_root_minimized.html @@ -0,0 +1,20 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_grow_shrink_at_most.html b/test_fixtures/flex_grow_shrink_at_most.html new file mode 100644 index 000000000..da1ae824f --- /dev/null +++ b/test_fixtures/flex_grow_shrink_at_most.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_grow_to_min.html b/test_fixtures/flex_grow_to_min.html new file mode 100644 index 000000000..97c493ab1 --- /dev/null +++ b/test_fixtures/flex_grow_to_min.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_grow_within_constrained_max_column.html b/test_fixtures/flex_grow_within_constrained_max_column.html new file mode 100644 index 000000000..33aa9c262 --- /dev/null +++ b/test_fixtures/flex_grow_within_constrained_max_column.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_grow_within_constrained_max_row.html b/test_fixtures/flex_grow_within_constrained_max_row.html new file mode 100644 index 000000000..30893f7e5 --- /dev/null +++ b/test_fixtures/flex_grow_within_constrained_max_row.html @@ -0,0 +1,20 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_grow_within_constrained_max_width.html b/test_fixtures/flex_grow_within_constrained_max_width.html new file mode 100644 index 000000000..d18613bcc --- /dev/null +++ b/test_fixtures/flex_grow_within_constrained_max_width.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_grow_within_constrained_min_column.html b/test_fixtures/flex_grow_within_constrained_min_column.html new file mode 100644 index 000000000..4eb4f6372 --- /dev/null +++ b/test_fixtures/flex_grow_within_constrained_min_column.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_grow_within_constrained_min_max_column.html b/test_fixtures/flex_grow_within_constrained_min_max_column.html new file mode 100644 index 000000000..51c19d853 --- /dev/null +++ b/test_fixtures/flex_grow_within_constrained_min_max_column.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_grow_within_constrained_min_row.html b/test_fixtures/flex_grow_within_constrained_min_row.html new file mode 100644 index 000000000..e8807a264 --- /dev/null +++ b/test_fixtures/flex_grow_within_constrained_min_row.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_grow_within_max_width.html b/test_fixtures/flex_grow_within_max_width.html new file mode 100644 index 000000000..7978606b1 --- /dev/null +++ b/test_fixtures/flex_grow_within_max_width.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_root_ignored.html b/test_fixtures/flex_root_ignored.html new file mode 100644 index 000000000..369c40679 --- /dev/null +++ b/test_fixtures/flex_root_ignored.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_shrink_by_outer_margin_with_max_size.html b/test_fixtures/flex_shrink_by_outer_margin_with_max_size.html new file mode 100644 index 000000000..825b1828c --- /dev/null +++ b/test_fixtures/flex_shrink_by_outer_margin_with_max_size.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_shrink_flex_grow_child_flex_shrink_other_child.html b/test_fixtures/flex_shrink_flex_grow_child_flex_shrink_other_child.html new file mode 100644 index 000000000..c90974f09 --- /dev/null +++ b/test_fixtures/flex_shrink_flex_grow_child_flex_shrink_other_child.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_shrink_flex_grow_row.html b/test_fixtures/flex_shrink_flex_grow_row.html new file mode 100644 index 000000000..1a9efe4db --- /dev/null +++ b/test_fixtures/flex_shrink_flex_grow_row.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_shrink_to_zero.html b/test_fixtures/flex_shrink_to_zero.html new file mode 100644 index 000000000..e5ca1c683 --- /dev/null +++ b/test_fixtures/flex_shrink_to_zero.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_wrap_align_stretch_fits_one_row.html b/test_fixtures/flex_wrap_align_stretch_fits_one_row.html new file mode 100644 index 000000000..3e2794637 --- /dev/null +++ b/test_fixtures/flex_wrap_align_stretch_fits_one_row.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_wrap_children_with_min_main_overriding_flex_basis.html b/test_fixtures/flex_wrap_children_with_min_main_overriding_flex_basis.html new file mode 100644 index 000000000..3f376a6b3 --- /dev/null +++ b/test_fixtures/flex_wrap_children_with_min_main_overriding_flex_basis.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/flex_wrap_wrap_to_child_height.html b/test_fixtures/flex_wrap_wrap_to_child_height.html new file mode 100644 index 000000000..308262e13 --- /dev/null +++ b/test_fixtures/flex_wrap_wrap_to_child_height.html @@ -0,0 +1,22 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/justify_content_column_center.html b/test_fixtures/justify_content_column_center.html new file mode 100644 index 000000000..7e8d697e9 --- /dev/null +++ b/test_fixtures/justify_content_column_center.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/justify_content_column_flex_end.html b/test_fixtures/justify_content_column_flex_end.html new file mode 100644 index 000000000..a428226e4 --- /dev/null +++ b/test_fixtures/justify_content_column_flex_end.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/justify_content_column_flex_start.html b/test_fixtures/justify_content_column_flex_start.html new file mode 100644 index 000000000..f4530b7d4 --- /dev/null +++ b/test_fixtures/justify_content_column_flex_start.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/justify_content_column_min_height_and_margin_bottom.html b/test_fixtures/justify_content_column_min_height_and_margin_bottom.html new file mode 100644 index 000000000..4eda0a929 --- /dev/null +++ b/test_fixtures/justify_content_column_min_height_and_margin_bottom.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/justify_content_column_min_height_and_margin_top.html b/test_fixtures/justify_content_column_min_height_and_margin_top.html new file mode 100644 index 000000000..c9fc1e71d --- /dev/null +++ b/test_fixtures/justify_content_column_min_height_and_margin_top.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/justify_content_column_space_around.html b/test_fixtures/justify_content_column_space_around.html new file mode 100644 index 000000000..c04cb799f --- /dev/null +++ b/test_fixtures/justify_content_column_space_around.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/justify_content_column_space_between.html b/test_fixtures/justify_content_column_space_between.html new file mode 100644 index 000000000..8249706ca --- /dev/null +++ b/test_fixtures/justify_content_column_space_between.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/justify_content_column_space_evenly.html b/test_fixtures/justify_content_column_space_evenly.html new file mode 100644 index 000000000..bf7b8896f --- /dev/null +++ b/test_fixtures/justify_content_column_space_evenly.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/justify_content_min_max.html b/test_fixtures/justify_content_min_max.html new file mode 100644 index 000000000..f51dddf0e --- /dev/null +++ b/test_fixtures/justify_content_min_max.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/justify_content_min_width_with_padding_child_width_greater_than_parent.html b/test_fixtures/justify_content_min_width_with_padding_child_width_greater_than_parent.html new file mode 100644 index 000000000..628e1a4a3 --- /dev/null +++ b/test_fixtures/justify_content_min_width_with_padding_child_width_greater_than_parent.html @@ -0,0 +1,21 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
> + + + \ No newline at end of file diff --git a/test_fixtures/justify_content_min_width_with_padding_child_width_lower_than_parent.html b/test_fixtures/justify_content_min_width_with_padding_child_width_lower_than_parent.html new file mode 100644 index 000000000..4a3c5f024 --- /dev/null +++ b/test_fixtures/justify_content_min_width_with_padding_child_width_lower_than_parent.html @@ -0,0 +1,21 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/justify_content_overflow_min_max.html b/test_fixtures/justify_content_overflow_min_max.html new file mode 100644 index 000000000..3300d7082 --- /dev/null +++ b/test_fixtures/justify_content_overflow_min_max.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/justify_content_row_center.html b/test_fixtures/justify_content_row_center.html new file mode 100644 index 000000000..a592b3f59 --- /dev/null +++ b/test_fixtures/justify_content_row_center.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/justify_content_row_flex_end.html b/test_fixtures/justify_content_row_flex_end.html new file mode 100644 index 000000000..9f69ae258 --- /dev/null +++ b/test_fixtures/justify_content_row_flex_end.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/justify_content_row_flex_start.html b/test_fixtures/justify_content_row_flex_start.html new file mode 100644 index 000000000..9a27329dd --- /dev/null +++ b/test_fixtures/justify_content_row_flex_start.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/justify_content_row_max_width_and_margin.html b/test_fixtures/justify_content_row_max_width_and_margin.html new file mode 100644 index 000000000..2dff79893 --- /dev/null +++ b/test_fixtures/justify_content_row_max_width_and_margin.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/justify_content_row_min_width_and_margin.html b/test_fixtures/justify_content_row_min_width_and_margin.html new file mode 100644 index 000000000..aba377f96 --- /dev/null +++ b/test_fixtures/justify_content_row_min_width_and_margin.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/justify_content_row_space_around.html b/test_fixtures/justify_content_row_space_around.html new file mode 100644 index 000000000..96c2a6ff0 --- /dev/null +++ b/test_fixtures/justify_content_row_space_around.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/justify_content_row_space_between.html b/test_fixtures/justify_content_row_space_between.html new file mode 100644 index 000000000..020c546d9 --- /dev/null +++ b/test_fixtures/justify_content_row_space_between.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/justify_content_row_space_evenly.html b/test_fixtures/justify_content_row_space_evenly.html new file mode 100644 index 000000000..0b1d53b52 --- /dev/null +++ b/test_fixtures/justify_content_row_space_evenly.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/margin_and_flex_column.html b/test_fixtures/margin_and_flex_column.html new file mode 100644 index 000000000..f263aa408 --- /dev/null +++ b/test_fixtures/margin_and_flex_column.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/margin_and_flex_row.html b/test_fixtures/margin_and_flex_row.html new file mode 100644 index 000000000..2418ce24c --- /dev/null +++ b/test_fixtures/margin_and_flex_row.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/margin_and_stretch_column.html b/test_fixtures/margin_and_stretch_column.html new file mode 100644 index 000000000..cc5658576 --- /dev/null +++ b/test_fixtures/margin_and_stretch_column.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/margin_and_stretch_row.html b/test_fixtures/margin_and_stretch_row.html new file mode 100644 index 000000000..4542d3873 --- /dev/null +++ b/test_fixtures/margin_and_stretch_row.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/margin_auto_bottom.html b/test_fixtures/margin_auto_bottom.html new file mode 100644 index 000000000..a05e91d31 --- /dev/null +++ b/test_fixtures/margin_auto_bottom.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/margin_auto_bottom_and_top.html b/test_fixtures/margin_auto_bottom_and_top.html new file mode 100644 index 000000000..80795887b --- /dev/null +++ b/test_fixtures/margin_auto_bottom_and_top.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/margin_auto_bottom_and_top_justify_center.html b/test_fixtures/margin_auto_bottom_and_top_justify_center.html new file mode 100644 index 000000000..c1254907e --- /dev/null +++ b/test_fixtures/margin_auto_bottom_and_top_justify_center.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/margin_auto_left.html b/test_fixtures/margin_auto_left.html new file mode 100644 index 000000000..7224c254e --- /dev/null +++ b/test_fixtures/margin_auto_left.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/margin_auto_left_and_right.html b/test_fixtures/margin_auto_left_and_right.html new file mode 100644 index 000000000..36c70dc02 --- /dev/null +++ b/test_fixtures/margin_auto_left_and_right.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/margin_auto_left_and_right_column.html b/test_fixtures/margin_auto_left_and_right_column.html new file mode 100644 index 000000000..d575c7dcb --- /dev/null +++ b/test_fixtures/margin_auto_left_and_right_column.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/margin_auto_left_and_right_column_and_center.html b/test_fixtures/margin_auto_left_and_right_column_and_center.html new file mode 100644 index 000000000..bf0b34d68 --- /dev/null +++ b/test_fixtures/margin_auto_left_and_right_column_and_center.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/margin_auto_left_and_right_strech.html b/test_fixtures/margin_auto_left_and_right_strech.html new file mode 100644 index 000000000..229b448b1 --- /dev/null +++ b/test_fixtures/margin_auto_left_and_right_strech.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/margin_auto_left_child_bigger_than_parent.html b/test_fixtures/margin_auto_left_child_bigger_than_parent.html new file mode 100644 index 000000000..731f28abc --- /dev/null +++ b/test_fixtures/margin_auto_left_child_bigger_than_parent.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/margin_auto_left_fix_right_child_bigger_than_parent.html b/test_fixtures/margin_auto_left_fix_right_child_bigger_than_parent.html new file mode 100644 index 000000000..a604fec1c --- /dev/null +++ b/test_fixtures/margin_auto_left_fix_right_child_bigger_than_parent.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/margin_auto_left_right_child_bigger_than_parent.html b/test_fixtures/margin_auto_left_right_child_bigger_than_parent.html new file mode 100644 index 000000000..9945a69f5 --- /dev/null +++ b/test_fixtures/margin_auto_left_right_child_bigger_than_parent.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/margin_auto_left_stretching_child.html b/test_fixtures/margin_auto_left_stretching_child.html new file mode 100644 index 000000000..7a7aa2018 --- /dev/null +++ b/test_fixtures/margin_auto_left_stretching_child.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/margin_auto_mutiple_children_column.html b/test_fixtures/margin_auto_mutiple_children_column.html new file mode 100644 index 000000000..a75288c52 --- /dev/null +++ b/test_fixtures/margin_auto_mutiple_children_column.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/margin_auto_mutiple_children_row.html b/test_fixtures/margin_auto_mutiple_children_row.html new file mode 100644 index 000000000..05be0c785 --- /dev/null +++ b/test_fixtures/margin_auto_mutiple_children_row.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/margin_auto_right.html b/test_fixtures/margin_auto_right.html new file mode 100644 index 000000000..c392be1a0 --- /dev/null +++ b/test_fixtures/margin_auto_right.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/margin_auto_top.html b/test_fixtures/margin_auto_top.html new file mode 100644 index 000000000..35dcb1692 --- /dev/null +++ b/test_fixtures/margin_auto_top.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/margin_auto_top_and_bottom_strech.html b/test_fixtures/margin_auto_top_and_bottom_strech.html new file mode 100644 index 000000000..ca117b380 --- /dev/null +++ b/test_fixtures/margin_auto_top_and_bottom_strech.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/margin_auto_top_stretching_child.html b/test_fixtures/margin_auto_top_stretching_child.html new file mode 100644 index 000000000..f99cda48d --- /dev/null +++ b/test_fixtures/margin_auto_top_stretching_child.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/margin_bottom.html b/test_fixtures/margin_bottom.html new file mode 100644 index 000000000..dd5b6a4b6 --- /dev/null +++ b/test_fixtures/margin_bottom.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/margin_fix_left_auto_right_child_bigger_than_parent.html b/test_fixtures/margin_fix_left_auto_right_child_bigger_than_parent.html new file mode 100644 index 000000000..418b21b7f --- /dev/null +++ b/test_fixtures/margin_fix_left_auto_right_child_bigger_than_parent.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/margin_left.html b/test_fixtures/margin_left.html new file mode 100644 index 000000000..1dbf09cd0 --- /dev/null +++ b/test_fixtures/margin_left.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/margin_right.html b/test_fixtures/margin_right.html new file mode 100644 index 000000000..63d71b9d4 --- /dev/null +++ b/test_fixtures/margin_right.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/margin_should_not_be_part_of_max_height.html b/test_fixtures/margin_should_not_be_part_of_max_height.html new file mode 100644 index 000000000..382d789c3 --- /dev/null +++ b/test_fixtures/margin_should_not_be_part_of_max_height.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/margin_should_not_be_part_of_max_width.html b/test_fixtures/margin_should_not_be_part_of_max_width.html new file mode 100644 index 000000000..015742ea8 --- /dev/null +++ b/test_fixtures/margin_should_not_be_part_of_max_width.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/margin_top.html b/test_fixtures/margin_top.html new file mode 100644 index 000000000..f0c3780dc --- /dev/null +++ b/test_fixtures/margin_top.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/margin_with_sibling_column.html b/test_fixtures/margin_with_sibling_column.html new file mode 100644 index 000000000..a04aaeaae --- /dev/null +++ b/test_fixtures/margin_with_sibling_column.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/margin_with_sibling_row.html b/test_fixtures/margin_with_sibling_row.html new file mode 100644 index 000000000..ca55d518f --- /dev/null +++ b/test_fixtures/margin_with_sibling_row.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/max_height.html b/test_fixtures/max_height.html new file mode 100644 index 000000000..3a2052c41 --- /dev/null +++ b/test_fixtures/max_height.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/max_height_overrides_height.html b/test_fixtures/max_height_overrides_height.html new file mode 100644 index 000000000..b4fc03391 --- /dev/null +++ b/test_fixtures/max_height_overrides_height.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/max_height_overrides_height_on_root.html b/test_fixtures/max_height_overrides_height_on_root.html new file mode 100644 index 000000000..dd41f7a54 --- /dev/null +++ b/test_fixtures/max_height_overrides_height_on_root.html @@ -0,0 +1,16 @@ + + + + + + + Test description + + + + +
+
+ + + \ No newline at end of file diff --git a/test_fixtures/max_width.html b/test_fixtures/max_width.html new file mode 100644 index 000000000..b6d9db15d --- /dev/null +++ b/test_fixtures/max_width.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/max_width_overrides_width.html b/test_fixtures/max_width_overrides_width.html new file mode 100644 index 000000000..c84960c4c --- /dev/null +++ b/test_fixtures/max_width_overrides_width.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/max_width_overrides_width_on_root.html b/test_fixtures/max_width_overrides_width_on_root.html new file mode 100644 index 000000000..7a7d90a9b --- /dev/null +++ b/test_fixtures/max_width_overrides_width_on_root.html @@ -0,0 +1,16 @@ + + + + + + + Test description + + + + +
+
+ + + \ No newline at end of file diff --git a/test_fixtures/min_height.html b/test_fixtures/min_height.html new file mode 100644 index 000000000..095e17a79 --- /dev/null +++ b/test_fixtures/min_height.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/min_height_overrides_height.html b/test_fixtures/min_height_overrides_height.html new file mode 100644 index 000000000..ed936504b --- /dev/null +++ b/test_fixtures/min_height_overrides_height.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/min_height_overrides_height_on_root.html b/test_fixtures/min_height_overrides_height_on_root.html new file mode 100644 index 000000000..2f3d431b0 --- /dev/null +++ b/test_fixtures/min_height_overrides_height_on_root.html @@ -0,0 +1,16 @@ + + + + + + + Test description + + + + +
+
+ + + \ No newline at end of file diff --git a/test_fixtures/min_max_percent_no_width_height.html b/test_fixtures/min_max_percent_no_width_height.html new file mode 100644 index 000000000..fc49401b8 --- /dev/null +++ b/test_fixtures/min_max_percent_no_width_height.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/min_width.html b/test_fixtures/min_width.html new file mode 100644 index 000000000..b9b21d905 --- /dev/null +++ b/test_fixtures/min_width.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/min_width_overrides_width.html b/test_fixtures/min_width_overrides_width.html new file mode 100644 index 000000000..1d05c2527 --- /dev/null +++ b/test_fixtures/min_width_overrides_width.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/min_width_overrides_width_on_root.html b/test_fixtures/min_width_overrides_width_on_root.html new file mode 100644 index 000000000..d0bf7c2b5 --- /dev/null +++ b/test_fixtures/min_width_overrides_width_on_root.html @@ -0,0 +1,16 @@ + + + + + + + Test description + + + + +
+
+ + + \ No newline at end of file diff --git a/test_fixtures/nested_overflowing_child.html b/test_fixtures/nested_overflowing_child.html new file mode 100644 index 000000000..2400fe479 --- /dev/null +++ b/test_fixtures/nested_overflowing_child.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/nested_overflowing_child_in_constraint_parent.html b/test_fixtures/nested_overflowing_child_in_constraint_parent.html new file mode 100644 index 000000000..723aa1a7a --- /dev/null +++ b/test_fixtures/nested_overflowing_child_in_constraint_parent.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/overflow_cross_axis.html b/test_fixtures/overflow_cross_axis.html new file mode 100644 index 000000000..1f706337a --- /dev/null +++ b/test_fixtures/overflow_cross_axis.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/overflow_main_axis.html b/test_fixtures/overflow_main_axis.html new file mode 100644 index 000000000..a800dd679 --- /dev/null +++ b/test_fixtures/overflow_main_axis.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/padding_align_end_child.html b/test_fixtures/padding_align_end_child.html new file mode 100644 index 000000000..31b88733c --- /dev/null +++ b/test_fixtures/padding_align_end_child.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/padding_center_child.html b/test_fixtures/padding_center_child.html new file mode 100644 index 000000000..547f7334b --- /dev/null +++ b/test_fixtures/padding_center_child.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/padding_flex_child.html b/test_fixtures/padding_flex_child.html new file mode 100644 index 000000000..dfcf1b3b4 --- /dev/null +++ b/test_fixtures/padding_flex_child.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/padding_no_child.html b/test_fixtures/padding_no_child.html new file mode 100644 index 000000000..ed6f22031 --- /dev/null +++ b/test_fixtures/padding_no_child.html @@ -0,0 +1,16 @@ + + + + + + + Test description + + + + +
+
+ + + \ No newline at end of file diff --git a/test_fixtures/padding_stretch_child.html b/test_fixtures/padding_stretch_child.html new file mode 100644 index 000000000..d50d05ef5 --- /dev/null +++ b/test_fixtures/padding_stretch_child.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/parent_wrap_child_size_overflowing_parent.html b/test_fixtures/parent_wrap_child_size_overflowing_parent.html new file mode 100644 index 000000000..03f11e0fd --- /dev/null +++ b/test_fixtures/parent_wrap_child_size_overflowing_parent.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/percent_absolute_position.html b/test_fixtures/percent_absolute_position.html new file mode 100644 index 000000000..ec033bdc0 --- /dev/null +++ b/test_fixtures/percent_absolute_position.html @@ -0,0 +1,20 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/percent_within_flex_grow.html b/test_fixtures/percent_within_flex_grow.html new file mode 100644 index 000000000..be0372bae --- /dev/null +++ b/test_fixtures/percent_within_flex_grow.html @@ -0,0 +1,21 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/percentage_absolute_position.html b/test_fixtures/percentage_absolute_position.html new file mode 100644 index 000000000..48281261c --- /dev/null +++ b/test_fixtures/percentage_absolute_position.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/percentage_container_in_wrapping_container.html b/test_fixtures/percentage_container_in_wrapping_container.html new file mode 100644 index 000000000..9b5d7c34b --- /dev/null +++ b/test_fixtures/percentage_container_in_wrapping_container.html @@ -0,0 +1,22 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/percentage_flex_basis.html b/test_fixtures/percentage_flex_basis.html new file mode 100644 index 000000000..711cadf56 --- /dev/null +++ b/test_fixtures/percentage_flex_basis.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/percentage_flex_basis_cross.html b/test_fixtures/percentage_flex_basis_cross.html new file mode 100644 index 000000000..0038a1b67 --- /dev/null +++ b/test_fixtures/percentage_flex_basis_cross.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/percentage_flex_basis_cross_max_height.html b/test_fixtures/percentage_flex_basis_cross_max_height.html new file mode 100644 index 000000000..6ecd627aa --- /dev/null +++ b/test_fixtures/percentage_flex_basis_cross_max_height.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/percentage_flex_basis_cross_max_width.html b/test_fixtures/percentage_flex_basis_cross_max_width.html new file mode 100644 index 000000000..b1d62851f --- /dev/null +++ b/test_fixtures/percentage_flex_basis_cross_max_width.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/percentage_flex_basis_cross_min_height.html b/test_fixtures/percentage_flex_basis_cross_min_height.html new file mode 100644 index 000000000..ddaa50e1c --- /dev/null +++ b/test_fixtures/percentage_flex_basis_cross_min_height.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/percentage_flex_basis_cross_min_width.html b/test_fixtures/percentage_flex_basis_cross_min_width.html new file mode 100644 index 000000000..717a8cb63 --- /dev/null +++ b/test_fixtures/percentage_flex_basis_cross_min_width.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/percentage_flex_basis_main_max_height.html b/test_fixtures/percentage_flex_basis_main_max_height.html new file mode 100644 index 000000000..44132d562 --- /dev/null +++ b/test_fixtures/percentage_flex_basis_main_max_height.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/percentage_flex_basis_main_max_width.html b/test_fixtures/percentage_flex_basis_main_max_width.html new file mode 100644 index 000000000..16f0cf815 --- /dev/null +++ b/test_fixtures/percentage_flex_basis_main_max_width.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/percentage_flex_basis_main_min_width.html b/test_fixtures/percentage_flex_basis_main_min_width.html new file mode 100644 index 000000000..43e4346ca --- /dev/null +++ b/test_fixtures/percentage_flex_basis_main_min_width.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/percentage_margin_should_calculate_based_only_on_width.html b/test_fixtures/percentage_margin_should_calculate_based_only_on_width.html new file mode 100644 index 000000000..9af2136f6 --- /dev/null +++ b/test_fixtures/percentage_margin_should_calculate_based_only_on_width.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/percentage_multiple_nested_with_padding_margin_and_percentage_values.html b/test_fixtures/percentage_multiple_nested_with_padding_margin_and_percentage_values.html new file mode 100644 index 000000000..44fdbdda5 --- /dev/null +++ b/test_fixtures/percentage_multiple_nested_with_padding_margin_and_percentage_values.html @@ -0,0 +1,22 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/percentage_padding_should_calculate_based_only_on_width.html b/test_fixtures/percentage_padding_should_calculate_based_only_on_width.html new file mode 100644 index 000000000..8cf0f8010 --- /dev/null +++ b/test_fixtures/percentage_padding_should_calculate_based_only_on_width.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/percentage_position_bottom_right.html b/test_fixtures/percentage_position_bottom_right.html new file mode 100644 index 000000000..5a065daf6 --- /dev/null +++ b/test_fixtures/percentage_position_bottom_right.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/percentage_position_left_top.html b/test_fixtures/percentage_position_left_top.html new file mode 100644 index 000000000..ca838f79e --- /dev/null +++ b/test_fixtures/percentage_position_left_top.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/percentage_size_based_on_parent_inner_size.html b/test_fixtures/percentage_size_based_on_parent_inner_size.html new file mode 100644 index 000000000..b9f47205b --- /dev/null +++ b/test_fixtures/percentage_size_based_on_parent_inner_size.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/percentage_size_of_flex_basis.html b/test_fixtures/percentage_size_of_flex_basis.html new file mode 100644 index 000000000..d0470fd55 --- /dev/null +++ b/test_fixtures/percentage_size_of_flex_basis.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/percentage_width_height.html b/test_fixtures/percentage_width_height.html new file mode 100644 index 000000000..1b1c7506b --- /dev/null +++ b/test_fixtures/percentage_width_height.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/percentage_width_height_undefined_parent_size.html b/test_fixtures/percentage_width_height_undefined_parent_size.html new file mode 100644 index 000000000..dae6f3a8d --- /dev/null +++ b/test_fixtures/percentage_width_height_undefined_parent_size.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/relative_position_should_not_nudge_siblings.html b/test_fixtures/relative_position_should_not_nudge_siblings.html new file mode 100644 index 000000000..26af1b0bc --- /dev/null +++ b/test_fixtures/relative_position_should_not_nudge_siblings.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/rounding_flex_basis_flex_grow_row_prime_number_width.html b/test_fixtures/rounding_flex_basis_flex_grow_row_prime_number_width.html new file mode 100644 index 000000000..99e149c94 --- /dev/null +++ b/test_fixtures/rounding_flex_basis_flex_grow_row_prime_number_width.html @@ -0,0 +1,21 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/rounding_flex_basis_flex_grow_row_width_of_100.html b/test_fixtures/rounding_flex_basis_flex_grow_row_width_of_100.html new file mode 100644 index 000000000..42f2e4dac --- /dev/null +++ b/test_fixtures/rounding_flex_basis_flex_grow_row_width_of_100.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/rounding_flex_basis_flex_shrink_row.html b/test_fixtures/rounding_flex_basis_flex_shrink_row.html new file mode 100644 index 000000000..c66b3c252 --- /dev/null +++ b/test_fixtures/rounding_flex_basis_flex_shrink_row.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/rounding_flex_basis_overrides_main_size.html b/test_fixtures/rounding_flex_basis_overrides_main_size.html new file mode 100644 index 000000000..f1967fcb8 --- /dev/null +++ b/test_fixtures/rounding_flex_basis_overrides_main_size.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/rounding_fractial_input_1.html b/test_fixtures/rounding_fractial_input_1.html new file mode 100644 index 000000000..b5288f857 --- /dev/null +++ b/test_fixtures/rounding_fractial_input_1.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/rounding_fractial_input_2.html b/test_fixtures/rounding_fractial_input_2.html new file mode 100644 index 000000000..20360cb94 --- /dev/null +++ b/test_fixtures/rounding_fractial_input_2.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/rounding_fractial_input_3.html b/test_fixtures/rounding_fractial_input_3.html new file mode 100644 index 000000000..b5288f857 --- /dev/null +++ b/test_fixtures/rounding_fractial_input_3.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/rounding_fractial_input_4.html b/test_fixtures/rounding_fractial_input_4.html new file mode 100644 index 000000000..b5288f857 --- /dev/null +++ b/test_fixtures/rounding_fractial_input_4.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/rounding_total_fractial.html b/test_fixtures/rounding_total_fractial.html new file mode 100644 index 000000000..a87b15fcf --- /dev/null +++ b/test_fixtures/rounding_total_fractial.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/rounding_total_fractial_nested.html b/test_fixtures/rounding_total_fractial_nested.html new file mode 100644 index 000000000..f5e9f6694 --- /dev/null +++ b/test_fixtures/rounding_total_fractial_nested.html @@ -0,0 +1,22 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/size_defined_by_child.html b/test_fixtures/size_defined_by_child.html new file mode 100644 index 000000000..baef13082 --- /dev/null +++ b/test_fixtures/size_defined_by_child.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/size_defined_by_child_with_border.html b/test_fixtures/size_defined_by_child_with_border.html new file mode 100644 index 000000000..397363650 --- /dev/null +++ b/test_fixtures/size_defined_by_child_with_border.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/size_defined_by_child_with_padding.html b/test_fixtures/size_defined_by_child_with_padding.html new file mode 100644 index 000000000..759e8182d --- /dev/null +++ b/test_fixtures/size_defined_by_child_with_padding.html @@ -0,0 +1,17 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/size_defined_by_grand_child.html b/test_fixtures/size_defined_by_grand_child.html new file mode 100644 index 000000000..1030077bf --- /dev/null +++ b/test_fixtures/size_defined_by_grand_child.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/width_smaller_then_content_with_flex_grow_large_size.html b/test_fixtures/width_smaller_then_content_with_flex_grow_large_size.html new file mode 100644 index 000000000..ac106bcf3 --- /dev/null +++ b/test_fixtures/width_smaller_then_content_with_flex_grow_large_size.html @@ -0,0 +1,22 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/width_smaller_then_content_with_flex_grow_small_size.html b/test_fixtures/width_smaller_then_content_with_flex_grow_small_size.html new file mode 100644 index 000000000..43a87cade --- /dev/null +++ b/test_fixtures/width_smaller_then_content_with_flex_grow_small_size.html @@ -0,0 +1,22 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/width_smaller_then_content_with_flex_grow_unconstraint_size.html b/test_fixtures/width_smaller_then_content_with_flex_grow_unconstraint_size.html new file mode 100644 index 000000000..7bd2b6dfa --- /dev/null +++ b/test_fixtures/width_smaller_then_content_with_flex_grow_unconstraint_size.html @@ -0,0 +1,22 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/width_smaller_then_content_with_flex_grow_very_large_size.html b/test_fixtures/width_smaller_then_content_with_flex_grow_very_large_size.html new file mode 100644 index 000000000..b025eca66 --- /dev/null +++ b/test_fixtures/width_smaller_then_content_with_flex_grow_very_large_size.html @@ -0,0 +1,22 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/wrap_column.html b/test_fixtures/wrap_column.html new file mode 100644 index 000000000..0934d06a4 --- /dev/null +++ b/test_fixtures/wrap_column.html @@ -0,0 +1,20 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/wrap_nodes_with_content_sizing_margin_cross.html b/test_fixtures/wrap_nodes_with_content_sizing_margin_cross.html new file mode 100644 index 000000000..256a5df4c --- /dev/null +++ b/test_fixtures/wrap_nodes_with_content_sizing_margin_cross.html @@ -0,0 +1,24 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/wrap_nodes_with_content_sizing_overflowing_margin.html b/test_fixtures/wrap_nodes_with_content_sizing_overflowing_margin.html new file mode 100644 index 000000000..863996613 --- /dev/null +++ b/test_fixtures/wrap_nodes_with_content_sizing_overflowing_margin.html @@ -0,0 +1,24 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/wrap_reverse_column.html b/test_fixtures/wrap_reverse_column.html new file mode 100644 index 000000000..2794228c7 --- /dev/null +++ b/test_fixtures/wrap_reverse_column.html @@ -0,0 +1,20 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/wrap_reverse_column_fixed_size.html b/test_fixtures/wrap_reverse_column_fixed_size.html new file mode 100644 index 000000000..fe85bfcb4 --- /dev/null +++ b/test_fixtures/wrap_reverse_column_fixed_size.html @@ -0,0 +1,21 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/wrap_reverse_row.html b/test_fixtures/wrap_reverse_row.html new file mode 100644 index 000000000..d61fbac7d --- /dev/null +++ b/test_fixtures/wrap_reverse_row.html @@ -0,0 +1,20 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/wrap_reverse_row_align_content_center.html b/test_fixtures/wrap_reverse_row_align_content_center.html new file mode 100644 index 000000000..5308f20ad --- /dev/null +++ b/test_fixtures/wrap_reverse_row_align_content_center.html @@ -0,0 +1,21 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/wrap_reverse_row_align_content_flex_start.html b/test_fixtures/wrap_reverse_row_align_content_flex_start.html new file mode 100644 index 000000000..65351a02e --- /dev/null +++ b/test_fixtures/wrap_reverse_row_align_content_flex_start.html @@ -0,0 +1,21 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/wrap_reverse_row_align_content_space_around.html b/test_fixtures/wrap_reverse_row_align_content_space_around.html new file mode 100644 index 000000000..607336f66 --- /dev/null +++ b/test_fixtures/wrap_reverse_row_align_content_space_around.html @@ -0,0 +1,21 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/wrap_reverse_row_align_content_stretch.html b/test_fixtures/wrap_reverse_row_align_content_stretch.html new file mode 100644 index 000000000..494b59796 --- /dev/null +++ b/test_fixtures/wrap_reverse_row_align_content_stretch.html @@ -0,0 +1,21 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/wrap_reverse_row_single_line_different_size.html b/test_fixtures/wrap_reverse_row_single_line_different_size.html new file mode 100644 index 000000000..c991a13da --- /dev/null +++ b/test_fixtures/wrap_reverse_row_single_line_different_size.html @@ -0,0 +1,21 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/wrap_row.html b/test_fixtures/wrap_row.html new file mode 100644 index 000000000..842fdcd5c --- /dev/null +++ b/test_fixtures/wrap_row.html @@ -0,0 +1,20 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/wrap_row_align_items_center.html b/test_fixtures/wrap_row_align_items_center.html new file mode 100644 index 000000000..91414cc0d --- /dev/null +++ b/test_fixtures/wrap_row_align_items_center.html @@ -0,0 +1,20 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/wrap_row_align_items_flex_end.html b/test_fixtures/wrap_row_align_items_flex_end.html new file mode 100644 index 000000000..3fcd8cd92 --- /dev/null +++ b/test_fixtures/wrap_row_align_items_flex_end.html @@ -0,0 +1,20 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/wrapped_column_max_height.html b/test_fixtures/wrapped_column_max_height.html new file mode 100644 index 000000000..00c693aef --- /dev/null +++ b/test_fixtures/wrapped_column_max_height.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/wrapped_column_max_height_flex.html b/test_fixtures/wrapped_column_max_height_flex.html new file mode 100644 index 000000000..7842d975c --- /dev/null +++ b/test_fixtures/wrapped_column_max_height_flex.html @@ -0,0 +1,19 @@ + + + + + + + Test description + + + + +
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/wrapped_row_within_align_items_center.html b/test_fixtures/wrapped_row_within_align_items_center.html new file mode 100644 index 000000000..018998a1c --- /dev/null +++ b/test_fixtures/wrapped_row_within_align_items_center.html @@ -0,0 +1,20 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/wrapped_row_within_align_items_flex_end.html b/test_fixtures/wrapped_row_within_align_items_flex_end.html new file mode 100644 index 000000000..9be73718a --- /dev/null +++ b/test_fixtures/wrapped_row_within_align_items_flex_end.html @@ -0,0 +1,20 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/wrapped_row_within_align_items_flex_start.html b/test_fixtures/wrapped_row_within_align_items_flex_start.html new file mode 100644 index 000000000..1a24b747b --- /dev/null +++ b/test_fixtures/wrapped_row_within_align_items_flex_start.html @@ -0,0 +1,20 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/tests/fixtures.rs b/tests/fixtures.rs new file mode 100644 index 000000000..904388cb7 --- /dev/null +++ b/tests/fixtures.rs @@ -0,0 +1,4 @@ +// this declaration is necessary to "mount" the generated code where cargo can see it +// this allows us to both keep code generation scoped to a singe directory for fs events +// and to keep each test in a separate file +mod generated; diff --git a/tests/generated/absolute_layout_align_items_and_justify_content_center.rs b/tests/generated/absolute_layout_align_items_and_justify_content_center.rs new file mode 100644 index 000000000..610e59536 --- /dev/null +++ b/tests/generated/absolute_layout_align_items_and_justify_content_center.rs @@ -0,0 +1,42 @@ +#[test] +fn absolute_layout_align_items_and_justify_content_center() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(110f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 110f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 25f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 30f32); +} diff --git a/tests/generated/absolute_layout_align_items_and_justify_content_center_and_bottom_position.rs b/tests/generated/absolute_layout_align_items_and_justify_content_center_and_bottom_position.rs new file mode 100644 index 000000000..1546f99aa --- /dev/null +++ b/tests/generated/absolute_layout_align_items_and_justify_content_center_and_bottom_position.rs @@ -0,0 +1,46 @@ +#[test] +fn absolute_layout_align_items_and_justify_content_center_and_bottom_position() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + position: taffy::geometry::Rect { + bottom: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(110f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 110f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 25f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 50f32); +} diff --git a/tests/generated/absolute_layout_align_items_and_justify_content_center_and_left_position.rs b/tests/generated/absolute_layout_align_items_and_justify_content_center_and_left_position.rs new file mode 100644 index 000000000..07a1bbe78 --- /dev/null +++ b/tests/generated/absolute_layout_align_items_and_justify_content_center_and_left_position.rs @@ -0,0 +1,43 @@ +#[test] +fn absolute_layout_align_items_and_justify_content_center_and_left_position() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + position: taffy::geometry::Rect { start: taffy::style::Dimension::Points(5f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(110f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 110f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 5f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 30f32); +} diff --git a/tests/generated/absolute_layout_align_items_and_justify_content_center_and_right_position.rs b/tests/generated/absolute_layout_align_items_and_justify_content_center_and_right_position.rs new file mode 100644 index 000000000..d0f21a367 --- /dev/null +++ b/tests/generated/absolute_layout_align_items_and_justify_content_center_and_right_position.rs @@ -0,0 +1,43 @@ +#[test] +fn absolute_layout_align_items_and_justify_content_center_and_right_position() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + position: taffy::geometry::Rect { end: taffy::style::Dimension::Points(5f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(110f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 110f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 45f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 30f32); +} diff --git a/tests/generated/absolute_layout_align_items_and_justify_content_center_and_top_position.rs b/tests/generated/absolute_layout_align_items_and_justify_content_center_and_top_position.rs new file mode 100644 index 000000000..033c2e356 --- /dev/null +++ b/tests/generated/absolute_layout_align_items_and_justify_content_center_and_top_position.rs @@ -0,0 +1,43 @@ +#[test] +fn absolute_layout_align_items_and_justify_content_center_and_top_position() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + position: taffy::geometry::Rect { top: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(110f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 110f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 25f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 10f32); +} diff --git a/tests/generated/absolute_layout_align_items_and_justify_content_flex_end.rs b/tests/generated/absolute_layout_align_items_and_justify_content_flex_end.rs new file mode 100644 index 000000000..97a234139 --- /dev/null +++ b/tests/generated/absolute_layout_align_items_and_justify_content_flex_end.rs @@ -0,0 +1,42 @@ +#[test] +fn absolute_layout_align_items_and_justify_content_flex_end() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::FlexEnd, + justify_content: taffy::style::JustifyContent::FlexEnd, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(110f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 110f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 50f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 60f32); +} diff --git a/tests/generated/absolute_layout_align_items_center.rs b/tests/generated/absolute_layout_align_items_center.rs new file mode 100644 index 000000000..7618f577a --- /dev/null +++ b/tests/generated/absolute_layout_align_items_center.rs @@ -0,0 +1,41 @@ +#[test] +fn absolute_layout_align_items_center() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(110f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 110f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 30f32); +} diff --git a/tests/generated/absolute_layout_align_items_center_on_child_only.rs b/tests/generated/absolute_layout_align_items_center_on_child_only.rs new file mode 100644 index 000000000..5c3d39491 --- /dev/null +++ b/tests/generated/absolute_layout_align_items_center_on_child_only.rs @@ -0,0 +1,41 @@ +#[test] +fn absolute_layout_align_items_center_on_child_only() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + align_self: taffy::style::AlignSelf::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(110f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 110f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 30f32); +} diff --git a/tests/generated/absolute_layout_child_order.rs b/tests/generated/absolute_layout_child_order.rs new file mode 100644 index 000000000..8b15dbfd9 --- /dev/null +++ b/tests/generated/absolute_layout_child_order.rs @@ -0,0 +1,76 @@ +#[test] +fn absolute_layout_child_order() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(110f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 110f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 55f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 30f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 25f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 30f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 55f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 55f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 30f32); +} diff --git a/tests/generated/absolute_layout_in_wrap_reverse_column_container.rs b/tests/generated/absolute_layout_in_wrap_reverse_column_container.rs new file mode 100644 index 000000000..442dee530 --- /dev/null +++ b/tests/generated/absolute_layout_in_wrap_reverse_column_container.rs @@ -0,0 +1,42 @@ +#[test] +fn absolute_layout_in_wrap_reverse_column_container() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_wrap: taffy::style::FlexWrap::WrapReverse, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); +} diff --git a/tests/generated/absolute_layout_in_wrap_reverse_column_container_flex_end.rs b/tests/generated/absolute_layout_in_wrap_reverse_column_container_flex_end.rs new file mode 100644 index 000000000..60fded02e --- /dev/null +++ b/tests/generated/absolute_layout_in_wrap_reverse_column_container_flex_end.rs @@ -0,0 +1,43 @@ +#[test] +fn absolute_layout_in_wrap_reverse_column_container_flex_end() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + align_self: taffy::style::AlignSelf::FlexEnd, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_wrap: taffy::style::FlexWrap::WrapReverse, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); +} diff --git a/tests/generated/absolute_layout_in_wrap_reverse_row_container.rs b/tests/generated/absolute_layout_in_wrap_reverse_row_container.rs new file mode 100644 index 000000000..0c0b044d4 --- /dev/null +++ b/tests/generated/absolute_layout_in_wrap_reverse_row_container.rs @@ -0,0 +1,41 @@ +#[test] +fn absolute_layout_in_wrap_reverse_row_container() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_wrap: taffy::style::FlexWrap::WrapReverse, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 80f32); +} diff --git a/tests/generated/absolute_layout_in_wrap_reverse_row_container_flex_end.rs b/tests/generated/absolute_layout_in_wrap_reverse_row_container_flex_end.rs new file mode 100644 index 000000000..2d43f4f91 --- /dev/null +++ b/tests/generated/absolute_layout_in_wrap_reverse_row_container_flex_end.rs @@ -0,0 +1,42 @@ +#[test] +fn absolute_layout_in_wrap_reverse_row_container_flex_end() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + align_self: taffy::style::AlignSelf::FlexEnd, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_wrap: taffy::style::FlexWrap::WrapReverse, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); +} diff --git a/tests/generated/absolute_layout_justify_content_center.rs b/tests/generated/absolute_layout_justify_content_center.rs new file mode 100644 index 000000000..274aa60e4 --- /dev/null +++ b/tests/generated/absolute_layout_justify_content_center.rs @@ -0,0 +1,41 @@ +#[test] +fn absolute_layout_justify_content_center() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(110f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 110f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 25f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); +} diff --git a/tests/generated/absolute_layout_no_size.rs b/tests/generated/absolute_layout_no_size.rs new file mode 100644 index 000000000..c52e3f3aa --- /dev/null +++ b/tests/generated/absolute_layout_no_size.rs @@ -0,0 +1,32 @@ +#[test] +fn absolute_layout_no_size() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { position_type: taffy::style::PositionType::Absolute, ..Default::default() }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); +} diff --git a/tests/generated/absolute_layout_percentage_bottom_based_on_parent_height.rs b/tests/generated/absolute_layout_percentage_bottom_based_on_parent_height.rs new file mode 100644 index 000000000..18c608d08 --- /dev/null +++ b/tests/generated/absolute_layout_percentage_bottom_based_on_parent_height.rs @@ -0,0 +1,82 @@ +#[test] +fn absolute_layout_percentage_bottom_based_on_parent_height() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + position: taffy::geometry::Rect { top: taffy::style::Dimension::Percent(0.5f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + position: taffy::geometry::Rect { + bottom: taffy::style::Dimension::Percent(0.5f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + position: taffy::geometry::Rect { + top: taffy::style::Dimension::Percent(0.1f32), + bottom: taffy::style::Dimension::Percent(0.1f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 100f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 90f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 160f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 20f32); +} diff --git a/tests/generated/absolute_layout_start_top_end_bottom.rs b/tests/generated/absolute_layout_start_top_end_bottom.rs new file mode 100644 index 000000000..e92e264cc --- /dev/null +++ b/tests/generated/absolute_layout_start_top_end_bottom.rs @@ -0,0 +1,42 @@ +#[test] +fn absolute_layout_start_top_end_bottom() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + position: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Points(10f32), + top: taffy::style::Dimension::Points(10f32), + bottom: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 80f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 80f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 10f32); +} diff --git a/tests/generated/absolute_layout_width_height_end_bottom.rs b/tests/generated/absolute_layout_width_height_end_bottom.rs new file mode 100644 index 000000000..f463030fc --- /dev/null +++ b/tests/generated/absolute_layout_width_height_end_bottom.rs @@ -0,0 +1,45 @@ +#[test] +fn absolute_layout_width_height_end_bottom() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + position: taffy::geometry::Rect { + end: taffy::style::Dimension::Points(10f32), + bottom: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 80f32); +} diff --git a/tests/generated/absolute_layout_width_height_start_top.rs b/tests/generated/absolute_layout_width_height_start_top.rs new file mode 100644 index 000000000..96d4e5f8f --- /dev/null +++ b/tests/generated/absolute_layout_width_height_start_top.rs @@ -0,0 +1,45 @@ +#[test] +fn absolute_layout_width_height_start_top() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + position: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + top: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 10f32); +} diff --git a/tests/generated/absolute_layout_width_height_start_top_end_bottom.rs b/tests/generated/absolute_layout_width_height_start_top_end_bottom.rs new file mode 100644 index 000000000..f018c2e52 --- /dev/null +++ b/tests/generated/absolute_layout_width_height_start_top_end_bottom.rs @@ -0,0 +1,47 @@ +#[test] +fn absolute_layout_width_height_start_top_end_bottom() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + position: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Points(10f32), + top: taffy::style::Dimension::Points(10f32), + bottom: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 10f32); +} diff --git a/tests/generated/absolute_layout_within_border.rs b/tests/generated/absolute_layout_within_border.rs new file mode 100644 index 000000000..0b8fd75dd --- /dev/null +++ b/tests/generated/absolute_layout_within_border.rs @@ -0,0 +1,142 @@ +#[test] +fn absolute_layout_within_border() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + position: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(0f32), + top: taffy::style::Dimension::Points(0f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + position: taffy::geometry::Rect { + end: taffy::style::Dimension::Points(0f32), + bottom: taffy::style::Dimension::Points(0f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Points(10f32), + top: taffy::style::Dimension::Points(10f32), + bottom: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + position: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(0f32), + top: taffy::style::Dimension::Points(0f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node3 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Points(10f32), + top: taffy::style::Dimension::Points(10f32), + bottom: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + position: taffy::geometry::Rect { + end: taffy::style::Dimension::Points(0f32), + bottom: taffy::style::Dimension::Points(0f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + padding: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Points(10f32), + top: taffy::style::Dimension::Points(10f32), + bottom: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + border: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Points(10f32), + top: taffy::style::Dimension::Points(10f32), + bottom: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2, node3], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 20f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 20f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 30f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 30f32); +} diff --git a/tests/generated/align_baseline.rs b/tests/generated/align_baseline.rs new file mode 100644 index 000000000..9dd10ee3b --- /dev/null +++ b/tests/generated/align_baseline.rs @@ -0,0 +1,57 @@ +#[test] +fn align_baseline() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Baseline, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 50f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 30f32); +} diff --git a/tests/generated/align_baseline_child_multiline.rs b/tests/generated/align_baseline_child_multiline.rs new file mode 100644 index 000000000..1029621b1 --- /dev/null +++ b/tests/generated/align_baseline_child_multiline.rs @@ -0,0 +1,118 @@ +#[test] +fn align_baseline_child_multiline() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(60f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node10 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(25f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node11 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(25f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node12 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(25f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node13 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(25f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_wrap: taffy::style::FlexWrap::Wrap, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), ..Default::default() }, + ..Default::default() + }, + &[node10, node11, node12, node13], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Baseline, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 80f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 60f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 50f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node10).unwrap().size.width, 25f32); + assert_eq!(taffy.layout(node10).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node10).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node10).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node11).unwrap().size.width, 25f32); + assert_eq!(taffy.layout(node11).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node11).unwrap().location.x, 25f32); + assert_eq!(taffy.layout(node11).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node12).unwrap().size.width, 25f32); + assert_eq!(taffy.layout(node12).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node12).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node12).unwrap().location.y, 20f32); + assert_eq!(taffy.layout(node13).unwrap().size.width, 25f32); + assert_eq!(taffy.layout(node13).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node13).unwrap().location.x, 25f32); + assert_eq!(taffy.layout(node13).unwrap().location.y, 20f32); +} diff --git a/tests/generated/align_baseline_nested_child.rs b/tests/generated/align_baseline_nested_child.rs new file mode 100644 index 000000000..22f89b98e --- /dev/null +++ b/tests/generated/align_baseline_nested_child.rs @@ -0,0 +1,75 @@ +#[test] +fn align_baseline_nested_child() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node10 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[node10], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Baseline, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 50f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node10).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node10).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node10).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node10).unwrap().location.y, 0f32); +} diff --git a/tests/generated/align_center_should_size_based_on_content.rs b/tests/generated/align_center_should_size_based_on_content.rs new file mode 100644 index 000000000..95cd036f0 --- /dev/null +++ b/tests/generated/align_center_should_size_based_on_content.rs @@ -0,0 +1,65 @@ +#[test] +fn align_center_should_size_based_on_content() { + let mut taffy = taffy::Taffy::new(); + let node000 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, + &[node000], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + justify_content: taffy::style::JustifyContent::Center, + flex_grow: 0f32, + flex_shrink: 1f32, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node000).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node000).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node000).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node000).unwrap().location.y, 0f32); +} diff --git a/tests/generated/align_flex_start_with_shrinking_children.rs b/tests/generated/align_flex_start_with_shrinking_children.rs new file mode 100644 index 000000000..6541b9278 --- /dev/null +++ b/tests/generated/align_flex_start_with_shrinking_children.rs @@ -0,0 +1,52 @@ +#[test] +fn align_flex_start_with_shrinking_children() { + let mut taffy = taffy::Taffy::new(); + let node000 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, + &[], + ) + .unwrap(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, + &[node000], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { align_items: taffy::style::AlignItems::FlexStart, ..Default::default() }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(500f32), + height: taffy::style::Dimension::Points(500f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 500f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 500f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 500f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node000).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node000).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node000).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node000).unwrap().location.y, 0f32); +} diff --git a/tests/generated/align_flex_start_with_shrinking_children_with_stretch.rs b/tests/generated/align_flex_start_with_shrinking_children_with_stretch.rs new file mode 100644 index 000000000..74fd444e0 --- /dev/null +++ b/tests/generated/align_flex_start_with_shrinking_children_with_stretch.rs @@ -0,0 +1,52 @@ +#[test] +fn align_flex_start_with_shrinking_children_with_stretch() { + let mut taffy = taffy::Taffy::new(); + let node000 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, + &[], + ) + .unwrap(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, + &[node000], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { align_items: taffy::style::AlignItems::FlexStart, ..Default::default() }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(500f32), + height: taffy::style::Dimension::Points(500f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 500f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 500f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 500f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node000).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node000).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node000).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node000).unwrap().location.y, 0f32); +} diff --git a/tests/generated/align_flex_start_with_stretching_children.rs b/tests/generated/align_flex_start_with_stretching_children.rs new file mode 100644 index 000000000..752f842d1 --- /dev/null +++ b/tests/generated/align_flex_start_with_stretching_children.rs @@ -0,0 +1,47 @@ +#[test] +fn align_flex_start_with_stretching_children() { + let mut taffy = taffy::Taffy::new(); + let node000 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, + &[], + ) + .unwrap(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, + &[node000], + ) + .unwrap(); + let node0 = taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[node00]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(500f32), + height: taffy::style::Dimension::Points(500f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 500f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 500f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 500f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 500f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node000).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node000).unwrap().size.height, 500f32); + assert_eq!(taffy.layout(node000).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node000).unwrap().location.y, 0f32); +} diff --git a/tests/generated/align_items_center.rs b/tests/generated/align_items_center.rs new file mode 100644 index 000000000..134208baa --- /dev/null +++ b/tests/generated/align_items_center.rs @@ -0,0 +1,40 @@ +#[test] +fn align_items_center() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 45f32); +} diff --git a/tests/generated/align_items_center_child_with_margin_bigger_than_parent.rs b/tests/generated/align_items_center_child_with_margin_bigger_than_parent.rs new file mode 100644 index 000000000..efced6fc2 --- /dev/null +++ b/tests/generated/align_items_center_child_with_margin_bigger_than_parent.rs @@ -0,0 +1,56 @@ +#[test] +fn align_items_center_child_with_margin_bigger_than_parent() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { align_items: taffy::style::AlignItems::Center, ..Default::default() }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 70f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, -10f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 10f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); +} diff --git a/tests/generated/align_items_center_child_without_margin_bigger_than_parent.rs b/tests/generated/align_items_center_child_without_margin_bigger_than_parent.rs new file mode 100644 index 000000000..e5ad6a021 --- /dev/null +++ b/tests/generated/align_items_center_child_without_margin_bigger_than_parent.rs @@ -0,0 +1,51 @@ +#[test] +fn align_items_center_child_without_margin_bigger_than_parent() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(70f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { align_items: taffy::style::AlignItems::Center, ..Default::default() }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 70f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 70f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, -10f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, -10f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 70f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 70f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); +} diff --git a/tests/generated/align_items_center_with_child_margin.rs b/tests/generated/align_items_center_with_child_margin.rs new file mode 100644 index 000000000..6b988c5fa --- /dev/null +++ b/tests/generated/align_items_center_with_child_margin.rs @@ -0,0 +1,41 @@ +#[test] +fn align_items_center_with_child_margin() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { top: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 50f32); +} diff --git a/tests/generated/align_items_center_with_child_top.rs b/tests/generated/align_items_center_with_child_top.rs new file mode 100644 index 000000000..93c91bbff --- /dev/null +++ b/tests/generated/align_items_center_with_child_top.rs @@ -0,0 +1,41 @@ +#[test] +fn align_items_center_with_child_top() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + position: taffy::geometry::Rect { top: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 55f32); +} diff --git a/tests/generated/align_items_flex_end.rs b/tests/generated/align_items_flex_end.rs new file mode 100644 index 000000000..8afd08847 --- /dev/null +++ b/tests/generated/align_items_flex_end.rs @@ -0,0 +1,40 @@ +#[test] +fn align_items_flex_end() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::FlexEnd, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 90f32); +} diff --git a/tests/generated/align_items_flex_end_child_with_margin_bigger_than_parent.rs b/tests/generated/align_items_flex_end_child_with_margin_bigger_than_parent.rs new file mode 100644 index 000000000..f831dd474 --- /dev/null +++ b/tests/generated/align_items_flex_end_child_with_margin_bigger_than_parent.rs @@ -0,0 +1,56 @@ +#[test] +fn align_items_flex_end_child_with_margin_bigger_than_parent() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { align_items: taffy::style::AlignItems::FlexEnd, ..Default::default() }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 70f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, -10f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 10f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); +} diff --git a/tests/generated/align_items_flex_end_child_without_margin_bigger_than_parent.rs b/tests/generated/align_items_flex_end_child_without_margin_bigger_than_parent.rs new file mode 100644 index 000000000..ce0a63026 --- /dev/null +++ b/tests/generated/align_items_flex_end_child_without_margin_bigger_than_parent.rs @@ -0,0 +1,51 @@ +#[test] +fn align_items_flex_end_child_without_margin_bigger_than_parent() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(70f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { align_items: taffy::style::AlignItems::FlexEnd, ..Default::default() }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 70f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 70f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, -10f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, -10f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 70f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 70f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); +} diff --git a/tests/generated/align_items_flex_start.rs b/tests/generated/align_items_flex_start.rs new file mode 100644 index 000000000..d18a55592 --- /dev/null +++ b/tests/generated/align_items_flex_start.rs @@ -0,0 +1,40 @@ +#[test] +fn align_items_flex_start() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::FlexStart, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); +} diff --git a/tests/generated/align_items_min_max.rs b/tests/generated/align_items_min_max.rs new file mode 100644 index 000000000..1c2f0e753 --- /dev/null +++ b/tests/generated/align_items_min_max.rs @@ -0,0 +1,45 @@ +#[test] +fn align_items_min_max() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + align_items: taffy::style::AlignItems::Center, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Default::default() }, + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 60f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 20f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); +} diff --git a/tests/generated/align_items_stretch.rs b/tests/generated/align_items_stretch.rs new file mode 100644 index 000000000..73295c76c --- /dev/null +++ b/tests/generated/align_items_stretch.rs @@ -0,0 +1,35 @@ +#[test] +fn align_items_stretch() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); +} diff --git a/tests/generated/align_self_baseline.rs b/tests/generated/align_self_baseline.rs new file mode 100644 index 000000000..e9ebe2584 --- /dev/null +++ b/tests/generated/align_self_baseline.rs @@ -0,0 +1,75 @@ +#[test] +fn align_self_baseline() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_self: taffy::style::AlignSelf::Baseline, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node10 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_self: taffy::style::AlignSelf::Baseline, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[node10], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 50f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node10).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node10).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node10).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node10).unwrap().location.y, 0f32); +} diff --git a/tests/generated/align_self_center.rs b/tests/generated/align_self_center.rs new file mode 100644 index 000000000..177cc8a62 --- /dev/null +++ b/tests/generated/align_self_center.rs @@ -0,0 +1,40 @@ +#[test] +fn align_self_center() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_self: taffy::style::AlignSelf::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 45f32); +} diff --git a/tests/generated/align_self_flex_end.rs b/tests/generated/align_self_flex_end.rs new file mode 100644 index 000000000..1d7e5fb74 --- /dev/null +++ b/tests/generated/align_self_flex_end.rs @@ -0,0 +1,40 @@ +#[test] +fn align_self_flex_end() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_self: taffy::style::AlignSelf::FlexEnd, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 90f32); +} diff --git a/tests/generated/align_self_flex_end_override_flex_start.rs b/tests/generated/align_self_flex_end_override_flex_start.rs new file mode 100644 index 000000000..fa14df87c --- /dev/null +++ b/tests/generated/align_self_flex_end_override_flex_start.rs @@ -0,0 +1,41 @@ +#[test] +fn align_self_flex_end_override_flex_start() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_self: taffy::style::AlignSelf::FlexEnd, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::FlexStart, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 90f32); +} diff --git a/tests/generated/align_self_flex_start.rs b/tests/generated/align_self_flex_start.rs new file mode 100644 index 000000000..f1de33f4d --- /dev/null +++ b/tests/generated/align_self_flex_start.rs @@ -0,0 +1,40 @@ +#[test] +fn align_self_flex_start() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_self: taffy::style::AlignSelf::FlexStart, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); +} diff --git a/tests/generated/align_strech_should_size_based_on_parent.rs b/tests/generated/align_strech_should_size_based_on_parent.rs new file mode 100644 index 000000000..6661165e5 --- /dev/null +++ b/tests/generated/align_strech_should_size_based_on_parent.rs @@ -0,0 +1,64 @@ +#[test] +fn align_strech_should_size_based_on_parent() { + let mut taffy = taffy::Taffy::new(); + let node000 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, + &[node000], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + justify_content: taffy::style::JustifyContent::Center, + flex_grow: 0f32, + flex_shrink: 1f32, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node000).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node000).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node000).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node000).unwrap().location.y, 0f32); +} diff --git a/tests/generated/border_center_child.rs b/tests/generated/border_center_child.rs new file mode 100644 index 000000000..71c04986a --- /dev/null +++ b/tests/generated/border_center_child.rs @@ -0,0 +1,46 @@ +#[test] +fn border_center_child() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + border: taffy::geometry::Rect { + top: taffy::style::Dimension::Points(10f32), + bottom: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 45f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 40f32); +} diff --git a/tests/generated/border_flex_child.rs b/tests/generated/border_flex_child.rs new file mode 100644 index 000000000..46afe3e2d --- /dev/null +++ b/tests/generated/border_flex_child.rs @@ -0,0 +1,43 @@ +#[test] +fn border_flex_child() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + border: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Points(10f32), + top: taffy::style::Dimension::Points(10f32), + bottom: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 80f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 80f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 10f32); +} diff --git a/tests/generated/border_no_child.rs b/tests/generated/border_no_child.rs new file mode 100644 index 000000000..0cc8d9d05 --- /dev/null +++ b/tests/generated/border_no_child.rs @@ -0,0 +1,24 @@ +#[test] +fn border_no_child() { + let mut taffy = taffy::Taffy::new(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + border: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Points(10f32), + top: taffy::style::Dimension::Points(10f32), + bottom: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); +} diff --git a/tests/generated/border_stretch_child.rs b/tests/generated/border_stretch_child.rs new file mode 100644 index 000000000..e11175463 --- /dev/null +++ b/tests/generated/border_stretch_child.rs @@ -0,0 +1,42 @@ +#[test] +fn border_stretch_child() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + border: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Points(10f32), + top: taffy::style::Dimension::Points(10f32), + bottom: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 80f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 10f32); +} diff --git a/tests/generated/child_min_max_width_flexing.rs b/tests/generated/child_min_max_width_flexing.rs new file mode 100644 index 000000000..3f2317c3a --- /dev/null +++ b/tests/generated/child_min_max_width_flexing.rs @@ -0,0 +1,54 @@ +#[test] +fn child_min_max_width_flexing() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_shrink: 0f32, + flex_basis: taffy::style::Dimension::Points(0f32), + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_shrink: 0f32, + flex_basis: taffy::style::Dimension::Percent(0.5f32), + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 120f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 100f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); +} diff --git a/tests/generated/container_with_unsized_child.rs b/tests/generated/container_with_unsized_child.rs new file mode 100644 index 000000000..0a3a3a95b --- /dev/null +++ b/tests/generated/container_with_unsized_child.rs @@ -0,0 +1,27 @@ +#[test] +fn container_with_unsized_child() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); +} diff --git a/tests/generated/display_none.rs b/tests/generated/display_none.rs new file mode 100644 index 000000000..000913556 --- /dev/null +++ b/tests/generated/display_none.rs @@ -0,0 +1,38 @@ +#[test] +fn display_none() { + let mut taffy = taffy::Taffy::new(); + let node0 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { display: taffy::style::Display::None, flex_grow: 1f32, ..Default::default() }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); +} diff --git a/tests/generated/display_none_fixed_size.rs b/tests/generated/display_none_fixed_size.rs new file mode 100644 index 000000000..24a844cbc --- /dev/null +++ b/tests/generated/display_none_fixed_size.rs @@ -0,0 +1,46 @@ +#[test] +fn display_none_fixed_size() { + let mut taffy = taffy::Taffy::new(); + let node0 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + display: taffy::style::Display::None, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); +} diff --git a/tests/generated/display_none_with_child.rs b/tests/generated/display_none_with_child.rs new file mode 100644 index 000000000..cafc34d01 --- /dev/null +++ b/tests/generated/display_none_with_child.rs @@ -0,0 +1,85 @@ +#[test] +fn display_none_with_child() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }, + &[], + ) + .unwrap(); + let node10 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + display: taffy::style::Display::None, + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }, + &[node10], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node10).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node10).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node10).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node10).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 50f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); +} diff --git a/tests/generated/display_none_with_margin.rs b/tests/generated/display_none_with_margin.rs new file mode 100644 index 000000000..03eb83e08 --- /dev/null +++ b/tests/generated/display_none_with_margin.rs @@ -0,0 +1,53 @@ +#[test] +fn display_none_with_margin() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + display: taffy::style::Display::None, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Points(10f32), + top: taffy::style::Dimension::Points(10f32), + bottom: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); +} diff --git a/tests/generated/display_none_with_position.rs b/tests/generated/display_none_with_position.rs new file mode 100644 index 000000000..5d2fadbbd --- /dev/null +++ b/tests/generated/display_none_with_position.rs @@ -0,0 +1,43 @@ +#[test] +fn display_none_with_position() { + let mut taffy = taffy::Taffy::new(); + let node0 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + display: taffy::style::Display::None, + flex_grow: 1f32, + position: taffy::geometry::Rect { top: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); +} diff --git a/tests/generated/flex_basis_and_main_dimen_set_when_flexing.rs b/tests/generated/flex_basis_and_main_dimen_set_when_flexing.rs new file mode 100644 index 000000000..a1f1659ef --- /dev/null +++ b/tests/generated/flex_basis_and_main_dimen_set_when_flexing.rs @@ -0,0 +1,56 @@ +#[test] +fn flex_basis_and_main_dimen_set_when_flexing() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(10f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(10f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(0f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 50f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); +} diff --git a/tests/generated/flex_basis_flex_grow_column.rs b/tests/generated/flex_basis_flex_grow_column.rs new file mode 100644 index 000000000..9831b1794 --- /dev/null +++ b/tests/generated/flex_basis_flex_grow_column.rs @@ -0,0 +1,43 @@ +#[test] +fn flex_basis_flex_grow_column() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 75f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 25f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 75f32); +} diff --git a/tests/generated/flex_basis_flex_grow_row.rs b/tests/generated/flex_basis_flex_grow_row.rs new file mode 100644 index 000000000..cc16842e2 --- /dev/null +++ b/tests/generated/flex_basis_flex_grow_row.rs @@ -0,0 +1,42 @@ +#[test] +fn flex_basis_flex_grow_row() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 75f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 25f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 75f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); +} diff --git a/tests/generated/flex_basis_flex_shrink_column.rs b/tests/generated/flex_basis_flex_shrink_column.rs new file mode 100644 index 000000000..6fe6c85f8 --- /dev/null +++ b/tests/generated/flex_basis_flex_shrink_column.rs @@ -0,0 +1,43 @@ +#[test] +fn flex_basis_flex_shrink_column() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_basis: taffy::style::Dimension::Points(100f32), ..Default::default() }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_basis: taffy::style::Dimension::Points(50f32), ..Default::default() }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 67f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 33f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 67f32); +} diff --git a/tests/generated/flex_basis_flex_shrink_row.rs b/tests/generated/flex_basis_flex_shrink_row.rs new file mode 100644 index 000000000..52b56b00d --- /dev/null +++ b/tests/generated/flex_basis_flex_shrink_row.rs @@ -0,0 +1,42 @@ +#[test] +fn flex_basis_flex_shrink_row() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_basis: taffy::style::Dimension::Points(100f32), ..Default::default() }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_basis: taffy::style::Dimension::Points(50f32), ..Default::default() }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 67f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 33f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 67f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); +} diff --git a/tests/generated/flex_basis_larger_than_content_column.rs b/tests/generated/flex_basis_larger_than_content_column.rs new file mode 100644 index 000000000..b6a8d7abb --- /dev/null +++ b/tests/generated/flex_basis_larger_than_content_column.rs @@ -0,0 +1,50 @@ +#[test] +fn flex_basis_larger_than_content_column() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_basis: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); +} diff --git a/tests/generated/flex_basis_larger_than_content_row.rs b/tests/generated/flex_basis_larger_than_content_row.rs new file mode 100644 index 000000000..f4d51b9e0 --- /dev/null +++ b/tests/generated/flex_basis_larger_than_content_row.rs @@ -0,0 +1,49 @@ +#[test] +fn flex_basis_larger_than_content_row() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_basis: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); +} diff --git a/tests/generated/flex_basis_overrides_main_size.rs b/tests/generated/flex_basis_overrides_main_size.rs new file mode 100644 index 000000000..efcba0da8 --- /dev/null +++ b/tests/generated/flex_basis_overrides_main_size.rs @@ -0,0 +1,65 @@ +#[test] +fn flex_basis_overrides_main_size() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(50f32), + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 60f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); +} diff --git a/tests/generated/flex_basis_slightly_smaller_then_content_with_flex_grow_large_size.rs b/tests/generated/flex_basis_slightly_smaller_then_content_with_flex_grow_large_size.rs new file mode 100644 index 000000000..d48f5a6c9 --- /dev/null +++ b/tests/generated/flex_basis_slightly_smaller_then_content_with_flex_grow_large_size.rs @@ -0,0 +1,82 @@ +#[test] +fn flex_basis_slightly_smaller_then_content_with_flex_grow_large_size() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(60f32), + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node10 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(0f32), + ..Default::default() + }, + &[node10], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 80f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 70f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node10).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node10).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node10).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node10).unwrap().location.y, 0f32); +} diff --git a/tests/generated/flex_basis_smaller_than_content_column.rs b/tests/generated/flex_basis_smaller_than_content_column.rs new file mode 100644 index 000000000..39973bc27 --- /dev/null +++ b/tests/generated/flex_basis_smaller_than_content_column.rs @@ -0,0 +1,50 @@ +#[test] +fn flex_basis_smaller_than_content_column() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_basis: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); +} diff --git a/tests/generated/flex_basis_smaller_than_content_row.rs b/tests/generated/flex_basis_smaller_than_content_row.rs new file mode 100644 index 000000000..4cb495ecb --- /dev/null +++ b/tests/generated/flex_basis_smaller_than_content_row.rs @@ -0,0 +1,49 @@ +#[test] +fn flex_basis_smaller_than_content_row() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_basis: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); +} diff --git a/tests/generated/flex_basis_smaller_than_main_dimen_column.rs b/tests/generated/flex_basis_smaller_than_main_dimen_column.rs new file mode 100644 index 000000000..68775423c --- /dev/null +++ b/tests/generated/flex_basis_smaller_than_main_dimen_column.rs @@ -0,0 +1,37 @@ +#[test] +fn flex_basis_smaller_than_main_dimen_column() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_basis: taffy::style::Dimension::Points(10f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); +} diff --git a/tests/generated/flex_basis_smaller_than_main_dimen_row.rs b/tests/generated/flex_basis_smaller_than_main_dimen_row.rs new file mode 100644 index 000000000..9dc2ffa22 --- /dev/null +++ b/tests/generated/flex_basis_smaller_than_main_dimen_row.rs @@ -0,0 +1,36 @@ +#[test] +fn flex_basis_smaller_than_main_dimen_row() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_basis: taffy::style::Dimension::Points(10f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); +} diff --git a/tests/generated/flex_basis_smaller_then_content_with_flex_grow_large_size.rs b/tests/generated/flex_basis_smaller_then_content_with_flex_grow_large_size.rs new file mode 100644 index 000000000..70eb24436 --- /dev/null +++ b/tests/generated/flex_basis_smaller_then_content_with_flex_grow_large_size.rs @@ -0,0 +1,82 @@ +#[test] +fn flex_basis_smaller_then_content_with_flex_grow_large_size() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(0f32), + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node10 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(0f32), + ..Default::default() + }, + &[node10], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 70f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 70f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 70f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node10).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node10).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node10).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node10).unwrap().location.y, 0f32); +} diff --git a/tests/generated/flex_basis_smaller_then_content_with_flex_grow_small_size.rs b/tests/generated/flex_basis_smaller_then_content_with_flex_grow_small_size.rs new file mode 100644 index 000000000..12243ddd0 --- /dev/null +++ b/tests/generated/flex_basis_smaller_then_content_with_flex_grow_small_size.rs @@ -0,0 +1,82 @@ +#[test] +fn flex_basis_smaller_then_content_with_flex_grow_small_size() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(0f32), + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node10 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(0f32), + ..Default::default() + }, + &[node10], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 70f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 70f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 70f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node10).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node10).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node10).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node10).unwrap().location.y, 0f32); +} diff --git a/tests/generated/flex_basis_smaller_then_content_with_flex_grow_unconstraint_size.rs b/tests/generated/flex_basis_smaller_then_content_with_flex_grow_unconstraint_size.rs new file mode 100644 index 000000000..d9a77a88c --- /dev/null +++ b/tests/generated/flex_basis_smaller_then_content_with_flex_grow_unconstraint_size.rs @@ -0,0 +1,74 @@ +#[test] +fn flex_basis_smaller_then_content_with_flex_grow_unconstraint_size() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(0f32), + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node10 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(0f32), + ..Default::default() + }, + &[node10], + ) + .unwrap(); + let node = taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[node0, node1]).unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 90f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 70f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 70f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 70f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node10).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node10).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node10).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node10).unwrap().location.y, 0f32); +} diff --git a/tests/generated/flex_basis_smaller_then_content_with_flex_grow_very_large_size.rs b/tests/generated/flex_basis_smaller_then_content_with_flex_grow_very_large_size.rs new file mode 100644 index 000000000..7483202d8 --- /dev/null +++ b/tests/generated/flex_basis_smaller_then_content_with_flex_grow_very_large_size.rs @@ -0,0 +1,82 @@ +#[test] +fn flex_basis_smaller_then_content_with_flex_grow_very_large_size() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(0f32), + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node10 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(0f32), + ..Default::default() + }, + &[node10], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 70f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 100f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node10).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node10).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node10).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node10).unwrap().location.y, 0f32); +} diff --git a/tests/generated/flex_basis_unconstraint_column.rs b/tests/generated/flex_basis_unconstraint_column.rs new file mode 100644 index 000000000..68b88d414 --- /dev/null +++ b/tests/generated/flex_basis_unconstraint_column.rs @@ -0,0 +1,29 @@ +#[test] +fn flex_basis_unconstraint_column() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_basis: taffy::style::Dimension::Points(50f32), + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); +} diff --git a/tests/generated/flex_basis_unconstraint_row.rs b/tests/generated/flex_basis_unconstraint_row.rs new file mode 100644 index 000000000..bad85ca0a --- /dev/null +++ b/tests/generated/flex_basis_unconstraint_row.rs @@ -0,0 +1,24 @@ +#[test] +fn flex_basis_unconstraint_row() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_basis: taffy::style::Dimension::Points(50f32), + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[node0]).unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); +} diff --git a/tests/generated/flex_direction_column.rs b/tests/generated/flex_direction_column.rs new file mode 100644 index 000000000..d14d38de5 --- /dev/null +++ b/tests/generated/flex_direction_column.rs @@ -0,0 +1,62 @@ +#[test] +fn flex_direction_column() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 20f32); +} diff --git a/tests/generated/flex_direction_column_no_height.rs b/tests/generated/flex_direction_column_no_height.rs new file mode 100644 index 000000000..39a6dcb90 --- /dev/null +++ b/tests/generated/flex_direction_column_no_height.rs @@ -0,0 +1,58 @@ +#[test] +fn flex_direction_column_no_height() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 30f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 20f32); +} diff --git a/tests/generated/flex_direction_column_reverse.rs b/tests/generated/flex_direction_column_reverse.rs new file mode 100644 index 000000000..f3e9934ba --- /dev/null +++ b/tests/generated/flex_direction_column_reverse.rs @@ -0,0 +1,62 @@ +#[test] +fn flex_direction_column_reverse() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::ColumnReverse, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 90f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 70f32); +} diff --git a/tests/generated/flex_direction_row.rs b/tests/generated/flex_direction_row.rs new file mode 100644 index 000000000..4117f25a4 --- /dev/null +++ b/tests/generated/flex_direction_row.rs @@ -0,0 +1,61 @@ +#[test] +fn flex_direction_row() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 10f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 20f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); +} diff --git a/tests/generated/flex_direction_row_no_width.rs b/tests/generated/flex_direction_row_no_width.rs new file mode 100644 index 000000000..7d9482f27 --- /dev/null +++ b/tests/generated/flex_direction_row_no_width.rs @@ -0,0 +1,57 @@ +#[test] +fn flex_direction_row_no_width() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 10f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 20f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); +} diff --git a/tests/generated/flex_direction_row_reverse.rs b/tests/generated/flex_direction_row_reverse.rs new file mode 100644 index 000000000..d169c9efb --- /dev/null +++ b/tests/generated/flex_direction_row_reverse.rs @@ -0,0 +1,62 @@ +#[test] +fn flex_direction_row_reverse() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::RowReverse, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 90f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 70f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); +} diff --git a/tests/generated/flex_grow_child.rs b/tests/generated/flex_grow_child.rs new file mode 100644 index 000000000..2e109bf9f --- /dev/null +++ b/tests/generated/flex_grow_child.rs @@ -0,0 +1,25 @@ +#[test] +fn flex_grow_child() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(0f32), + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[node0]).unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); +} diff --git a/tests/generated/flex_grow_flex_basis_percent_min_max.rs b/tests/generated/flex_grow_flex_basis_percent_min_max.rs new file mode 100644 index 000000000..d4dbe0f56 --- /dev/null +++ b/tests/generated/flex_grow_flex_basis_percent_min_max.rs @@ -0,0 +1,56 @@ +#[test] +fn flex_grow_flex_basis_percent_min_max() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_shrink: 0f32, + flex_basis: taffy::style::Dimension::Points(0f32), + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20f32), ..Default::default() }, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_shrink: 0f32, + flex_basis: taffy::style::Dimension::Percent(0.5f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(120f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 120f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 100f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); +} diff --git a/tests/generated/flex_grow_height_maximized.rs b/tests/generated/flex_grow_height_maximized.rs new file mode 100644 index 000000000..7c2a10354 --- /dev/null +++ b/tests/generated/flex_grow_height_maximized.rs @@ -0,0 +1,72 @@ +#[test] +fn flex_grow_height_maximized() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + &[], + ) + .unwrap(); + let node01 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + min_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + max_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(500f32), + ..Default::default() + }, + ..Default::default() + }, + &[node00, node01], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(500f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 500f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 500f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 400f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node01).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node01).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node01).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node01).unwrap().location.y, 400f32); +} diff --git a/tests/generated/flex_grow_in_at_most_container.rs b/tests/generated/flex_grow_in_at_most_container.rs new file mode 100644 index 000000000..5262b1d7a --- /dev/null +++ b/tests/generated/flex_grow_in_at_most_container.rs @@ -0,0 +1,42 @@ +#[test] +fn flex_grow_in_at_most_container() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(0f32), + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[node00]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::FlexStart, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); +} diff --git a/tests/generated/flex_grow_less_than_factor_one.rs b/tests/generated/flex_grow_less_than_factor_one.rs new file mode 100644 index 000000000..6336d2815 --- /dev/null +++ b/tests/generated/flex_grow_less_than_factor_one.rs @@ -0,0 +1,57 @@ +#[test] +fn flex_grow_less_than_factor_one() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 0.2f32, + flex_shrink: 0f32, + flex_basis: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_grow: 0.2f32, flex_shrink: 0f32, ..Default::default() }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_grow: 0.4f32, flex_shrink: 0f32, ..Default::default() }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(500f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 500f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 132f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 92f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 132f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 184f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 224f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); +} diff --git a/tests/generated/flex_grow_root_minimized.rs b/tests/generated/flex_grow_root_minimized.rs new file mode 100644 index 000000000..85b4b4407 --- /dev/null +++ b/tests/generated/flex_grow_root_minimized.rs @@ -0,0 +1,76 @@ +#[test] +fn flex_grow_root_minimized() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + &[], + ) + .unwrap(); + let node01 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + min_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + max_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(500f32), + ..Default::default() + }, + ..Default::default() + }, + &[node00, node01], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + min_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + max_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(500f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 300f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 300f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node01).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node01).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node01).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node01).unwrap().location.y, 200f32); +} diff --git a/tests/generated/flex_grow_shrink_at_most.rs b/tests/generated/flex_grow_shrink_at_most.rs new file mode 100644 index 000000000..bcc47e095 --- /dev/null +++ b/tests/generated/flex_grow_shrink_at_most.rs @@ -0,0 +1,37 @@ +#[test] +fn flex_grow_shrink_at_most() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, + &[], + ) + .unwrap(); + let node0 = taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[node00]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); +} diff --git a/tests/generated/flex_grow_to_min.rs b/tests/generated/flex_grow_to_min.rs new file mode 100644 index 000000000..62d89b18f --- /dev/null +++ b/tests/generated/flex_grow_to_min.rs @@ -0,0 +1,50 @@ +#[test] +fn flex_grow_to_min() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + min_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + max_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(500f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 50f32); +} diff --git a/tests/generated/flex_grow_within_constrained_max_column.rs b/tests/generated/flex_grow_within_constrained_max_column.rs new file mode 100644 index 000000000..46d29ebf8 --- /dev/null +++ b/tests/generated/flex_grow_within_constrained_max_column.rs @@ -0,0 +1,50 @@ +#[test] +fn flex_grow_within_constrained_max_column() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + max_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 67f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 33f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 67f32); +} diff --git a/tests/generated/flex_grow_within_constrained_max_row.rs b/tests/generated/flex_grow_within_constrained_max_row.rs new file mode 100644 index 000000000..d8621f1d3 --- /dev/null +++ b/tests/generated/flex_grow_within_constrained_max_row.rs @@ -0,0 +1,63 @@ +#[test] +fn flex_grow_within_constrained_max_row() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + &[], + ) + .unwrap(); + let node01 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Default::default() }, + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node00, node01], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), ..Default::default() }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 67f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node01).unwrap().size.width, 33f32); + assert_eq!(taffy.layout(node01).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node01).unwrap().location.x, 67f32); + assert_eq!(taffy.layout(node01).unwrap().location.y, 0f32); +} diff --git a/tests/generated/flex_grow_within_constrained_max_width.rs b/tests/generated/flex_grow_within_constrained_max_width.rs new file mode 100644 index 000000000..9ae4ae09d --- /dev/null +++ b/tests/generated/flex_grow_within_constrained_max_width.rs @@ -0,0 +1,53 @@ +#[test] +fn flex_grow_within_constrained_max_width() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(300f32), + ..Default::default() + }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); +} diff --git a/tests/generated/flex_grow_within_constrained_min_column.rs b/tests/generated/flex_grow_within_constrained_min_column.rs new file mode 100644 index 000000000..52e28efcf --- /dev/null +++ b/tests/generated/flex_grow_within_constrained_min_column.rs @@ -0,0 +1,41 @@ +#[test] +fn flex_grow_within_constrained_min_column() { + let mut taffy = taffy::Taffy::new(); + let node0 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + min_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 50f32); +} diff --git a/tests/generated/flex_grow_within_constrained_min_max_column.rs b/tests/generated/flex_grow_within_constrained_min_max_column.rs new file mode 100644 index 000000000..f626a8e86 --- /dev/null +++ b/tests/generated/flex_grow_within_constrained_min_max_column.rs @@ -0,0 +1,40 @@ +#[test] +fn flex_grow_within_constrained_min_max_column() { + let mut taffy = taffy::Taffy::new(); + let node0 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + min_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); +} diff --git a/tests/generated/flex_grow_within_constrained_min_row.rs b/tests/generated/flex_grow_within_constrained_min_row.rs new file mode 100644 index 000000000..360963b96 --- /dev/null +++ b/tests/generated/flex_grow_within_constrained_min_row.rs @@ -0,0 +1,41 @@ +#[test] +fn flex_grow_within_constrained_min_row() { + let mut taffy = taffy::Taffy::new(); + let node0 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Default::default() }, + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 50f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); +} diff --git a/tests/generated/flex_grow_within_max_width.rs b/tests/generated/flex_grow_within_max_width.rs new file mode 100644 index 000000000..b7e89e8bc --- /dev/null +++ b/tests/generated/flex_grow_within_max_width.rs @@ -0,0 +1,53 @@ +#[test] +fn flex_grow_within_max_width() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); +} diff --git a/tests/generated/flex_root_ignored.rs b/tests/generated/flex_root_ignored.rs new file mode 100644 index 000000000..9007b96e7 --- /dev/null +++ b/tests/generated/flex_root_ignored.rs @@ -0,0 +1,54 @@ +#[test] +fn flex_root_ignored() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + min_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + max_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(500f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 300f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 200f32); +} diff --git a/tests/generated/flex_shrink_by_outer_margin_with_max_size.rs b/tests/generated/flex_shrink_by_outer_margin_with_max_size.rs new file mode 100644 index 000000000..27ba85740 --- /dev/null +++ b/tests/generated/flex_shrink_by_outer_margin_with_max_size.rs @@ -0,0 +1,41 @@ +#[test] +fn flex_shrink_by_outer_margin_with_max_size() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { top: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Default::default() }, + max_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(80f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 80f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 100f32); +} diff --git a/tests/generated/flex_shrink_flex_grow_child_flex_shrink_other_child.rs b/tests/generated/flex_shrink_flex_grow_child_flex_shrink_other_child.rs new file mode 100644 index 000000000..f3969ed71 --- /dev/null +++ b/tests/generated/flex_shrink_flex_grow_child_flex_shrink_other_child.rs @@ -0,0 +1,60 @@ +#[test] +fn flex_shrink_flex_grow_child_flex_shrink_other_child() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 0f32, + flex_shrink: 1f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(500f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_shrink: 1f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(500f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(500f32), + height: taffy::style::Dimension::Points(500f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 500f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 500f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 250f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 250f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 250f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); +} diff --git a/tests/generated/flex_shrink_flex_grow_row.rs b/tests/generated/flex_shrink_flex_grow_row.rs new file mode 100644 index 000000000..d5dce82de --- /dev/null +++ b/tests/generated/flex_shrink_flex_grow_row.rs @@ -0,0 +1,60 @@ +#[test] +fn flex_shrink_flex_grow_row() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 0f32, + flex_shrink: 1f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(500f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 0f32, + flex_shrink: 1f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(500f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(500f32), + height: taffy::style::Dimension::Points(500f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 500f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 500f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 250f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 250f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 250f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); +} diff --git a/tests/generated/flex_shrink_to_zero.rs b/tests/generated/flex_shrink_to_zero.rs new file mode 100644 index 000000000..fbf3531a1 --- /dev/null +++ b/tests/generated/flex_shrink_to_zero.rs @@ -0,0 +1,72 @@ +#[test] +fn flex_shrink_to_zero() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_shrink: 1f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(75f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 75f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 50f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 50f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); +} diff --git a/tests/generated/flex_wrap_align_stretch_fits_one_row.rs b/tests/generated/flex_wrap_align_stretch_fits_one_row.rs new file mode 100644 index 000000000..cc33c9719 --- /dev/null +++ b/tests/generated/flex_wrap_align_stretch_fits_one_row.rs @@ -0,0 +1,49 @@ +#[test] +fn flex_wrap_align_stretch_fits_one_row() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_wrap: taffy::style::FlexWrap::Wrap, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(150f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 150f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 50f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); +} diff --git a/tests/generated/flex_wrap_children_with_min_main_overriding_flex_basis.rs b/tests/generated/flex_wrap_children_with_min_main_overriding_flex_basis.rs new file mode 100644 index 000000000..e23f7c493 --- /dev/null +++ b/tests/generated/flex_wrap_children_with_min_main_overriding_flex_basis.rs @@ -0,0 +1,49 @@ +#[test] +fn flex_wrap_children_with_min_main_overriding_flex_basis() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_basis: taffy::style::Dimension::Points(50f32), + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Default::default() }, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(55f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_basis: taffy::style::Dimension::Points(50f32), + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Default::default() }, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(55f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_wrap: taffy::style::FlexWrap::Wrap, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 55f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 55f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 50f32); +} diff --git a/tests/generated/flex_wrap_wrap_to_child_height.rs b/tests/generated/flex_wrap_wrap_to_child_height.rs new file mode 100644 index 000000000..e455d558e --- /dev/null +++ b/tests/generated/flex_wrap_wrap_to_child_height.rs @@ -0,0 +1,77 @@ +#[test] +fn flex_wrap_wrap_to_child_height() { + let mut taffy = taffy::Taffy::new(); + let node000 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node000], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_wrap: taffy::style::FlexWrap::Wrap, + align_items: taffy::style::AlignItems::FlexStart, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node000).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node000).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node000).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node000).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 100f32); +} diff --git a/tests/generated/justify_content_column_center.rs b/tests/generated/justify_content_column_center.rs new file mode 100644 index 000000000..d3f05cb16 --- /dev/null +++ b/tests/generated/justify_content_column_center.rs @@ -0,0 +1,63 @@ +#[test] +fn justify_content_column_center() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 35f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 45f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 55f32); +} diff --git a/tests/generated/justify_content_column_flex_end.rs b/tests/generated/justify_content_column_flex_end.rs new file mode 100644 index 000000000..32ebfd66a --- /dev/null +++ b/tests/generated/justify_content_column_flex_end.rs @@ -0,0 +1,63 @@ +#[test] +fn justify_content_column_flex_end() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + justify_content: taffy::style::JustifyContent::FlexEnd, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 70f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 90f32); +} diff --git a/tests/generated/justify_content_column_flex_start.rs b/tests/generated/justify_content_column_flex_start.rs new file mode 100644 index 000000000..39726c01b --- /dev/null +++ b/tests/generated/justify_content_column_flex_start.rs @@ -0,0 +1,62 @@ +#[test] +fn justify_content_column_flex_start() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 20f32); +} diff --git a/tests/generated/justify_content_column_min_height_and_margin_bottom.rs b/tests/generated/justify_content_column_min_height_and_margin_bottom.rs new file mode 100644 index 000000000..52659df79 --- /dev/null +++ b/tests/generated/justify_content_column_min_height_and_margin_bottom.rs @@ -0,0 +1,41 @@ +#[test] +fn justify_content_column_min_height_and_margin_bottom() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { bottom: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + justify_content: taffy::style::JustifyContent::Center, + min_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 10f32); +} diff --git a/tests/generated/justify_content_column_min_height_and_margin_top.rs b/tests/generated/justify_content_column_min_height_and_margin_top.rs new file mode 100644 index 000000000..7e9b2a5d1 --- /dev/null +++ b/tests/generated/justify_content_column_min_height_and_margin_top.rs @@ -0,0 +1,41 @@ +#[test] +fn justify_content_column_min_height_and_margin_top() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { top: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + justify_content: taffy::style::JustifyContent::Center, + min_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 20f32); +} diff --git a/tests/generated/justify_content_column_space_around.rs b/tests/generated/justify_content_column_space_around.rs new file mode 100644 index 000000000..4aedb32a7 --- /dev/null +++ b/tests/generated/justify_content_column_space_around.rs @@ -0,0 +1,63 @@ +#[test] +fn justify_content_column_space_around() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + justify_content: taffy::style::JustifyContent::SpaceAround, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 12f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 45f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 78f32); +} diff --git a/tests/generated/justify_content_column_space_between.rs b/tests/generated/justify_content_column_space_between.rs new file mode 100644 index 000000000..24539949b --- /dev/null +++ b/tests/generated/justify_content_column_space_between.rs @@ -0,0 +1,63 @@ +#[test] +fn justify_content_column_space_between() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + justify_content: taffy::style::JustifyContent::SpaceBetween, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 45f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 90f32); +} diff --git a/tests/generated/justify_content_column_space_evenly.rs b/tests/generated/justify_content_column_space_evenly.rs new file mode 100644 index 000000000..cf7c86182 --- /dev/null +++ b/tests/generated/justify_content_column_space_evenly.rs @@ -0,0 +1,63 @@ +#[test] +fn justify_content_column_space_evenly() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + justify_content: taffy::style::JustifyContent::SpaceEvenly, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 18f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 45f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 73f32); +} diff --git a/tests/generated/justify_content_min_max.rs b/tests/generated/justify_content_min_max.rs new file mode 100644 index 000000000..212801fb0 --- /dev/null +++ b/tests/generated/justify_content_min_max.rs @@ -0,0 +1,45 @@ +#[test] +fn justify_content_min_max() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + min_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + max_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 60f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 20f32); +} diff --git a/tests/generated/justify_content_min_width_with_padding_child_width_greater_than_parent.rs b/tests/generated/justify_content_min_width_with_padding_child_width_greater_than_parent.rs new file mode 100644 index 000000000..23e8da0e4 --- /dev/null +++ b/tests/generated/justify_content_min_width_with_padding_child_width_greater_than_parent.rs @@ -0,0 +1,67 @@ +#[test] +fn justify_content_min_width_with_padding_child_width_greater_than_parent() { + let mut taffy = taffy::Taffy::new(); + let node000 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(300f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + justify_content: taffy::style::JustifyContent::Center, + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(400f32), + ..Default::default() + }, + padding: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(100f32), + end: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node000], + ) + .unwrap(); + let node0 = taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[node00]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(1000f32), + height: taffy::style::Dimension::Points(1584f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 1000f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 1584f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 1000f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 500f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node000).unwrap().size.width, 300f32); + assert_eq!(taffy.layout(node000).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node000).unwrap().location.x, 100f32); + assert_eq!(taffy.layout(node000).unwrap().location.y, 0f32); +} diff --git a/tests/generated/justify_content_min_width_with_padding_child_width_lower_than_parent.rs b/tests/generated/justify_content_min_width_with_padding_child_width_lower_than_parent.rs new file mode 100644 index 000000000..2dc3fe0b3 --- /dev/null +++ b/tests/generated/justify_content_min_width_with_padding_child_width_lower_than_parent.rs @@ -0,0 +1,67 @@ +#[test] +fn justify_content_min_width_with_padding_child_width_lower_than_parent() { + let mut taffy = taffy::Taffy::new(); + let node000 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(199f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + justify_content: taffy::style::JustifyContent::Center, + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(400f32), + ..Default::default() + }, + padding: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(100f32), + end: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node000], + ) + .unwrap(); + let node0 = taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[node00]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(1080f32), + height: taffy::style::Dimension::Points(1584f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 1080f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 1584f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 1080f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 400f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node000).unwrap().size.width, 199f32); + assert_eq!(taffy.layout(node000).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node000).unwrap().location.x, 101f32); + assert_eq!(taffy.layout(node000).unwrap().location.y, 0f32); +} diff --git a/tests/generated/justify_content_overflow_min_max.rs b/tests/generated/justify_content_overflow_min_max.rs new file mode 100644 index 000000000..ffb25031a --- /dev/null +++ b/tests/generated/justify_content_overflow_min_max.rs @@ -0,0 +1,81 @@ +#[test] +fn justify_content_overflow_min_max() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + justify_content: taffy::style::JustifyContent::Center, + min_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + max_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(110f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 110f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, -20f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 30f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 80f32); +} diff --git a/tests/generated/justify_content_row_center.rs b/tests/generated/justify_content_row_center.rs new file mode 100644 index 000000000..2b11ac561 --- /dev/null +++ b/tests/generated/justify_content_row_center.rs @@ -0,0 +1,62 @@ +#[test] +fn justify_content_row_center() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 35f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 45f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 55f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); +} diff --git a/tests/generated/justify_content_row_flex_end.rs b/tests/generated/justify_content_row_flex_end.rs new file mode 100644 index 000000000..2fc811c31 --- /dev/null +++ b/tests/generated/justify_content_row_flex_end.rs @@ -0,0 +1,62 @@ +#[test] +fn justify_content_row_flex_end() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + justify_content: taffy::style::JustifyContent::FlexEnd, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 70f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 90f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); +} diff --git a/tests/generated/justify_content_row_flex_start.rs b/tests/generated/justify_content_row_flex_start.rs new file mode 100644 index 000000000..1c5397644 --- /dev/null +++ b/tests/generated/justify_content_row_flex_start.rs @@ -0,0 +1,61 @@ +#[test] +fn justify_content_row_flex_start() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 10f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 20f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); +} diff --git a/tests/generated/justify_content_row_max_width_and_margin.rs b/tests/generated/justify_content_row_max_width_and_margin.rs new file mode 100644 index 000000000..778f8884d --- /dev/null +++ b/tests/generated/justify_content_row_max_width_and_margin.rs @@ -0,0 +1,38 @@ +#[test] +fn justify_content_row_max_width_and_margin() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { start: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(80f32), ..Default::default() }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 80f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 90f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); +} diff --git a/tests/generated/justify_content_row_min_width_and_margin.rs b/tests/generated/justify_content_row_min_width_and_margin.rs new file mode 100644 index 000000000..7d7bafefc --- /dev/null +++ b/tests/generated/justify_content_row_min_width_and_margin.rs @@ -0,0 +1,37 @@ +#[test] +fn justify_content_row_min_width_and_margin() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { start: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + justify_content: taffy::style::JustifyContent::Center, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), ..Default::default() }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 20f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); +} diff --git a/tests/generated/justify_content_row_space_around.rs b/tests/generated/justify_content_row_space_around.rs new file mode 100644 index 000000000..d67481d36 --- /dev/null +++ b/tests/generated/justify_content_row_space_around.rs @@ -0,0 +1,62 @@ +#[test] +fn justify_content_row_space_around() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + justify_content: taffy::style::JustifyContent::SpaceAround, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 12f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 45f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 78f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); +} diff --git a/tests/generated/justify_content_row_space_between.rs b/tests/generated/justify_content_row_space_between.rs new file mode 100644 index 000000000..c0b45ff6d --- /dev/null +++ b/tests/generated/justify_content_row_space_between.rs @@ -0,0 +1,62 @@ +#[test] +fn justify_content_row_space_between() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + justify_content: taffy::style::JustifyContent::SpaceBetween, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 45f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 90f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); +} diff --git a/tests/generated/justify_content_row_space_evenly.rs b/tests/generated/justify_content_row_space_evenly.rs new file mode 100644 index 000000000..864f8d90c --- /dev/null +++ b/tests/generated/justify_content_row_space_evenly.rs @@ -0,0 +1,62 @@ +#[test] +fn justify_content_row_space_evenly() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + justify_content: taffy::style::JustifyContent::SpaceEvenly, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 25f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 50f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 75f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); +} diff --git a/tests/generated/margin_and_flex_column.rs b/tests/generated/margin_and_flex_column.rs new file mode 100644 index 000000000..b98a31387 --- /dev/null +++ b/tests/generated/margin_and_flex_column.rs @@ -0,0 +1,41 @@ +#[test] +fn margin_and_flex_column() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + margin: taffy::geometry::Rect { + top: taffy::style::Dimension::Points(10f32), + bottom: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 80f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 10f32); +} diff --git a/tests/generated/margin_and_flex_row.rs b/tests/generated/margin_and_flex_row.rs new file mode 100644 index 000000000..671cdc285 --- /dev/null +++ b/tests/generated/margin_and_flex_row.rs @@ -0,0 +1,40 @@ +#[test] +fn margin_and_flex_row() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + margin: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 80f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); +} diff --git a/tests/generated/margin_and_stretch_column.rs b/tests/generated/margin_and_stretch_column.rs new file mode 100644 index 000000000..2966e1044 --- /dev/null +++ b/tests/generated/margin_and_stretch_column.rs @@ -0,0 +1,41 @@ +#[test] +fn margin_and_stretch_column() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + margin: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 80f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); +} diff --git a/tests/generated/margin_and_stretch_row.rs b/tests/generated/margin_and_stretch_row.rs new file mode 100644 index 000000000..7b90aa530 --- /dev/null +++ b/tests/generated/margin_and_stretch_row.rs @@ -0,0 +1,40 @@ +#[test] +fn margin_and_stretch_row() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + margin: taffy::geometry::Rect { + top: taffy::style::Dimension::Points(10f32), + bottom: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 80f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 10f32); +} diff --git a/tests/generated/margin_auto_bottom.rs b/tests/generated/margin_auto_bottom.rs new file mode 100644 index 000000000..b5de799bd --- /dev/null +++ b/tests/generated/margin_auto_bottom.rs @@ -0,0 +1,58 @@ +#[test] +fn margin_auto_bottom() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { bottom: taffy::style::Dimension::Auto, ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 50f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 75f32); +} diff --git a/tests/generated/margin_auto_bottom_and_top.rs b/tests/generated/margin_auto_bottom_and_top.rs new file mode 100644 index 000000000..9a46cd216 --- /dev/null +++ b/tests/generated/margin_auto_bottom_and_top.rs @@ -0,0 +1,62 @@ +#[test] +fn margin_auto_bottom_and_top() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { + top: taffy::style::Dimension::Auto, + bottom: taffy::style::Dimension::Auto, + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 75f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 50f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 75f32); +} diff --git a/tests/generated/margin_auto_bottom_and_top_justify_center.rs b/tests/generated/margin_auto_bottom_and_top_justify_center.rs new file mode 100644 index 000000000..2034d6902 --- /dev/null +++ b/tests/generated/margin_auto_bottom_and_top_justify_center.rs @@ -0,0 +1,62 @@ +#[test] +fn margin_auto_bottom_and_top_justify_center() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { + top: taffy::style::Dimension::Auto, + bottom: taffy::style::Dimension::Auto, + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 50f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 75f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 100f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); +} diff --git a/tests/generated/margin_auto_left.rs b/tests/generated/margin_auto_left.rs new file mode 100644 index 000000000..ca503d944 --- /dev/null +++ b/tests/generated/margin_auto_left.rs @@ -0,0 +1,58 @@ +#[test] +fn margin_auto_left() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { start: taffy::style::Dimension::Auto, ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 75f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 150f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 75f32); +} diff --git a/tests/generated/margin_auto_left_and_right.rs b/tests/generated/margin_auto_left_and_right.rs new file mode 100644 index 000000000..4fdeabb98 --- /dev/null +++ b/tests/generated/margin_auto_left_and_right.rs @@ -0,0 +1,61 @@ +#[test] +fn margin_auto_left_and_right() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { + start: taffy::style::Dimension::Auto, + end: taffy::style::Dimension::Auto, + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 50f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 150f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); +} diff --git a/tests/generated/margin_auto_left_and_right_column.rs b/tests/generated/margin_auto_left_and_right_column.rs new file mode 100644 index 000000000..475c5e2f4 --- /dev/null +++ b/tests/generated/margin_auto_left_and_right_column.rs @@ -0,0 +1,62 @@ +#[test] +fn margin_auto_left_and_right_column() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { + start: taffy::style::Dimension::Auto, + end: taffy::style::Dimension::Auto, + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 50f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 75f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 150f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 75f32); +} diff --git a/tests/generated/margin_auto_left_and_right_column_and_center.rs b/tests/generated/margin_auto_left_and_right_column_and_center.rs new file mode 100644 index 000000000..7b078ad2d --- /dev/null +++ b/tests/generated/margin_auto_left_and_right_column_and_center.rs @@ -0,0 +1,62 @@ +#[test] +fn margin_auto_left_and_right_column_and_center() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { + start: taffy::style::Dimension::Auto, + end: taffy::style::Dimension::Auto, + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 50f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 75f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 150f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 75f32); +} diff --git a/tests/generated/margin_auto_left_and_right_strech.rs b/tests/generated/margin_auto_left_and_right_strech.rs new file mode 100644 index 000000000..6511948ce --- /dev/null +++ b/tests/generated/margin_auto_left_and_right_strech.rs @@ -0,0 +1,61 @@ +#[test] +fn margin_auto_left_and_right_strech() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { + start: taffy::style::Dimension::Auto, + end: taffy::style::Dimension::Auto, + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 50f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 150f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); +} diff --git a/tests/generated/margin_auto_left_child_bigger_than_parent.rs b/tests/generated/margin_auto_left_child_bigger_than_parent.rs new file mode 100644 index 000000000..feb672407 --- /dev/null +++ b/tests/generated/margin_auto_left_child_bigger_than_parent.rs @@ -0,0 +1,41 @@ +#[test] +fn margin_auto_left_child_bigger_than_parent() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(72f32), + height: taffy::style::Dimension::Points(72f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { start: taffy::style::Dimension::Auto, ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(52f32), + height: taffy::style::Dimension::Points(52f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 52f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 52f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 52f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 72f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); +} diff --git a/tests/generated/margin_auto_left_fix_right_child_bigger_than_parent.rs b/tests/generated/margin_auto_left_fix_right_child_bigger_than_parent.rs new file mode 100644 index 000000000..02fea8631 --- /dev/null +++ b/tests/generated/margin_auto_left_fix_right_child_bigger_than_parent.rs @@ -0,0 +1,45 @@ +#[test] +fn margin_auto_left_fix_right_child_bigger_than_parent() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(72f32), + height: taffy::style::Dimension::Points(72f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { + start: taffy::style::Dimension::Auto, + end: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(52f32), + height: taffy::style::Dimension::Points(52f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 52f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 52f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 42f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 72f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); +} diff --git a/tests/generated/margin_auto_left_right_child_bigger_than_parent.rs b/tests/generated/margin_auto_left_right_child_bigger_than_parent.rs new file mode 100644 index 000000000..e71536d78 --- /dev/null +++ b/tests/generated/margin_auto_left_right_child_bigger_than_parent.rs @@ -0,0 +1,45 @@ +#[test] +fn margin_auto_left_right_child_bigger_than_parent() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(72f32), + height: taffy::style::Dimension::Points(72f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { + start: taffy::style::Dimension::Auto, + end: taffy::style::Dimension::Auto, + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(52f32), + height: taffy::style::Dimension::Points(52f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 52f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 52f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 52f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 72f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); +} diff --git a/tests/generated/margin_auto_left_stretching_child.rs b/tests/generated/margin_auto_left_stretching_child.rs new file mode 100644 index 000000000..c632a824b --- /dev/null +++ b/tests/generated/margin_auto_left_stretching_child.rs @@ -0,0 +1,56 @@ +#[test] +fn margin_auto_left_stretching_child() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + margin: taffy::geometry::Rect { start: taffy::style::Dimension::Auto, ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 150f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 100f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 150f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 75f32); +} diff --git a/tests/generated/margin_auto_mutiple_children_column.rs b/tests/generated/margin_auto_mutiple_children_column.rs new file mode 100644 index 000000000..22f93a94d --- /dev/null +++ b/tests/generated/margin_auto_mutiple_children_column.rs @@ -0,0 +1,77 @@ +#[test] +fn margin_auto_mutiple_children_column() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { top: taffy::style::Dimension::Auto, ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { top: taffy::style::Dimension::Auto, ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + align_items: taffy::style::AlignItems::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 75f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 25f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 75f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 100f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 75f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 150f32); +} diff --git a/tests/generated/margin_auto_mutiple_children_row.rs b/tests/generated/margin_auto_mutiple_children_row.rs new file mode 100644 index 000000000..499f33a84 --- /dev/null +++ b/tests/generated/margin_auto_mutiple_children_row.rs @@ -0,0 +1,76 @@ +#[test] +fn margin_auto_mutiple_children_row() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { end: taffy::style::Dimension::Auto, ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { end: taffy::style::Dimension::Auto, ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 75f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 75f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 75f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 150f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 75f32); +} diff --git a/tests/generated/margin_auto_right.rs b/tests/generated/margin_auto_right.rs new file mode 100644 index 000000000..c0a696325 --- /dev/null +++ b/tests/generated/margin_auto_right.rs @@ -0,0 +1,58 @@ +#[test] +fn margin_auto_right() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { end: taffy::style::Dimension::Auto, ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 75f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 150f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 75f32); +} diff --git a/tests/generated/margin_auto_top.rs b/tests/generated/margin_auto_top.rs new file mode 100644 index 000000000..d21ca6bf2 --- /dev/null +++ b/tests/generated/margin_auto_top.rs @@ -0,0 +1,58 @@ +#[test] +fn margin_auto_top() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { top: taffy::style::Dimension::Auto, ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 150f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 50f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 75f32); +} diff --git a/tests/generated/margin_auto_top_and_bottom_strech.rs b/tests/generated/margin_auto_top_and_bottom_strech.rs new file mode 100644 index 000000000..1834be931 --- /dev/null +++ b/tests/generated/margin_auto_top_and_bottom_strech.rs @@ -0,0 +1,62 @@ +#[test] +fn margin_auto_top_and_bottom_strech() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { + top: taffy::style::Dimension::Auto, + bottom: taffy::style::Dimension::Auto, + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 150f32); +} diff --git a/tests/generated/margin_auto_top_stretching_child.rs b/tests/generated/margin_auto_top_stretching_child.rs new file mode 100644 index 000000000..8c079cb23 --- /dev/null +++ b/tests/generated/margin_auto_top_stretching_child.rs @@ -0,0 +1,56 @@ +#[test] +fn margin_auto_top_stretching_child() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + margin: taffy::geometry::Rect { top: taffy::style::Dimension::Auto, ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 150f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 200f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 150f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 75f32); +} diff --git a/tests/generated/margin_bottom.rs b/tests/generated/margin_bottom.rs new file mode 100644 index 000000000..c98be74a8 --- /dev/null +++ b/tests/generated/margin_bottom.rs @@ -0,0 +1,38 @@ +#[test] +fn margin_bottom() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + margin: taffy::geometry::Rect { bottom: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + justify_content: taffy::style::JustifyContent::FlexEnd, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 80f32); +} diff --git a/tests/generated/margin_fix_left_auto_right_child_bigger_than_parent.rs b/tests/generated/margin_fix_left_auto_right_child_bigger_than_parent.rs new file mode 100644 index 000000000..89962ee23 --- /dev/null +++ b/tests/generated/margin_fix_left_auto_right_child_bigger_than_parent.rs @@ -0,0 +1,45 @@ +#[test] +fn margin_fix_left_auto_right_child_bigger_than_parent() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(72f32), + height: taffy::style::Dimension::Points(72f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Auto, + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(52f32), + height: taffy::style::Dimension::Points(52f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 52f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 52f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 42f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 72f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); +} diff --git a/tests/generated/margin_left.rs b/tests/generated/margin_left.rs new file mode 100644 index 000000000..91e0ce223 --- /dev/null +++ b/tests/generated/margin_left.rs @@ -0,0 +1,36 @@ +#[test] +fn margin_left() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + margin: taffy::geometry::Rect { start: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); +} diff --git a/tests/generated/margin_right.rs b/tests/generated/margin_right.rs new file mode 100644 index 000000000..8903b7abc --- /dev/null +++ b/tests/generated/margin_right.rs @@ -0,0 +1,37 @@ +#[test] +fn margin_right() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + margin: taffy::geometry::Rect { end: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + justify_content: taffy::style::JustifyContent::FlexEnd, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); +} diff --git a/tests/generated/margin_should_not_be_part_of_max_height.rs b/tests/generated/margin_should_not_be_part_of_max_height.rs new file mode 100644 index 000000000..7e5361f7e --- /dev/null +++ b/tests/generated/margin_should_not_be_part_of_max_height.rs @@ -0,0 +1,44 @@ +#[test] +fn margin_should_not_be_part_of_max_height() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + max_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { top: taffy::style::Dimension::Points(20f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(250f32), + height: taffy::style::Dimension::Points(250f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 250f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 250f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 20f32); +} diff --git a/tests/generated/margin_should_not_be_part_of_max_width.rs b/tests/generated/margin_should_not_be_part_of_max_width.rs new file mode 100644 index 000000000..8a94264df --- /dev/null +++ b/tests/generated/margin_should_not_be_part_of_max_width.rs @@ -0,0 +1,44 @@ +#[test] +fn margin_should_not_be_part_of_max_width() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { start: taffy::style::Dimension::Points(20f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(250f32), + height: taffy::style::Dimension::Points(250f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 250f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 250f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 20f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); +} diff --git a/tests/generated/margin_top.rs b/tests/generated/margin_top.rs new file mode 100644 index 000000000..37b6438c6 --- /dev/null +++ b/tests/generated/margin_top.rs @@ -0,0 +1,37 @@ +#[test] +fn margin_top() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + margin: taffy::geometry::Rect { top: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 10f32); +} diff --git a/tests/generated/margin_with_sibling_column.rs b/tests/generated/margin_with_sibling_column.rs new file mode 100644 index 000000000..81bba7b1d --- /dev/null +++ b/tests/generated/margin_with_sibling_column.rs @@ -0,0 +1,43 @@ +#[test] +fn margin_with_sibling_column() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + margin: taffy::geometry::Rect { bottom: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 45f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 45f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 55f32); +} diff --git a/tests/generated/margin_with_sibling_row.rs b/tests/generated/margin_with_sibling_row.rs new file mode 100644 index 000000000..c9475b8d0 --- /dev/null +++ b/tests/generated/margin_with_sibling_row.rs @@ -0,0 +1,42 @@ +#[test] +fn margin_with_sibling_row() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + margin: taffy::geometry::Rect { end: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 45f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 45f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 55f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); +} diff --git a/tests/generated/max_height.rs b/tests/generated/max_height.rs new file mode 100644 index 000000000..ac56d96b0 --- /dev/null +++ b/tests/generated/max_height.rs @@ -0,0 +1,39 @@ +#[test] +fn max_height() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + max_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); +} diff --git a/tests/generated/max_height_overrides_height.rs b/tests/generated/max_height_overrides_height.rs new file mode 100644 index 000000000..98c934930 --- /dev/null +++ b/tests/generated/max_height_overrides_height.rs @@ -0,0 +1,27 @@ +#[test] +fn max_height_overrides_height() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(200f32), ..Default::default() }, + max_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[node0]).unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); +} diff --git a/tests/generated/max_height_overrides_height_on_root.rs b/tests/generated/max_height_overrides_height_on_root.rs new file mode 100644 index 000000000..41568816a --- /dev/null +++ b/tests/generated/max_height_overrides_height_on_root.rs @@ -0,0 +1,22 @@ +#[test] +fn max_height_overrides_height_on_root() { + let mut taffy = taffy::Taffy::new(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(200f32), ..Default::default() }, + max_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); +} diff --git a/tests/generated/max_width.rs b/tests/generated/max_width.rs new file mode 100644 index 000000000..445c263eb --- /dev/null +++ b/tests/generated/max_width.rs @@ -0,0 +1,37 @@ +#[test] +fn max_width() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); +} diff --git a/tests/generated/max_width_overrides_width.rs b/tests/generated/max_width_overrides_width.rs new file mode 100644 index 000000000..eca6bd279 --- /dev/null +++ b/tests/generated/max_width_overrides_width.rs @@ -0,0 +1,27 @@ +#[test] +fn max_width_overrides_width() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), ..Default::default() }, + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[node0]).unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); +} diff --git a/tests/generated/max_width_overrides_width_on_root.rs b/tests/generated/max_width_overrides_width_on_root.rs new file mode 100644 index 000000000..5726f3649 --- /dev/null +++ b/tests/generated/max_width_overrides_width_on_root.rs @@ -0,0 +1,22 @@ +#[test] +fn max_width_overrides_width_on_root() { + let mut taffy = taffy::Taffy::new(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), ..Default::default() }, + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); +} diff --git a/tests/generated/min_height.rs b/tests/generated/min_height.rs new file mode 100644 index 000000000..77fdd9471 --- /dev/null +++ b/tests/generated/min_height.rs @@ -0,0 +1,46 @@ +#[test] +fn min_height() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + min_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(60f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 60f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 60f32); +} diff --git a/tests/generated/min_height_overrides_height.rs b/tests/generated/min_height_overrides_height.rs new file mode 100644 index 000000000..7daa7aa7b --- /dev/null +++ b/tests/generated/min_height_overrides_height.rs @@ -0,0 +1,27 @@ +#[test] +fn min_height_overrides_height() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Default::default() }, + min_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[node0]).unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); +} diff --git a/tests/generated/min_height_overrides_height_on_root.rs b/tests/generated/min_height_overrides_height_on_root.rs new file mode 100644 index 000000000..94ae666a1 --- /dev/null +++ b/tests/generated/min_height_overrides_height_on_root.rs @@ -0,0 +1,22 @@ +#[test] +fn min_height_overrides_height_on_root() { + let mut taffy = taffy::Taffy::new(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Default::default() }, + min_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); +} diff --git a/tests/generated/min_max_percent_no_width_height.rs b/tests/generated/min_max_percent_no_width_height.rs new file mode 100644 index 000000000..0f98df176 --- /dev/null +++ b/tests/generated/min_max_percent_no_width_height.rs @@ -0,0 +1,46 @@ +#[test] +fn min_max_percent_no_width_height() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.1f32), + height: taffy::style::Dimension::Percent(0.1f32), + ..Default::default() + }, + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.1f32), + height: taffy::style::Dimension::Percent(0.1f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + align_items: taffy::style::AlignItems::FlexStart, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); +} diff --git a/tests/generated/min_width.rs b/tests/generated/min_width.rs new file mode 100644 index 000000000..83b877818 --- /dev/null +++ b/tests/generated/min_width.rs @@ -0,0 +1,42 @@ +#[test] +fn min_width() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 60f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); +} diff --git a/tests/generated/min_width_overrides_width.rs b/tests/generated/min_width_overrides_width.rs new file mode 100644 index 000000000..ce9be599b --- /dev/null +++ b/tests/generated/min_width_overrides_width.rs @@ -0,0 +1,27 @@ +#[test] +fn min_width_overrides_width() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), ..Default::default() }, + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[node0]).unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); +} diff --git a/tests/generated/min_width_overrides_width_on_root.rs b/tests/generated/min_width_overrides_width_on_root.rs new file mode 100644 index 000000000..c45ea3a42 --- /dev/null +++ b/tests/generated/min_width_overrides_width_on_root.rs @@ -0,0 +1,22 @@ +#[test] +fn min_width_overrides_width_on_root() { + let mut taffy = taffy::Taffy::new(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), ..Default::default() }, + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); +} diff --git a/tests/generated/mod.rs b/tests/generated/mod.rs new file mode 100644 index 000000000..561cf4ae2 --- /dev/null +++ b/tests/generated/mod.rs @@ -0,0 +1,238 @@ +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; +mod absolute_layout_align_items_and_justify_content_center_and_right_position; +mod absolute_layout_align_items_and_justify_content_center_and_top_position; +mod absolute_layout_align_items_and_justify_content_flex_end; +mod absolute_layout_align_items_center; +mod absolute_layout_align_items_center_on_child_only; +mod absolute_layout_child_order; +mod absolute_layout_in_wrap_reverse_column_container; +mod absolute_layout_in_wrap_reverse_column_container_flex_end; +mod absolute_layout_in_wrap_reverse_row_container; +mod absolute_layout_in_wrap_reverse_row_container_flex_end; +mod absolute_layout_justify_content_center; +mod absolute_layout_no_size; +mod absolute_layout_percentage_bottom_based_on_parent_height; +mod absolute_layout_start_top_end_bottom; +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 align_baseline; +mod align_baseline_child_multiline; +mod align_baseline_nested_child; +mod align_center_should_size_based_on_content; +mod align_flex_start_with_shrinking_children; +mod align_flex_start_with_shrinking_children_with_stretch; +mod align_flex_start_with_stretching_children; +mod align_items_center; +mod align_items_center_child_with_margin_bigger_than_parent; +mod align_items_center_child_without_margin_bigger_than_parent; +mod align_items_center_with_child_margin; +mod align_items_center_with_child_top; +mod align_items_flex_end; +mod align_items_flex_end_child_with_margin_bigger_than_parent; +mod align_items_flex_end_child_without_margin_bigger_than_parent; +mod align_items_flex_start; +mod align_items_min_max; +mod align_items_stretch; +mod align_self_baseline; +mod align_self_center; +mod align_self_flex_end; +mod align_self_flex_end_override_flex_start; +mod align_self_flex_start; +mod align_strech_should_size_based_on_parent; +mod border_center_child; +mod border_flex_child; +mod border_no_child; +mod border_stretch_child; +mod child_min_max_width_flexing; +mod container_with_unsized_child; +mod display_none; +mod display_none_fixed_size; +mod display_none_with_child; +mod display_none_with_margin; +mod display_none_with_position; +mod flex_basis_and_main_dimen_set_when_flexing; +mod flex_basis_flex_grow_column; +mod flex_basis_flex_grow_row; +mod flex_basis_flex_shrink_column; +mod flex_basis_flex_shrink_row; +mod flex_basis_larger_than_content_column; +mod flex_basis_larger_than_content_row; +mod flex_basis_overrides_main_size; +mod flex_basis_slightly_smaller_then_content_with_flex_grow_large_size; +mod flex_basis_smaller_than_content_column; +mod flex_basis_smaller_than_content_row; +mod flex_basis_smaller_than_main_dimen_column; +mod flex_basis_smaller_than_main_dimen_row; +mod flex_basis_smaller_then_content_with_flex_grow_large_size; +mod flex_basis_smaller_then_content_with_flex_grow_small_size; +mod flex_basis_smaller_then_content_with_flex_grow_unconstraint_size; +mod flex_basis_smaller_then_content_with_flex_grow_very_large_size; +mod flex_basis_unconstraint_column; +mod flex_basis_unconstraint_row; +mod flex_direction_column; +mod flex_direction_column_no_height; +mod flex_direction_column_reverse; +mod flex_direction_row; +mod flex_direction_row_no_width; +mod flex_direction_row_reverse; +mod flex_grow_child; +mod flex_grow_flex_basis_percent_min_max; +mod flex_grow_height_maximized; +mod flex_grow_in_at_most_container; +mod flex_grow_less_than_factor_one; +mod flex_grow_root_minimized; +mod flex_grow_shrink_at_most; +mod flex_grow_to_min; +mod flex_grow_within_constrained_max_column; +mod flex_grow_within_constrained_max_row; +mod flex_grow_within_constrained_max_width; +mod flex_grow_within_constrained_min_column; +mod flex_grow_within_constrained_min_max_column; +mod flex_grow_within_constrained_min_row; +mod flex_grow_within_max_width; +mod flex_root_ignored; +mod flex_shrink_by_outer_margin_with_max_size; +mod flex_shrink_flex_grow_child_flex_shrink_other_child; +mod flex_shrink_flex_grow_row; +mod flex_shrink_to_zero; +mod flex_wrap_align_stretch_fits_one_row; +mod flex_wrap_children_with_min_main_overriding_flex_basis; +mod flex_wrap_wrap_to_child_height; +mod justify_content_column_center; +mod justify_content_column_flex_end; +mod justify_content_column_flex_start; +mod justify_content_column_min_height_and_margin_bottom; +mod justify_content_column_min_height_and_margin_top; +mod justify_content_column_space_around; +mod justify_content_column_space_between; +mod justify_content_column_space_evenly; +mod justify_content_min_max; +mod justify_content_min_width_with_padding_child_width_greater_than_parent; +mod justify_content_min_width_with_padding_child_width_lower_than_parent; +mod justify_content_overflow_min_max; +mod justify_content_row_center; +mod justify_content_row_flex_end; +mod justify_content_row_flex_start; +mod justify_content_row_max_width_and_margin; +mod justify_content_row_min_width_and_margin; +mod justify_content_row_space_around; +mod justify_content_row_space_between; +mod justify_content_row_space_evenly; +mod margin_and_flex_column; +mod margin_and_flex_row; +mod margin_and_stretch_column; +mod margin_and_stretch_row; +mod margin_auto_bottom; +mod margin_auto_bottom_and_top; +mod margin_auto_bottom_and_top_justify_center; +mod margin_auto_left; +mod margin_auto_left_and_right; +mod margin_auto_left_and_right_column; +mod margin_auto_left_and_right_column_and_center; +mod margin_auto_left_and_right_strech; +mod margin_auto_left_child_bigger_than_parent; +mod margin_auto_left_fix_right_child_bigger_than_parent; +mod margin_auto_left_right_child_bigger_than_parent; +mod margin_auto_left_stretching_child; +mod margin_auto_mutiple_children_column; +mod margin_auto_mutiple_children_row; +mod margin_auto_right; +mod margin_auto_top; +mod margin_auto_top_and_bottom_strech; +mod margin_auto_top_stretching_child; +mod margin_bottom; +mod margin_fix_left_auto_right_child_bigger_than_parent; +mod margin_left; +mod margin_right; +mod margin_should_not_be_part_of_max_height; +mod margin_should_not_be_part_of_max_width; +mod margin_top; +mod margin_with_sibling_column; +mod margin_with_sibling_row; +mod max_height; +mod max_height_overrides_height; +mod max_height_overrides_height_on_root; +mod max_width; +mod max_width_overrides_width; +mod max_width_overrides_width_on_root; +mod min_height; +mod min_height_overrides_height; +mod min_height_overrides_height_on_root; +mod min_max_percent_no_width_height; +mod min_width; +mod min_width_overrides_width; +mod min_width_overrides_width_on_root; +mod nested_overflowing_child; +mod nested_overflowing_child_in_constraint_parent; +mod overflow_cross_axis; +mod overflow_main_axis; +mod padding_align_end_child; +mod padding_center_child; +mod padding_flex_child; +mod padding_no_child; +mod padding_stretch_child; +mod parent_wrap_child_size_overflowing_parent; +mod percent_absolute_position; +mod percent_within_flex_grow; +mod percentage_absolute_position; +mod percentage_container_in_wrapping_container; +mod percentage_flex_basis; +mod percentage_flex_basis_cross; +mod percentage_flex_basis_cross_max_height; +mod percentage_flex_basis_cross_max_width; +mod percentage_flex_basis_cross_min_height; +mod percentage_flex_basis_cross_min_width; +mod percentage_flex_basis_main_max_height; +mod percentage_flex_basis_main_max_width; +mod percentage_flex_basis_main_min_width; +mod percentage_margin_should_calculate_based_only_on_width; +mod percentage_multiple_nested_with_padding_margin_and_percentage_values; +mod percentage_padding_should_calculate_based_only_on_width; +mod percentage_position_bottom_right; +mod percentage_position_left_top; +mod percentage_size_based_on_parent_inner_size; +mod percentage_size_of_flex_basis; +mod percentage_width_height; +mod percentage_width_height_undefined_parent_size; +mod relative_position_should_not_nudge_siblings; +mod rounding_flex_basis_flex_grow_row_prime_number_width; +mod rounding_flex_basis_flex_grow_row_width_of_100; +mod rounding_flex_basis_flex_shrink_row; +mod rounding_flex_basis_overrides_main_size; +mod rounding_fractial_input_1; +mod rounding_fractial_input_2; +mod rounding_fractial_input_3; +mod rounding_fractial_input_4; +mod rounding_total_fractial; +mod rounding_total_fractial_nested; +mod size_defined_by_child; +mod size_defined_by_child_with_border; +mod size_defined_by_child_with_padding; +mod size_defined_by_grand_child; +mod width_smaller_then_content_with_flex_grow_large_size; +mod width_smaller_then_content_with_flex_grow_small_size; +mod width_smaller_then_content_with_flex_grow_unconstraint_size; +mod width_smaller_then_content_with_flex_grow_very_large_size; +mod wrap_column; +mod wrap_nodes_with_content_sizing_margin_cross; +mod wrap_nodes_with_content_sizing_overflowing_margin; +mod wrap_reverse_column; +mod wrap_reverse_column_fixed_size; +mod wrap_reverse_row; +mod wrap_reverse_row_align_content_center; +mod wrap_reverse_row_align_content_flex_start; +mod wrap_reverse_row_align_content_space_around; +mod wrap_reverse_row_align_content_stretch; +mod wrap_reverse_row_single_line_different_size; +mod wrap_row; +mod wrap_row_align_items_center; +mod wrap_row_align_items_flex_end; +mod wrapped_column_max_height; +mod wrapped_column_max_height_flex; +mod wrapped_row_within_align_items_center; +mod wrapped_row_within_align_items_flex_end; +mod wrapped_row_within_align_items_flex_start; diff --git a/tests/generated/nested_overflowing_child.rs b/tests/generated/nested_overflowing_child.rs new file mode 100644 index 000000000..4515cf275 --- /dev/null +++ b/tests/generated/nested_overflowing_child.rs @@ -0,0 +1,44 @@ +#[test] +fn nested_overflowing_child() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[node00]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); +} diff --git a/tests/generated/nested_overflowing_child_in_constraint_parent.rs b/tests/generated/nested_overflowing_child_in_constraint_parent.rs new file mode 100644 index 000000000..ca84c3ff9 --- /dev/null +++ b/tests/generated/nested_overflowing_child_in_constraint_parent.rs @@ -0,0 +1,56 @@ +#[test] +fn nested_overflowing_child_in_constraint_parent() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); +} diff --git a/tests/generated/overflow_cross_axis.rs b/tests/generated/overflow_cross_axis.rs new file mode 100644 index 000000000..c9fc72e0a --- /dev/null +++ b/tests/generated/overflow_cross_axis.rs @@ -0,0 +1,39 @@ +#[test] +fn overflow_cross_axis() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); +} diff --git a/tests/generated/overflow_main_axis.rs b/tests/generated/overflow_main_axis.rs new file mode 100644 index 000000000..66b16c11a --- /dev/null +++ b/tests/generated/overflow_main_axis.rs @@ -0,0 +1,36 @@ +#[test] +fn overflow_main_axis() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_shrink: 0f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); +} diff --git a/tests/generated/padding_align_end_child.rs b/tests/generated/padding_align_end_child.rs new file mode 100644 index 000000000..c224ef229 --- /dev/null +++ b/tests/generated/padding_align_end_child.rs @@ -0,0 +1,48 @@ +#[test] +fn padding_align_end_child() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + padding: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(20f32), + end: taffy::style::Dimension::Points(20f32), + top: taffy::style::Dimension::Points(20f32), + bottom: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::FlexEnd, + justify_content: taffy::style::JustifyContent::FlexEnd, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 100f32); +} diff --git a/tests/generated/padding_center_child.rs b/tests/generated/padding_center_child.rs new file mode 100644 index 000000000..056eae758 --- /dev/null +++ b/tests/generated/padding_center_child.rs @@ -0,0 +1,48 @@ +#[test] +fn padding_center_child() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_items: taffy::style::AlignItems::Center, + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + padding: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Points(20f32), + top: taffy::style::Dimension::Points(10f32), + bottom: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 40f32); +} diff --git a/tests/generated/padding_flex_child.rs b/tests/generated/padding_flex_child.rs new file mode 100644 index 000000000..3ea358a9e --- /dev/null +++ b/tests/generated/padding_flex_child.rs @@ -0,0 +1,43 @@ +#[test] +fn padding_flex_child() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + padding: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Points(10f32), + top: taffy::style::Dimension::Points(10f32), + bottom: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 80f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 80f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 10f32); +} diff --git a/tests/generated/padding_no_child.rs b/tests/generated/padding_no_child.rs new file mode 100644 index 000000000..8bb91c885 --- /dev/null +++ b/tests/generated/padding_no_child.rs @@ -0,0 +1,24 @@ +#[test] +fn padding_no_child() { + let mut taffy = taffy::Taffy::new(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + padding: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Points(10f32), + top: taffy::style::Dimension::Points(10f32), + bottom: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); +} diff --git a/tests/generated/padding_stretch_child.rs b/tests/generated/padding_stretch_child.rs new file mode 100644 index 000000000..ce6e1fb1d --- /dev/null +++ b/tests/generated/padding_stretch_child.rs @@ -0,0 +1,42 @@ +#[test] +fn padding_stretch_child() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + padding: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Points(10f32), + top: taffy::style::Dimension::Points(10f32), + bottom: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 10f32); +} diff --git a/tests/generated/parent_wrap_child_size_overflowing_parent.rs b/tests/generated/parent_wrap_child_size_overflowing_parent.rs new file mode 100644 index 000000000..4c9e9242a --- /dev/null +++ b/tests/generated/parent_wrap_child_size_overflowing_parent.rs @@ -0,0 +1,52 @@ +#[test] +fn parent_wrap_child_size_overflowing_parent() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); +} diff --git a/tests/generated/percent_absolute_position.rs b/tests/generated/percent_absolute_position.rs new file mode 100644 index 000000000..43eddf582 --- /dev/null +++ b/tests/generated/percent_absolute_position.rs @@ -0,0 +1,71 @@ +#[test] +fn percent_absolute_position() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node01 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(1f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + position: taffy::geometry::Rect { + start: taffy::style::Dimension::Percent(0.5f32), + ..Default::default() + }, + ..Default::default() + }, + &[node00, node01], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 30f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node01).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node01).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node01).unwrap().location.x, 30f32); + assert_eq!(taffy.layout(node01).unwrap().location.y, 0f32); +} diff --git a/tests/generated/percent_within_flex_grow.rs b/tests/generated/percent_within_flex_grow.rs new file mode 100644 index 000000000..52c0e9079 --- /dev/null +++ b/tests/generated/percent_within_flex_grow.rs @@ -0,0 +1,75 @@ +#[test] +fn percent_within_flex_grow() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node10 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + ..Default::default() + }, + &[node10], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(350f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 350f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 150f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 100f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node10).unwrap().size.width, 150f32); + assert_eq!(taffy.layout(node10).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node10).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node10).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 250f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); +} diff --git a/tests/generated/percentage_absolute_position.rs b/tests/generated/percentage_absolute_position.rs new file mode 100644 index 000000000..4fd8b7f5f --- /dev/null +++ b/tests/generated/percentage_absolute_position.rs @@ -0,0 +1,46 @@ +#[test] +fn percentage_absolute_position() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + position: taffy::geometry::Rect { + start: taffy::style::Dimension::Percent(0.3f32), + top: taffy::style::Dimension::Percent(0.1f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 60f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 10f32); +} diff --git a/tests/generated/percentage_container_in_wrapping_container.rs b/tests/generated/percentage_container_in_wrapping_container.rs new file mode 100644 index 000000000..155dd61df --- /dev/null +++ b/tests/generated/percentage_container_in_wrapping_container.rs @@ -0,0 +1,83 @@ +#[test] +fn percentage_container_in_wrapping_container() { + let mut taffy = taffy::Taffy::new(); + let node000 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node001 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), ..Default::default() }, + ..Default::default() + }, + &[node000, node001], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + align_items: taffy::style::AlignItems::Center, + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 50f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 75f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node000).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node000).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node000).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node000).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node001).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node001).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node001).unwrap().location.x, 50f32); + assert_eq!(taffy.layout(node001).unwrap().location.y, 0f32); +} diff --git a/tests/generated/percentage_flex_basis.rs b/tests/generated/percentage_flex_basis.rs new file mode 100644 index 000000000..0438d18d9 --- /dev/null +++ b/tests/generated/percentage_flex_basis.rs @@ -0,0 +1,50 @@ +#[test] +fn percentage_flex_basis() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.5f32), + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.25f32), + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 125f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 75f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 125f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); +} diff --git a/tests/generated/percentage_flex_basis_cross.rs b/tests/generated/percentage_flex_basis_cross.rs new file mode 100644 index 000000000..60ac6fdcf --- /dev/null +++ b/tests/generated/percentage_flex_basis_cross.rs @@ -0,0 +1,51 @@ +#[test] +fn percentage_flex_basis_cross() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.5f32), + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.25f32), + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(400f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 400f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 250f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 150f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 250f32); +} diff --git a/tests/generated/percentage_flex_basis_cross_max_height.rs b/tests/generated/percentage_flex_basis_cross_max_height.rs new file mode 100644 index 000000000..899873792 --- /dev/null +++ b/tests/generated/percentage_flex_basis_cross_max_height.rs @@ -0,0 +1,59 @@ +#[test] +fn percentage_flex_basis_cross_max_height() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + max_size: taffy::geometry::Size { + height: taffy::style::Dimension::Percent(0.6f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 4f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + max_size: taffy::geometry::Size { + height: taffy::style::Dimension::Percent(0.2f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(400f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 400f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 240f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 80f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 240f32); +} diff --git a/tests/generated/percentage_flex_basis_cross_max_width.rs b/tests/generated/percentage_flex_basis_cross_max_width.rs new file mode 100644 index 000000000..a0b4c8216 --- /dev/null +++ b/tests/generated/percentage_flex_basis_cross_max_width.rs @@ -0,0 +1,59 @@ +#[test] +fn percentage_flex_basis_cross_max_width() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.6f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 4f32, + flex_basis: taffy::style::Dimension::Percent(0.15f32), + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.2f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(400f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 400f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 120f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 300f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 100f32); +} diff --git a/tests/generated/percentage_flex_basis_cross_min_height.rs b/tests/generated/percentage_flex_basis_cross_min_height.rs new file mode 100644 index 000000000..7dbb75119 --- /dev/null +++ b/tests/generated/percentage_flex_basis_cross_min_height.rs @@ -0,0 +1,57 @@ +#[test] +fn percentage_flex_basis_cross_min_height() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + min_size: taffy::geometry::Size { + height: taffy::style::Dimension::Percent(0.6f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 2f32, + min_size: taffy::geometry::Size { + height: taffy::style::Dimension::Percent(0.1f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(400f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 400f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 240f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 160f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 240f32); +} diff --git a/tests/generated/percentage_flex_basis_cross_min_width.rs b/tests/generated/percentage_flex_basis_cross_min_width.rs new file mode 100644 index 000000000..fa4c28826 --- /dev/null +++ b/tests/generated/percentage_flex_basis_cross_min_width.rs @@ -0,0 +1,59 @@ +#[test] +fn percentage_flex_basis_cross_min_width() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.6f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 4f32, + flex_basis: taffy::style::Dimension::Percent(0.15f32), + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.2f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(400f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 400f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 300f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 100f32); +} diff --git a/tests/generated/percentage_flex_basis_main_max_height.rs b/tests/generated/percentage_flex_basis_main_max_height.rs new file mode 100644 index 000000000..6e41bfdb9 --- /dev/null +++ b/tests/generated/percentage_flex_basis_main_max_height.rs @@ -0,0 +1,58 @@ +#[test] +fn percentage_flex_basis_main_max_height() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + max_size: taffy::geometry::Size { + height: taffy::style::Dimension::Percent(0.6f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 4f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + max_size: taffy::geometry::Size { + height: taffy::style::Dimension::Percent(0.2f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(400f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 400f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 52f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 240f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 148f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 80f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 52f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); +} diff --git a/tests/generated/percentage_flex_basis_main_max_width.rs b/tests/generated/percentage_flex_basis_main_max_width.rs new file mode 100644 index 000000000..fbc2634dc --- /dev/null +++ b/tests/generated/percentage_flex_basis_main_max_width.rs @@ -0,0 +1,58 @@ +#[test] +fn percentage_flex_basis_main_max_width() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.15f32), + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.6f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 4f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.2f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(400f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 400f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 120f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 400f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 400f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); +} diff --git a/tests/generated/percentage_flex_basis_main_min_width.rs b/tests/generated/percentage_flex_basis_main_min_width.rs new file mode 100644 index 000000000..e625bf832 --- /dev/null +++ b/tests/generated/percentage_flex_basis_main_min_width.rs @@ -0,0 +1,58 @@ +#[test] +fn percentage_flex_basis_main_min_width() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.15f32), + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.6f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 4f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.2f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(400f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 400f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 120f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 400f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 80f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 400f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); +} diff --git a/tests/generated/percentage_margin_should_calculate_based_only_on_width.rs b/tests/generated/percentage_margin_should_calculate_based_only_on_width.rs new file mode 100644 index 000000000..157f98e78 --- /dev/null +++ b/tests/generated/percentage_margin_should_calculate_based_only_on_width.rs @@ -0,0 +1,61 @@ +#[test] +fn percentage_margin_should_calculate_based_only_on_width() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + margin: taffy::geometry::Rect { + start: taffy::style::Dimension::Percent(0.1f32), + end: taffy::style::Dimension::Percent(0.1f32), + top: taffy::style::Dimension::Percent(0.1f32), + bottom: taffy::style::Dimension::Percent(0.1f32), + ..Default::default() + }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 160f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 60f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 20f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 20f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); +} diff --git a/tests/generated/percentage_multiple_nested_with_padding_margin_and_percentage_values.rs b/tests/generated/percentage_multiple_nested_with_padding_margin_and_percentage_values.rs new file mode 100644 index 000000000..d47cfe232 --- /dev/null +++ b/tests/generated/percentage_multiple_nested_with_padding_margin_and_percentage_values.rs @@ -0,0 +1,129 @@ +#[test] +fn percentage_multiple_nested_with_padding_margin_and_percentage_values() { + let mut taffy = taffy::Taffy::new(); + let node000 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.45f32), ..Default::default() }, + margin: taffy::geometry::Rect { + start: taffy::style::Dimension::Percent(0.05f32), + end: taffy::style::Dimension::Percent(0.05f32), + top: taffy::style::Dimension::Percent(0.05f32), + bottom: taffy::style::Dimension::Percent(0.05f32), + ..Default::default() + }, + padding: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(3f32), + end: taffy::style::Dimension::Points(3f32), + top: taffy::style::Dimension::Points(3f32), + bottom: taffy::style::Dimension::Points(3f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.5f32), ..Default::default() }, + margin: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(5f32), + end: taffy::style::Dimension::Points(5f32), + top: taffy::style::Dimension::Points(5f32), + bottom: taffy::style::Dimension::Points(5f32), + ..Default::default() + }, + padding: taffy::geometry::Rect { + start: taffy::style::Dimension::Percent(0.03f32), + end: taffy::style::Dimension::Percent(0.03f32), + top: taffy::style::Dimension::Percent(0.03f32), + bottom: taffy::style::Dimension::Percent(0.03f32), + ..Default::default() + }, + ..Default::default() + }, + &[node000], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.6f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(5f32), + end: taffy::style::Dimension::Points(5f32), + top: taffy::style::Dimension::Points(5f32), + bottom: taffy::style::Dimension::Points(5f32), + ..Default::default() + }, + padding: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(3f32), + end: taffy::style::Dimension::Points(3f32), + top: taffy::style::Dimension::Points(3f32), + bottom: taffy::style::Dimension::Points(3f32), + ..Default::default() + }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 4f32, + flex_basis: taffy::style::Dimension::Percent(0.15f32), + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.2f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 190f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 48f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 5f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 5f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 92f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 25f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 8f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 8f32); + assert_eq!(taffy.layout(node000).unwrap().size.width, 36f32); + assert_eq!(taffy.layout(node000).unwrap().size.height, 6f32); + assert_eq!(taffy.layout(node000).unwrap().location.x, 10f32); + assert_eq!(taffy.layout(node000).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 142f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 58f32); +} diff --git a/tests/generated/percentage_padding_should_calculate_based_only_on_width.rs b/tests/generated/percentage_padding_should_calculate_based_only_on_width.rs new file mode 100644 index 000000000..0c07f0ce5 --- /dev/null +++ b/tests/generated/percentage_padding_should_calculate_based_only_on_width.rs @@ -0,0 +1,61 @@ +#[test] +fn percentage_padding_should_calculate_based_only_on_width() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + padding: taffy::geometry::Rect { + start: taffy::style::Dimension::Percent(0.1f32), + end: taffy::style::Dimension::Percent(0.1f32), + top: taffy::style::Dimension::Percent(0.1f32), + bottom: taffy::style::Dimension::Percent(0.1f32), + ..Default::default() + }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 20f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 20f32); +} diff --git a/tests/generated/percentage_position_bottom_right.rs b/tests/generated/percentage_position_bottom_right.rs new file mode 100644 index 000000000..3ccf7a33e --- /dev/null +++ b/tests/generated/percentage_position_bottom_right.rs @@ -0,0 +1,44 @@ +#[test] +fn percentage_position_bottom_right() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.55f32), + height: taffy::style::Dimension::Percent(0.15f32), + ..Default::default() + }, + position: taffy::geometry::Rect { + end: taffy::style::Dimension::Percent(0.2f32), + bottom: taffy::style::Dimension::Percent(0.1f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(500f32), + height: taffy::style::Dimension::Points(500f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 500f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 500f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 275f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 75f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, -100f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, -50f32); +} diff --git a/tests/generated/percentage_position_left_top.rs b/tests/generated/percentage_position_left_top.rs new file mode 100644 index 000000000..f273f872a --- /dev/null +++ b/tests/generated/percentage_position_left_top.rs @@ -0,0 +1,44 @@ +#[test] +fn percentage_position_left_top() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.45f32), + height: taffy::style::Dimension::Percent(0.55f32), + ..Default::default() + }, + position: taffy::geometry::Rect { + start: taffy::style::Dimension::Percent(0.1f32), + top: taffy::style::Dimension::Percent(0.2f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(400f32), + height: taffy::style::Dimension::Points(400f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 400f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 400f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 180f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 220f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 80f32); +} diff --git a/tests/generated/percentage_size_based_on_parent_inner_size.rs b/tests/generated/percentage_size_based_on_parent_inner_size.rs new file mode 100644 index 000000000..79b9d1180 --- /dev/null +++ b/tests/generated/percentage_size_based_on_parent_inner_size.rs @@ -0,0 +1,47 @@ +#[test] +fn percentage_size_based_on_parent_inner_size() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.5f32), + height: taffy::style::Dimension::Percent(0.5f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(400f32), + ..Default::default() + }, + padding: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(20f32), + end: taffy::style::Dimension::Points(20f32), + top: taffy::style::Dimension::Points(20f32), + bottom: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 400f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 80f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 180f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 20f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 20f32); +} diff --git a/tests/generated/percentage_size_of_flex_basis.rs b/tests/generated/percentage_size_of_flex_basis.rs new file mode 100644 index 000000000..03037f06a --- /dev/null +++ b/tests/generated/percentage_size_of_flex_basis.rs @@ -0,0 +1,45 @@ +#[test] +fn percentage_size_of_flex_basis() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(1f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_basis: taffy::style::Dimension::Points(50f32), ..Default::default() }, + &[node00], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); +} diff --git a/tests/generated/percentage_width_height.rs b/tests/generated/percentage_width_height.rs new file mode 100644 index 000000000..544a9c813 --- /dev/null +++ b/tests/generated/percentage_width_height.rs @@ -0,0 +1,39 @@ +#[test] +fn percentage_width_height() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.3f32), + height: taffy::style::Dimension::Percent(0.3f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(400f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 400f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); +} diff --git a/tests/generated/percentage_width_height_undefined_parent_size.rs b/tests/generated/percentage_width_height_undefined_parent_size.rs new file mode 100644 index 000000000..b4fa47e7e --- /dev/null +++ b/tests/generated/percentage_width_height_undefined_parent_size.rs @@ -0,0 +1,32 @@ +#[test] +fn percentage_width_height_undefined_parent_size() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.5f32), + height: taffy::style::Dimension::Percent(0.5f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); +} diff --git a/tests/generated/relative_position_should_not_nudge_siblings.rs b/tests/generated/relative_position_should_not_nudge_siblings.rs new file mode 100644 index 000000000..21f84090e --- /dev/null +++ b/tests/generated/relative_position_should_not_nudge_siblings.rs @@ -0,0 +1,51 @@ +#[test] +fn relative_position_should_not_nudge_siblings() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + position: taffy::geometry::Rect { top: taffy::style::Dimension::Points(15f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + position: taffy::geometry::Rect { top: taffy::style::Dimension::Points(15f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 15f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 25f32); +} diff --git a/tests/generated/rounding_flex_basis_flex_grow_row_prime_number_width.rs b/tests/generated/rounding_flex_basis_flex_grow_row_prime_number_width.rs new file mode 100644 index 000000000..75ed48a30 --- /dev/null +++ b/tests/generated/rounding_flex_basis_flex_grow_row_prime_number_width.rs @@ -0,0 +1,52 @@ +#[test] +fn rounding_flex_basis_flex_grow_row_prime_number_width() { + let mut taffy = taffy::Taffy::new(); + let node0 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node1 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node2 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node3 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node4 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(113f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 113f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 23f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 23f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 23f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 23f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 45f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 23f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 68f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 23f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 90f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 0f32); +} diff --git a/tests/generated/rounding_flex_basis_flex_grow_row_width_of_100.rs b/tests/generated/rounding_flex_basis_flex_grow_row_width_of_100.rs new file mode 100644 index 000000000..eadb3f2bc --- /dev/null +++ b/tests/generated/rounding_flex_basis_flex_grow_row_width_of_100.rs @@ -0,0 +1,40 @@ +#[test] +fn rounding_flex_basis_flex_grow_row_width_of_100() { + let mut taffy = taffy::Taffy::new(); + let node0 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node1 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node2 = + taffy.new_with_children(taffy::style::FlexboxLayout { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 33f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 33f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 33f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 33f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 67f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); +} diff --git a/tests/generated/rounding_flex_basis_flex_shrink_row.rs b/tests/generated/rounding_flex_basis_flex_shrink_row.rs new file mode 100644 index 000000000..a2354483f --- /dev/null +++ b/tests/generated/rounding_flex_basis_flex_shrink_row.rs @@ -0,0 +1,56 @@ +#[test] +fn rounding_flex_basis_flex_shrink_row() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_basis: taffy::style::Dimension::Points(25f32), ..Default::default() }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_basis: taffy::style::Dimension::Points(25f32), ..Default::default() }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(101f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 101f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 67f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 17f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 67f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 17f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 84f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); +} diff --git a/tests/generated/rounding_flex_basis_overrides_main_size.rs b/tests/generated/rounding_flex_basis_overrides_main_size.rs new file mode 100644 index 000000000..5274b9683 --- /dev/null +++ b/tests/generated/rounding_flex_basis_overrides_main_size.rs @@ -0,0 +1,66 @@ +#[test] +fn rounding_flex_basis_overrides_main_size() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(50f32), + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(113f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 113f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 64f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 24f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 64f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 24f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 89f32); +} diff --git a/tests/generated/rounding_fractial_input_1.rs b/tests/generated/rounding_fractial_input_1.rs new file mode 100644 index 000000000..46600499a --- /dev/null +++ b/tests/generated/rounding_fractial_input_1.rs @@ -0,0 +1,66 @@ +#[test] +fn rounding_fractial_input_1() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(50f32), + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(113.4f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 113f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 64f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 24f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 64f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 24f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 89f32); +} diff --git a/tests/generated/rounding_fractial_input_2.rs b/tests/generated/rounding_fractial_input_2.rs new file mode 100644 index 000000000..d4186021e --- /dev/null +++ b/tests/generated/rounding_fractial_input_2.rs @@ -0,0 +1,66 @@ +#[test] +fn rounding_fractial_input_2() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(50f32), + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(113.6f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 114f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 65f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 25f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 65f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 25f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 89f32); +} diff --git a/tests/generated/rounding_fractial_input_3.rs b/tests/generated/rounding_fractial_input_3.rs new file mode 100644 index 000000000..4855300d8 --- /dev/null +++ b/tests/generated/rounding_fractial_input_3.rs @@ -0,0 +1,66 @@ +#[test] +fn rounding_fractial_input_3() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(50f32), + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(113.4f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 113f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 64f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 24f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 64f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 24f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 89f32); +} diff --git a/tests/generated/rounding_fractial_input_4.rs b/tests/generated/rounding_fractial_input_4.rs new file mode 100644 index 000000000..ea6aa826c --- /dev/null +++ b/tests/generated/rounding_fractial_input_4.rs @@ -0,0 +1,66 @@ +#[test] +fn rounding_fractial_input_4() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(50f32), + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(113.4f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 113f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 64f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 24f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 64f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 24f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 89f32); +} diff --git a/tests/generated/rounding_total_fractial.rs b/tests/generated/rounding_total_fractial.rs new file mode 100644 index 000000000..a5a99a78d --- /dev/null +++ b/tests/generated/rounding_total_fractial.rs @@ -0,0 +1,66 @@ +#[test] +fn rounding_total_fractial() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 0.7f32, + flex_basis: taffy::style::Dimension::Points(50.3f32), + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20.3f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1.6f32, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1.1f32, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10.7f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(87.4f32), + height: taffy::style::Dimension::Points(113.4f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 87f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 113f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 87f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 59f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 87f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 30f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 59f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 87f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 24f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 89f32); +} diff --git a/tests/generated/rounding_total_fractial_nested.rs b/tests/generated/rounding_total_fractial_nested.rs new file mode 100644 index 000000000..b32652d23 --- /dev/null +++ b/tests/generated/rounding_total_fractial_nested.rs @@ -0,0 +1,102 @@ +#[test] +fn rounding_total_fractial_nested() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(0.3f32), + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(9.9f32), ..Default::default() }, + position: taffy::geometry::Rect { + bottom: taffy::style::Dimension::Points(13.3f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node01 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 4f32, + flex_basis: taffy::style::Dimension::Points(0.3f32), + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(1.1f32), ..Default::default() }, + position: taffy::geometry::Rect { top: taffy::style::Dimension::Points(13.3f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 0.7f32, + flex_basis: taffy::style::Dimension::Points(50.3f32), + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20.3f32), ..Default::default() }, + ..Default::default() + }, + &[node00, node01], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1.6f32, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1.1f32, + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10.7f32), ..Default::default() }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(87.4f32), + height: taffy::style::Dimension::Points(113.4f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 87f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 113f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 87f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 59f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 87f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 12f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, -13f32); + assert_eq!(taffy.layout(node01).unwrap().size.width, 87f32); + assert_eq!(taffy.layout(node01).unwrap().size.height, 47f32); + assert_eq!(taffy.layout(node01).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node01).unwrap().location.y, 25f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 87f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 30f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 59f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 87f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 24f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 89f32); +} diff --git a/tests/generated/size_defined_by_child.rs b/tests/generated/size_defined_by_child.rs new file mode 100644 index 000000000..53123137f --- /dev/null +++ b/tests/generated/size_defined_by_child.rs @@ -0,0 +1,27 @@ +#[test] +fn size_defined_by_child() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[node0]).unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); +} diff --git a/tests/generated/size_defined_by_child_with_border.rs b/tests/generated/size_defined_by_child_with_border.rs new file mode 100644 index 000000000..ed13004bd --- /dev/null +++ b/tests/generated/size_defined_by_child_with_border.rs @@ -0,0 +1,41 @@ +#[test] +fn size_defined_by_child_with_border() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + border: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Points(10f32), + top: taffy::style::Dimension::Points(10f32), + bottom: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 30f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 10f32); +} diff --git a/tests/generated/size_defined_by_child_with_padding.rs b/tests/generated/size_defined_by_child_with_padding.rs new file mode 100644 index 000000000..bf16d6a4c --- /dev/null +++ b/tests/generated/size_defined_by_child_with_padding.rs @@ -0,0 +1,41 @@ +#[test] +fn size_defined_by_child_with_padding() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + padding: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10f32), + end: taffy::style::Dimension::Points(10f32), + top: taffy::style::Dimension::Points(10f32), + bottom: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 30f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 10f32); +} diff --git a/tests/generated/size_defined_by_grand_child.rs b/tests/generated/size_defined_by_grand_child.rs new file mode 100644 index 000000000..6b7a2ca36 --- /dev/null +++ b/tests/generated/size_defined_by_grand_child.rs @@ -0,0 +1,32 @@ +#[test] +fn size_defined_by_grand_child() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[node00]).unwrap(); + let node = taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[node0]).unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); +} diff --git a/tests/generated/width_smaller_then_content_with_flex_grow_large_size.rs b/tests/generated/width_smaller_then_content_with_flex_grow_large_size.rs new file mode 100644 index 000000000..78434ed76 --- /dev/null +++ b/tests/generated/width_smaller_then_content_with_flex_grow_large_size.rs @@ -0,0 +1,82 @@ +#[test] +fn width_smaller_then_content_with_flex_grow_large_size() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), ..Default::default() }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node10 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), ..Default::default() }, + ..Default::default() + }, + &[node10], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 70f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 50f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 50f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node10).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node10).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node10).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node10).unwrap().location.y, 0f32); +} diff --git a/tests/generated/width_smaller_then_content_with_flex_grow_small_size.rs b/tests/generated/width_smaller_then_content_with_flex_grow_small_size.rs new file mode 100644 index 000000000..a1255b347 --- /dev/null +++ b/tests/generated/width_smaller_then_content_with_flex_grow_small_size.rs @@ -0,0 +1,82 @@ +#[test] +fn width_smaller_then_content_with_flex_grow_small_size() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), ..Default::default() }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node10 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), ..Default::default() }, + ..Default::default() + }, + &[node10], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 5f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 70f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 5f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 5f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node10).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node10).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node10).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node10).unwrap().location.y, 0f32); +} diff --git a/tests/generated/width_smaller_then_content_with_flex_grow_unconstraint_size.rs b/tests/generated/width_smaller_then_content_with_flex_grow_unconstraint_size.rs new file mode 100644 index 000000000..fc16819f9 --- /dev/null +++ b/tests/generated/width_smaller_then_content_with_flex_grow_unconstraint_size.rs @@ -0,0 +1,74 @@ +#[test] +fn width_smaller_then_content_with_flex_grow_unconstraint_size() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), ..Default::default() }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node10 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), ..Default::default() }, + ..Default::default() + }, + &[node10], + ) + .unwrap(); + let node = taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[node0, node1]).unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 70f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node10).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node10).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node10).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node10).unwrap().location.y, 0f32); +} diff --git a/tests/generated/width_smaller_then_content_with_flex_grow_very_large_size.rs b/tests/generated/width_smaller_then_content_with_flex_grow_very_large_size.rs new file mode 100644 index 000000000..8bbbea4b9 --- /dev/null +++ b/tests/generated/width_smaller_then_content_with_flex_grow_very_large_size.rs @@ -0,0 +1,82 @@ +#[test] +fn width_smaller_then_content_with_flex_grow_very_large_size() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), ..Default::default() }, + ..Default::default() + }, + &[node00], + ) + .unwrap(); + let node10 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), ..Default::default() }, + ..Default::default() + }, + &[node10], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 70f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 100f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node10).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node10).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node10).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node10).unwrap().location.y, 0f32); +} diff --git a/tests/generated/wrap_column.rs b/tests/generated/wrap_column.rs new file mode 100644 index 000000000..54164e38f --- /dev/null +++ b/tests/generated/wrap_column.rs @@ -0,0 +1,92 @@ +#[test] +fn wrap_column() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(31f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(32f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(33f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node3 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(34f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_wrap: taffy::style::FlexWrap::Wrap, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2, node3], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 31f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 32f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 31f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 33f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 63f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 34f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 50f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 0f32); +} diff --git a/tests/generated/wrap_nodes_with_content_sizing_margin_cross.rs b/tests/generated/wrap_nodes_with_content_sizing_margin_cross.rs new file mode 100644 index 000000000..b20032868 --- /dev/null +++ b/tests/generated/wrap_nodes_with_content_sizing_margin_cross.rs @@ -0,0 +1,95 @@ +#[test] +fn wrap_nodes_with_content_sizing_margin_cross() { + let mut taffy = taffy::Taffy::new(); + let node000 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(40f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + &[node000], + ) + .unwrap(); + let node010 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(40f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node01 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + margin: taffy::geometry::Rect { top: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[node010], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_wrap: taffy::style::FlexWrap::Wrap, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(70f32), ..Default::default() }, + ..Default::default() + }, + &[node00, node01], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(500f32), + height: taffy::style::Dimension::Points(500f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 500f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 500f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 70f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 90f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node000).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node000).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node000).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node000).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node01).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node01).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node01).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node01).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node010).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node010).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node010).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node010).unwrap().location.y, 0f32); +} diff --git a/tests/generated/wrap_nodes_with_content_sizing_overflowing_margin.rs b/tests/generated/wrap_nodes_with_content_sizing_overflowing_margin.rs new file mode 100644 index 000000000..c80217fb1 --- /dev/null +++ b/tests/generated/wrap_nodes_with_content_sizing_overflowing_margin.rs @@ -0,0 +1,95 @@ +#[test] +fn wrap_nodes_with_content_sizing_overflowing_margin() { + let mut taffy = taffy::Taffy::new(); + let node000 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(40f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() }, + &[node000], + ) + .unwrap(); + let node010 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(40f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node01 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + margin: taffy::geometry::Rect { end: taffy::style::Dimension::Points(10f32), ..Default::default() }, + ..Default::default() + }, + &[node010], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_wrap: taffy::style::FlexWrap::Wrap, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(85f32), ..Default::default() }, + ..Default::default() + }, + &[node00, node01], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(500f32), + height: taffy::style::Dimension::Points(500f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 500f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 500f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 85f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 80f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node000).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node000).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node000).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node000).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node01).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node01).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node01).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node01).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node010).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node010).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node010).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node010).unwrap().location.y, 0f32); +} diff --git a/tests/generated/wrap_reverse_column.rs b/tests/generated/wrap_reverse_column.rs new file mode 100644 index 000000000..58bc03288 --- /dev/null +++ b/tests/generated/wrap_reverse_column.rs @@ -0,0 +1,92 @@ +#[test] +fn wrap_reverse_column() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(31f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(32f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(33f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node3 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(34f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_wrap: taffy::style::FlexWrap::WrapReverse, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2, node3], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 31f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 70f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 32f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 70f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 31f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 33f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 70f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 63f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 34f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 20f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 0f32); +} diff --git a/tests/generated/wrap_reverse_column_fixed_size.rs b/tests/generated/wrap_reverse_column_fixed_size.rs new file mode 100644 index 000000000..3422d2f50 --- /dev/null +++ b/tests/generated/wrap_reverse_column_fixed_size.rs @@ -0,0 +1,110 @@ +#[test] +fn wrap_reverse_column_fixed_size() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(30f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node3 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node4 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_wrap: taffy::style::FlexWrap::WrapReverse, + align_items: taffy::style::AlignItems::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 135f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 135f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 30f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 135f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 30f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 135f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 60f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 35f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 0f32); +} diff --git a/tests/generated/wrap_reverse_row.rs b/tests/generated/wrap_reverse_row.rs new file mode 100644 index 000000000..6e23e0b7d --- /dev/null +++ b/tests/generated/wrap_reverse_row.rs @@ -0,0 +1,87 @@ +#[test] +fn wrap_reverse_row() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(31f32), + height: taffy::style::Dimension::Points(30f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(32f32), + height: taffy::style::Dimension::Points(30f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(33f32), + height: taffy::style::Dimension::Points(30f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node3 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(34f32), + height: taffy::style::Dimension::Points(30f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_wrap: taffy::style::FlexWrap::WrapReverse, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1, node2, node3], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 60f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 31f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 30f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 30f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 32f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 30f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 31f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 30f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 33f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 30f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 63f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 30f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 34f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 30f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 0f32); +} diff --git a/tests/generated/wrap_reverse_row_align_content_center.rs b/tests/generated/wrap_reverse_row_align_content_center.rs new file mode 100644 index 000000000..186491f84 --- /dev/null +++ b/tests/generated/wrap_reverse_row_align_content_center.rs @@ -0,0 +1,105 @@ +#[test] +fn wrap_reverse_row_align_content_center() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(30f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node3 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node4 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_wrap: taffy::style::FlexWrap::WrapReverse, + align_content: taffy::style::AlignContent::Center, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 80f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 70f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 30f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 60f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 30f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 60f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 30f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 0f32); +} diff --git a/tests/generated/wrap_reverse_row_align_content_flex_start.rs b/tests/generated/wrap_reverse_row_align_content_flex_start.rs new file mode 100644 index 000000000..56c912b7c --- /dev/null +++ b/tests/generated/wrap_reverse_row_align_content_flex_start.rs @@ -0,0 +1,105 @@ +#[test] +fn wrap_reverse_row_align_content_flex_start() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(30f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node3 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node4 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_wrap: taffy::style::FlexWrap::WrapReverse, + align_content: taffy::style::AlignContent::FlexStart, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 80f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 70f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 30f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 60f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 30f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 60f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 30f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 0f32); +} diff --git a/tests/generated/wrap_reverse_row_align_content_space_around.rs b/tests/generated/wrap_reverse_row_align_content_space_around.rs new file mode 100644 index 000000000..f65c8f5bc --- /dev/null +++ b/tests/generated/wrap_reverse_row_align_content_space_around.rs @@ -0,0 +1,105 @@ +#[test] +fn wrap_reverse_row_align_content_space_around() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(30f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node3 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node4 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_wrap: taffy::style::FlexWrap::WrapReverse, + align_content: taffy::style::AlignContent::SpaceAround, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 80f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 70f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 30f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 60f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 30f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 60f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 30f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 0f32); +} diff --git a/tests/generated/wrap_reverse_row_align_content_stretch.rs b/tests/generated/wrap_reverse_row_align_content_stretch.rs new file mode 100644 index 000000000..652b12af0 --- /dev/null +++ b/tests/generated/wrap_reverse_row_align_content_stretch.rs @@ -0,0 +1,104 @@ +#[test] +fn wrap_reverse_row_align_content_stretch() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(30f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node3 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node4 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_wrap: taffy::style::FlexWrap::WrapReverse, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 80f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 70f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 30f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 60f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 30f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 60f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 30f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 0f32); +} diff --git a/tests/generated/wrap_reverse_row_single_line_different_size.rs b/tests/generated/wrap_reverse_row_single_line_different_size.rs new file mode 100644 index 000000000..2da555662 --- /dev/null +++ b/tests/generated/wrap_reverse_row_single_line_different_size.rs @@ -0,0 +1,105 @@ +#[test] +fn wrap_reverse_row_single_line_different_size() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(30f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node3 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(40f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node4 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(50f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_wrap: taffy::style::FlexWrap::WrapReverse, + align_content: taffy::style::AlignContent::FlexStart, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(300f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 300f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 30f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 30f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 30f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 60f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 20f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 90f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 50f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 0f32); +} diff --git a/tests/generated/wrap_row.rs b/tests/generated/wrap_row.rs new file mode 100644 index 000000000..56ff948c6 --- /dev/null +++ b/tests/generated/wrap_row.rs @@ -0,0 +1,87 @@ +#[test] +fn wrap_row() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(31f32), + height: taffy::style::Dimension::Points(30f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(32f32), + height: taffy::style::Dimension::Points(30f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(33f32), + height: taffy::style::Dimension::Points(30f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node3 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(34f32), + height: taffy::style::Dimension::Points(30f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_wrap: taffy::style::FlexWrap::Wrap, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1, node2, node3], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 60f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 31f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 30f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 32f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 30f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 31f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 33f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 30f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 63f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 34f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 30f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 30f32); +} diff --git a/tests/generated/wrap_row_align_items_center.rs b/tests/generated/wrap_row_align_items_center.rs new file mode 100644 index 000000000..187e1a5a4 --- /dev/null +++ b/tests/generated/wrap_row_align_items_center.rs @@ -0,0 +1,88 @@ +#[test] +fn wrap_row_align_items_center() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(30f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node3 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(30f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_wrap: taffy::style::FlexWrap::Wrap, + align_items: taffy::style::AlignItems::Center, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1, node2, node3], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 60f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 30f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 5f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 30f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 60f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 30f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 30f32); +} diff --git a/tests/generated/wrap_row_align_items_flex_end.rs b/tests/generated/wrap_row_align_items_flex_end.rs new file mode 100644 index 000000000..7510ff79e --- /dev/null +++ b/tests/generated/wrap_row_align_items_flex_end.rs @@ -0,0 +1,88 @@ +#[test] +fn wrap_row_align_items_flex_end() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(10f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(30f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node3 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(30f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_wrap: taffy::style::FlexWrap::Wrap, + align_items: taffy::style::AlignItems::FlexEnd, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() }, + ..Default::default() + }, + &[node0, node1, node2, node3], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 60f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 20f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 30f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 30f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 60f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 30f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 30f32); +} diff --git a/tests/generated/wrapped_column_max_height.rs b/tests/generated/wrapped_column_max_height.rs new file mode 100644 index 000000000..9022ba456 --- /dev/null +++ b/tests/generated/wrapped_column_max_height.rs @@ -0,0 +1,89 @@ +#[test] +fn wrapped_column_max_height() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(500f32), + ..Default::default() + }, + max_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(20f32), + end: taffy::style::Dimension::Points(20f32), + top: taffy::style::Dimension::Points(20f32), + bottom: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_wrap: taffy::style::FlexWrap::Wrap, + align_items: taffy::style::AlignItems::Center, + align_content: taffy::style::AlignContent::Center, + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(700f32), + height: taffy::style::Dimension::Points(500f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 700f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 500f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 250f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 30f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 200f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 250f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 420f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 200f32); +} diff --git a/tests/generated/wrapped_column_max_height_flex.rs b/tests/generated/wrapped_column_max_height_flex.rs new file mode 100644 index 000000000..23c367139 --- /dev/null +++ b/tests/generated/wrapped_column_max_height_flex.rs @@ -0,0 +1,95 @@ +#[test] +fn wrapped_column_max_height_flex() { + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(500f32), + ..Default::default() + }, + max_size: taffy::geometry::Size { + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + margin: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(20f32), + end: taffy::style::Dimension::Points(20f32), + top: taffy::style::Dimension::Points(20f32), + bottom: taffy::style::Dimension::Points(20f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node2 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + flex_wrap: taffy::style::FlexWrap::Wrap, + align_items: taffy::style::AlignItems::Center, + align_content: taffy::style::AlignContent::Center, + justify_content: taffy::style::JustifyContent::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(700f32), + height: taffy::style::Dimension::Points(500f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0, node1, node2], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 700f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 500f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 180f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 300f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 180f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 250f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 200f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 100f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 300f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 400f32); +} diff --git a/tests/generated/wrapped_row_within_align_items_center.rs b/tests/generated/wrapped_row_within_align_items_center.rs new file mode 100644 index 000000000..c2ae63ab1 --- /dev/null +++ b/tests/generated/wrapped_row_within_align_items_center.rs @@ -0,0 +1,68 @@ +#[test] +fn wrapped_row_within_align_items_center() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(150f32), + height: taffy::style::Dimension::Points(80f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node01 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(80f32), + height: taffy::style::Dimension::Points(80f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_wrap: taffy::style::FlexWrap::Wrap, ..Default::default() }, + &[node00, node01], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + align_items: taffy::style::AlignItems::Center, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 160f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 150f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 80f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node01).unwrap().size.width, 80f32); + assert_eq!(taffy.layout(node01).unwrap().size.height, 80f32); + assert_eq!(taffy.layout(node01).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node01).unwrap().location.y, 80f32); +} diff --git a/tests/generated/wrapped_row_within_align_items_flex_end.rs b/tests/generated/wrapped_row_within_align_items_flex_end.rs new file mode 100644 index 000000000..99a126c33 --- /dev/null +++ b/tests/generated/wrapped_row_within_align_items_flex_end.rs @@ -0,0 +1,68 @@ +#[test] +fn wrapped_row_within_align_items_flex_end() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(150f32), + height: taffy::style::Dimension::Points(80f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node01 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(80f32), + height: taffy::style::Dimension::Points(80f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_wrap: taffy::style::FlexWrap::Wrap, ..Default::default() }, + &[node00, node01], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + align_items: taffy::style::AlignItems::FlexEnd, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 160f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 150f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 80f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node01).unwrap().size.width, 80f32); + assert_eq!(taffy.layout(node01).unwrap().size.height, 80f32); + assert_eq!(taffy.layout(node01).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node01).unwrap().location.y, 80f32); +} diff --git a/tests/generated/wrapped_row_within_align_items_flex_start.rs b/tests/generated/wrapped_row_within_align_items_flex_start.rs new file mode 100644 index 000000000..50708923b --- /dev/null +++ b/tests/generated/wrapped_row_within_align_items_flex_start.rs @@ -0,0 +1,68 @@ +#[test] +fn wrapped_row_within_align_items_flex_start() { + let mut taffy = taffy::Taffy::new(); + let node00 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(150f32), + height: taffy::style::Dimension::Points(80f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node01 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(80f32), + height: taffy::style::Dimension::Points(80f32), + ..Default::default() + }, + ..Default::default() + }, + &[], + ) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { flex_wrap: taffy::style::FlexWrap::Wrap, ..Default::default() }, + &[node00, node01], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + flex_direction: taffy::style::FlexDirection::Column, + align_items: taffy::style::AlignItems::FlexStart, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + ..Default::default() + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 160f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node00).unwrap().size.width, 150f32); + assert_eq!(taffy.layout(node00).unwrap().size.height, 80f32); + assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node01).unwrap().size.width, 80f32); + assert_eq!(taffy.layout(node01).unwrap().size.height, 80f32); + assert_eq!(taffy.layout(node01).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node01).unwrap().location.y, 80f32); +} diff --git a/tests/lib.rs b/tests/lib.rs deleted file mode 100644 index 7d02c7323..000000000 --- a/tests/lib.rs +++ /dev/null @@ -1,636 +0,0 @@ -#[cfg(test)] -mod tests { - #[test] - fn test_1() { - let layout = stretch::compute(&stretch::style::Node { - width: stretch::style::Dimension::Points(100.0), - height: stretch::style::Dimension::Points(100.0), - ..Default::default() - }); - - assert_eq!(layout.width, 100.0); - assert_eq!(layout.height, 100.0); - } - - #[test] - fn test_2() { - let layout = stretch::compute(&stretch::style::Node { - width: stretch::style::Dimension::Points(100.0), - height: stretch::style::Dimension::Points(100.0), - - children: vec![ - stretch::style::Node { - width: stretch::style::Dimension::Percent(0.5), - - ..Default::default() - }, - ], - - ..Default::default() - }); - - assert_eq!(layout.children[0].width, 50.0); - assert_eq!(layout.children[0].height, 100.0); - } - - #[test] - fn test_3() { - let layout = stretch::compute(&stretch::style::Node { - width: stretch::style::Dimension::Points(100.0), - height: stretch::style::Dimension::Points(100.0), - - children: vec![ - stretch::style::Node { - width: stretch::style::Dimension::Percent(0.5), - - ..Default::default() - }, - stretch::style::Node { - width: stretch::style::Dimension::Percent(0.5), - - ..Default::default() - }, - ], - - ..Default::default() - }); - - assert_eq!(layout.children[0].width, 50.0); - assert_eq!(layout.children[0].height, 100.0); - assert_eq!(layout.children[0].x, 0.0); - assert_eq!(layout.children[0].y, 0.0); - - assert_eq!(layout.children[1].width, 50.0); - assert_eq!(layout.children[1].height, 100.0); - assert_eq!(layout.children[1].x, 50.0); - assert_eq!(layout.children[1].y, 0.0); - } - - #[test] - fn test_4() { - let layout = stretch::compute(&stretch::style::Node { - width: stretch::style::Dimension::Points(100.0), - height: stretch::style::Dimension::Points(100.0), - - children: vec![ - stretch::style::Node { - width: stretch::style::Dimension::Points(20.0), - flex_grow: 1.0, - - ..Default::default() - }, - stretch::style::Node { - width: stretch::style::Dimension::Points(20.0), - - ..Default::default() - }, - ], - - ..Default::default() - }); - - assert_eq!(layout.children[0].width, 80.0); - assert_eq!(layout.children[0].height, 100.0); - assert_eq!(layout.children[0].x, 0.0); - assert_eq!(layout.children[0].y, 0.0); - - assert_eq!(layout.children[1].width, 20.0); - assert_eq!(layout.children[1].height, 100.0); - assert_eq!(layout.children[1].x, 80.0); - assert_eq!(layout.children[1].y, 0.0); - } - - #[test] - fn test_5() { - let layout = stretch::compute(&stretch::style::Node { - width: stretch::style::Dimension::Points(100.0), - height: stretch::style::Dimension::Points(100.0), - - children: vec![ - stretch::style::Node { - width: stretch::style::Dimension::Points(100.0), - flex_shrink: 1.0, - - ..Default::default() - }, - stretch::style::Node { - width: stretch::style::Dimension::Points(100.0), - flex_shrink: 1.0, - - ..Default::default() - }, - ], - - ..Default::default() - }); - - assert_eq!(layout.children[0].width, 50.0); - assert_eq!(layout.children[0].height, 100.0); - assert_eq!(layout.children[0].x, 0.0); - assert_eq!(layout.children[0].y, 0.0); - - assert_eq!(layout.children[1].width, 50.0); - assert_eq!(layout.children[1].height, 100.0); - assert_eq!(layout.children[1].x, 50.0); - assert_eq!(layout.children[1].y, 0.0); - } - - #[test] - fn test_6() { - let layout = stretch::compute(&stretch::style::Node { - width: stretch::style::Dimension::Points(100.0), - height: stretch::style::Dimension::Points(100.0), - - children: vec![ - stretch::style::Node { - width: stretch::style::Dimension::Points(50.0), - - ..Default::default() - }, - stretch::style::Node { - width: stretch::style::Dimension::Points(20.0), - margin: stretch::style::Edges { - start: stretch::style::Dimension::Points(30.0), - ..Default::default() - }, - - ..Default::default() - }, - ], - - ..Default::default() - }); - - assert_eq!(layout.children[0].width, 50.0); - assert_eq!(layout.children[0].height, 100.0); - assert_eq!(layout.children[0].x, 0.0); - assert_eq!(layout.children[0].y, 0.0); - - assert_eq!(layout.children[1].width, 20.0); - assert_eq!(layout.children[1].height, 100.0); - assert_eq!(layout.children[1].x, 80.0); - assert_eq!(layout.children[1].y, 0.0); - } - - #[test] - fn test_7() { - let layout = stretch::compute(&stretch::style::Node { - width: stretch::style::Dimension::Points(100.0), - height: stretch::style::Dimension::Points(100.0), - padding: stretch::style::Edges { - start: stretch::style::Dimension::Points(10.0), - end: stretch::style::Dimension::Points(10.0), - top: stretch::style::Dimension::Points(10.0), - bottom: stretch::style::Dimension::Points(10.0), - }, - - children: vec![ - stretch::style::Node { - width: stretch::style::Dimension::Points(40.0), - - ..Default::default() - }, - stretch::style::Node { - width: stretch::style::Dimension::Points(40.0), - - ..Default::default() - }, - ], - - ..Default::default() - }); - - assert_eq!(layout.children[0].width, 40.0); - assert_eq!(layout.children[0].height, 80.0); - assert_eq!(layout.children[0].x, 10.0); - assert_eq!(layout.children[0].y, 10.0); - - assert_eq!(layout.children[1].width, 40.0); - assert_eq!(layout.children[1].height, 80.0); - assert_eq!(layout.children[1].x, 50.0); - assert_eq!(layout.children[1].y, 10.0); - } - - #[test] - fn test_8() { - let layout = stretch::compute(&stretch::style::Node { - width: stretch::style::Dimension::Points(100.0), - height: stretch::style::Dimension::Points(100.0), - border: stretch::style::Edges { - start: stretch::style::Dimension::Points(10.0), - end: stretch::style::Dimension::Points(10.0), - top: stretch::style::Dimension::Points(10.0), - bottom: stretch::style::Dimension::Points(10.0), - }, - - children: vec![ - stretch::style::Node { - width: stretch::style::Dimension::Points(40.0), - - ..Default::default() - }, - stretch::style::Node { - width: stretch::style::Dimension::Points(40.0), - - ..Default::default() - }, - ], - - ..Default::default() - }); - - assert_eq!(layout.children[0].width, 40.0); - assert_eq!(layout.children[0].height, 80.0); - assert_eq!(layout.children[0].x, 10.0); - assert_eq!(layout.children[0].y, 10.0); - - assert_eq!(layout.children[1].width, 40.0); - assert_eq!(layout.children[1].height, 80.0); - assert_eq!(layout.children[1].x, 50.0); - assert_eq!(layout.children[1].y, 10.0); - } - - #[test] - fn test_9() { - let layout = stretch::compute(&stretch::style::Node { - width: stretch::style::Dimension::Points(100.0), - height: stretch::style::Dimension::Points(100.0), - justify_content: stretch::style::JustifyContent::Center, - - children: vec![ - stretch::style::Node { - width: stretch::style::Dimension::Points(20.0), - height: stretch::style::Dimension::Points(20.0), - - ..Default::default() - }, - stretch::style::Node { - width: stretch::style::Dimension::Points(20.0), - height: stretch::style::Dimension::Points(20.0), - - ..Default::default() - }, - ], - - ..Default::default() - }); - - assert_eq!(layout.children[0].width, 20.0); - assert_eq!(layout.children[0].height, 20.0); - assert_eq!(layout.children[0].x, 30.0); - assert_eq!(layout.children[0].y, 0.0); - - assert_eq!(layout.children[1].width, 20.0); - assert_eq!(layout.children[1].height, 20.0); - assert_eq!(layout.children[1].x, 50.0); - assert_eq!(layout.children[1].y, 0.0); - } - - #[test] - fn test_10() { - let layout = stretch::compute(&stretch::style::Node { - width: stretch::style::Dimension::Points(100.0), - height: stretch::style::Dimension::Points(100.0), - justify_content: stretch::style::JustifyContent::FlexEnd, - - children: vec![ - stretch::style::Node { - width: stretch::style::Dimension::Points(20.0), - height: stretch::style::Dimension::Points(20.0), - - ..Default::default() - }, - stretch::style::Node { - width: stretch::style::Dimension::Points(20.0), - height: stretch::style::Dimension::Points(20.0), - - ..Default::default() - }, - ], - - ..Default::default() - }); - - assert_eq!(layout.children[0].width, 20.0); - assert_eq!(layout.children[0].height, 20.0); - assert_eq!(layout.children[0].x, 60.0); - assert_eq!(layout.children[0].y, 0.0); - - assert_eq!(layout.children[1].width, 20.0); - assert_eq!(layout.children[1].height, 20.0); - assert_eq!(layout.children[1].x, 80.0); - assert_eq!(layout.children[1].y, 0.0); - } - - #[test] - fn test_11() { - let layout = stretch::compute(&stretch::style::Node { - width: stretch::style::Dimension::Points(100.0), - height: stretch::style::Dimension::Points(100.0), - justify_content: stretch::style::JustifyContent::SpaceBetween, - - children: vec![ - stretch::style::Node { - width: stretch::style::Dimension::Points(20.0), - height: stretch::style::Dimension::Points(20.0), - - ..Default::default() - }, - stretch::style::Node { - width: stretch::style::Dimension::Points(20.0), - height: stretch::style::Dimension::Points(20.0), - - ..Default::default() - }, - ], - - ..Default::default() - }); - - assert_eq!(layout.children[0].width, 20.0); - assert_eq!(layout.children[0].height, 20.0); - assert_eq!(layout.children[0].x, 0.0); - assert_eq!(layout.children[0].y, 0.0); - - assert_eq!(layout.children[1].width, 20.0); - assert_eq!(layout.children[1].height, 20.0); - assert_eq!(layout.children[1].x, 80.0); - assert_eq!(layout.children[1].y, 0.0); - } - - #[test] - fn test_12() { - let layout = stretch::compute(&stretch::style::Node { - width: stretch::style::Dimension::Points(100.0), - height: stretch::style::Dimension::Points(100.0), - align_items: stretch::style::AlignItems::FlexEnd, - - children: vec![ - stretch::style::Node { - width: stretch::style::Dimension::Points(20.0), - height: stretch::style::Dimension::Points(20.0), - - ..Default::default() - }, - stretch::style::Node { - width: stretch::style::Dimension::Points(20.0), - height: stretch::style::Dimension::Points(20.0), - - ..Default::default() - }, - ], - - ..Default::default() - }); - - assert_eq!(layout.children[0].width, 20.0); - assert_eq!(layout.children[0].height, 20.0); - assert_eq!(layout.children[0].x, 0.0); - assert_eq!(layout.children[0].y, 80.0); - - assert_eq!(layout.children[1].width, 20.0); - assert_eq!(layout.children[1].height, 20.0); - assert_eq!(layout.children[1].x, 20.0); - assert_eq!(layout.children[1].y, 80.0); - } - - #[test] - fn test_13() { - let layout = stretch::compute(&stretch::style::Node { - width: stretch::style::Dimension::Points(100.0), - height: stretch::style::Dimension::Points(100.0), - align_items: stretch::style::AlignItems::Center, - - children: vec![ - stretch::style::Node { - width: stretch::style::Dimension::Points(20.0), - height: stretch::style::Dimension::Points(20.0), - - ..Default::default() - }, - stretch::style::Node { - width: stretch::style::Dimension::Points(20.0), - height: stretch::style::Dimension::Points(20.0), - - ..Default::default() - }, - ], - - ..Default::default() - }); - - assert_eq!(layout.children[0].width, 20.0); - assert_eq!(layout.children[0].height, 20.0); - assert_eq!(layout.children[0].x, 0.0); - assert_eq!(layout.children[0].y, 40.0); - - assert_eq!(layout.children[1].width, 20.0); - assert_eq!(layout.children[1].height, 20.0); - assert_eq!(layout.children[1].x, 20.0); - assert_eq!(layout.children[1].y, 40.0); - } - - #[test] - fn test_14() { - let layout = stretch::compute(&stretch::style::Node { - width: stretch::style::Dimension::Points(100.0), - height: stretch::style::Dimension::Points(100.0), - align_items: stretch::style::AlignItems::Center, - - children: vec![ - stretch::style::Node { - width: stretch::style::Dimension::Points(20.0), - height: stretch::style::Dimension::Points(20.0), - - ..Default::default() - }, - stretch::style::Node { - width: stretch::style::Dimension::Points(20.0), - height: stretch::style::Dimension::Points(20.0), - align_self: stretch::style::AlignSelf::FlexStart, - - ..Default::default() - }, - ], - - ..Default::default() - }); - - assert_eq!(layout.children[0].width, 20.0); - assert_eq!(layout.children[0].height, 20.0); - assert_eq!(layout.children[0].x, 0.0); - assert_eq!(layout.children[0].y, 40.0); - - assert_eq!(layout.children[1].width, 20.0); - assert_eq!(layout.children[1].height, 20.0); - assert_eq!(layout.children[1].x, 20.0); - assert_eq!(layout.children[1].y, 0.0); - } - - #[test] - fn test_15() { - let layout = stretch::compute(&stretch::style::Node { - width: stretch::style::Dimension::Points(100.0), - - children: vec![ - stretch::style::Node { - width: stretch::style::Dimension::Points(40.0), - height: stretch::style::Dimension::Points(40.0), - - ..Default::default() - }, - stretch::style::Node { - width: stretch::style::Dimension::Points(40.0), - height: stretch::style::Dimension::Points(40.0), - - ..Default::default() - }, - ], - - ..Default::default() - }); - - assert_eq!(layout.height, 40.0); - - assert_eq!(layout.children[0].width, 40.0); - assert_eq!(layout.children[0].height, 40.0); - assert_eq!(layout.children[0].x, 0.0); - assert_eq!(layout.children[0].y, 0.0); - - assert_eq!(layout.children[1].width, 40.0); - assert_eq!(layout.children[1].height, 40.0); - assert_eq!(layout.children[1].x, 40.0); - assert_eq!(layout.children[1].y, 0.0); - } - - #[test] - fn test_16() { - let layout = stretch::compute(&stretch::style::Node { - width: stretch::style::Dimension::Points(100.0), - wrap: stretch::style::Wrap::Wrap, - - children: vec![ - stretch::style::Node { - width: stretch::style::Dimension::Points(40.0), - height: stretch::style::Dimension::Points(40.0), - - ..Default::default() - }, - stretch::style::Node { - width: stretch::style::Dimension::Points(40.0), - height: stretch::style::Dimension::Points(40.0), - - ..Default::default() - }, - stretch::style::Node { - width: stretch::style::Dimension::Points(40.0), - height: stretch::style::Dimension::Points(40.0), - - ..Default::default() - }, - stretch::style::Node { - width: stretch::style::Dimension::Points(40.0), - height: stretch::style::Dimension::Points(40.0), - - ..Default::default() - }, - stretch::style::Node { - width: stretch::style::Dimension::Points(40.0), - height: stretch::style::Dimension::Points(40.0), - - ..Default::default() - }, - ], - - ..Default::default() - }); - - assert_eq!(layout.height, 120.0); - - assert_eq!(layout.children[0].width, 40.0); - assert_eq!(layout.children[0].height, 40.0); - assert_eq!(layout.children[0].x, 0.0); - assert_eq!(layout.children[0].y, 0.0); - - assert_eq!(layout.children[1].width, 40.0); - assert_eq!(layout.children[1].height, 40.0); - assert_eq!(layout.children[1].x, 40.0); - assert_eq!(layout.children[1].y, 0.0); - - assert_eq!(layout.children[2].width, 40.0); - assert_eq!(layout.children[2].height, 40.0); - assert_eq!(layout.children[2].x, 0.0); - assert_eq!(layout.children[2].y, 40.0); - - assert_eq!(layout.children[3].width, 40.0); - assert_eq!(layout.children[3].height, 40.0); - assert_eq!(layout.children[3].x, 40.0); - assert_eq!(layout.children[3].y, 40.0); - - assert_eq!(layout.children[4].width, 40.0); - assert_eq!(layout.children[4].height, 40.0); - assert_eq!(layout.children[4].x, 0.0); - assert_eq!(layout.children[4].y, 80.0); - } - - #[test] - fn test_17() { - let layout = stretch::compute(&stretch::style::Node { - width: stretch::style::Dimension::Points(100.0), - height: stretch::style::Dimension::Points(100.0), - align_content: stretch::style::AlignContent::Center, - wrap: stretch::style::Wrap::Wrap, - - children: vec![ - stretch::style::Node { - width: stretch::style::Dimension::Points(40.0), - height: stretch::style::Dimension::Points(40.0), - - ..Default::default() - }, - stretch::style::Node { - width: stretch::style::Dimension::Points(40.0), - height: stretch::style::Dimension::Points(40.0), - - ..Default::default() - }, - stretch::style::Node { - width: stretch::style::Dimension::Points(40.0), - height: stretch::style::Dimension::Points(40.0), - - ..Default::default() - }, - stretch::style::Node { - width: stretch::style::Dimension::Points(40.0), - height: stretch::style::Dimension::Points(40.0), - - ..Default::default() - }, - ], - - ..Default::default() - }); - - assert_eq!(layout.height, 100.0); - - assert_eq!(layout.children[0].width, 40.0); - assert_eq!(layout.children[0].height, 40.0); - assert_eq!(layout.children[0].x, 0.0); - assert_eq!(layout.children[0].y, 10.0); - - assert_eq!(layout.children[1].width, 40.0); - assert_eq!(layout.children[1].height, 40.0); - assert_eq!(layout.children[1].x, 40.0); - assert_eq!(layout.children[1].y, 10.0); - - assert_eq!(layout.children[2].width, 40.0); - assert_eq!(layout.children[2].height, 40.0); - assert_eq!(layout.children[2].x, 0.0); - assert_eq!(layout.children[2].y, 50.0); - - assert_eq!(layout.children[3].width, 40.0); - assert_eq!(layout.children[3].height, 40.0); - assert_eq!(layout.children[3].x, 40.0); - assert_eq!(layout.children[3].y, 50.0); - } -} diff --git a/tests/measure.rs b/tests/measure.rs new file mode 100644 index 000000000..0f4f5b0f5 --- /dev/null +++ b/tests/measure.rs @@ -0,0 +1,492 @@ +#[cfg(test)] +mod measure { + use taffy::node::Measure; + use taffy::node::Node; + use taffy::node::Taffy; + use taffy::prelude::Size; + use taffy::style::FlexboxLayout; + + struct ReturnConstraintOrStored(f32, f32); + + impl Measure for ReturnConstraintOrStored { + fn measure(&self, _node: Node, constraint: Size>) -> Size { + let ReturnConstraintOrStored(width, height) = self; + Size { width: constraint.width.unwrap_or(*width), height: constraint.height.unwrap_or(*height) } + } + } + + #[test] + fn measure_root() { + let mut taffy = Taffy::new(); + + let node = taffy.new_leaf_with_required_measure(FlexboxLayout::default()).unwrap(); + + let measure = ReturnConstraintOrStored(100., 100.); + taffy.compute_measured_layout(node, &measure, Size::undefined()).unwrap(); + + assert_eq!(taffy.layout(node).unwrap().size.width, 100.0); + assert_eq!(taffy.layout(node).unwrap().size.height, 100.0); + } + + #[test] + fn measure_child() { + let mut taffy = taffy::node::Taffy::new(); + + let child = taffy.new_leaf_with_required_measure(taffy::style::FlexboxLayout { ..Default::default() }).unwrap(); + + let node = taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[child]).unwrap(); + + let measure = ReturnConstraintOrStored(100., 100.); + taffy.compute_measured_layout(node, &measure, taffy::geometry::Size::undefined()).unwrap(); + + assert_eq!(taffy.layout(node).unwrap().size.width, 100.0); + assert_eq!(taffy.layout(node).unwrap().size.height, 100.0); + + assert_eq!(taffy.layout(child).unwrap().size.width, 100.0); + assert_eq!(taffy.layout(child).unwrap().size.height, 100.0); + } + + #[test] + fn measure_child_constraint() { + let mut taffy = taffy::node::Taffy::new(); + let child = taffy.new_leaf_with_required_measure(taffy::style::FlexboxLayout { ..Default::default() }).unwrap(); + + let measure = ReturnConstraintOrStored(100., 100.); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50.0), ..Default::default() }, + ..Default::default() + }, + &[child], + ) + .unwrap(); + + taffy.compute_measured_layout(node, &measure, taffy::geometry::Size::undefined()).unwrap(); + + assert_eq!(taffy.layout(node).unwrap().size.width, 50.0); + assert_eq!(taffy.layout(node).unwrap().size.height, 100.0); + + assert_eq!(taffy.layout(child).unwrap().size.width, 50.0); + assert_eq!(taffy.layout(child).unwrap().size.height, 100.0); + } + + #[test] + fn measure_child_constraint_padding_parent() { + let mut taffy = taffy::node::Taffy::new(); + let child = taffy.new_leaf_with_required_measure(taffy::style::FlexboxLayout { ..Default::default() }).unwrap(); + + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50.0), ..Default::default() }, + padding: taffy::geometry::Rect { + start: taffy::style::Dimension::Points(10.0), + end: taffy::style::Dimension::Points(10.0), + top: taffy::style::Dimension::Points(10.0), + bottom: taffy::style::Dimension::Points(10.0), + }, + ..Default::default() + }, + &[child], + ) + .unwrap(); + + let measure = ReturnConstraintOrStored(100., 100.); + taffy.compute_measured_layout(node, &measure, taffy::geometry::Size::undefined()).unwrap(); + + assert_eq!(taffy.layout(node).unwrap().size.width, 50.0); + assert_eq!(taffy.layout(node).unwrap().size.height, 120.0); + + assert_eq!(taffy.layout(child).unwrap().size.width, 30.0); + assert_eq!(taffy.layout(child).unwrap().size.height, 100.0); + } + + #[test] + fn measure_child_with_flex_grow() { + let mut taffy = taffy::node::Taffy::new(); + let child0 = taffy + .new_leaf(taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50.0), + height: taffy::style::Dimension::Points(50.0), + }, + ..Default::default() + }) + .unwrap(); + + let child1 = taffy + .new_leaf_with_required_measure(taffy::style::FlexboxLayout { flex_grow: 1.0, ..Default::default() }) + .unwrap(); + + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100.0), ..Default::default() }, + ..Default::default() + }, + &[child0, child1], + ) + .unwrap(); + + let measure = ReturnConstraintOrStored(10., 50.); + taffy.compute_measured_layout(node, &measure, taffy::geometry::Size::undefined()).unwrap(); + + assert_eq!(taffy.layout(child1).unwrap().size.width, 50.0); + assert_eq!(taffy.layout(child1).unwrap().size.height, 50.0); + } + + #[test] + fn measure_child_with_flex_shrink() { + let mut taffy = taffy::node::Taffy::new(); + let child0 = taffy + .new_leaf(taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50.0), + height: taffy::style::Dimension::Points(50.0), + }, + flex_shrink: 0.0, + ..Default::default() + }) + .unwrap(); + + let child1 = + taffy.new_leaf_with_required_measure(taffy::style::FlexboxLayout { ..Default::default() }).unwrap(); + + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100.0), ..Default::default() }, + ..Default::default() + }, + &[child0, child1], + ) + .unwrap(); + + let measure = ReturnConstraintOrStored(100., 50.); + taffy.compute_measured_layout(node, &measure, taffy::geometry::Size::undefined()).unwrap(); + + assert_eq!(taffy.layout(child1).unwrap().size.width, 50.0); + assert_eq!(taffy.layout(child1).unwrap().size.height, 50.0); + } + + #[test] + fn remeasure_child_after_growing() { + struct HeightIsTwiceWidth(f32); + + impl Measure for HeightIsTwiceWidth { + fn measure(&self, _node: Node, constraint: Size>) -> Size { + let HeightIsTwiceWidth(size) = self; + let width = constraint.width.unwrap_or(*size); + let height = constraint.height.unwrap_or(width * 2.0); + taffy::geometry::Size { width, height } + } + } + + let mut taffy = taffy::node::Taffy::new(); + let child0 = taffy + .new_leaf(taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50.0), + height: taffy::style::Dimension::Points(50.0), + }, + ..Default::default() + }) + .unwrap(); + + let child1 = taffy + .new_leaf_with_required_measure(taffy::style::FlexboxLayout { flex_grow: 1.0, ..Default::default() }) + .unwrap(); + + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100.0), ..Default::default() }, + align_items: taffy::style::AlignItems::FlexStart, + ..Default::default() + }, + &[child0, child1], + ) + .unwrap(); + + let measure = HeightIsTwiceWidth(10.); + taffy.compute_measured_layout(node, &measure, taffy::geometry::Size::undefined()).unwrap(); + + assert_eq!(taffy.layout(child1).unwrap().size.width, 50.0); + assert_eq!(taffy.layout(child1).unwrap().size.height, 100.0); + } + + #[test] + fn remeasure_child_after_shrinking() { + struct HeightIsTwiceWidth(f32); + + impl Measure for HeightIsTwiceWidth { + fn measure(&self, _node: Node, constraint: Size>) -> Size { + let HeightIsTwiceWidth(size) = self; + let width = constraint.width.unwrap_or(*size); + let height = constraint.height.unwrap_or(width * 2.0); + taffy::geometry::Size { width, height } + } + } + + let mut taffy = taffy::node::Taffy::new(); + + let child0 = taffy + .new_leaf(taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50.0), + height: taffy::style::Dimension::Points(50.0), + }, + flex_shrink: 0.0, + ..Default::default() + }) + .unwrap(); + + let child1 = + taffy.new_leaf_with_required_measure(taffy::style::FlexboxLayout { ..Default::default() }).unwrap(); + + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100.0), ..Default::default() }, + align_items: taffy::style::AlignItems::FlexStart, + ..Default::default() + }, + &[child0, child1], + ) + .unwrap(); + + let measure = HeightIsTwiceWidth(100.); + taffy.compute_measured_layout(node, &measure, taffy::geometry::Size::undefined()).unwrap(); + + assert_eq!(taffy.layout(child1).unwrap().size.width, 50.0); + assert_eq!(taffy.layout(child1).unwrap().size.height, 100.0); + } + + #[test] + fn remeasure_child_after_stretching() { + struct WidthEqualsHeight(f32); + + impl Measure for WidthEqualsHeight { + fn measure(&self, _node: Node, constraint: Size>) -> Size { + let WidthEqualsHeight(size) = self; + let height = constraint.height.unwrap_or(*size); + let width = constraint.width.unwrap_or(height); + taffy::geometry::Size { width, height } + } + } + + let mut taffy = taffy::node::Taffy::new(); + + let child = taffy.new_leaf_with_required_measure(taffy::style::FlexboxLayout { ..Default::default() }).unwrap(); + + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100.0), + height: taffy::style::Dimension::Points(100.0), + }, + ..Default::default() + }, + &[child], + ) + .unwrap(); + + let measure = WidthEqualsHeight(50.); + taffy.compute_measured_layout(node, &measure, taffy::geometry::Size::undefined()).unwrap(); + + assert_eq!(taffy.layout(child).unwrap().size.width, 100.0); + assert_eq!(taffy.layout(child).unwrap().size.height, 100.0); + } + + #[test] + fn width_overrides_measure() { + let mut taffy = taffy::node::Taffy::new(); + let child = taffy + .new_leaf_with_required_measure(taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50.0), ..Default::default() }, + ..Default::default() + }) + .unwrap(); + + let node = taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[child]).unwrap(); + + let measure = ReturnConstraintOrStored(100., 100.); + taffy.compute_measured_layout(node, &measure, taffy::geometry::Size::undefined()).unwrap(); + + assert_eq!(taffy.layout(child).unwrap().size.width, 50.0); + assert_eq!(taffy.layout(child).unwrap().size.height, 100.0); + } + + #[test] + fn height_overrides_measure() { + let mut taffy = taffy::node::Taffy::new(); + let child = taffy + .new_leaf_with_required_measure(taffy::style::FlexboxLayout { + size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50.0), ..Default::default() }, + ..Default::default() + }) + .unwrap(); + + let node = taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[child]).unwrap(); + + let measure = ReturnConstraintOrStored(100., 100.); + taffy.compute_measured_layout(node, &measure, taffy::geometry::Size::undefined()).unwrap(); + + assert_eq!(taffy.layout(child).unwrap().size.width, 100.0); + assert_eq!(taffy.layout(child).unwrap().size.height, 50.0); + } + + #[test] + fn flex_basis_overrides_measure() { + let mut taffy = taffy::node::Taffy::new(); + let child0 = taffy + .new_leaf(taffy::style::FlexboxLayout { + flex_basis: taffy::style::Dimension::Points(50.0), + flex_grow: 1.0, + ..Default::default() + }) + .unwrap(); + + let child1 = taffy + .new_leaf_with_required_measure(taffy::style::FlexboxLayout { + flex_basis: taffy::style::Dimension::Points(50.0), + flex_grow: 1.0, + ..Default::default() + }) + .unwrap(); + + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200.0), + height: taffy::style::Dimension::Points(100.0), + }, + ..Default::default() + }, + &[child0, child1], + ) + .unwrap(); + + let measure = ReturnConstraintOrStored(100., 100.); + taffy.compute_measured_layout(node, &measure, taffy::geometry::Size::undefined()).unwrap(); + + assert_eq!(taffy.layout(child0).unwrap().size.width, 100.0); + assert_eq!(taffy.layout(child0).unwrap().size.height, 100.0); + assert_eq!(taffy.layout(child1).unwrap().size.width, 100.0); + assert_eq!(taffy.layout(child1).unwrap().size.height, 100.0); + } + + #[test] + fn stretch_overrides_measure() { + let mut taffy = taffy::node::Taffy::new(); + let child = taffy.new_leaf_with_required_measure(taffy::style::FlexboxLayout { ..Default::default() }).unwrap(); + + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100.0), + height: taffy::style::Dimension::Points(100.0), + }, + ..Default::default() + }, + &[child], + ) + .unwrap(); + + let measure = ReturnConstraintOrStored(50., 50.); + taffy.compute_measured_layout(node, &measure, taffy::geometry::Size::undefined()).unwrap(); + + assert_eq!(taffy.layout(child).unwrap().size.width, 50.0); + assert_eq!(taffy.layout(child).unwrap().size.height, 100.0); + } + + #[test] + fn measure_absolute_child() { + let mut taffy = taffy::node::Taffy::new(); + let child = taffy + .new_leaf_with_required_measure(taffy::style::FlexboxLayout { + position_type: taffy::style::PositionType::Absolute, + ..Default::default() + }) + .unwrap(); + + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100.0), + height: taffy::style::Dimension::Points(100.0), + }, + ..Default::default() + }, + &[child], + ) + .unwrap(); + + let measure = ReturnConstraintOrStored(50., 50.); + taffy.compute_measured_layout(node, &measure, taffy::geometry::Size::undefined()).unwrap(); + + assert_eq!(taffy.layout(child).unwrap().size.width, 50.0); + assert_eq!(taffy.layout(child).unwrap().size.height, 50.0); + } + + #[test] + fn ignore_invalid_measure() { + let mut taffy = taffy::node::Taffy::new(); + let child = taffy.new_leaf(taffy::style::FlexboxLayout { flex_grow: 1.0, ..Default::default() }).unwrap(); + + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100.0), + height: taffy::style::Dimension::Points(100.0), + }, + ..Default::default() + }, + &[child], + ) + .unwrap(); + + taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); + + assert_eq!(taffy.layout(child).unwrap().size.width, 100.0); + assert_eq!(taffy.layout(child).unwrap().size.height, 100.0); + } + + #[test] + fn only_measure_once() { + use std::sync::atomic; + struct CountingMeasure { + width: f32, + height: f32, + num_measures: atomic::AtomicU32, + } + + impl Measure for CountingMeasure { + fn measure(&self, _node: Node, constraint: Size>) -> Size { + self.num_measures.fetch_add(1, atomic::Ordering::Relaxed); + Size { width: constraint.width.unwrap_or(self.width), height: constraint.height.unwrap_or(self.height) } + } + } + + let measure = CountingMeasure { width: 50., height: 50., num_measures: atomic::AtomicU32::new(0) }; + + let mut taffy = taffy::node::Taffy::new(); + + let grandchild = + taffy.new_leaf_with_required_measure(taffy::style::FlexboxLayout { ..Default::default() }).unwrap(); + + let child = + taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[grandchild]).unwrap(); + + let node = taffy.new_with_children(taffy::style::FlexboxLayout { ..Default::default() }, &[child]).unwrap(); + taffy.compute_measured_layout(node, &measure, taffy::geometry::Size::undefined()).unwrap(); + + assert_eq!(measure.num_measures.load(atomic::Ordering::Relaxed), 2); + } +} diff --git a/tests/relayout.rs b/tests/relayout.rs new file mode 100644 index 000000000..2345ea187 --- /dev/null +++ b/tests/relayout.rs @@ -0,0 +1,44 @@ +use taffy::style::Dimension; + +#[test] +fn relayout() { + let mut taffy = taffy::Taffy::new(); + let node1 = taffy + .new_leaf(taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: Dimension::Points(8f32), height: Dimension::Points(80f32) }, + ..Default::default() + }) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + align_self: taffy::prelude::AlignSelf::Center, + size: taffy::geometry::Size { width: Dimension::Auto, height: Dimension::Auto }, + // size: taffy::geometry::Size { width: Dimension::Percent(1.0), height: Dimension::Percent(1.0) }, + ..Default::default() + }, + &[node1], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: Dimension::Percent(1f32), height: Dimension::Percent(1f32) }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + println!("0:"); + taffy.compute_layout(node, taffy::geometry::Size { width: Some(100f32), height: Some(100f32) }).unwrap(); + let initial = taffy.layout(node).unwrap().location; + let initial0 = taffy.layout(node0).unwrap().location; + let initial1 = taffy.layout(node1).unwrap().location; + for i in 1..10 { + println!("\n\n{i}:"); + taffy.compute_layout(node, taffy::geometry::Size { width: Some(100f32), height: Some(100f32) }).unwrap(); + assert_eq!(taffy.layout(node).unwrap().location, initial); + assert_eq!(taffy.layout(node0).unwrap().location, initial0); + assert_eq!(taffy.layout(node1).unwrap().location, initial1); + } +} diff --git a/tests/root_constraints.rs b/tests/root_constraints.rs new file mode 100644 index 000000000..f31467a0c --- /dev/null +++ b/tests/root_constraints.rs @@ -0,0 +1,55 @@ +#[cfg(test)] +mod root_constraints { + + #[test] + fn root_with_percentage_size() { + let mut taffy = taffy::node::Taffy::new(); + let node = taffy + .new_leaf(taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(1.0), + height: taffy::style::Dimension::Percent(1.0), + }, + ..Default::default() + }) + .unwrap(); + + taffy.compute_layout(node, taffy::geometry::Size { width: Some(100.0), height: Some(200.0) }).unwrap(); + let layout = taffy.layout(node).unwrap(); + + assert_eq!(layout.size.width, 100.0); + assert_eq!(layout.size.height, 200.0); + } + + #[test] + fn root_with_no_size() { + let mut taffy = taffy::node::Taffy::new(); + let node = taffy.new_leaf(taffy::style::FlexboxLayout { ..Default::default() }).unwrap(); + + taffy.compute_layout(node, taffy::geometry::Size { width: Some(100.0), height: Some(100.0) }).unwrap(); + let layout = taffy.layout(node).unwrap(); + + assert_eq!(layout.size.width, 0.0); + assert_eq!(layout.size.height, 0.0); + } + + #[test] + fn root_with_larger_size() { + let mut taffy = taffy::node::Taffy::new(); + let node = taffy + .new_leaf(taffy::style::FlexboxLayout { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200.0), + height: taffy::style::Dimension::Points(200.0), + }, + ..Default::default() + }) + .unwrap(); + + taffy.compute_layout(node, taffy::geometry::Size { width: Some(100.0), height: Some(100.0) }).unwrap(); + let layout = taffy.layout(node).unwrap(); + + assert_eq!(layout.size.width, 200.0); + assert_eq!(layout.size.height, 200.0); + } +} diff --git a/tests/simple_child.rs b/tests/simple_child.rs new file mode 100644 index 000000000..002fa0f5a --- /dev/null +++ b/tests/simple_child.rs @@ -0,0 +1,62 @@ +use taffy::{geometry::Point, style::Dimension}; + +#[test] +fn simple_child() { + let mut taffy = taffy::Taffy::new(); + let node0_0 = taffy + .new_leaf(taffy::style::FlexboxLayout { + align_self: taffy::prelude::AlignSelf::Center, + size: taffy::geometry::Size { width: Dimension::Points(10f32), height: Dimension::Points(10f32) }, + ..Default::default() + }) + .unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: Dimension::Points(10f32), height: Dimension::Points(10f32) }, + ..Default::default() + }, + &[node0_0], + ) + .unwrap(); + let node1_0 = taffy + .new_leaf(taffy::style::FlexboxLayout { + align_self: taffy::prelude::AlignSelf::Center, + size: taffy::geometry::Size { width: Dimension::Points(10f32), height: Dimension::Points(10f32) }, + ..Default::default() + }) + .unwrap(); + let node1_1 = taffy + .new_leaf(taffy::style::FlexboxLayout { + align_self: taffy::prelude::AlignSelf::Center, + size: taffy::geometry::Size { width: Dimension::Points(10f32), height: Dimension::Points(10f32) }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: Dimension::Undefined, height: Dimension::Undefined }, + ..Default::default() + }, + &[node1_0, node1_1], + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::FlexboxLayout { + size: taffy::geometry::Size { width: Dimension::Percent(100.0), height: Dimension::Percent(100.0) }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size { width: Some(100.), height: Some(100.) }).unwrap(); + assert_eq!(taffy.layout(node).unwrap().location, Point { x: 0.0, y: 0.0 }); + assert_eq!(taffy.layout(node0).unwrap().location, Point { x: 0.0, y: 0.0 }); + assert_eq!(taffy.layout(node1).unwrap().location, Point { x: 10.0, y: 0.0 }); + assert_eq!(taffy.layout(node0_0).unwrap().location, Point { x: 0.0, y: 0.0 }); + // Layout is relative so node1_0 location starts at (0,0) and is not ofset by it's parent location + assert_eq!(taffy.layout(node1_0).unwrap().location, Point { x: 00.0, y: 0.0 }); + assert_eq!(taffy.layout(node1_1).unwrap().location, Point { x: 10.0, y: 0.0 }); +}