Merge main into feat/scripts-api-d8b-tracing

This commit is contained in:
dotCooCoo committed 2026-12-02 02:46:39 -08:00
commit 47a8bcde18
38 files changed
+2780 -190

No files matched your search

+31
View File
@@ -195,6 +195,37 @@ fn page_item_size_setters_on_a_rotated_object_give_the_page_aligned_size() {
assert_eq!(format!("{:?}", s.active().unwrap().doc.node(b)), other, "the other object stays as it was");
}
/// Type in a document in the back that the switch to that document measures again (here: not
/// measured yet) is sized and moved by the bounds measured after the switch.
#[test]
fn page_item_size_and_position_setters_measure_type_in_a_back_document_after_the_switch() {
let mut s = Session::new();
s.execute("file.new", &json!({"width": 400, "height": 300})).unwrap();
let id = NodeId(s.execute("text.create", &json!({"x": 10, "y": 100, "text": "Wide type here", "size": 40})).unwrap()["id"].as_u64().unwrap());
let uid = s.active().unwrap().uid;
s.execute("file.new", &json!({"width": 200, "height": 100})).unwrap();
let front = s.active().unwrap().uid;
let unmeasure = |s: &mut Session| {
let st = s.document_mut(uid).unwrap();
if let Some(NodeKind::Text(t)) = std::sync::Arc::make_mut(&mut st.doc).node_mut(id).map(|n| &mut n.kind) {
t.cached_bounds = None;
t.cached_baselines.clear();
}
};
let mut got = Vec::new();
for (set, want) in
[("t.width = 150; vc.log(t.width);", 150.0), ("t.height = 90; vc.log(t.height);", 90.0), ("t.top = 200; vc.log(t.top);", 200.0)]
{
unmeasure(&mut s);
let out = log(&mut s, &format!("var t = app.documents[1].pageItems[0]; {set}"));
got.push((set, out[0].as_f64().unwrap(), want));
}
for (set, got, want) in got {
assert!((got - want).abs() < 1e-6, "{set} read {got}");
}
assert_eq!(s.active().unwrap().uid, front, "the front document stays in front");
}
/// `controlBounds` holds a curve's handles, which reach past the curve; for a rectangle it is the
/// visible bounds.
#[test]