layout: overlays in the never-panic sweep; no 'offset' in layout

This commit is contained in:
Meta Vens 2026-11-28 06:48:31 +01:00
commit 0995694789
2 changed files with 6 additions and 4 deletions

View file

@ -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,
}

View file

@ -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())));
}
}