diff --git a/Cargo.toml b/Cargo.toml index 19ae17f1..ddece921 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,7 +38,7 @@ dioxus-core = { version = "0.6" } dioxus-html = { version = "0.6" } dioxus-cli-config = { version = "0.6" } dioxus-devtools = { version = "0.6" } -taffy = { version = "0.6", default-features = false, features = ["std", "flexbox", "grid", "block_layout", "content_size"] } +taffy = { git = "https://github.com/dioxuslabs/taffy", rev = "63f4adebf", default-features = false, features = ["std", "flexbox", "grid", "block_layout", "content_size"] } # Linebender + WGPU peniko = "0.2" diff --git a/packages/blitz-dom/src/layout/mod.rs b/packages/blitz-dom/src/layout/mod.rs index c2edaf0c..40a084ff 100644 --- a/packages/blitz-dom/src/layout/mod.rs +++ b/packages/blitz-dom/src/layout/mod.rs @@ -15,7 +15,7 @@ use std::cell::Ref; use std::sync::Arc; use taffy::{ compute_block_layout, compute_cached_layout, compute_flexbox_layout, compute_grid_layout, - compute_leaf_layout, prelude::*, Cache, FlexDirection, LayoutPartialTree, NodeId, + compute_leaf_layout, prelude::*, FlexDirection, LayoutPartialTree, NodeId, ResolveOrZero, RoundTree, Style, TraversePartialTree, TraverseTree, }; @@ -70,10 +70,6 @@ impl LayoutPartialTree for Document { = &'a taffy::Style where Self: 'a; - type CacheMut<'b> - = &'b mut Cache - where - Self: 'b; fn get_core_container_style(&self, node_id: NodeId) -> &Style { &self.node_from_id(node_id).style @@ -83,10 +79,6 @@ impl LayoutPartialTree for Document { self.node_from_id_mut(node_id).unrounded_layout = *layout; } - fn get_cache_mut(&mut self, node_id: NodeId) -> &mut Cache { - &mut self.node_from_id_mut(node_id).cache - } - fn compute_child_layout( &mut self, node_id: NodeId, @@ -281,6 +273,43 @@ impl LayoutPartialTree for Document { } } +impl taffy::CacheTree for Document { + #[inline] + fn cache_get( + &self, + node_id: NodeId, + known_dimensions: Size>, + available_space: Size, + run_mode: taffy::RunMode, + ) -> Option { + self.node_from_id(node_id) + .cache + .get(known_dimensions, available_space, run_mode) + } + + #[inline] + fn cache_store( + &mut self, + node_id: NodeId, + known_dimensions: Size>, + available_space: Size, + run_mode: taffy::RunMode, + layout_output: taffy::LayoutOutput, + ) { + self.node_from_id_mut(node_id).cache.store( + known_dimensions, + available_space, + run_mode, + layout_output, + ); + } + + #[inline] + fn cache_clear(&mut self, node_id: NodeId) { + self.node_from_id_mut(node_id).cache.clear(); + } +} + impl taffy::LayoutBlockContainer for Document { type BlockContainerStyle<'a> = &'a Style diff --git a/packages/blitz-dom/src/layout/table.rs b/packages/blitz-dom/src/layout/table.rs index cbde4973..af9c8e65 100644 --- a/packages/blitz-dom/src/layout/table.rs +++ b/packages/blitz-dom/src/layout/table.rs @@ -193,10 +193,6 @@ impl taffy::LayoutPartialTree for TableTreeWrapper<'_> { = &'a taffy::Style where Self: 'a; - type CacheMut<'b> - = &'b mut taffy::Cache - where - Self: 'b; fn get_core_container_style(&self, _node_id: taffy::NodeId) -> &taffy::Style { &self.ctx.style @@ -207,11 +203,6 @@ impl taffy::LayoutPartialTree for TableTreeWrapper<'_> { self.doc.set_unrounded_layout(node_id, layout) } - fn get_cache_mut(&mut self, node_id: taffy::NodeId) -> &mut taffy::Cache { - let node_id = taffy::NodeId::from(self.ctx.items[usize::from(node_id)].node_id); - &mut self.doc.node_from_id_mut(node_id).cache - } - fn compute_child_layout( &mut self, node_id: taffy::NodeId,