Decide reuse on the box a widget drew against, in pixels

Two holes the random trees found, both of which kept a wrapping text shaped
for a width it no longer had.

**A region is a fraction of a slot's box, so an unchanged region is not an
unchanged box.** `try_reuse` compared regions, and a child drawn at
`UiRegion::FULL` of a slot whose box had just halved compared equal to
itself and was reused without being descended into. `ActiveData` now keeps
the pixel size of the box it drew against and the comparison is against
that, which is the question that was being asked all along and is right
through a slot change and an output resize alike.

**A size the parent learnt by drawing the child is an answer for that box
only.** The walk looking for what cannot survive a length change skipped a
child whose own box was a fixed width -- correctly, its box does not change
-- but that width was what the child reported when the span drew it in the
span's box, and the span's box did change. So a child whose size the widget
read is redrawn unless it declares an exact `size_hint` for the changed
axis, which is the one case the parent did not have to draw it to know.

The cost is that a size-reading container gives up its reuse when its box
changes length, which is every span, so `OnResize::Scale` now earns its
keep on moves and on subtrees whose sizes nobody read rather than on every
stretch. Correct first; `replace_cost` still measures the case the chain was
built for.

`tests/generated.rs` is what found both and what says they are fixed: 90 of
90 warm trees now land where a cold build does, against 83 before this
commit and 83 on `db1751f`. The ignored sweep agrees over 300 checks on 100
seeds.

`a_fixed_length_child_is_not_redrawn_when_the_box_around_it_grows` became
`a_declared_length_...`: the child now says its width, since a width the
span measured is not one it may keep.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
iris-aiandClaude Opus 5 committed 2026-09-14 13:23:29 -04:00
1 parent 86a7e8dfc3
commit b0f9f046da
4 files changed
+65 -32

No files matched your search

+4 -6
View File
@@ -17,9 +17,7 @@ use iris::prelude::*;
use iris::random::{Lens, Rng, Tree, grow};
const DEPTH: usize = 4;
/// Seeds whose trees agree. The ones left out are `a_wrapping_child_of_a_row`
/// below, which is a defect older than the chain.
const SEEDS: [u64; 6] = [2, 3, 4, 5, 8, 9];
const SEEDS: [u64; 6] = [1, 2, 3, 5, 8, 13];
fn plant(h: &mut Harness, seed: u64, edits: &HashMap<usize, Lens>) -> Tree {
let (root, tree) = grow(&mut h.rsc, seed, DEPTH, edits);
@@ -161,9 +159,9 @@ fn a_size_change_after_a_resize_lands_the_same_way() {
/// same defect, and it wants fixing where the two draws meet -- LAYOUT.md §4 --
/// rather than anywhere in the chain.
#[test]
#[ignore = "known divergence, and the reproduction for fixing it"]
fn a_wrapping_child_of_a_row_settles_somewhere_else_each_time() {
for seed in 1..=30 {
#[ignore = "a hundred seeds, rather than the six the others check"]
fn a_long_run_of_seeds_agrees() {
for seed in 1..=100 {
changed_size(seed);
resized(seed);
resized_then_changed(seed);