feat: allocate weighted flex space and remeasure affected occurrences
Verify Tessera GUI / verify (push) Failing after 7m59s

This commit is contained in:
2026-10-22 22:01:28 +08:00
parent 0c1cc12b6b
commit 78fb66277d
12 changed files with 202 additions and 18 deletions
+87
View File
@@ -3889,6 +3889,93 @@ page.render(block)
);
}
#[test]
fn native_flex_reflows_shared_text_per_occurrence() {
let (mut session, initial) = ReplSession::load(
r#"
paragraph = TextBlock("Shared text has one object identity and separate layout constraints in each occurrence. Changing the sibling weight reflows only the affected occurrence.")
paragraph.flex = 1
filler = RectBlock(20, 20)
filler.flex = 1
first = Row(10, 10, paragraph, filler)
second = Row(10, 10, paragraph, RectBlock(300, 20))
page = Page()
page.render(Column(10, 10, first, second))
"#,
"app.main",
266,
1,
)
.unwrap();
initial.validate().unwrap();
let height = |session: &mut ReplSession, index| -> f32 {
session
.execute(
&format!("paragraph.mounts().at({index}).bounds().height"),
"app.main",
)
.unwrap()
.value
.parse()
.unwrap()
};
let before = height(&mut session, 0);
let other = height(&mut session, 1);
assert!(before > other);
session.execute("filler.flex = 3", "app.main").unwrap();
assert!(height(&mut session, 0) > before);
assert_eq!(height(&mut session, 1), other);
}
#[test]
fn weighted_flex_remeasures_children_and_updates_live_weights() {
let (mut session, initial) = ReplSession::load(r#"
class Wide: Row {
function measure(self: Wide, mount: Mount, constraints: Constraints): MeasureResult { return MeasureResult(340, 40) }
}
first = RectBlock(20, 20)
fixed = RectBlock(60, 20)
last = RectBlock(40, 20)
first.flex = 1
last.flex = 2
row = Wide(10, 10, first, fixed, last)
page = Page()
page.render(row)
"#, "app.main", 265, 1).unwrap();
initial.validate().unwrap();
assert_eq!(
session
.execute("first.mounts().at(0).bounds().width", "app.main")
.unwrap()
.value,
"80"
);
assert_eq!(
session
.execute("last.mounts().at(0).bounds().width", "app.main")
.unwrap()
.value,
"160"
);
session
.execute("first.flex = 3\nlast.flex = 1", "app.main")
.unwrap();
assert_eq!(
session
.execute("first.mounts().at(0).bounds().width", "app.main")
.unwrap()
.value,
"180"
);
assert_eq!(
session
.execute("last.mounts().at(0).bounds().width", "app.main")
.unwrap()
.value,
"60"
);
}
#[test]
fn main_alignment_updates_live_geometry_without_changing_sizes() {
let (mut session, initial) = ReplSession::load(r#"