Delta semántico · 4
tests/root_constraints.rs
diff --git a/Cargo.toml b/Cargo.toml
index 6f696c7a0..e503e5a71 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "stretch"
-version = "0.1.4"
+version = "0.1.5"
authors = ["Emil Sjölander <emil@visly.app>"]
edition = "2018"
include = ["src/**/*", "Cargo.toml"]
diff --git a/src/algo.rs b/src/algo.rs
index 4a52786dd..29b19b97b 100644
--- a/src/algo.rs
+++ b/src/algo.rs
@@ -59,7 +59,7 @@ pub fn compute(root: &style::Node, size: Size<Number>) -> layout::Node {
// Probably want to pass min/max down as top level paramerer instead.
let first_pass = compute_internal(
root,
- Size { width: root.size.width.resolve(size.width), height: root.size.height.resolve(size.width) },
+ Size { width: root.size.width.resolve(size.width), height: root.size.height.resolve(size.height) },
size,
size.width,
);
@@ -76,8 +76,8 @@ pub fn compute(root: &style::Node, size: Size<Number>) -> layout::Node {
height: first_pass
.size
.height
- .maybe_max(root.min_size.height.resolve(size.width))
- .maybe_min(root.max_size.height.resolve(size.width))
+ .maybe_max(root.min_size.height.resolve(size.height))
+ .maybe_min(root.max_size.height.resolve(size.height))
.to_number(),
},
size,
diff --git a/src/style.rs b/src/style.rs
index e80b4a4c8..fa5fea1ed 100644
--- a/src/style.rs
+++ b/src/style.rs
@@ -191,6 +191,8 @@ impl Default for Size<Dimension> {
}
}
+type MeasureFunc = Box<Fn(Size<Number>) -> Size<f32>>;
+
pub struct Node {
pub display: Display,
@@ -221,7 +223,7 @@ pub struct Node {
pub max_size: Size<Dimension>,
pub aspect_ratio: Number,
- pub measure: Option<Box<Fn(Size<Number>) -> Size<f32>>>,
+ pub measure: Option<MeasureFunc>,
pub children: Vec<Node>,
}
diff --git a/tests/root_constraints.rs b/tests/root_constraints.rs
index eaa6aad38..ab12421d0 100644
--- a/tests/root_constraints.rs
+++ b/tests/root_constraints.rs
@@ -12,11 +12,11 @@ mod root_constraints {
},
..Default::default()
},
- stretch::geometry::Size { width: Number::Defined(100.0), height: Number::Defined(100.0) },
+ stretch::geometry::Size { width: Number::Defined(100.0), height: Number::Defined(200.0) },
);
assert_eq!(layout.size.width, 100.0);
- assert_eq!(layout.size.height, 100.0);
+ assert_eq!(layout.size.height, 200.0);
}
#[test]