tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 583HTML 275Markdown 8TOML 41586 Sutichaykuna

fix root min/max

30dcc345e93fa855ce4bf92cadee21a8602de392 · ruwaq Emil Sjölander · (7 wata ñawpaq) · tayta e190f9900 · kay commitpi sach'ata qhaway

Semántico sayk'uy · 1

src/algo.rs

  • ukhunpi t'ikrakurqan fn compute pub

1 qillqakuna · +13 −4

diff --git a/src/algo.rs b/src/algo.rs
index cd3b035a3..69d06e50a 100644
--- a/src/algo.rs
+++ b/src/algo.rs
@@ -68,14 +68,23 @@ struct FlexLine<'a> {
 }
 
 pub fn compute(root: &style::Node) -> layout::Node {
+    // TODO - Don't do two passes here just to handle min/max.
+    // Probably want to pass min/max down as top level paramerer instead.
+    let first_pass = compute_internal(
+        root,
+        root.width.resolve(f32::NAN, f32::NAN),
+        root.height.resolve(f32::NAN, f32::NAN),
+        f32::NAN,
+        f32::NAN,
+        f32::NAN,
+    );
+
     let result = compute_internal(
         root,
-        root.width
-            .resolve(f32::NAN, f32::NAN)
+        first_pass.size.width
             .max(root.min_width.resolve(f32::NAN, f32::NAN))
             .min(root.max_width.resolve(f32::NAN, f32::NAN)),
-        root.height
-            .resolve(f32::NAN, f32::NAN)
+        first_pass.size.height
             .max(root.min_height.resolve(f32::NAN, f32::NAN))
             .min(root.max_height.resolve(f32::NAN, f32::NAN)),
         f32::NAN,