Repository navigation
Conversation
taffy 0.15 returns TaffyResult everywhere but panics on a missing node
through its own slotmap indexing, so the 49 `.expect("node exists" …)`
sites could never have been handled at the call. `LayoutTree` wraps the
tree and is the one place that maps taffy's results. Every node is made
by `new_node(style, kids, node)` with its context, so "has a context" is
the existence check made before each taffy call.
A miss reports Problem::Internal("taffy: missing node") (a refusal,
"taffy: refused") at the caller, to the context of the last build
(reset/scratch), and falls back: a default Layout and Style, no
children, no node, and a no-op set_style/compute. A missing child is
left out of new_node.
leaf_node and container return their NodeId, removing the
`kids.last().expect` sites.
No behaviour change for a well-formed tree; no golden changed. The
max_content_width candidate root now carries a bare Root node so it
passes the existence check, like every other node.
Part of #279. Fixes #284.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
Owner
Author
|
Gate (my run on de8e7f6 with current main): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #279
Fixes #284
What
src/layout_tree.rs: a crate-privateLayoutTreearoundTaffyTree<Node>, the one place taffy'sTaffyResultis mapped. taffy 0.15 panics on a missing node in its own slotmap indexing rather than returningErr, so the wrapper checks existence first. Every node is made bynew_nodewith its context, so "has a context" is the existence check.API (all
#[track_caller], so the report names the calling site):new(),scratch()(an empty tree that reports to the same context),reset(ctx)(clear, then report toctx)new_node(style, kids, node) -> NodeId: a missing kid is left out and reported. If taffy refuses, the result is a dangling id that every accessor treats as missing.node(id) -> Option<&Node>,node_mut(id) -> Option<&mut Node>layout(id) -> Layout(default when missing),style(id) -> &Style(Style::DEFAULT),children(id) -> Vec<NodeId>(empty)set_style(id, style),compute(root, available, measure): no-ops when the node is missingA miss reports
Problem::Internal("taffy: missing node"); a taffyErrreportsProblem::Internal("taffy: refused").leaf_nodeandcontainerreturn theirNodeId.handle(node)takes it, so thekids.last().expectsites are gone.Sites converted
kids.last) and 5 Result-handling sitesThat is 49 library expects. measure, roots, stack, draw and debug make no taffy-tree accesses.
Reporting
Every accessor reports, to the context of the build that last reset the tree. A scratch tree inherits that context. The only silent case is a tree that has never been reset: before the first build, and in unit tests that never call
reset.Behaviour
For a well-formed tree, nothing changes. CI is green (
cargo xtask ciexit 0) and no golden changed. Themax_content_widthcandidate root now carries a bareRootnode like every other node; its layout is the same.When a child is missing,
collectreturns early, and the parent's reach widening (widen_reach) skips the missing child instead of indexing it.Left for WP4 (structural expects kept as-is)
the node is identified(builderNodeHandle::id),a context menu needs an identified node,a scroll leaf has a scroll node(pipelinesolve_content),a list's container is a scroll container(vlistview),a root's body was built,a scroll container is identified(pipelinecollect),the node is inside the root(pipelinereachable).Likely conflicts with #300
In builder.rs:
attach_draw(both rewrite it),region()(thekids.last/leaf_textlines sit next to #300'sadd_region), the collapsiblematch step(#300 editsexited.pushinside it), and the window root. In region.rs: theuse taffyimport line. Each is small and mechanical.🤖 Generated with Claude Code