Add per-Mount scrolling with shared paint and input clipping
Verify Tessera GUI / verify (push) Failing after 7m33s

This commit is contained in:
2026-10-21 22:05:08 +08:00
parent 7acc5783a5
commit 6e69c5e5ce
18 changed files with 784 additions and 33 deletions
+156
View File
@@ -1008,6 +1008,7 @@ mod tests {
mount,
kind: "click".into(),
point: None,
delta: None,
press_point: None
})
.is_err()
@@ -1190,6 +1191,7 @@ mod tests {
mount: initial.frame.tabs[0].id,
kind: "tab-activate".into(),
point: None,
delta: None,
press_point: None,
};
let selected = session.dispatch(&input).unwrap().document.unwrap();
@@ -1217,6 +1219,7 @@ mod tests {
mount: renamed.frame.tabs[1].id,
kind: "tab-close".into(),
point: None,
delta: None,
press_point: None,
})
.unwrap()
@@ -1431,6 +1434,7 @@ mod tests {
mount: mount.id,
kind: "click".into(),
point: None,
delta: None,
press_point: None,
})
.unwrap()
@@ -1757,6 +1761,7 @@ mod tests {
mount: circle.id,
kind: "click".into(),
point: Some(release),
delta: None,
press_point: Some(press),
})
.unwrap();
@@ -1800,6 +1805,7 @@ mod tests {
mount: circle.id,
kind: "click".into(),
point: Some([64.0, 64.0]),
delta: None,
press_point: Some([64.0, 64.0]),
})
.err()
@@ -2265,6 +2271,7 @@ mod tests {
mount: mount.id,
kind: "click".into(),
point: None,
delta: None,
press_point: None,
})
.unwrap()
@@ -2544,6 +2551,7 @@ mod tests {
mount: mount.id,
kind: "click".into(),
point: None,
delta: None,
press_point: None,
};
let updated = session.dispatch(&event).unwrap().document.unwrap();
@@ -2562,6 +2570,154 @@ mod tests {
assert!(!session.is_faulted());
}
#[test]
fn scroll_occurrences_are_independent_and_clipped_pointer_input_is_ignored() {
let (mut session, initial) =
ReplSession::load(include_str!("../examples/scroll.endor"), "app.main", 1, 240)
.unwrap();
let globals = session.candidate.globals.unwrap();
let Value::Object(middle) = session
.candidate
.vm
.dict_get(globals, &Value::Text("middle".into()))
.unwrap()
.unwrap()
else {
panic!("expected Block");
};
let target = initial
.frame
.mounts
.iter()
.find(|m| m.block_id == middle.to_string())
.unwrap();
let point = [
target.x + target.width / 2.0,
target.y + target.height / 2.0,
];
assert!(!target.contains(crate::geometry::Point::new(point[0], point[1])));
session
.dispatch(&crate::events::Input {
window: 1,
session: 240,
layout_version: initial.frame.layout_version,
mount: target.id,
kind: "click".into(),
point: Some(point),
press_point: Some(point),
delta: None,
})
.unwrap();
assert_eq!(
session.execute("count.value", "app.main").unwrap().value,
"0"
);
session.execute("saved = scroller.mounts().at(0)\nsaved.scrollTo(0,100)\nsaved.scrollBy(0,20)\nsaved.scrollBy(0,30)","app.main").unwrap();
assert_eq!(
session
.execute("saved.scrollPosition().y", "app.main")
.unwrap()
.value,
"150"
);
assert_eq!(
session
.execute("scroller.mounts().at(1).scrollPosition().y", "app.main")
.unwrap()
.value,
"0"
);
session
.execute("last.mounts().at(0).scrollIntoView()", "app.main")
.unwrap();
let Value::Object(last) = session
.candidate
.vm
.dict_get(globals, &Value::Text("last".into()))
.unwrap()
.unwrap()
else {
panic!("expected Block");
};
let frame = &session.documents[&crate::window::MAIN_WINDOW].frame;
let target = frame
.mounts
.iter()
.find(|m| m.block_id == last.to_string())
.unwrap();
assert!(target.contains(crate::geometry::Point::new(
target.x + target.width / 2.0,
target.y + target.height / 2.0
)));
assert_eq!(frame.command_clips.len(), frame.commands.len());
session
.execute("scroller.height = 1000", "app.main")
.unwrap();
assert_eq!(
session
.execute("saved.scrollPosition().y", "app.main")
.unwrap()
.value,
"0"
);
assert_eq!(
session
.execute("saved.scrollPosition().maxY", "app.main")
.unwrap()
.value,
"0"
);
}
#[test]
fn nested_scroll_into_view_and_source_paint_share_clipped_geometry() {
let mut session = ReplSession::new(241).unwrap();
let result = session
.execute(
r#"
class Painted: RectBlock {
function paint(self: Painted, mount: Mount, geometry: Bounds): DisplayList {
return RectBlock.paint(self,mount,geometry)
}
}
last = Button("last")
inner = ScrollBlock(160,100,Column(0,8,Painted(200,180),last))
outer = ScrollBlock(180,140,Column(0,8,RectBlock(180,180),inner))
page = Page()
page.render(outer)
"#,
"app.main",
)
.unwrap()
.document
.unwrap();
assert!(result.frame.command_clips.iter().any(Option::is_some));
session
.execute("last.mounts().at(0).scrollIntoView()", "app.main")
.unwrap();
assert_eq!(
session
.execute("inner.mounts().at(0).scrollPosition().y", "app.main")
.unwrap()
.value,
"128"
);
assert_eq!(
session
.execute("outer.mounts().at(0).scrollPosition().y", "app.main")
.unwrap()
.value,
"148"
);
assert_eq!(
session
.execute("last.mounts().at(0).hitTest(10,110)", "app.main")
.unwrap()
.value,
"true"
);
}
#[test]
fn presentable_dispatch_preserves_source_identity_and_reactive_display() {
let (mut session, initial) = ReplSession::load(