Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ edition = "2024"
xkbcommon = { version = "0.8", default-features = false }
wasm_thread = { git = "https://github.com/zed-industries/wasm_thread", rev = "0cf96c7708dfb97ccf3da50347e25edcf75d6937", version = "0.3", features = ["es_modules"] }
tracing-subscriber = "0.3"
taffy = { version = "=0.13.0", default-features = false }
taffy = { version = "=0.14.0", default-features = false }
oo7 = { version = "0.6", default-features = false }
font-kit = { git = "https://github.com/zed-industries/font-kit", rev = "94b0f28166665e8fd2f53ff6d268a14955c82269", package = "zed-font-kit", version = "0.14.1-zed", default-features = false }
web-sys = "0.3"
Expand Down
38 changes: 36 additions & 2 deletions crates/gpui/src/fast/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -839,8 +839,11 @@ impl TaffyLayoutEngine {
width: taffy::style::Dimension::length(given.width),
height: taffy::style::Dimension::length(given.height),
};
held.min_size = held.size;
held.max_size = held.size;
held.min_size = taffy::geometry::Size {
width: taffy::style::LengthPercentageAuto::length(given.width),
height: taffy::style::LengthPercentageAuto::length(given.height),
};
held.max_size = held.min_size;
held.box_sizing = taffy::style::BoxSizing::BorderBox;
self.taffy.set_style(id.into(), held).expect(EXPECT_MESSAGE);
self.compute_layout(id, available_space, window, cx);
Expand Down Expand Up @@ -1127,6 +1130,37 @@ fn request_measured_node(
id
}

/// The tree as [`TaffyLayoutEngine::compute_layout`] lays it out: each leaf is
/// measured by a function of the constraints Taffy measures it under. Since
/// 0.14, Taffy hands that function the leaf's whole layout instead; this lays
/// the leaf out around the measurement, as Taffy did before.
pub(crate) struct MeasuredTaffy<'a>(pub(crate) &'a mut TaffyTree<NodeContext>);

impl MeasuredTaffy<'_> {
pub(crate) fn compute_layout_with_measure(
self,
node: taffy::NodeId,
available_space: taffy::Size<taffy::AvailableSpace>,
mut measure: impl FnMut(
taffy::Size<Option<f32>>,
taffy::Size<taffy::AvailableSpace>,
taffy::NodeId,
Option<&mut NodeContext>,
&taffy::Style,
) -> taffy::Size<f32>,
) -> taffy::TaffyResult<()> {
self.0
.compute_layout_with_measure(node, available_space, |inputs, id, context, style| {
taffy::compute_leaf_layout(
inputs,
style,
|_, _| 0.0,
|known, available| measure(known, available, id, context, style),
)
})
}
}

/// Measures, with the closures they were given this frame, the measured
/// nodes [`request_retained_measured_layout`] left clean, under every
/// constraint their [`MeasureLog`] holds, dirtying those whose size came out
Expand Down
2 changes: 1 addition & 1 deletion crates/gpui/src/taffy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ impl TaffyLayoutEngine {

crate::fast::layout::replay_pending_measures(self, window, cx);
let mut measures = crate::fast::stats::begin_measure_tally(self);
self.taffy
crate::fast::layout::MeasuredTaffy(&mut self.taffy)
.compute_layout_with_measure(
id.into(),
available_space.into(),
Expand Down
9 changes: 9 additions & 0 deletions docs/upstream-sync.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@ unchanged, and a new entry needs as good a reason.
layers from the scene. Polychrome sprites whose texture index is at or
above `LAYER_TILE_TEXTURE_BASE` are scroll layer tiles, not atlas textures.
- `crates/gpui/Cargo.toml` names this repository and sets `publish = false`.
- The workspace pins Taffy 0.14 where upstream pins 0.13. Taffy 0.13 keeps
one cached size per kind of constraint, so a node measured under two widths
in one layout evicts one with the other, and the clean subtrees around a
single dirty node are laid out again on every frame; 0.14 keeps nine sizes
per node whatever their kind. 0.14 hands a leaf's measure function its whole
layout, so `taffy.rs` lays the tree out through
`fast::layout::MeasuredTaffy`, which lays each leaf out around GPUI's
measurement as 0.13 did. When upstream moves to 0.14 or later, the sync
takes its version and drops `MeasuredTaffy`.
- Window composition, the API of
[zed#62379](https://github.com/zed-industries/zed/pull/62379), which
upstream has not merged yet: native views drawn between a window's GPUI
Expand Down
Loading