feat: constrain flex bases and redistribute bounded growth and shrink
Verify Tessera GUI / verify (push) Failing after 9m4s
Verify Tessera GUI / verify (push) Failing after 9m4s
This commit is contained in:
+12
-4
@@ -68,6 +68,7 @@ struct Plan {
|
||||
nodes: Vec<Arc<UiNode>>,
|
||||
children: Vec<Vec<usize>>,
|
||||
sizes: Vec<Size>,
|
||||
preferred: Vec<Option<Size>>,
|
||||
bounds: Vec<Option<[f32; 4]>>,
|
||||
runtime: LayoutRuntime,
|
||||
custom: bool,
|
||||
@@ -125,7 +126,7 @@ impl NativeCallable for Step {
|
||||
self.phase.method(),
|
||||
self.desktop,
|
||||
)?;
|
||||
let (node, children, bounds, native_size) = {
|
||||
let (node, children, preferred, bounds, native_size) = {
|
||||
let mut plan = self
|
||||
.plan
|
||||
.lock()
|
||||
@@ -135,6 +136,10 @@ impl NativeCallable for Step {
|
||||
.iter()
|
||||
.map(|child| plan.sizes[*child])
|
||||
.collect::<Vec<_>>();
|
||||
let preferred = plan.children[self.index]
|
||||
.iter()
|
||||
.map(|child| plan.preferred[*child].unwrap_or(plan.sizes[*child]))
|
||||
.collect::<Vec<_>>();
|
||||
let bounds = if matches!(self.phase, Phase::Arrange) {
|
||||
plan.bounds[self.index]
|
||||
} else {
|
||||
@@ -194,9 +199,9 @@ impl NativeCallable for Step {
|
||||
if matches!(self.phase, Phase::Arrange) {
|
||||
plan.runtime.arranged += 1;
|
||||
plan.custom_arrange[self.index] =
|
||||
!intrinsic || node.children().iter().any(|child| child.flex > 0.0);
|
||||
!intrinsic || node.children().iter().any(|child| child.has_flex());
|
||||
}
|
||||
(node, children, bounds, native_size)
|
||||
(node, children, preferred, bounds, native_size)
|
||||
};
|
||||
let context = mount.layout.ok_or(invalid("missing pre-layout context"))?;
|
||||
{
|
||||
@@ -205,6 +210,7 @@ impl NativeCallable for Step {
|
||||
.map_err(|_| invalid("layout context poisoned"))?;
|
||||
context.node = Some(node);
|
||||
context.children = children;
|
||||
context.preferred = preferred;
|
||||
context.bounds = bounds;
|
||||
}
|
||||
if let Some(size) = native_size {
|
||||
@@ -385,6 +391,7 @@ impl NativeCallable for Collect {
|
||||
);
|
||||
}
|
||||
}
|
||||
plan.preferred[self.index].get_or_insert(size);
|
||||
plan.sizes[self.index] = size;
|
||||
if self.index == 0 {
|
||||
plan.bounds[0] = Some([0.0, 0.0, size.width, size.height]);
|
||||
@@ -686,7 +693,7 @@ pub fn render(
|
||||
let mut nodes = Vec::new();
|
||||
let mut work = vec![root.clone()];
|
||||
while let Some(node) = work.pop() {
|
||||
custom |= node.flex > 0.0;
|
||||
custom |= node.has_flex();
|
||||
work.extend(node.children().iter().rev().cloned());
|
||||
nodes.push(node);
|
||||
}
|
||||
@@ -727,6 +734,7 @@ pub fn render(
|
||||
let count = nodes.len();
|
||||
let plan = Arc::new(Mutex::new(Plan {
|
||||
sizes: vec![Size::default(); nodes.len()],
|
||||
preferred: vec![None; nodes.len()],
|
||||
bounds: vec![None; nodes.len()],
|
||||
nodes,
|
||||
children,
|
||||
|
||||
Reference in New Issue
Block a user