gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 1081HTML 1013Markdown 12TOML 83219 Definitions

clean up tests

791f63b8cc0eff89e2f8e26e58c3bb4990e5ec7d · by Emil Sjölander · (7 years ago) · parent f7955ba2d · browse the tree at this commit

Semantic delta · 5

src/algo.rs

6 files · +56 −53

diff --git a/src/algo.rs b/src/algo.rs
index 5703dd385..501dd1b1f 100644
--- a/src/algo.rs
+++ b/src/algo.rs
@@ -900,9 +900,8 @@ fn compute_internal(
     for line in &mut flex_lines {
         // TODO this is super basic and has to be fixed to support a lot more such as custom baselines
         // as well as nested children.
-        let baseline: f32 = line.items.iter().map(|child| {
-            child.hypothetical_outer_cross_size
-        }).fold(0.0, |acc, x| acc.max(x));
+        let baseline: f32 =
+            line.items.iter().map(|child| child.hypothetical_outer_cross_size).fold(0.0, |acc, x| acc.max(x));
 
         for child in &mut line.items {
             // TODO probably move this somewhere else, as with main margin resolution. Only auto margins should be resolved here.
@@ -948,9 +947,13 @@ fn compute_internal(
                             } else {
                                 // basline alignment only makes sense if the direction is row
                                 // we treat it as flex-start alignment in columns.
-                                if wrap_reverse { free_space } else { 0.0 }
+                                if wrap_reverse {
+                                    free_space
+                                } else {
+                                    0.0
+                                }
                             }
-                        },
+                        }
                         style::AlignSelf::Stretch => if wrap_reverse {
                             free_space
                         } else {
diff --git a/test_fixtures/align_items_center_child_with_margin_bigger_than_parent.html b/test_fixtures/align_items_center_child_with_margin_bigger_than_parent.html
index e93ec83d4..c4df92a8b 100644
--- a/test_fixtures/align_items_center_child_with_margin_bigger_than_parent.html
+++ b/test_fixtures/align_items_center_child_with_margin_bigger_than_parent.html
@@ -9,9 +9,9 @@
 <head/>
 <body>
 
-<div id="test-root" style="height: 52px; width: 52px; align-items: center; justify-content: center;">
+<div id="test-root" style="height: 50px; width: 50px; align-items: center; justify-content: center;">
   <div style="align-items: center;">
-    <div style="width: 52px; height: 52px; margin-left: 10px; margin-right: 10px;"></div>
+    <div style="width: 50px; height: 50px; margin-left: 10px; margin-right: 10px;"></div>
   </div>
 </div>
 
diff --git a/test_fixtures/align_items_center_child_without_margin_bigger_than_parent.html b/test_fixtures/align_items_center_child_without_margin_bigger_than_parent.html
index e6ff72279..d938cff9d 100644
--- a/test_fixtures/align_items_center_child_without_margin_bigger_than_parent.html
+++ b/test_fixtures/align_items_center_child_without_margin_bigger_than_parent.html
@@ -9,9 +9,9 @@
 <head/>
 <body>
 
-<div id="test-root" style="height: 52px; width: 52px; align-items: center; justify-content: center;">
+<div id="test-root" style="height: 50px; width: 50px; align-items: center; justify-content: center;">
   <div style="align-items: center;">
-    <div style="width: 72px; height: 72px;"></div>
+    <div style="width: 70px; height: 70px;"></div>
   </div>
 </div>
 
diff --git a/test_fixtures/align_items_flex_end_child_with_margin_bigger_than_parent.html b/test_fixtures/align_items_flex_end_child_with_margin_bigger_than_parent.html
index 1a92aef71..9fde8bbd3 100644
--- a/test_fixtures/align_items_flex_end_child_with_margin_bigger_than_parent.html
+++ b/test_fixtures/align_items_flex_end_child_with_margin_bigger_than_parent.html
@@ -9,9 +9,9 @@
 <head/>
 <body>
 
-<div id="test-root" style="height: 52px; width: 52px; align-items: center; justify-content: center;">
+<div id="test-root" style="height: 50px; width: 50px; align-items: center; justify-content: center;">
   <div style="align-items: flex-end;">
-    <div style="width: 52px; height: 52px; margin-left: 10px; margin-right: 10px;"></div>
+    <div style="width: 50px; height: 50px; margin-left: 10px; margin-right: 10px;"></div>
   </div>
 </div>
 
diff --git a/test_fixtures/align_items_flex_end_child_without_margin_bigger_than_parent.html b/test_fixtures/align_items_flex_end_child_without_margin_bigger_than_parent.html
index bfe7dff5b..4a77ecadc 100644
--- a/test_fixtures/align_items_flex_end_child_without_margin_bigger_than_parent.html
+++ b/test_fixtures/align_items_flex_end_child_without_margin_bigger_than_parent.html
@@ -9,9 +9,9 @@
 <head/>
 <body>
 
-<div id="test-root" style="height: 52px; width: 52px; align-items: center; justify-content: center;">
+<div id="test-root" style="height: 50px; width: 50px; align-items: center; justify-content: center;">
   <div style="align-items: flex-end;">
-    <div style="width: 72px; height: 72px;"></div>
+    <div style="width: 70px; height: 70px;"></div>
   </div>
 </div>
 
diff --git a/tests/generated.rs b/tests/generated.rs
index 97ebb9356..cbe0ace66 100644
--- a/tests/generated.rs
+++ b/tests/generated.rs
@@ -2829,13 +2829,13 @@ mod generated {
         let layout = stretch::compute(&stretch::style::Node {
             align_items: stretch::style::AlignItems::Center,
             justify_content: stretch::style::JustifyContent::Center,
-            width: stretch::style::Dimension::Points(52.0000),
-            height: stretch::style::Dimension::Points(52.0000),
+            width: stretch::style::Dimension::Points(50.0000),
+            height: stretch::style::Dimension::Points(50.0000),
             children: vec![stretch::style::Node {
                 align_items: stretch::style::AlignItems::FlexEnd,
                 children: vec![stretch::style::Node {
-                    width: stretch::style::Dimension::Points(72.0000),
-                    height: stretch::style::Dimension::Points(72.0000),
+                    width: stretch::style::Dimension::Points(70.0000),
+                    height: stretch::style::Dimension::Points(70.0000),
                     ..Default::default()
                 }],
                 ..Default::default()
@@ -2843,18 +2843,18 @@ mod generated {
             ..Default::default()
         });
 
-        assert_eq!(layout.width, 52.0000);
-        assert_eq!(layout.height, 52.0000);
+        assert_eq!(layout.width, 50.0000);
+        assert_eq!(layout.height, 50.0000);
         assert_eq!(layout.x, 0.0000);
         assert_eq!(layout.y, 0.0000);
 
-        assert_eq!(layout.children[0].width, 72.0000);
-        assert_eq!(layout.children[0].height, 72.0000);
+        assert_eq!(layout.children[0].width, 70.0000);
+        assert_eq!(layout.children[0].height, 70.0000);
         assert_eq!(layout.children[0].x, -10.0000);
         assert_eq!(layout.children[0].y, -10.0000);
 
-        assert_eq!(layout.children[0].children[0].width, 72.0000);
-        assert_eq!(layout.children[0].children[0].height, 72.0000);
+        assert_eq!(layout.children[0].children[0].width, 70.0000);
+        assert_eq!(layout.children[0].children[0].height, 70.0000);
         assert_eq!(layout.children[0].children[0].x, 0.0000);
         assert_eq!(layout.children[0].children[0].y, 0.0000);
     }
@@ -3344,13 +3344,13 @@ mod generated {
         let layout = stretch::compute(&stretch::style::Node {
             align_items: stretch::style::AlignItems::Center,
             justify_content: stretch::style::JustifyContent::Center,
-            width: stretch::style::Dimension::Points(52.0000),
-            height: stretch::style::Dimension::Points(52.0000),
+            width: stretch::style::Dimension::Points(50.0000),
+            height: stretch::style::Dimension::Points(50.0000),
             children: vec![stretch::style::Node {
                 align_items: stretch::style::AlignItems::Center,
                 children: vec![stretch::style::Node {
-                    width: stretch::style::Dimension::Points(52.0000),
-                    height: stretch::style::Dimension::Points(52.0000),
+                    width: stretch::style::Dimension::Points(50.0000),
+                    height: stretch::style::Dimension::Points(50.0000),
                     margin: stretch::style::Edges {
                         start: stretch::style::Dimension::Points(10.0000),
                         end: stretch::style::Dimension::Points(10.0000),
@@ -3363,18 +3363,18 @@ mod generated {
             ..Default::default()
         });
 
-        assert_eq!(layout.width, 52.0000);
-        assert_eq!(layout.height, 52.0000);
+        assert_eq!(layout.width, 50.0000);
+        assert_eq!(layout.height, 50.0000);
         assert_eq!(layout.x, 0.0000);
         assert_eq!(layout.y, 0.0000);
 
-        assert_eq!(layout.children[0].width, 72.0000);
-        assert_eq!(layout.children[0].height, 52.0000);
+        assert_eq!(layout.children[0].width, 70.0000);
+        assert_eq!(layout.children[0].height, 50.0000);
         assert_eq!(layout.children[0].x, -10.0000);
         assert_eq!(layout.children[0].y, 0.0000);
 
-        assert_eq!(layout.children[0].children[0].width, 52.0000);
-        assert_eq!(layout.children[0].children[0].height, 52.0000);
+        assert_eq!(layout.children[0].children[0].width, 50.0000);
+        assert_eq!(layout.children[0].children[0].height, 50.0000);
         assert_eq!(layout.children[0].children[0].x, 10.0000);
         assert_eq!(layout.children[0].children[0].y, 0.0000);
     }
@@ -3889,13 +3889,13 @@ mod generated {
         let layout = stretch::compute(&stretch::style::Node {
             align_items: stretch::style::AlignItems::Center,
             justify_content: stretch::style::JustifyContent::Center,
-            width: stretch::style::Dimension::Points(52.0000),
-            height: stretch::style::Dimension::Points(52.0000),
+            width: stretch::style::Dimension::Points(50.0000),
+            height: stretch::style::Dimension::Points(50.0000),
             children: vec![stretch::style::Node {
                 align_items: stretch::style::AlignItems::Center,
                 children: vec![stretch::style::Node {
-                    width: stretch::style::Dimension::Points(72.0000),
-                    height: stretch::style::Dimension::Points(72.0000),
+                    width: stretch::style::Dimension::Points(70.0000),
+                    height: stretch::style::Dimension::Points(70.0000),
                     ..Default::default()
                 }],
                 ..Default::default()
@@ -3903,18 +3903,18 @@ mod generated {
             ..Default::default()
         });
 
-        assert_eq!(layout.width, 52.0000);
-        assert_eq!(layout.height, 52.0000);
+        assert_eq!(layout.width, 50.0000);
+        assert_eq!(layout.height, 50.0000);
         assert_eq!(layout.x, 0.0000);
         assert_eq!(layout.y, 0.0000);
 
-        assert_eq!(layout.children[0].width, 72.0000);
-        assert_eq!(layout.children[0].height, 72.0000);
+        assert_eq!(layout.children[0].width, 70.0000);
+        assert_eq!(layout.children[0].height, 70.0000);
         assert_eq!(layout.children[0].x, -10.0000);
         assert_eq!(layout.children[0].y, -10.0000);
 
-        assert_eq!(layout.children[0].children[0].width, 72.0000);
-        assert_eq!(layout.children[0].children[0].height, 72.0000);
+        assert_eq!(layout.children[0].children[0].width, 70.0000);
+        assert_eq!(layout.children[0].children[0].height, 70.0000);
         assert_eq!(layout.children[0].children[0].x, 0.0000);
         assert_eq!(layout.children[0].children[0].y, 0.0000);
     }
@@ -5759,13 +5759,13 @@ mod generated {
         let layout = stretch::compute(&stretch::style::Node {
             align_items: stretch::style::AlignItems::Center,
             justify_content: stretch::style::JustifyContent::Center,
-            width: stretch::style::Dimension::Points(52.0000),
-            height: stretch::style::Dimension::Points(52.0000),
+            width: stretch::style::Dimension::Points(50.0000),
+            height: stretch::style::Dimension::Points(50.0000),
             children: vec![stretch::style::Node {
                 align_items: stretch::style::AlignItems::FlexEnd,
                 children: vec![stretch::style::Node {
-                    width: stretch::style::Dimension::Points(52.0000),
-                    height: stretch::style::Dimension::Points(52.0000),
+                    width: stretch::style::Dimension::Points(50.0000),
+                    height: stretch::style::Dimension::Points(50.0000),
                     margin: stretch::style::Edges {
                         start: stretch::style::Dimension::Points(10.0000),
                         end: stretch::style::Dimension::Points(10.0000),
@@ -5778,18 +5778,18 @@ mod generated {
             ..Default::default()
         });
 
-        assert_eq!(layout.width, 52.0000);
-        assert_eq!(layout.height, 52.0000);
+        assert_eq!(layout.width, 50.0000);
+        assert_eq!(layout.height, 50.0000);
         assert_eq!(layout.x, 0.0000);
         assert_eq!(layout.y, 0.0000);
 
-        assert_eq!(layout.children[0].width, 72.0000);
-        assert_eq!(layout.children[0].height, 52.0000);
+        assert_eq!(layout.children[0].width, 70.0000);
+        assert_eq!(layout.children[0].height, 50.0000);
         assert_eq!(layout.children[0].x, -10.0000);
         assert_eq!(layout.children[0].y, 0.0000);
 
-        assert_eq!(layout.children[0].children[0].width, 52.0000);
-        assert_eq!(layout.children[0].children[0].height, 52.0000);
+        assert_eq!(layout.children[0].children[0].width, 50.0000);
+        assert_eq!(layout.children[0].children[0].height, 50.0000);
         assert_eq!(layout.children[0].children[0].x, 10.0000);
         assert_eq!(layout.children[0].children[0].y, 0.0000);
     }