diff --git a/crates/thing-core/src/layout/mod.rs b/crates/thing-core/src/layout/mod.rs index c732a35..71c646f 100644 --- a/crates/thing-core/src/layout/mod.rs +++ b/crates/thing-core/src/layout/mod.rs @@ -60,9 +60,9 @@ pub struct LaidNode { pub id: NodeId, pub rect: Rect, pub content: Option<(f32, f32)>, - /// How far `content` reaches past the padding box, never negative: the most an offset may - /// scroll. Input owns the offset and clamps it here; render and hit-test translate the - /// children by it. Layout never sees an offset, so a scroll never re-runs layout. + /// How far `content` reaches past the padding box, never negative: the furthest the content + /// may scroll. Input clamps its position here; render and hit-test translate the children by + /// it. Layout never sees a scroll position, so a scroll never re-runs layout. pub max_scroll: Option<(f32, f32)>, pub clip: bool, } diff --git a/crates/thing-core/tests/layout.rs b/crates/thing-core/tests/layout.rs index 2ee4f99..533a3d4 100644 --- a/crates/thing-core/tests/layout.rs +++ b/crates/thing-core/tests/layout.rs @@ -925,11 +925,13 @@ fn random_styles_never_panic() { let root = bx("root", styles[0].clone(), vec![ leaf("a", &styles[1]), bx("m", styles[2].clone(), vec![leaf("b", &styles[3]), leaf("c", &styles[4])]), + overlay("oa", at("a"), vec![leaf("o", &styles[2])]), + overlay("ov", Anchor::Viewport, vec![leaf("p", &styles[4]), overlay("on", at("o"), vec![leaf("q", &styles[1])])]), ]); let scale = [1.0, 1.5, 2.0][round % 3]; let tree = bind(&mut MemState::new(), &surface_of(root)).unwrap(); let Ok(laid) = layout(&tree, &pixels(800.0, 600.0, scale), &mut FixedMeasure::pixels(&[])) else { continue }; - assert!(laid.nodes.iter().all(|n| [n.rect.x, n.rect.y, n.rect.w, n.rect.h].iter().all(|v| v.is_finite()))); + assert!(laid.nodes.iter().all(|n| [n.rect.x, n.rect.y, n.rect.w, n.rect.h].iter().chain(n.max_scroll.iter().flat_map(|m| [&m.0, &m.1])).all(|v| v.is_finite()))); } }