Fix 1px wide gaps between adjacent UI nodes (#374)
* Fractional pixel investigations
* Enable rounding test
* Reinstate old rounding function
* Add option to disable rounding of layout output
* Match Taffy's rounding in gentests
Disable rounding for the "percent moderate" tests which fail due to
Taffy's lack of precision (only using f32) causing it round in the
opposite direction for those two tests.
* Simplify and document round_layout function
e8253b1ae8ad9e95777144ce91aa6fb1ec8d4e32 · by Nico Burns · 2023-02-25T16:38:53Z (3 years ago) · parent 606643cc5 · browse the tree at this commit
Semantic delta · 38
scripts/gentest/src/main.rs
scripts/gentest/test_helper.js
tests/generated/align_content_space_around_single_line.rs
tests/generated/gap_column_gap_percentage_flexible.rs
tests/generated/gap_column_gap_percentage_flexible_with_padding.rs
tests/generated/gap_column_gap_wrap_align_stretch.rs
tests/generated/grid_percent_items_nested_moderate.rs
tests/generated/grid_span_13_most_non_flex_with_minmax_indefinite.rs
tests/generated/grid_span_6_all_non_flex_indefinite.rs
tests/generated/percentage_moderate_complexity.rs
tests/generated/rounding_flex_basis_flex_grow_row_prime_number_width.rs
tests/generated/rounding_flex_basis_flex_grow_row_width_of_100.rs
tests/generated/rounding_flex_basis_overrides_main_size.rs
tests/generated/rounding_fractial_input_1.rs
tests/generated/rounding_fractial_input_2.rs
tests/generated/rounding_fractial_input_3.rs
tests/generated/rounding_fractial_input_4.rs
tests/generated/rounding_fractial_input_5.rs
tests/generated/rounding_fractial_input_6.rs
tests/generated/rounding_fractial_input_7.rs
tests/generated/rounding_inner_node_controversy_combined.rs
tests/generated/rounding_inner_node_controversy_horizontal.rs
tests/generated/rounding_inner_node_controversy_vertical.rs
diff --git a/scripts/gentest/src/main.rs b/scripts/gentest/src/main.rs
index 377ffdeb5..fee14f8ae 100644
--- a/scripts/gentest/src/main.rs
+++ b/scripts/gentest/src/main.rs
@@ -121,8 +121,11 @@ async fn test_root_element(client: Client, name: String, fixture_path: impl AsRe
fn generate_test(name: impl AsRef<str>, description: &Value) -> TokenStream {
let name = name.as_ref();
let name = Ident::new(name, Span::call_site());
+ let use_rounding = description["useRounding"].as_bool().unwrap();
+ let assertions = generate_assertions("node", description, use_rounding);
let node_description = generate_node("node", description);
- let assertions = generate_assertions("node", description);
+
+ let set_rounding_mode = if use_rounding { quote!() } else { quote!(taffy.disable_rounding();) };
quote!(
#[test]
@@ -131,6 +134,7 @@ fn generate_test(name: impl AsRef<str>, description: &Value) -> TokenStream {
use taffy::{layout::Layout, prelude::*};
use slotmap::Key;
let mut taffy = taffy::Taffy::new();
+ #set_rounding_mode
#node_description
taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
@@ -143,8 +147,8 @@ fn generate_test(name: impl AsRef<str>, description: &Value) -> TokenStream {
)
}
-fn generate_assertions(ident: &str, node: &Value) -> TokenStream {
- let layout = &node["layout"];
+fn generate_assertions(ident: &str, node: &Value, use_rounding: bool) -> TokenStream {
+ let layout = if use_rounding { &node["smartRoundedLayout"] } else { &node["unroundedLayout"] };
let read_f32 = |s: &str| layout[s].as_f64().unwrap() as f32;
let width = read_f32("width");
@@ -156,7 +160,7 @@ fn generate_assertions(ident: &str, node: &Value) -> TokenStream {
let mut c = Vec::new();
if let Value::Array(ref value) = node["children"] {
for (idx, child) in value.iter().enumerate() {
- c.push(generate_assertions(&format!("{ident}{idx}"), child));
+ c.push(generate_assertions(&format!("{ident}{idx}"), child, use_rounding));
}
};
c.into_iter().fold(quote!(), |a, b| quote!(#a #b))
@@ -164,15 +168,27 @@ fn generate_assertions(ident: &str, node: &Value) -> TokenStream {
let ident = Ident::new(ident, Span::call_site());
- quote!(
- let Layout { size, location, .. } = taffy.layout(#ident).unwrap();
- assert_eq!(size.width, #width, "width of node {:?}. Expected {}. Actual {}", #ident.data(), #width, size.width);
- assert_eq!(size.height, #height, "height of node {:?}. Expected {}. Actual {}", #ident.data(), #height, size.height);
- assert_eq!(location.x, #x, "x of node {:?}. Expected {}. Actual {}", #ident.data(), #x, location.x);
- assert_eq!(location.y, #y, "y of node {:?}. Expected {}. Actual {}", #ident.data(), #y, location.y);
+ if use_rounding {
+ quote!(
+ let Layout { size, location, .. } = taffy.layout(#ident).unwrap();
+ assert_eq!(size.width, #width, "width of node {:?}. Expected {}. Actual {}", #ident.data(), #width, size.width);
+ assert_eq!(size.height, #height, "height of node {:?}. Expected {}. Actual {}", #ident.data(), #height, size.height);
+ assert_eq!(location.x, #x, "x of node {:?}. Expected {}. Actual {}", #ident.data(), #x, location.x);
+ assert_eq!(location.y, #y, "y of node {:?}. Expected {}. Actual {}", #ident.data(), #y, location.y);
- #children
- )
+ #children
+ )
+ } else {
+ quote!(
+ let Layout { size, location, .. } = taffy.layout(#ident).unwrap();
+ assert!(size.width - #width < 0.1, "width of node {:?}. Expected {}. Actual {}", #ident.data(), #width, size.width);
+ assert!(size.height - #height < 0.1, "height of node {:?}. Expected {}. Actual {}", #ident.data(), #height, size.height);
+ assert!(location.x - #x < 0.1, "x of node {:?}. Expected {}. Actual {}", #ident.data(), #x, location.x);
+ assert!(location.y - #y < 0.1, "y of node {:?}. Expected {}. Actual {}", #ident.data(), #y, location.y);
+
+ #children
+ )
+ }
}
macro_rules! dim_quoted_renamed {
diff --git a/scripts/gentest/test_helper.js b/scripts/gentest/test_helper.js
index 070f55906..b05eb7e7d 100644
--- a/scripts/gentest/test_helper.js
+++ b/scripts/gentest/test_helper.js
@@ -173,6 +173,10 @@ function parseGridPosition(input) {
function describeElement(e) {
+ // Get precise, unrounded dimensions for the current element and it's parent
+ let boundingRect = e.getBoundingClientRect();
+ let parentBoundingRect = e.parentNode.getBoundingClientRect();
+
return {
style: {
display: parseEnum(e.style.display),
@@ -249,13 +253,36 @@ function describeElement(e) {
// So we're only interested in the text content of leaf nodes
textContent: e.childElementCount === 0 && e.textContent.length && e.textContent !== "\n" ? e.textContent : undefined,
- layout: {
+ // The layout of the node in full precision (floating-point)
+ unroundedLayout: {
+ width: boundingRect.width,
+ height: boundingRect.height,
+ x: boundingRect.x - parentBoundingRect.x,
+ y: boundingRect.y - parentBoundingRect.y,
+ },
+
+ // The naively rounded layout of the node. This is equivalent to calling Math.round() on
+ // each value in the unrounded layout individually
+ naivelyRoundedLayout: {
width: e.offsetWidth,
height: e.offsetHeight,
x: e.offsetLeft + e.parentNode.clientLeft,
y: e.offsetTop + e.parentNode.clientTop,
},
+ // The naive rounding can result in 1px gaps in the layout, so Taffy uses a smarter algorithm to avoid this.
+ // Chrome also uses a smarter algorithm, but it doesn't expose the output of that rounding.
+ // So we just emulate Taffy's computation here.
+ smartRoundedLayout: {
+ width: Math.round(boundingRect.right) - Math.round(boundingRect.left),
+ height: Math.round(boundingRect.bottom) - Math.round(boundingRect.top),
+ x: Math.round(boundingRect.x - parentBoundingRect.x),
+ y: Math.round(boundingRect.y - parentBoundingRect.y),
+ },
+
+ // Whether the test should enable rounding
+ useRounding: e.getAttribute("data-test-rounding") !== "false",
+
children: Array.from(e.children).map(c => describeElement(c)),
}
}
diff --git a/src/compute/mod.rs b/src/compute/mod.rs
index 31d783b07..ba4b2eb3b 100644
--- a/src/compute/mod.rs
+++ b/src/compute/mod.rs
@@ -11,7 +11,7 @@ use crate::data::CACHE_SIZE;
use crate::error::TaffyError;
use crate::geometry::{Point, Size};
use crate::layout::{Cache, Layout, RunMode, SizeAndBaselines, SizingMode};
-use crate::node::Node;
+use crate::node::{Node, Taffy};
use crate::style::{AvailableSpace, Display};
use crate::sys::round;
use crate::tree::LayoutTree;
@@ -25,14 +25,10 @@ use self::leaf::LeafAlgorithm;
use crate::debug::NODE_LOGGER;
/// Updates the stored layout of the provided `node` and its children
-pub fn compute_layout(
- tree: &mut impl LayoutTree,
- root: Node,
- available_space: Size<AvailableSpace>,
-) -> Result<(), TaffyError> {
+pub fn compute_layout(taffy: &mut Taffy, root: Node, available_space: Size<AvailableSpace>) -> Result<(), TaffyError> {
// Recursively compute node layout
let size_and_baselines = GenericAlgorithm::perform_layout(
- tree,
+ taffy,
root,
Size::NONE,
available_space.into_options(),
@@ -41,10 +37,12 @@ pub fn compute_layout(
);
let layout = Layout { order: 0, size: size_and_baselines.size, location: Point::ZERO };
- *tree.layout_mut(root) = layout;
+ *taffy.layout_mut(root) = layout;
- // Recursively round the layout's of this node and all children
- round_layout(tree, root);
+ // If rounding is enabled, recursively round the layout's of this node and all children
+ if taffy.config.use_rounding {
+ round_layout(taffy, root, 0.0, 0.0);
+ }
Ok(())
}
@@ -390,20 +388,27 @@ fn perform_hidden_layout(tree: &mut impl LayoutTree, node: Node) {
}
}
-/// Rounds the calculated [`NodeData`] according to the spec
-fn round_layout(tree: &mut impl LayoutTree, root: Node) {
- let layout = tree.layout_mut(root);
+/// Rounds the calculated [`Layout`] to exact pixel values
+/// In order to ensure that no gaps in the layout are introduced we:
+/// - Always round based on the absolute coordinates rather than parent-relative coordinates
+/// - Compute width/height by first rounding the top/bottom/left/right and then computing the difference
+/// rather than rounding the width/height directly
+///
+/// See <https://github.com/facebook/yoga/commit/aa5b296ac78f7a22e1aeaf4891243c6bb76488e2> for more context
+fn round_layout(tree: &mut impl LayoutTree, node: Node, abs_x: f32, abs_y: f32) {
+ let layout = tree.layout_mut(node);
+ let abs_x = abs_x + layout.location.x;
+ let abs_y = abs_y + layout.location.y;
layout.location.x = round(layout.location.x);
layout.location.y = round(layout.location.y);
+ layout.size.width = round(abs_x + layout.size.width) - round(abs_x);
+ layout.size.height = round(abs_y + layout.size.height) - round(abs_y);
- layout.size.width = round(layout.size.width);
- layout.size.height = round(layout.size.height);
-
- // Satisfy the borrow checker here by re-indexing to shorten the lifetime to the loop scope
- for x in 0..tree.child_count(root) {
- let child = tree.child(root, x);
- round_layout(tree, child);
+ let child_count = tree.child_count(node);
+ for index in 0..child_count {
+ let child = tree.child(node, index);
+ round_layout(tree, child, abs_x, abs_y);
}
}
diff --git a/src/node.rs b/src/node.rs
index e4f575b71..500f9d9eb 100644
--- a/src/node.rs
+++ b/src/node.rs
@@ -32,6 +32,18 @@ pub enum MeasureFunc {
Boxed(Box<dyn Measurable>),
}
+/// Global configuration values for a Taffy instance
+pub(crate) struct TaffyConfig {
+ /// Whether to round layout values
+ pub(crate) use_rounding: bool,
+}
+
+impl Default for TaffyConfig {
+ fn default() -> Self {
+ Self { use_rounding: true }
+ }
+}
+
/// A tree of UI [`Nodes`](`Node`), suitable for UI layout
pub struct Taffy {
/// The [`NodeData`] for each node stored in this tree
@@ -49,6 +61,9 @@ pub struct Taffy {
///
/// The indexes in the outer vector correspond to the position of the child [`NodeData`]
pub(crate) parents: SlotMap<Node, Option<Node>>,
+
+ /// Layout mode configuration
+ pub(crate) config: TaffyConfig,
}
impl Default for Taffy {
@@ -140,9 +155,20 @@ impl Taffy {
children: SlotMap::with_capacity(capacity),
parents: SlotMap::with_capacity(capacity),
measure_funcs: SparseSecondaryMap::with_capacity(capacity),
+ config: TaffyConfig::default(),
}
}
+ /// Enable rounding of layout values. Rounding is enabled by default.
+ pub fn enable_rounding(&mut self) {
+ self.config.use_rounding = true;
+ }
+
+ /// Disable rounding of layout values. Rounding is enabled by default.
+ pub fn disable_rounding(&mut self) {
+ self.config.use_rounding = false;
+ }
+
/// Creates and adds a new unattached leaf node to the tree, and returns the [`Node`] of the new node
pub fn new_leaf(&mut self, layout: Style) -> TaffyResult<Node> {
let id = self.nodes.insert(NodeData::new(layout));
diff --git a/test_fixtures/grid_percent_items_nested_moderate.html b/test_fixtures/grid_percent_items_nested_moderate.html
index 9dd670f2f..16c3a740b 100644
--- a/test_fixtures/grid_percent_items_nested_moderate.html
+++ b/test_fixtures/grid_percent_items_nested_moderate.html
@@ -9,7 +9,7 @@
<head/>
<body>
-<div id="test-root" style="display: grid;width: 200px;padding: 3px;">
+<div id="test-root" data-test-rounding="false" style="display: grid;width: 200px;padding: 3px;">
<div style="display: grid;width: 50%; margin: 5px; padding: 3%;">
<div style="width: 45%; margin: 5%; padding: 3px;"></div>
</div>
diff --git a/test_fixtures/percentage_moderate_complexity.html b/test_fixtures/percentage_moderate_complexity.html
index ce93de9ce..024a9a34b 100644
--- a/test_fixtures/percentage_moderate_complexity.html
+++ b/test_fixtures/percentage_moderate_complexity.html
@@ -9,7 +9,7 @@
<head/>
<body>
-<div id="test-root" style="display: flex;flex-direction:column;width: 200px;padding: 3px;">
+<div id="test-root" data-test-rounding="false" style="display: flex;flex-direction:column;width: 200px;padding: 3px;">
<div style="display: flex;flex-direction:column;width: 50%; margin: 5px; padding: 3%;">
<div style="width: 45%; margin: 5%; padding: 3px;"></div>
</div>
diff --git a/test_fixtures/rounding_fractial_input_5.html b/test_fixtures/rounding_fractial_input_5.html
new file mode 100644
index 000000000..544b3bdb8
--- /dev/null
+++ b/test_fixtures/rounding_fractial_input_5.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <script src="../scripts/gentest/test_helper.js"></script>
+ <link rel="stylesheet" type="text/css" href="../scripts/gentest/test_base_style.css">
+ <title>
+ Test description
+ </title>
+<head/>
+<body>
+
+<div id="test-root" style="height: 100px;width:963.3333px;justify-content: center;">
+ <div style="width:100.3px;height:100.3px"></div>
+ <div style="width:100.3px;height:100.3px"></div>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/test_fixtures/rounding_fractial_input_6.html b/test_fixtures/rounding_fractial_input_6.html
new file mode 100644
index 000000000..78eb3db02
--- /dev/null
+++ b/test_fixtures/rounding_fractial_input_6.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <script src="../scripts/gentest/test_helper.js"></script>
+ <link rel="stylesheet" type="text/css" href="../scripts/gentest/test_base_style.css">
+ <title>
+ Test description
+ </title>
+<head/>
+<body>
+
+<div id="test-root" style="width:7px;">
+ <div style="width:50%;flex-wrap: wrap;">
+ <div style="width: 2px;height: 10px;background-color: red"></div>
+ <div style="width: 2px;height: 10px;background-color: green"></div>
+ </div>
+ <div style="width:50%;flex-wrap: wrap;">
+ <div style="width: 2px;height: 10px;background-color: yellow"></div>
+ <div style="width: 2px;height: 10px;background-color: blue"></div>
+ </div>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/test_fixtures/rounding_fractial_input_7.html b/test_fixtures/rounding_fractial_input_7.html
new file mode 100644
index 000000000..00b9a561c
--- /dev/null
+++ b/test_fixtures/rounding_fractial_input_7.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <script src="../scripts/gentest/test_helper.js"></script>
+ <link rel="stylesheet" type="text/css" href="../scripts/gentest/test_base_style.css">
+ <title>
+ Test description
+ </title>
+<head/>
+<body>
+
+<div id="test-root" style="width:7px;">
+ <div style="width:25%;flex-wrap: wrap;">
+ <div style="width: 1px;height: 10px;background-color: red"></div>
+ <div style="width: 1px;height: 10px;background-color: green"></div>
+ </div>
+ <div style="width:25%;flex-wrap: wrap;">
+ <div style="width: 1px;height: 10px;background-color: yellow"></div>
+ <div style="width: 1px;height: 10px;background-color: blue"></div>
+ </div>
+ <div style="width:25%;flex-wrap: wrap;">
+ <div style="width: 1px;height: 10px;background-color: red"></div>
+ <div style="width: 1px;height: 10px;background-color: green"></div>
+ </div>
+ <div style="width:25%;flex-wrap: wrap;">
+ <div style="width: 1px;height: 10px;background-color: yellow"></div>
+ <div style="width: 1px;height: 10px;background-color: blue"></div>
+ </div>
+</div>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/test_fixtures/xrounding_inner_node_controversy_combined.html b/test_fixtures/rounding_inner_node_controversy_combined.html
similarity index 92%
rename from test_fixtures/xrounding_inner_node_controversy_combined.html
rename to test_fixtures/rounding_inner_node_controversy_combined.html
index 3e30fd484..634f1dfaf 100644
--- a/test_fixtures/xrounding_inner_node_controversy_combined.html
+++ b/test_fixtures/rounding_inner_node_controversy_combined.html
@@ -14,8 +14,7 @@
<div style="height: 100%; flex-grow:1; flex-direction: column;">
<div style="width: 100%; flex-grow:1;"></div>
<div style="flex-direction: column;width: 100%; flex-grow:1;">
- <div style="flex-grow:1; width: 100%;">
- </div>
+ <div style="flex-grow:1; width: 100%;"></div>
</div>
<div style="width: 100%; flex-grow:1;"></div>
</div>
diff --git a/test_fixtures/xrounding_inner_node_controversy_horizontal.html b/test_fixtures/rounding_inner_node_controversy_horizontal.html
similarity index 100%
rename from test_fixtures/xrounding_inner_node_controversy_horizontal.html
rename to test_fixtures/rounding_inner_node_controversy_horizontal.html
diff --git a/tests/generated/align_content_space_around_single_line.rs b/tests/generated/align_content_space_around_single_line.rs
index 94292d204..f05c8c885 100644
--- a/tests/generated/align_content_space_around_single_line.rs
+++ b/tests/generated/align_content_space_around_single_line.rs
@@ -86,7 +86,7 @@ fn align_content_space_around_single_line() {
assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x);
assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y);
let Layout { size, location, .. } = taffy.layout(node1).unwrap();
- assert_eq!(size.width, 17f32, "width of node {:?}. Expected {}. Actual {}", node1.data(), 17f32, size.width);
+ assert_eq!(size.width, 16f32, "width of node {:?}. Expected {}. Actual {}", node1.data(), 16f32, size.width);
assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1.data(), 10f32, size.height);
assert_eq!(location.x, 17f32, "x of node {:?}. Expected {}. Actual {}", node1.data(), 17f32, location.x);
assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1.data(), 0f32, location.y);
@@ -101,7 +101,7 @@ fn align_content_space_around_single_line() {
assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3.data(), 50f32, location.x);
assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3.data(), 0f32, location.y);
let Layout { size, location, .. } = taffy.layout(node4).unwrap();
- assert_eq!(size.width, 17f32, "width of node {:?}. Expected {}. Actual {}", node4.data(), 17f32, size.width);
+ assert_eq!(size.width, 16f32, "width of node {:?}. Expected {}. Actual {}", node4.data(), 16f32, size.width);
assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4.data(), 10f32, size.height);
assert_eq!(location.x, 67f32, "x of node {:?}. Expected {}. Actual {}", node4.data(), 67f32, location.x);
assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4.data(), 0f32, location.y);
diff --git a/tests/generated/gap_column_gap_percentage_flexible.rs b/tests/generated/gap_column_gap_percentage_flexible.rs
index baf69dd16..89155f56d 100644
--- a/tests/generated/gap_column_gap_percentage_flexible.rs
+++ b/tests/generated/gap_column_gap_percentage_flexible.rs
@@ -59,7 +59,7 @@ fn gap_column_gap_percentage_flexible() {
assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x);
assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y);
let Layout { size, location, .. } = taffy.layout(node1).unwrap();
- assert_eq!(size.width, 27f32, "width of node {:?}. Expected {}. Actual {}", node1.data(), 27f32, size.width);
+ assert_eq!(size.width, 26f32, "width of node {:?}. Expected {}. Actual {}", node1.data(), 26f32, size.width);
assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1.data(), 100f32, size.height);
assert_eq!(location.x, 37f32, "x of node {:?}. Expected {}. Actual {}", node1.data(), 37f32, location.x);
assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1.data(), 0f32, location.y);
diff --git a/tests/generated/gap_column_gap_percentage_flexible_with_padding.rs b/tests/generated/gap_column_gap_percentage_flexible_with_padding.rs
index 9fff69660..c971a179f 100644
--- a/tests/generated/gap_column_gap_percentage_flexible_with_padding.rs
+++ b/tests/generated/gap_column_gap_percentage_flexible_with_padding.rs
@@ -65,7 +65,7 @@ fn gap_column_gap_percentage_flexible_with_padding() {
assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 10f32, location.x);
assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 10f32, location.y);
let Layout { size, location, .. } = taffy.layout(node1).unwrap();
- assert_eq!(size.width, 21f32, "width of node {:?}. Expected {}. Actual {}", node1.data(), 21f32, size.width);
+ assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node1.data(), 22f32, size.width);
assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node1.data(), 80f32, size.height);
assert_eq!(location.x, 39f32, "x of node {:?}. Expected {}. Actual {}", node1.data(), 39f32, location.x);
assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1.data(), 10f32, location.y);
diff --git a/tests/generated/gap_column_gap_wrap_align_stretch.rs b/tests/generated/gap_column_gap_wrap_align_stretch.rs
index de3f42de7..576e0cb44 100644
--- a/tests/generated/gap_column_gap_wrap_align_stretch.rs
+++ b/tests/generated/gap_column_gap_wrap_align_stretch.rs
@@ -69,7 +69,7 @@ fn gap_column_gap_wrap_align_stretch() {
assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x);
assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y);
let Layout { size, location, .. } = taffy.layout(node1).unwrap();
- assert_eq!(size.width, 71f32, "width of node {:?}. Expected {}. Actual {}", node1.data(), 71f32, size.width);
+ assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node1.data(), 72f32, size.width);
assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node1.data(), 150f32, size.height);
assert_eq!(location.x, 76f32, "x of node {:?}. Expected {}. Actual {}", node1.data(), 76f32, location.x);
assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1.data(), 0f32, location.y);
diff --git a/tests/generated/grid_percent_items_nested_moderate.rs b/tests/generated/grid_percent_items_nested_moderate.rs
index 454d27cc9..da361ae74 100644
--- a/tests/generated/grid_percent_items_nested_moderate.rs
+++ b/tests/generated/grid_percent_items_nested_moderate.rs
@@ -4,6 +4,7 @@ fn grid_percent_items_nested_moderate() {
#[allow(unused_imports)]
use taffy::{layout::Layout, prelude::*};
let mut taffy = taffy::Taffy::new();
+ taffy.disable_rounding();
let node00 = taffy
.new_leaf(taffy::style::Style {
size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.45f32), height: auto() },
@@ -65,18 +66,48 @@ fn grid_percent_items_nested_moderate() {
taffy::debug::print_tree(&taffy, node);
println!();
let Layout { size, location, .. } = taffy.layout(node).unwrap();
- assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 200f32, size.width);
- assert_eq!(size.height, 42f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 42f32, size.height);
- assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
- assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
+ assert!(size.width - 200f32 < 0.1, "width of node {:?}. Expected {}. Actual {}", node.data(), 200f32, size.width);
+ assert!(
+ size.height - 42.15625f32 < 0.1,
+ "height of node {:?}. Expected {}. Actual {}",
+ node.data(),
+ 42.15625f32,
+ size.height
+ );
+ assert!(location.x - 0f32 < 0.1, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
+ assert!(location.y - 0f32 < 0.1, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
let Layout { size, location, .. } = taffy.layout(node0).unwrap();
- assert_eq!(size.width, 97f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 97f32, size.width);
- assert_eq!(size.height, 26f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 26f32, size.height);
- assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 8f32, location.x);
- assert_eq!(location.y, 8f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 8f32, location.y);
+ assert!(size.width - 97f32 < 0.1, "width of node {:?}. Expected {}. Actual {}", node0.data(), 97f32, size.width);
+ assert!(
+ size.height - 26.15625f32 < 0.1,
+ "height of node {:?}. Expected {}. Actual {}",
+ node0.data(),
+ 26.15625f32,
+ size.height
+ );
+ assert!(location.x - 8f32 < 0.1, "x of node {:?}. Expected {}. Actual {}", node0.data(), 8f32, location.x);
+ assert!(location.y - 8f32 < 0.1, "y of node {:?}. Expected {}. Actual {}", node0.data(), 8f32, location.y);
let Layout { size, location, .. } = taffy.layout(node00).unwrap();
- assert_eq!(size.width, 38f32, "width of node {:?}. Expected {}. Actual {}", node00.data(), 38f32, size.width);
- assert_eq!(size.height, 6f32, "height of node {:?}. Expected {}. Actual {}", node00.data(), 6f32, size.height);
- assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node00.data(), 10f32, location.x);
- assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node00.data(), 10f32, location.y);
+ assert!(
+ size.width - 38.414063f32 < 0.1,
+ "width of node {:?}. Expected {}. Actual {}",
+ node00.data(),
+ 38.414063f32,
+ size.width
+ );
+ assert!(size.height - 6f32 < 0.1, "height of node {:?}. Expected {}. Actual {}", node00.data(), 6f32, size.height);
+ assert!(
+ location.x - 10.078125f32 < 0.1,
+ "x of node {:?}. Expected {}. Actual {}",
+ node00.data(),
+ 10.078125f32,
+ location.x
+ );
+ assert!(
+ location.y - 10.078125f32 < 0.1,
+ "y of node {:?}. Expected {}. Actual {}",
+ node00.data(),
+ 10.078125f32,
+ location.y
+ );
}
diff --git a/tests/generated/grid_span_13_most_non_flex_with_minmax_indefinite.rs b/tests/generated/grid_span_13_most_non_flex_with_minmax_indefinite.rs
index be7537c4c..ad501b1bb 100644
--- a/tests/generated/grid_span_13_most_non_flex_with_minmax_indefinite.rs
+++ b/tests/generated/grid_span_13_most_non_flex_with_minmax_indefinite.rs
@@ -100,7 +100,7 @@ fn grid_span_13_most_non_flex_with_minmax_indefinite() {
assert_eq!(location.x, 124f32, "x of node {:?}. Expected {}. Actual {}", node5.data(), 124f32, location.x);
assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node5.data(), 40f32, location.y);
let Layout { size, location, .. } = taffy.layout(node6).unwrap();
- assert_eq!(size.width, 64f32, "width of node {:?}. Expected {}. Actual {}", node6.data(), 64f32, size.width);
+ assert_eq!(size.width, 65f32, "width of node {:?}. Expected {}. Actual {}", node6.data(), 65f32, size.width);
assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6.data(), 40f32, size.height);
assert_eq!(location.x, 134f32, "x of node {:?}. Expected {}. Actual {}", node6.data(), 134f32, location.x);
assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node6.data(), 40f32, location.y);
diff --git a/tests/generated/grid_span_6_all_non_flex_indefinite.rs b/tests/generated/grid_span_6_all_non_flex_indefinite.rs
index cc6510adf..2f7402900 100644
--- a/tests/generated/grid_span_6_all_non_flex_indefinite.rs
+++ b/tests/generated/grid_span_6_all_non_flex_indefinite.rs
@@ -66,7 +66,7 @@ fn grid_span_6_all_non_flex_indefinite() {
assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1.data(), 0f32, location.x);
assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node1.data(), 40f32, location.y);
let Layout { size, location, .. } = taffy.layout(node2).unwrap();
- assert_eq!(size.width, 90f32, "width of node {:?}. Expected {}. Actual {}", node2.data(), 90f32, size.width);
+ assert_eq!(size.width, 89f32, "width of node {:?}. Expected {}. Actual {}", node2.data(), 89f32, size.width);
assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2.data(), 40f32, size.height);
assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node2.data(), 10f32, location.x);
assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2.data(), 40f32, location.y);
@@ -76,7 +76,7 @@ fn grid_span_6_all_non_flex_indefinite() {
assert_eq!(location.x, 99f32, "x of node {:?}. Expected {}. Actual {}", node3.data(), 99f32, location.x);
assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node3.data(), 40f32, location.y);
let Layout { size, location, .. } = taffy.layout(node4).unwrap();
- assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node4.data(), 10f32, size.width);
+ assert_eq!(size.width, 9f32, "width of node {:?}. Expected {}. Actual {}", node4.data(), 9f32, size.width);
assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4.data(), 40f32, size.height);
assert_eq!(location.x, 109f32, "x of node {:?}. Expected {}. Actual {}", node4.data(), 109f32, location.x);
assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node4.data(), 40f32, location.y);
diff --git a/tests/generated/mod.rs b/tests/generated/mod.rs
index 83b4a2a7b..a34a6142c 100644
--- a/tests/generated/mod.rs
+++ b/tests/generated/mod.rs
@@ -858,6 +858,11 @@ mod rounding_fractial_input_1;
mod rounding_fractial_input_2;
mod rounding_fractial_input_3;
mod rounding_fractial_input_4;
+mod rounding_fractial_input_5;
+mod rounding_fractial_input_6;
+mod rounding_fractial_input_7;
+mod rounding_inner_node_controversy_combined;
+mod rounding_inner_node_controversy_horizontal;
mod rounding_inner_node_controversy_vertical;
mod rounding_total_fractial;
mod rounding_total_fractial_nested;
diff --git a/tests/generated/percentage_moderate_complexity.rs b/tests/generated/percentage_moderate_complexity.rs
index 87df70f35..0e93704d5 100644
--- a/tests/generated/percentage_moderate_complexity.rs
+++ b/tests/generated/percentage_moderate_complexity.rs
@@ -4,6 +4,7 @@ fn percentage_moderate_complexity() {
#[allow(unused_imports)]
use taffy::{layout::Layout, prelude::*};
let mut taffy = taffy::Taffy::new();
+ taffy.disable_rounding();
let node00 = taffy
.new_leaf(taffy::style::Style {
size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.45f32), height: auto() },
@@ -67,18 +68,48 @@ fn percentage_moderate_complexity() {
taffy::debug::print_tree(&taffy, node);
println!();
let Layout { size, location, .. } = taffy.layout(node).unwrap();
- assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 200f32, size.width);
- assert_eq!(size.height, 42f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 42f32, size.height);
- assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
- assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
+ assert!(size.width - 200f32 < 0.1, "width of node {:?}. Expected {}. Actual {}", node.data(), 200f32, size.width);
+ assert!(
+ size.height - 42.15625f32 < 0.1,
+ "height of node {:?}. Expected {}. Actual {}",
+ node.data(),
+ 42.15625f32,
+ size.height
+ );
+ assert!(location.x - 0f32 < 0.1, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
+ assert!(location.y - 0f32 < 0.1, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
let Layout { size, location, .. } = taffy.layout(node0).unwrap();
- assert_eq!(size.width, 97f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 97f32, size.width);
- assert_eq!(size.height, 26f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 26f32, size.height);
- assert_eq!(location.x, 8f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 8f32, location.x);
- assert_eq!(location.y, 8f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 8f32, location.y);
+ assert!(size.width - 97f32 < 0.1, "width of node {:?}. Expected {}. Actual {}", node0.data(), 97f32, size.width);
+ assert!(
+ size.height - 26.15625f32 < 0.1,
+ "height of node {:?}. Expected {}. Actual {}",
+ node0.data(),
+ 26.15625f32,
+ size.height
+ );
+ assert!(location.x - 8f32 < 0.1, "x of node {:?}. Expected {}. Actual {}", node0.data(), 8f32, location.x);
+ assert!(location.y - 8f32 < 0.1, "y of node {:?}. Expected {}. Actual {}", node0.data(), 8f32, location.y);
let Layout { size, location, .. } = taffy.layout(node00).unwrap();
- assert_eq!(size.width, 38f32, "width of node {:?}. Expected {}. Actual {}", node00.data(), 38f32, size.width);
- assert_eq!(size.height, 6f32, "height of node {:?}. Expected {}. Actual {}", node00.data(), 6f32, size.height);
- assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node00.data(), 10f32, location.x);
- assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node00.data(), 10f32, location.y);
+ assert!(
+ size.width - 38.414063f32 < 0.1,
+ "width of node {:?}. Expected {}. Actual {}",
+ node00.data(),
+ 38.414063f32,
+ size.width
+ );
+ assert!(size.height - 6f32 < 0.1, "height of node {:?}. Expected {}. Actual {}", node00.data(), 6f32, size.height);
+ assert!(
+ location.x - 10.078125f32 < 0.1,
+ "x of node {:?}. Expected {}. Actual {}",
+ node00.data(),
+ 10.078125f32,
+ location.x
+ );
+ assert!(
+ location.y - 10.078125f32 < 0.1,
+ "y of node {:?}. Expected {}. Actual {}",
+ node00.data(),
+ 10.078125f32,
+ location.y
+ );
}
diff --git a/tests/generated/rounding_flex_basis_flex_grow_row_prime_number_width.rs b/tests/generated/rounding_flex_basis_flex_grow_row_prime_number_width.rs
index c13ef0e4a..0d49c539e 100644
--- a/tests/generated/rounding_flex_basis_flex_grow_row_prime_number_width.rs
+++ b/tests/generated/rounding_flex_basis_flex_grow_row_prime_number_width.rs
@@ -36,7 +36,7 @@ fn rounding_flex_basis_flex_grow_row_prime_number_width() {
assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x);
assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y);
let Layout { size, location, .. } = taffy.layout(node1).unwrap();
- assert_eq!(size.width, 23f32, "width of node {:?}. Expected {}. Actual {}", node1.data(), 23f32, size.width);
+ assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node1.data(), 22f32, size.width);
assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1.data(), 100f32, size.height);
assert_eq!(location.x, 23f32, "x of node {:?}. Expected {}. Actual {}", node1.data(), 23f32, location.x);
assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1.data(), 0f32, location.y);
@@ -46,7 +46,7 @@ fn rounding_flex_basis_flex_grow_row_prime_number_width() {
assert_eq!(location.x, 45f32, "x of node {:?}. Expected {}. Actual {}", node2.data(), 45f32, location.x);
assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2.data(), 0f32, location.y);
let Layout { size, location, .. } = taffy.layout(node3).unwrap();
- assert_eq!(size.width, 23f32, "width of node {:?}. Expected {}. Actual {}", node3.data(), 23f32, size.width);
+ assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node3.data(), 22f32, size.width);
assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node3.data(), 100f32, size.height);
assert_eq!(location.x, 68f32, "x of node {:?}. Expected {}. Actual {}", node3.data(), 68f32, location.x);
assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3.data(), 0f32, location.y);
diff --git a/tests/generated/rounding_flex_basis_flex_grow_row_width_of_100.rs b/tests/generated/rounding_flex_basis_flex_grow_row_width_of_100.rs
index 462bde539..049bbefc2 100644
--- a/tests/generated/rounding_flex_basis_flex_grow_row_width_of_100.rs
+++ b/tests/generated/rounding_flex_basis_flex_grow_row_width_of_100.rs
@@ -34,7 +34,7 @@ fn rounding_flex_basis_flex_grow_row_width_of_100() {
assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x);
assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y);
let Layout { size, location, .. } = taffy.layout(node1).unwrap();
- assert_eq!(size.width, 33f32, "width of node {:?}. Expected {}. Actual {}", node1.data(), 33f32, size.width);
+ assert_eq!(size.width, 34f32, "width of node {:?}. Expected {}. Actual {}", node1.data(), 34f32, size.width);
assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1.data(), 100f32, size.height);
assert_eq!(location.x, 33f32, "x of node {:?}. Expected {}. Actual {}", node1.data(), 33f32, location.x);
assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1.data(), 0f32, location.y);
diff --git a/tests/generated/rounding_flex_basis_overrides_main_size.rs b/tests/generated/rounding_flex_basis_overrides_main_size.rs
index 390490117..a29a57096 100644
--- a/tests/generated/rounding_flex_basis_overrides_main_size.rs
+++ b/tests/generated/rounding_flex_basis_overrides_main_size.rs
@@ -55,7 +55,7 @@ fn rounding_flex_basis_overrides_main_size() {
assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y);
let Layout { size, location, .. } = taffy.layout(node1).unwrap();
assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1.data(), 100f32, size.width);
- assert_eq!(size.height, 24f32, "height of node {:?}. Expected {}. Actual {}", node1.data(), 24f32, size.height);
+ assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1.data(), 25f32, size.height);
assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1.data(), 0f32, location.x);
assert_eq!(location.y, 64f32, "y of node {:?}. Expected {}. Actual {}", node1.data(), 64f32, location.y);
let Layout { size, location, .. } = taffy.layout(node2).unwrap();
diff --git a/tests/generated/rounding_fractial_input_1.rs b/tests/generated/rounding_fractial_input_1.rs
index 0d83e3f39..c116b0b7d 100644
--- a/tests/generated/rounding_fractial_input_1.rs
+++ b/tests/generated/rounding_fractial_input_1.rs
@@ -55,7 +55,7 @@ fn rounding_fractial_input_1() {
assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y);
let Layout { size, location, .. } = taffy.layout(node1).unwrap();
assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1.data(), 100f32, size.width);
- assert_eq!(size.height, 24f32, "height of node {:?}. Expected {}. Actual {}", node1.data(), 24f32, size.height);
+ assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1.data(), 25f32, size.height);
assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1.data(), 0f32, location.x);
assert_eq!(location.y, 64f32, "y of node {:?}. Expected {}. Actual {}", node1.data(), 64f32, location.y);
let Layout { size, location, .. } = taffy.layout(node2).unwrap();
diff --git a/tests/generated/rounding_fractial_input_2.rs b/tests/generated/rounding_fractial_input_2.rs
index 0ad5e7115..57cb62246 100644
--- a/tests/generated/rounding_fractial_input_2.rs
+++ b/tests/generated/rounding_fractial_input_2.rs
@@ -55,7 +55,7 @@ fn rounding_fractial_input_2() {
assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y);
let Layout { size, location, .. } = taffy.layout(node1).unwrap();
assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1.data(), 100f32, size.width);
- assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1.data(), 25f32, size.height);
+ assert_eq!(size.height, 24f32, "height of node {:?}. Expected {}. Actual {}", node1.data(), 24f32, size.height);
assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1.data(), 0f32, location.x);
assert_eq!(location.y, 65f32, "y of node {:?}. Expected {}. Actual {}", node1.data(), 65f32, location.y);
let Layout { size, location, .. } = taffy.layout(node2).unwrap();
diff --git a/tests/generated/rounding_fractial_input_3.rs b/tests/generated/rounding_fractial_input_3.rs
index 0dd9d4ce3..96e7eb690 100644
--- a/tests/generated/rounding_fractial_input_3.rs
+++ b/tests/generated/rounding_fractial_input_3.rs
@@ -55,7 +55,7 @@ fn rounding_fractial_input_3() {
assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y);
let Layout { size, location, .. } = taffy.layout(node1).unwrap();
assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1.data(), 100f32, size.width);
- assert_eq!(size.height, 24f32, "height of node {:?}. Expected {}. Actual {}", node1.data(), 24f32, size.height);
+ assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1.data(), 25f32, size.height);
assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1.data(), 0f32, location.x);
assert_eq!(location.y, 64f32, "y of node {:?}. Expected {}. Actual {}", node1.data(), 64f32, location.y);
let Layout { size, location, .. } = taffy.layout(node2).unwrap();
diff --git a/tests/generated/rounding_fractial_input_4.rs b/tests/generated/rounding_fractial_input_4.rs
index 7137b9c8b..0a9faa674 100644
--- a/tests/generated/rounding_fractial_input_4.rs
+++ b/tests/generated/rounding_fractial_input_4.rs
@@ -55,7 +55,7 @@ fn rounding_fractial_input_4() {
assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y);
let Layout { size, location, .. } = taffy.layout(node1).unwrap();
assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1.data(), 100f32, size.width);
- assert_eq!(size.height, 24f32, "height of node {:?}. Expected {}. Actual {}", node1.data(), 24f32, size.height);
+ assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1.data(), 25f32, size.height);
assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1.data(), 0f32, location.x);
assert_eq!(location.y, 64f32, "y of node {:?}. Expected {}. Actual {}", node1.data(), 64f32, location.y);
let Layout { size, location, .. } = taffy.layout(node2).unwrap();
diff --git a/tests/generated/rounding_fractial_input_5.rs b/tests/generated/rounding_fractial_input_5.rs
new file mode 100644
index 000000000..90c5eaa00
--- /dev/null
+++ b/tests/generated/rounding_fractial_input_5.rs
@@ -0,0 +1,57 @@
+#[test]
+fn rounding_fractial_input_5() {
+ use slotmap::Key;
+ #[allow(unused_imports)]
+ use taffy::{layout::Layout, prelude::*};
+ let mut taffy = taffy::Taffy::new();
+ let node0 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Points(100.3f32),
+ height: taffy::style::Dimension::Points(100.3f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node1 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Points(100.3f32),
+ height: taffy::style::Dimension::Points(100.3f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node = taffy
+ .new_with_children(
+ taffy::style::Style {
+ justify_content: Some(taffy::style::JustifyContent::Center),
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Points(963.333f32),
+ height: taffy::style::Dimension::Points(100f32),
+ },
+ ..Default::default()
+ },
+ &[node0, node1],
+ )
+ .unwrap();
+ taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
+ println!("\nComputed tree:");
+ taffy::debug::print_tree(&taffy, node);
+ println!();
+ let Layout { size, location, .. } = taffy.layout(node).unwrap();
+ assert_eq!(size.width, 963f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 963f32, size.width);
+ assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node0).unwrap();
+ assert_eq!(size.width, 101f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 101f32, size.width);
+ assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 100f32, size.height);
+ assert_eq!(location.x, 381f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 381f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node1).unwrap();
+ assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1.data(), 100f32, size.width);
+ assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1.data(), 100f32, size.height);
+ assert_eq!(location.x, 482f32, "x of node {:?}. Expected {}. Actual {}", node1.data(), 482f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1.data(), 0f32, location.y);
+}
diff --git a/tests/generated/rounding_fractial_input_6.rs b/tests/generated/rounding_fractial_input_6.rs
new file mode 100644
index 000000000..8778c62d4
--- /dev/null
+++ b/tests/generated/rounding_fractial_input_6.rs
@@ -0,0 +1,111 @@
+#[test]
+fn rounding_fractial_input_6() {
+ use slotmap::Key;
+ #[allow(unused_imports)]
+ use taffy::{layout::Layout, prelude::*};
+ let mut taffy = taffy::Taffy::new();
+ let node00 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Points(2f32),
+ height: taffy::style::Dimension::Points(10f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node01 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Points(2f32),
+ height: taffy::style::Dimension::Points(10f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node0 = taffy
+ .new_with_children(
+ taffy::style::Style {
+ flex_wrap: taffy::style::FlexWrap::Wrap,
+ size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.5f32), height: auto() },
+ ..Default::default()
+ },
+ &[node00, node01],
+ )
+ .unwrap();
+ let node10 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Points(2f32),
+ height: taffy::style::Dimension::Points(10f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node11 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Points(2f32),
+ height: taffy::style::Dimension::Points(10f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node1 = taffy
+ .new_with_children(
+ taffy::style::Style {
+ flex_wrap: taffy::style::FlexWrap::Wrap,
+ size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.5f32), height: auto() },
+ ..Default::default()
+ },
+ &[node10, node11],
+ )
+ .unwrap();
+ let node = taffy
+ .new_with_children(
+ taffy::style::Style {
+ size: taffy::geometry::Size { width: taffy::style::Dimension::Points(7f32), height: auto() },
+ ..Default::default()
+ },
+ &[node0, node1],
+ )
+ .unwrap();
+ taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
+ println!("\nComputed tree:");
+ taffy::debug::print_tree(&taffy, node);
+ println!();
+ let Layout { size, location, .. } = taffy.layout(node).unwrap();
+ assert_eq!(size.width, 7f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 7f32, size.width);
+ assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 20f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node0).unwrap();
+ assert_eq!(size.width, 4f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 4f32, size.width);
+ assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 20f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node00).unwrap();
+ assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node00.data(), 2f32, size.width);
+ assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00.data(), 10f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node01).unwrap();
+ assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node01.data(), 2f32, size.width);
+ assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node01.data(), 10f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01.data(), 0f32, location.x);
+ assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node01.data(), 10f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node1).unwrap();
+ assert_eq!(size.width, 3f32, "width of node {:?}. Expected {}. Actual {}", node1.data(), 3f32, size.width);
+ assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1.data(), 20f32, size.height);
+ assert_eq!(location.x, 4f32, "x of node {:?}. Expected {}. Actual {}", node1.data(), 4f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node10).unwrap();
+ assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node10.data(), 2f32, size.width);
+ assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10.data(), 10f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node11).unwrap();
+ assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node11.data(), 2f32, size.width);
+ assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node11.data(), 10f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node11.data(), 0f32, location.x);
+ assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node11.data(), 10f32, location.y);
+}
diff --git a/tests/generated/rounding_fractial_input_7.rs b/tests/generated/rounding_fractial_input_7.rs
new file mode 100644
index 000000000..4592769bf
--- /dev/null
+++ b/tests/generated/rounding_fractial_input_7.rs
@@ -0,0 +1,197 @@
+#[test]
+fn rounding_fractial_input_7() {
+ use slotmap::Key;
+ #[allow(unused_imports)]
+ use taffy::{layout::Layout, prelude::*};
+ let mut taffy = taffy::Taffy::new();
+ let node00 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Points(1f32),
+ height: taffy::style::Dimension::Points(10f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node01 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Points(1f32),
+ height: taffy::style::Dimension::Points(10f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node0 = taffy
+ .new_with_children(
+ taffy::style::Style {
+ flex_wrap: taffy::style::FlexWrap::Wrap,
+ size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.25f32), height: auto() },
+ ..Default::default()
+ },
+ &[node00, node01],
+ )
+ .unwrap();
+ let node10 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Points(1f32),
+ height: taffy::style::Dimension::Points(10f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node11 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Points(1f32),
+ height: taffy::style::Dimension::Points(10f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node1 = taffy
+ .new_with_children(
+ taffy::style::Style {
+ flex_wrap: taffy::style::FlexWrap::Wrap,
+ size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.25f32), height: auto() },
+ ..Default::default()
+ },
+ &[node10, node11],
+ )
+ .unwrap();
+ let node20 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Points(1f32),
+ height: taffy::style::Dimension::Points(10f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node21 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Points(1f32),
+ height: taffy::style::Dimension::Points(10f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node2 = taffy
+ .new_with_children(
+ taffy::style::Style {
+ flex_wrap: taffy::style::FlexWrap::Wrap,
+ size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.25f32), height: auto() },
+ ..Default::default()
+ },
+ &[node20, node21],
+ )
+ .unwrap();
+ let node30 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Points(1f32),
+ height: taffy::style::Dimension::Points(10f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node31 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Points(1f32),
+ height: taffy::style::Dimension::Points(10f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node3 = taffy
+ .new_with_children(
+ taffy::style::Style {
+ flex_wrap: taffy::style::FlexWrap::Wrap,
+ size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.25f32), height: auto() },
+ ..Default::default()
+ },
+ &[node30, node31],
+ )
+ .unwrap();
+ let node = taffy
+ .new_with_children(
+ taffy::style::Style {
+ size: taffy::geometry::Size { width: taffy::style::Dimension::Points(7f32), height: auto() },
+ ..Default::default()
+ },
+ &[node0, node1, node2, node3],
+ )
+ .unwrap();
+ taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
+ println!("\nComputed tree:");
+ taffy::debug::print_tree(&taffy, node);
+ println!();
+ let Layout { size, location, .. } = taffy.layout(node).unwrap();
+ assert_eq!(size.width, 7f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 7f32, size.width);
+ assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 20f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node0).unwrap();
+ assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 2f32, size.width);
+ assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 20f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node00).unwrap();
+ assert_eq!(size.width, 1f32, "width of node {:?}. Expected {}. Actual {}", node00.data(), 1f32, size.width);
+ assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00.data(), 10f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node01).unwrap();
+ assert_eq!(size.width, 1f32, "width of node {:?}. Expected {}. Actual {}", node01.data(), 1f32, size.width);
+ assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node01.data(), 10f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node01.data(), 0f32, location.x);
+ assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node01.data(), 10f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node1).unwrap();
+ assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node1.data(), 2f32, size.width);
+ assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1.data(), 20f32, size.height);
+ assert_eq!(location.x, 2f32, "x of node {:?}. Expected {}. Actual {}", node1.data(), 2f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node10).unwrap();
+ assert_eq!(size.width, 1f32, "width of node {:?}. Expected {}. Actual {}", node10.data(), 1f32, size.width);
+ assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10.data(), 10f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node11).unwrap();
+ assert_eq!(size.width, 1f32, "width of node {:?}. Expected {}. Actual {}", node11.data(), 1f32, size.width);
+ assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node11.data(), 10f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node11.data(), 0f32, location.x);
+ assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node11.data(), 10f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node2).unwrap();
+ assert_eq!(size.width, 1f32, "width of node {:?}. Expected {}. Actual {}", node2.data(), 1f32, size.width);
+ assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2.data(), 20f32, size.height);
+ assert_eq!(location.x, 4f32, "x of node {:?}. Expected {}. Actual {}", node2.data(), 4f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node20).unwrap();
+ assert_eq!(size.width, 1f32, "width of node {:?}. Expected {}. Actual {}", node20.data(), 1f32, size.width);
+ assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node20.data(), 10f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node20.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node20.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node21).unwrap();
+ assert_eq!(size.width, 1f32, "width of node {:?}. Expected {}. Actual {}", node21.data(), 1f32, size.width);
+ assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node21.data(), 10f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node21.data(), 0f32, location.x);
+ assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node21.data(), 10f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node3).unwrap();
+ assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node3.data(), 2f32, size.width);
+ assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3.data(), 20f32, size.height);
+ assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node3.data(), 5f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node30).unwrap();
+ assert_eq!(size.width, 1f32, "width of node {:?}. Expected {}. Actual {}", node30.data(), 1f32, size.width);
+ assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node30.data(), 10f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node30.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node30.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node31).unwrap();
+ assert_eq!(size.width, 1f32, "width of node {:?}. Expected {}. Actual {}", node31.data(), 1f32, size.width);
+ assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node31.data(), 10f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node31.data(), 0f32, location.x);
+ assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node31.data(), 10f32, location.y);
+}
diff --git a/tests/generated/rounding_inner_node_controversy_combined.rs b/tests/generated/rounding_inner_node_controversy_combined.rs
new file mode 100644
index 000000000..6ffce1f8b
--- /dev/null
+++ b/tests/generated/rounding_inner_node_controversy_combined.rs
@@ -0,0 +1,120 @@
+#[test]
+fn rounding_inner_node_controversy_combined() {
+ use slotmap::Key;
+ #[allow(unused_imports)]
+ use taffy::{layout::Layout, prelude::*};
+ let mut taffy = taffy::Taffy::new();
+ let node0 = taffy
+ .new_leaf(taffy::style::Style {
+ flex_grow: 1f32,
+ size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(1f32) },
+ ..Default::default()
+ })
+ .unwrap();
+ let node10 = taffy
+ .new_leaf(taffy::style::Style {
+ flex_grow: 1f32,
+ size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), height: auto() },
+ ..Default::default()
+ })
+ .unwrap();
+ let node110 = taffy
+ .new_leaf(taffy::style::Style {
+ flex_grow: 1f32,
+ size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), height: auto() },
+ ..Default::default()
+ })
+ .unwrap();
+ let node11 = taffy
+ .new_with_children(
+ taffy::style::Style {
+ flex_direction: taffy::style::FlexDirection::Column,
+ flex_grow: 1f32,
+ size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), height: auto() },
+ ..Default::default()
+ },
+ &[node110],
+ )
+ .unwrap();
+ let node12 = taffy
+ .new_leaf(taffy::style::Style {
+ flex_grow: 1f32,
+ size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), height: auto() },
+ ..Default::default()
+ })
+ .unwrap();
+ let node1 = taffy
+ .new_with_children(
+ taffy::style::Style {
+ flex_direction: taffy::style::FlexDirection::Column,
+ flex_grow: 1f32,
+ size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(1f32) },
+ ..Default::default()
+ },
+ &[node10, node11, node12],
+ )
+ .unwrap();
+ let node2 = taffy
+ .new_leaf(taffy::style::Style {
+ flex_grow: 1f32,
+ size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(1f32) },
+ ..Default::default()
+ })
+ .unwrap();
+ let node = taffy
+ .new_with_children(
+ taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Points(640f32),
+ height: taffy::style::Dimension::Points(320f32),
+ },
+ ..Default::default()
+ },
+ &[node0, node1, node2],
+ )
+ .unwrap();
+ taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
+ println!("\nComputed tree:");
+ taffy::debug::print_tree(&taffy, node);
+ println!();
+ let Layout { size, location, .. } = taffy.layout(node).unwrap();
+ assert_eq!(size.width, 640f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 640f32, size.width);
+ assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 320f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node0).unwrap();
+ assert_eq!(size.width, 213f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 213f32, size.width);
+ assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 320f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node1).unwrap();
+ assert_eq!(size.width, 214f32, "width of node {:?}. Expected {}. Actual {}", node1.data(), 214f32, size.width);
+ assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node1.data(), 320f32, size.height);
+ assert_eq!(location.x, 213f32, "x of node {:?}. Expected {}. Actual {}", node1.data(), 213f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node10).unwrap();
+ assert_eq!(size.width, 214f32, "width of node {:?}. Expected {}. Actual {}", node10.data(), 214f32, size.width);
+ assert_eq!(size.height, 107f32, "height of node {:?}. Expected {}. Actual {}", node10.data(), 107f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node11).unwrap();
+ assert_eq!(size.width, 214f32, "width of node {:?}. Expected {}. Actual {}", node11.data(), 214f32, size.width);
+ assert_eq!(size.height, 106f32, "height of node {:?}. Expected {}. Actual {}", node11.data(), 106f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node11.data(), 0f32, location.x);
+ assert_eq!(location.y, 107f32, "y of node {:?}. Expected {}. Actual {}", node11.data(), 107f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node110).unwrap();
+ assert_eq!(size.width, 214f32, "width of node {:?}. Expected {}. Actual {}", node110.data(), 214f32, size.width);
+ assert_eq!(size.height, 106f32, "height of node {:?}. Expected {}. Actual {}", node110.data(), 106f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node110.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node110.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node12).unwrap();
+ assert_eq!(size.width, 214f32, "width of node {:?}. Expected {}. Actual {}", node12.data(), 214f32, size.width);
+ assert_eq!(size.height, 107f32, "height of node {:?}. Expected {}. Actual {}", node12.data(), 107f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node12.data(), 0f32, location.x);
+ assert_eq!(location.y, 213f32, "y of node {:?}. Expected {}. Actual {}", node12.data(), 213f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node2).unwrap();
+ assert_eq!(size.width, 213f32, "width of node {:?}. Expected {}. Actual {}", node2.data(), 213f32, size.width);
+ assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node2.data(), 320f32, size.height);
+ assert_eq!(location.x, 427f32, "x of node {:?}. Expected {}. Actual {}", node2.data(), 427f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2.data(), 0f32, location.y);
+}
diff --git a/tests/generated/rounding_inner_node_controversy_horizontal.rs b/tests/generated/rounding_inner_node_controversy_horizontal.rs
new file mode 100644
index 000000000..2795b4508
--- /dev/null
+++ b/tests/generated/rounding_inner_node_controversy_horizontal.rs
@@ -0,0 +1,77 @@
+#[test]
+fn rounding_inner_node_controversy_horizontal() {
+ use slotmap::Key;
+ #[allow(unused_imports)]
+ use taffy::{layout::Layout, prelude::*};
+ let mut taffy = taffy::Taffy::new();
+ let node0 = taffy
+ .new_leaf(taffy::style::Style {
+ flex_grow: 1f32,
+ size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) },
+ ..Default::default()
+ })
+ .unwrap();
+ let node10 = taffy
+ .new_leaf(taffy::style::Style {
+ flex_grow: 1f32,
+ size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) },
+ ..Default::default()
+ })
+ .unwrap();
+ let node1 = taffy
+ .new_with_children(
+ taffy::style::Style {
+ flex_direction: taffy::style::FlexDirection::Column,
+ flex_grow: 1f32,
+ size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) },
+ ..Default::default()
+ },
+ &[node10],
+ )
+ .unwrap();
+ let node2 = taffy
+ .new_leaf(taffy::style::Style {
+ flex_grow: 1f32,
+ size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) },
+ ..Default::default()
+ })
+ .unwrap();
+ let node = taffy
+ .new_with_children(
+ taffy::style::Style {
+ size: taffy::geometry::Size { width: taffy::style::Dimension::Points(320f32), height: auto() },
+ ..Default::default()
+ },
+ &[node0, node1, node2],
+ )
+ .unwrap();
+ taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
+ println!("\nComputed tree:");
+ taffy::debug::print_tree(&taffy, node);
+ println!();
+ let Layout { size, location, .. } = taffy.layout(node).unwrap();
+ assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 320f32, size.width);
+ assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 10f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node0).unwrap();
+ assert_eq!(size.width, 107f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 107f32, size.width);
+ assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 10f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node1).unwrap();
+ assert_eq!(size.width, 106f32, "width of node {:?}. Expected {}. Actual {}", node1.data(), 106f32, size.width);
+ assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1.data(), 10f32, size.height);
+ assert_eq!(location.x, 107f32, "x of node {:?}. Expected {}. Actual {}", node1.data(), 107f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node10).unwrap();
+ assert_eq!(size.width, 106f32, "width of node {:?}. Expected {}. Actual {}", node10.data(), 106f32, size.width);
+ assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10.data(), 10f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node2).unwrap();
+ assert_eq!(size.width, 107f32, "width of node {:?}. Expected {}. Actual {}", node2.data(), 107f32, size.width);
+ assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2.data(), 10f32, size.height);
+ assert_eq!(location.x, 213f32, "x of node {:?}. Expected {}. Actual {}", node2.data(), 213f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2.data(), 0f32, location.y);
+}
diff --git a/tests/generated/rounding_inner_node_controversy_vertical.rs b/tests/generated/rounding_inner_node_controversy_vertical.rs
index 253b921bb..51488af3b 100644
--- a/tests/generated/rounding_inner_node_controversy_vertical.rs
+++ b/tests/generated/rounding_inner_node_controversy_vertical.rs
@@ -62,12 +62,12 @@ fn rounding_inner_node_controversy_vertical() {
assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y);
let Layout { size, location, .. } = taffy.layout(node1).unwrap();
assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1.data(), 10f32, size.width);
- assert_eq!(size.height, 107f32, "height of node {:?}. Expected {}. Actual {}", node1.data(), 107f32, size.height);
+ assert_eq!(size.height, 106f32, "height of node {:?}. Expected {}. Actual {}", node1.data(), 106f32, size.height);
assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1.data(), 0f32, location.x);
assert_eq!(location.y, 107f32, "y of node {:?}. Expected {}. Actual {}", node1.data(), 107f32, location.y);
let Layout { size, location, .. } = taffy.layout(node10).unwrap();
assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node10.data(), 10f32, size.width);
- assert_eq!(size.height, 107f32, "height of node {:?}. Expected {}. Actual {}", node10.data(), 107f32, size.height);
+ assert_eq!(size.height, 106f32, "height of node {:?}. Expected {}. Actual {}", node10.data(), 106f32, size.height);
assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10.data(), 0f32, location.x);
assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10.data(), 0f32, location.y);
let Layout { size, location, .. } = taffy.layout(node2).unwrap();
diff --git a/tests/rounding.rs b/tests/rounding.rs
new file mode 100644
index 000000000..8aa46103c
--- /dev/null
+++ b/tests/rounding.rs
@@ -0,0 +1,29 @@
+use taffy::prelude::*;
+
+#[test]
+fn rounding_doesnt_leave_gaps() {
+ // First create an instance of Taffy
+ let mut taffy = Taffy::new();
+
+ let w_square = Size { width: points(100.3), height: points(100.3) };
+ let child_a = taffy.new_leaf(Style { size: w_square, ..Default::default() }).unwrap();
+ let child_b = taffy.new_leaf(Style { size: w_square, ..Default::default() }).unwrap();
+
+ let root_node = taffy
+ .new_with_children(
+ Style {
+ size: Size { width: points(963.3333), height: points(1000.) },
+ justify_content: Some(JustifyContent::Center),
+ ..Default::default()
+ },
+ &[child_a, child_b],
+ )
+ .unwrap();
+
+ taffy.compute_layout(root_node, Size::MAX_CONTENT).unwrap();
+
+ let layout_a = taffy.layout(child_a).unwrap();
+ let layout_b = taffy.layout(child_b).unwrap();
+ taffy::debug::print_tree(&taffy, root_node);
+ assert_eq!(layout_a.location.x + layout_a.size.width, layout_b.location.x);
+}