tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 497HTML 254C 19JavaScript 81329 Definiciones

minor fixes

416e9c6d4965ac3c68f60caafa5145f871cacf4f · por Emil Sjölander · (hace 7 años) · padre 2d65e48bf · ver el árbol en este commit

Delta semántico · 5

src/algo.rs

src/style.rs

  • cambió de firma struct Node pub
  • cambió por dentro fn default

tests/generated.rs

5 archivos · +20 −18

diff --git a/src/algo.rs b/src/algo.rs
index a85e0ba60..c766c671a 100644
--- a/src/algo.rs
+++ b/src/algo.rs
@@ -189,7 +189,7 @@ fn compute_internal(
     let (inner_intrinsic_main_size, inner_intrinsic_cross_size) =
         (intrinsic_main_size - padding_main - border_main, intrinsic_cross_size - padding_cross - border_cross);
 
-    let wrap_reverse = node.flexWrap == style::FlexWrap::WrapReverse;
+    let wrap_reverse = node.flex_wrap == style::FlexWrap::WrapReverse;
 
     // 9.2. Line Length Determination
 
@@ -358,7 +358,7 @@ fn compute_internal(
         let mut lines: Vec<FlexLine> = vec![];
         let mut line_length = 0.0;
 
-        if node.flexWrap == style::FlexWrap::NoWrap {
+        if node.flex_wrap == style::FlexWrap::NoWrap {
             lines.push(FlexLine { items: flex_items, cross_size: 0.0, offset_cross: 0.0 });
         } else {
             let mut line = FlexLine { items: vec![], cross_size: 0.0, offset_cross: 0.0 };
@@ -992,13 +992,17 @@ fn compute_internal(
         let end_main = child.main_end(node.flex_direction).resolve(container_main_size, f32::NAN);
         let main = if start_main.is_finite() && end_main.is_finite() {
             container_main_size - start_main - end_main
-        } else { f32::NAN };
+        } else {
+            f32::NAN
+        };
 
         let start_cross = child.cross_start(node.flex_direction).resolve(container_cross_size, f32::NAN);
         let end_cross = child.cross_end(node.flex_direction).resolve(container_cross_size, f32::NAN);
-        let cross = if start_cross.is_finite() && end_cross.is_finite() { 
+        let cross = if start_cross.is_finite() && end_cross.is_finite() {
             container_cross_size - start_cross - end_cross
-         } else { f32::NAN };
+        } else {
+            f32::NAN
+        };
 
         let result = compute_internal(
             child,
diff --git a/src/style.rs b/src/style.rs
index c2b78d365..a71a8d70c 100644
--- a/src/style.rs
+++ b/src/style.rs
@@ -196,7 +196,7 @@ pub struct Node {
     pub direction: Direction,
     pub flex_direction: FlexDirection,
 
-    pub flexWrap: FlexWrap,
+    pub flex_wrap: FlexWrap,
     pub overflow: Overflow,
 
     pub align_items: AlignItems,
@@ -238,7 +238,7 @@ impl Default for Node {
             direction: Default::default(),
             flex_direction: Default::default(),
 
-            flexWrap: Default::default(),
+            flex_wrap: Default::default(),
             overflow: Default::default(),
 
             align_items: Default::default(),
diff --git a/test_fixtures/wrap_column.html b/test_fixtures/wrap_column.html
index 0934d06a4..64952c74b 100644
--- a/test_fixtures/wrap_column.html
+++ b/test_fixtures/wrap_column.html
@@ -9,7 +9,7 @@
 <head/>
 <body>
 
-<div id="test-root" style="width: 100px; height: 100px; flex-wrap: wrap; flex-direction: column;">
+<div id="test-root" style="height: 100px; flex-wrap: wrap; flex-direction: column;">
   <div style="height: 31px; width: 30px;"></div>
   <div style="height: 32px; width: 30px;"></div>
   <div style="height: 33px; width: 30px;"></div>
diff --git a/test_fixtures/wrap_reverse_column.html b/test_fixtures/wrap_reverse_column.html
index 2794228c7..d61bcd7eb 100644
--- a/test_fixtures/wrap_reverse_column.html
+++ b/test_fixtures/wrap_reverse_column.html
@@ -9,7 +9,7 @@
 <head/>
 <body>
 
-<div id="test-root" style="width: 100px; height: 100px; flex-wrap: wrap-reverse; flex-direction: column;">
+<div id="test-root" style="height: 100px; flex-wrap: wrap-reverse; flex-direction: column;">
   <div style="height: 31px; width: 30px;"></div>
   <div style="height: 32px; width: 30px;"></div>
   <div style="height: 33px; width: 30px;"></div>
diff --git a/tests/generated.rs b/tests/generated.rs
index 1a1b806f0..1d5f5a692 100644
--- a/tests/generated.rs
+++ b/tests/generated.rs
@@ -3418,7 +3418,6 @@ mod generated {
         let layout = stretch::compute(&stretch::style::Node {
             flex_direction: stretch::style::FlexDirection::Column,
             flexWrap: stretch::style::FlexWrap::WrapReverse,
-            width: stretch::style::Dimension::Points(100.0000),
             height: stretch::style::Dimension::Points(100.0000),
             children: vec![
                 stretch::style::Node {
@@ -3445,29 +3444,29 @@ mod generated {
             ..Default::default()
         });
 
-        assert_eq!(layout.width, 100.0000);
+        assert_eq!(layout.width, 30.0000);
         assert_eq!(layout.height, 100.0000);
         assert_eq!(layout.x, 0.0000);
         assert_eq!(layout.y, 0.0000);
 
         assert_eq!(layout.children[0].width, 30.0000);
         assert_eq!(layout.children[0].height, 31.0000);
-        assert_eq!(layout.children[0].x, 70.0000);
+        assert_eq!(layout.children[0].x, 0.0000);
         assert_eq!(layout.children[0].y, 0.0000);
 
         assert_eq!(layout.children[1].width, 30.0000);
         assert_eq!(layout.children[1].height, 32.0000);
-        assert_eq!(layout.children[1].x, 70.0000);
+        assert_eq!(layout.children[1].x, 0.0000);
         assert_eq!(layout.children[1].y, 31.0000);
 
         assert_eq!(layout.children[2].width, 30.0000);
         assert_eq!(layout.children[2].height, 33.0000);
-        assert_eq!(layout.children[2].x, 70.0000);
+        assert_eq!(layout.children[2].x, 0.0000);
         assert_eq!(layout.children[2].y, 63.0000);
 
         assert_eq!(layout.children[3].width, 30.0000);
         assert_eq!(layout.children[3].height, 34.0000);
-        assert_eq!(layout.children[3].x, 20.0000);
+        assert_eq!(layout.children[3].x, -30.0000);
         assert_eq!(layout.children[3].y, 0.0000);
     }
 
@@ -5843,7 +5842,6 @@ mod generated {
         let layout = stretch::compute(&stretch::style::Node {
             flex_direction: stretch::style::FlexDirection::Column,
             flexWrap: stretch::style::FlexWrap::Wrap,
-            width: stretch::style::Dimension::Points(100.0000),
             height: stretch::style::Dimension::Points(100.0000),
             children: vec![
                 stretch::style::Node {
@@ -5870,7 +5868,7 @@ mod generated {
             ..Default::default()
         });
 
-        assert_eq!(layout.width, 100.0000);
+        assert_eq!(layout.width, 30.0000);
         assert_eq!(layout.height, 100.0000);
         assert_eq!(layout.x, 0.0000);
         assert_eq!(layout.y, 0.0000);
@@ -5892,7 +5890,7 @@ mod generated {
 
         assert_eq!(layout.children[3].width, 30.0000);
         assert_eq!(layout.children[3].height, 34.0000);
-        assert_eq!(layout.children[3].x, 50.0000);
+        assert_eq!(layout.children[3].x, 30.0000);
         assert_eq!(layout.children[3].y, 0.0000);
     }