gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 788HTML 740Markdown 12TOML 62535 Definiciones

Enable `taffy_tree` feature when running tests in CI (#453)

* Enable taffy_tree feature for tests in CI

* Enable taffy_tree feature for tests in CI

* Add extra missing feature flag

* Fix imports in compute/taffy_tree module

* Add missing LayoutAlgorithm import

2f5d0d1df229df22613a9cd7cd1bd74e3f192d47 · por Nico Burns · (hace 3 años) · padre fda1f88ed · ver el árbol en este commit

Delta semántico · 1

src/compute/taffy_tree.rs

2 archivos · +26 −21

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index aa8e1c130..d8b5be01e 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -18,7 +18,7 @@ jobs:
       - uses: dtolnay/rust-toolchain@stable
       - uses: Leafwing-Studios/cargo-cache@v1
       - run: cargo build --no-default-features
-      - run: cargo test --no-default-features
+      - run: cargo test --no-default-features --features taffy_tree
 
   # Default
   test-features-default:
@@ -46,7 +46,8 @@ jobs:
       - uses: actions/checkout@v3
       - uses: dtolnay/rust-toolchain@stable
       - run: cargo build --no-default-features --features std
-      - run: cargo test --no-default-features --features std
+      - run: cargo build --no-default-features --features std,taffy_tree
+      - run: cargo test --no-default-features --features std,taffy_tree
 
   # Flexbox
   test-features-flexbox:
@@ -56,7 +57,8 @@ jobs:
       - uses: actions/checkout@v3
       - uses: dtolnay/rust-toolchain@stable
       - run: cargo build --no-default-features --features flexbox,std
-      - run: cargo test --no-default-features --features flexbox,std
+      - run: cargo build --no-default-features --features flexbox,std,taffy_tree
+      - run: cargo test --no-default-features --features flexbox,std,taffy_tree
 
   # Grid
   test-features-grid:
@@ -66,7 +68,8 @@ jobs:
       - uses: actions/checkout@v3
       - uses: dtolnay/rust-toolchain@stable
       - run: cargo build --no-default-features --features grid,std
-      - run: cargo test --no-default-features --features grid,std
+      - run: cargo build --no-default-features --features grid,std,taffy_tree
+      - run: cargo test --no-default-features --features grid,std,taffy_tree
 
   test-features-grid-with-alloc:
     name: "Test Suite [Features: grid + alloc]"
@@ -75,7 +78,8 @@ jobs:
       - uses: actions/checkout@v3
       - uses: dtolnay/rust-toolchain@stable
       - run: cargo build --no-default-features --features alloc,grid
-      - run: cargo test --no-default-features --features alloc,grid
+      - run: cargo build --no-default-features --features alloc,grid,taffy_tree
+      - run: cargo test --no-default-features --features alloc,grid,taffy_tree
 
   test-features-alloc:
     name: "Test Suite [Features: alloc]"
@@ -84,7 +88,8 @@ jobs:
       - uses: actions/checkout@v3
       - uses: dtolnay/rust-toolchain@stable
       - run: cargo build --no-default-features --features alloc
-      - run: cargo test  --no-default-features --features alloc
+      - run: cargo build --no-default-features --features alloc,taffy_tree
+      - run: cargo test  --no-default-features --features alloc,taffy_tree
 
   test-features-default-no-grid:
     name: "Test Suite [Features: std (no grid)]"
@@ -94,7 +99,8 @@ jobs:
       - uses: dtolnay/rust-toolchain@stable
       - uses: Leafwing-Studios/cargo-cache@v1
       - run: cargo build --no-default-features --features std
-      - run: cargo test --no-default-features --features std
+      - run: cargo build --no-default-features --features std,taffy_tree
+      - run: cargo test --no-default-features --features std,taffy_tree
 
   fmt:
     name: Rustfmt
diff --git a/src/compute/taffy_tree.rs b/src/compute/taffy_tree.rs
index d9cf43c73..27eae8319 100644
--- a/src/compute/taffy_tree.rs
+++ b/src/compute/taffy_tree.rs
@@ -1,17 +1,16 @@
 //! Computation specific for the default `Taffy` tree implementation
 
-use crate::{
-    compute::{
-        leaf::{measure_size, perform_layout},
-        HiddenAlgorithm,
-    },
-    geometry::Point,
-    prelude::{Layout, NodeId, Size},
-    style::{AvailableSpace, Display},
-    tree::{RunMode, SizeAndBaselines, SizingMode},
-    util::sys::round,
-    CssGridAlgorithm, FlexboxAlgorithm, LayoutAlgorithm, LayoutTree, Taffy, TaffyError,
-};
+use crate::compute::{leaf, HiddenAlgorithm, LayoutAlgorithm};
+use crate::geometry::{Point, Size};
+use crate::style::{AvailableSpace, Display};
+use crate::tree::{Layout, LayoutTree, NodeId, RunMode, SizeAndBaselines, SizingMode, Taffy, TaffyError};
+use crate::util::sys::round;
+
+#[cfg(feature = "flexbox")]
+use crate::compute::FlexboxAlgorithm;
+
+#[cfg(feature = "grid")]
+use crate::compute::CssGridAlgorithm;
 
 /// Updates the stored layout of the provided `node` and its children
 pub(crate) fn compute_layout(
@@ -156,7 +155,7 @@ fn compute_node_layout(
             sizing_mode,
         ),
         (_, false) => match run_mode {
-            RunMode::PeformLayout => perform_layout(
+            RunMode::PeformLayout => leaf::perform_layout(
                 &tree.nodes[node_key].style,
                 tree.nodes[node_key].needs_measure.then(|| &tree.measure_funcs[node_key]),
                 known_dimensions,
@@ -164,7 +163,7 @@ fn compute_node_layout(
                 available_space,
                 sizing_mode,
             ),
-            RunMode::ComputeSize => measure_size(
+            RunMode::ComputeSize => leaf::measure_size(
                 &tree.nodes[node_key].style,
                 tree.nodes[node_key].needs_measure.then(|| &tree.measure_funcs[node_key]),
                 known_dimensions,