From 571fbe9e0b8372b4bd7aec59d2863ce85c00fb5a Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 28 Nov 2026 06:45:29 +0100 Subject: [PATCH] layout: max_scroll from the unclamped extent; declare dismiss in tests --- crates/thing-core/src/layout/mod.rs | 10 ++++++---- crates/thing-core/tests/layout.rs | 8 +++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/thing-core/src/layout/mod.rs b/crates/thing-core/src/layout/mod.rs index 001a96f..c732a35 100644 --- a/crates/thing-core/src/layout/mod.rs +++ b/crates/thing-core/src/layout/mod.rs @@ -167,13 +167,15 @@ fn solve<'a>( let (x, y) = (px + laid.location.x, py + laid.location.y); absolute.push((x, y)); let (w, h) = (laid.size.width, laid.size.height); - let content = entry.scroll.then(|| { + // Taffy's content extent is measured from the padding box. `content` is never smaller than + // the border box; `max_scroll` is what the content reaches past the padding box. + let reached = entry.scroll.then(|| { let overflow = laid.scrollable_overflow_rect.rect(); let round = |v: f32| (v + 0.5).floor(); - (clean(round(overflow.right).max(w)), clean(round(overflow.bottom).max(h))) + (round(overflow.right), round(overflow.bottom)) }); - // What the content reaches past the padding box, which is what an offset may scroll. - let max_scroll = content.map(|(cw, ch)| { + let content = reached.map(|(cw, ch)| (clean(cw.max(w)), clean(ch.max(h)))); + let max_scroll = reached.map(|(cw, ch)| { let inner_w = w - laid.border.left - laid.border.right; let inner_h = h - laid.border.top - laid.border.bottom; (clean((cw - inner_w).max(0.0)), clean((ch - inner_h).max(0.0))) diff --git a/crates/thing-core/tests/layout.rs b/crates/thing-core/tests/layout.rs index dd9f719..99e441c 100644 --- a/crates/thing-core/tests/layout.rs +++ b/crates/thing-core/tests/layout.rs @@ -238,7 +238,8 @@ fn surface_of(root: Node) -> SurfaceDocument { version: ver(1), title: "inline".into(), root, - commands: vec![], + // Declared so an overlay can name it as its dismiss. + commands: vec![CommandDecl { id: CommandId::new("dismiss"), payload_schema: SchemaId::new("gamecult.thing.test.dismiss.v1"), captures: vec![], confirm: None }], } } @@ -1156,10 +1157,7 @@ fn scroll_extent_is_measured_from_the_padding_box() { let style = BoxStyle { overflow: Overflow::Scroll, direction: Direction::Column, ..sized(100.0, 100.0) }; let laid = lay(bx("root", plain(), vec![bx_paint("list", style, paint, rows)]), 400.0, 300.0); let list = laid.nodes.iter().find(|n| n.id.as_str() == "list").unwrap(); - println!("PROBE border: content {:?} max_scroll {:?}", list.content, list.max_scroll); - let (_, content_h) = list.content.unwrap(); - let (_, scroll_y) = list.max_scroll.unwrap(); - assert_eq!(scroll_y, content_h - 92.0); + assert_eq!(list.max_scroll, Some((0.0, 158.0))); } #[test]