feat: constrain flex bases and redistribute bounded growth and shrink
Verify Tessera GUI / verify (push) Failing after 9m4s

This commit is contained in:
2026-10-23 00:42:48 +08:00
parent 78fb66277d
commit 1fda07ebc5
12 changed files with 298 additions and 55 deletions
+16 -6
View File
@@ -148,7 +148,11 @@ impl NativeCallable for Method {
let layout = layout
.lock()
.map_err(|_| invalid("layout context poisoned"))?;
Ok::<_, VmError>((layout.node.clone(), layout.children.clone()))
Ok::<_, VmError>((
layout.node.clone(),
layout.children.clone(),
layout.preferred.clone(),
))
})
.transpose()?;
let input = object(input)?;
@@ -162,12 +166,12 @@ impl NativeCallable for Method {
x >= 0.0 && y >= 0.0 && x < geometry.width && y < geometry.height,
)));
}
if matches!(&staged, Some((None, _))) {
if matches!(&staged, Some((None, _, _))) {
return Err(invalid(
"layout context is not prepared for this occurrence",
));
}
let node = if let Some((Some(node), _)) = &staged {
let node = if let Some((Some(node), _, _)) = &staged {
node.clone()
} else {
block::snapshot(cx.store(), owner)?
@@ -181,7 +185,7 @@ impl NativeCallable for Method {
if min_w > max_w || min_h > max_h {
return Err(invalid("minimum exceeds maximum constraint"));
}
let size = if let Some((_, children)) = &staged {
let size = if let Some((_, children, _)) = &staged {
layout::measure_native(&node, children.clone(), [min_w, min_h, max_w, max_h])
.map_err(|_| invalid("native measurement exceeds layout limits"))?
} else {
@@ -205,7 +209,7 @@ impl NativeCallable for Method {
if x + width > MAX_DIMENSION as f32 || y + height > MAX_DIMENSION as f32 {
return Err(invalid("visual bounds exceed limits"));
}
let children = if let Some((_, children)) = &staged {
let children = if let Some((_, children, _)) = &staged {
children.clone()
} else {
node.children()
@@ -222,7 +226,13 @@ impl NativeCallable for Method {
})
.collect::<Result<Vec<_>, _>>()?
};
let children = layout::flex_sizes(&node, Size { width, height }, &children);
let preferred = staged
.as_ref()
.map_or(children.as_slice(), |(_, _, preferred)| {
preferred.as_slice()
});
let children =
layout::flex_sizes(&node, Size { width, height }, &children, preferred);
let points = layout::arrange_native(&node, x, y, Size { width, height }, &children)
.map_err(|_| invalid("native arrangement exceeds limits"))?;
let mut result = Vec::new();