Upgrade to Taffy 0.4 (#7868)

Upgraded Taffy to v0.4.0 from crates.io (previously using prerelease
version from git).

Code changes required were minor as gpui was already using a recent
version of Taffy.

Release Notes:

- N/A
This commit is contained in:
Nico Burns 2024-02-16 11:30:39 +13:00 committed by GitHub
parent 94426c4393
commit 694e18417e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 12 deletions

View file

@ -6,17 +6,15 @@ use collections::{FxHashMap, FxHashSet};
use smallvec::SmallVec;
use std::fmt::Debug;
use taffy::{
geometry::{Point as TaffyPoint, Rect as TaffyRect, Size as TaffySize},
style::AvailableSpace as TaffyAvailableSpace,
tree::NodeId,
Taffy,
AvailableSpace as TaffyAvailableSpace, NodeId, Point as TaffyPoint, Rect as TaffyRect,
Size as TaffySize, TaffyTree, TraversePartialTree,
};
type NodeMeasureFn =
Box<dyn FnMut(Size<Option<Pixels>>, Size<AvailableSpace>, &mut WindowContext) -> Size<Pixels>>;
pub struct TaffyLayoutEngine {
taffy: Taffy,
taffy: TaffyTree<()>,
styles: FxHashMap<LayoutId, Style>,
children_to_parents: FxHashMap<LayoutId, LayoutId>,
absolute_layout_bounds: FxHashMap<LayoutId, Bounds<Pixels>>,
@ -29,7 +27,7 @@ static EXPECT_MESSAGE: &str = "we should avoid taffy layout errors by constructi
impl TaffyLayoutEngine {
pub fn new() -> Self {
TaffyLayoutEngine {
taffy: Taffy::new(),
taffy: TaffyTree::new(),
styles: FxHashMap::default(),
children_to_parents: FxHashMap::default(),
absolute_layout_bounds: FxHashMap::default(),
@ -120,7 +118,7 @@ impl TaffyLayoutEngine {
fn max_depth(&self, depth: u32, parent: LayoutId) -> anyhow::Result<u32> {
println!(
"{parent:?} at depth {depth} has {} children",
self.taffy.child_count(parent.0)?
self.taffy.child_count(parent.0)
);
let mut max_child_depth = 0;