diff --git a/csharp/tests/Facebook.Yoga/YGFlexWrapTest.cs b/csharp/tests/Facebook.Yoga/YGFlexWrapTest.cs
index 3489a068..877af508 100644
--- a/csharp/tests/Facebook.Yoga/YGFlexWrapTest.cs
+++ b/csharp/tests/Facebook.Yoga/YGFlexWrapTest.cs
@@ -1545,5 +1545,103 @@ namespace Facebook.Yoga
Assert.AreEqual(100f, root_child2.LayoutHeight);
}
+ [Test]
+ public void Test_wrap_nodes_with_content_sizing_overflowing_margin()
+ {
+ YogaConfig config = new YogaConfig();
+
+ YogaNode root = new YogaNode(config);
+ root.Width = 500;
+ root.Height = 500;
+
+ YogaNode root_child0 = new YogaNode(config);
+ root_child0.FlexDirection = YogaFlexDirection.Row;
+ root_child0.Wrap = YogaWrap.Wrap;
+ root_child0.Width = 85;
+ root.Insert(0, root_child0);
+
+ YogaNode root_child0_child0 = new YogaNode(config);
+ root_child0.Insert(0, root_child0_child0);
+
+ YogaNode root_child0_child0_child0 = new YogaNode(config);
+ root_child0_child0_child0.Width = 40;
+ root_child0_child0_child0.Height = 40;
+ root_child0_child0.Insert(0, root_child0_child0_child0);
+
+ YogaNode root_child0_child1 = new YogaNode(config);
+ root_child0_child1.MarginRight = 10;
+ root_child0.Insert(1, root_child0_child1);
+
+ YogaNode root_child0_child1_child0 = new YogaNode(config);
+ root_child0_child1_child0.Width = 40;
+ root_child0_child1_child0.Height = 40;
+ root_child0_child1.Insert(0, root_child0_child1_child0);
+ root.StyleDirection = YogaDirection.LTR;
+ root.CalculateLayout();
+
+ Assert.AreEqual(0f, root.LayoutX);
+ Assert.AreEqual(0f, root.LayoutY);
+ Assert.AreEqual(500f, root.LayoutWidth);
+ Assert.AreEqual(500f, root.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child0.LayoutX);
+ Assert.AreEqual(0f, root_child0.LayoutY);
+ Assert.AreEqual(85f, root_child0.LayoutWidth);
+ Assert.AreEqual(80f, root_child0.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child0_child0.LayoutX);
+ Assert.AreEqual(0f, root_child0_child0.LayoutY);
+ Assert.AreEqual(40f, root_child0_child0.LayoutWidth);
+ Assert.AreEqual(40f, root_child0_child0.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child0_child0_child0.LayoutX);
+ Assert.AreEqual(0f, root_child0_child0_child0.LayoutY);
+ Assert.AreEqual(40f, root_child0_child0_child0.LayoutWidth);
+ Assert.AreEqual(40f, root_child0_child0_child0.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child0_child1.LayoutX);
+ Assert.AreEqual(40f, root_child0_child1.LayoutY);
+ Assert.AreEqual(40f, root_child0_child1.LayoutWidth);
+ Assert.AreEqual(40f, root_child0_child1.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child0_child1_child0.LayoutX);
+ Assert.AreEqual(0f, root_child0_child1_child0.LayoutY);
+ Assert.AreEqual(40f, root_child0_child1_child0.LayoutWidth);
+ Assert.AreEqual(40f, root_child0_child1_child0.LayoutHeight);
+
+ root.StyleDirection = YogaDirection.RTL;
+ root.CalculateLayout();
+
+ Assert.AreEqual(0f, root.LayoutX);
+ Assert.AreEqual(0f, root.LayoutY);
+ Assert.AreEqual(500f, root.LayoutWidth);
+ Assert.AreEqual(500f, root.LayoutHeight);
+
+ Assert.AreEqual(415f, root_child0.LayoutX);
+ Assert.AreEqual(0f, root_child0.LayoutY);
+ Assert.AreEqual(85f, root_child0.LayoutWidth);
+ Assert.AreEqual(80f, root_child0.LayoutHeight);
+
+ Assert.AreEqual(45f, root_child0_child0.LayoutX);
+ Assert.AreEqual(0f, root_child0_child0.LayoutY);
+ Assert.AreEqual(40f, root_child0_child0.LayoutWidth);
+ Assert.AreEqual(40f, root_child0_child0.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child0_child0_child0.LayoutX);
+ Assert.AreEqual(0f, root_child0_child0_child0.LayoutY);
+ Assert.AreEqual(40f, root_child0_child0_child0.LayoutWidth);
+ Assert.AreEqual(40f, root_child0_child0_child0.LayoutHeight);
+
+ Assert.AreEqual(35f, root_child0_child1.LayoutX);
+ Assert.AreEqual(40f, root_child0_child1.LayoutY);
+ Assert.AreEqual(40f, root_child0_child1.LayoutWidth);
+ Assert.AreEqual(40f, root_child0_child1.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child0_child1_child0.LayoutX);
+ Assert.AreEqual(0f, root_child0_child1_child0.LayoutY);
+ Assert.AreEqual(40f, root_child0_child1_child0.LayoutWidth);
+ Assert.AreEqual(40f, root_child0_child1_child0.LayoutHeight);
+ }
+
}
}
diff --git a/gentest/fixtures/YGFlexWrapTest.html b/gentest/fixtures/YGFlexWrapTest.html
index 67789b77..97aa2959 100644
--- a/gentest/fixtures/YGFlexWrapTest.html
+++ b/gentest/fixtures/YGFlexWrapTest.html
@@ -124,4 +124,15 @@
-
\ No newline at end of file
+
+
+
diff --git a/java/tests/com/facebook/yoga/YGFlexWrapTest.java b/java/tests/com/facebook/yoga/YGFlexWrapTest.java
index 5af79279..bb184c69 100644
--- a/java/tests/com/facebook/yoga/YGFlexWrapTest.java
+++ b/java/tests/com/facebook/yoga/YGFlexWrapTest.java
@@ -1526,4 +1526,101 @@ public class YGFlexWrapTest {
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
}
+ @Test
+ public void test_wrap_nodes_with_content_sizing_overflowing_margin() {
+ YogaConfig config = new YogaConfig();
+
+ final YogaNode root = new YogaNode(config);
+ root.setWidth(500f);
+ root.setHeight(500f);
+
+ final YogaNode root_child0 = new YogaNode(config);
+ root_child0.setFlexDirection(YogaFlexDirection.ROW);
+ root_child0.setWrap(YogaWrap.WRAP);
+ root_child0.setWidth(85f);
+ root.addChildAt(root_child0, 0);
+
+ final YogaNode root_child0_child0 = new YogaNode(config);
+ root_child0.addChildAt(root_child0_child0, 0);
+
+ final YogaNode root_child0_child0_child0 = new YogaNode(config);
+ root_child0_child0_child0.setWidth(40f);
+ root_child0_child0_child0.setHeight(40f);
+ root_child0_child0.addChildAt(root_child0_child0_child0, 0);
+
+ final YogaNode root_child0_child1 = new YogaNode(config);
+ root_child0_child1.setMargin(YogaEdge.RIGHT, 10f);
+ root_child0.addChildAt(root_child0_child1, 1);
+
+ final YogaNode root_child0_child1_child0 = new YogaNode(config);
+ root_child0_child1_child0.setWidth(40f);
+ root_child0_child1_child0.setHeight(40f);
+ root_child0_child1.addChildAt(root_child0_child1_child0, 0);
+ root.setDirection(YogaDirection.LTR);
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
+
+ assertEquals(0f, root.getLayoutX(), 0.0f);
+ assertEquals(0f, root.getLayoutY(), 0.0f);
+ assertEquals(500f, root.getLayoutWidth(), 0.0f);
+ assertEquals(500f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(85f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(80f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
+ assertEquals(40f, root_child0_child0.getLayoutWidth(), 0.0f);
+ assertEquals(40f, root_child0_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0_child0_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f);
+ assertEquals(40f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
+ assertEquals(40f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f);
+ assertEquals(40f, root_child0_child1.getLayoutY(), 0.0f);
+ assertEquals(40f, root_child0_child1.getLayoutWidth(), 0.0f);
+ assertEquals(40f, root_child0_child1.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0_child1_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0_child1_child0.getLayoutY(), 0.0f);
+ assertEquals(40f, root_child0_child1_child0.getLayoutWidth(), 0.0f);
+ assertEquals(40f, root_child0_child1_child0.getLayoutHeight(), 0.0f);
+
+ root.setDirection(YogaDirection.RTL);
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
+
+ assertEquals(0f, root.getLayoutX(), 0.0f);
+ assertEquals(0f, root.getLayoutY(), 0.0f);
+ assertEquals(500f, root.getLayoutWidth(), 0.0f);
+ assertEquals(500f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(415f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(85f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(80f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(45f, root_child0_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
+ assertEquals(40f, root_child0_child0.getLayoutWidth(), 0.0f);
+ assertEquals(40f, root_child0_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0_child0_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f);
+ assertEquals(40f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
+ assertEquals(40f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(35f, root_child0_child1.getLayoutX(), 0.0f);
+ assertEquals(40f, root_child0_child1.getLayoutY(), 0.0f);
+ assertEquals(40f, root_child0_child1.getLayoutWidth(), 0.0f);
+ assertEquals(40f, root_child0_child1.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0_child1_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0_child1_child0.getLayoutY(), 0.0f);
+ assertEquals(40f, root_child0_child1_child0.getLayoutWidth(), 0.0f);
+ assertEquals(40f, root_child0_child1_child0.getLayoutHeight(), 0.0f);
+ }
+
}
diff --git a/javascript/tests/Facebook.Yoga/YGFlexWrapTest.js b/javascript/tests/Facebook.Yoga/YGFlexWrapTest.js
index 503f945b..add2eb0c 100644
--- a/javascript/tests/Facebook.Yoga/YGFlexWrapTest.js
+++ b/javascript/tests/Facebook.Yoga/YGFlexWrapTest.js
@@ -1593,3 +1593,104 @@ it("wrapped_column_max_height_flex", function () {
config.free();
}
});
+it("wrap_nodes_with_content_sizing_overflowing_margin", function () {
+ var config = Yoga.Config.create();
+
+ try {
+ var root = Yoga.Node.create(config);
+ root.setWidth(500);
+ root.setHeight(500);
+
+ var root_child0 = Yoga.Node.create(config);
+ root_child0.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
+ root_child0.setFlexWrap(Yoga.WRAP_WRAP);
+ root_child0.setWidth(85);
+ root.insertChild(root_child0, 0);
+
+ var root_child0_child0 = Yoga.Node.create(config);
+ root_child0.insertChild(root_child0_child0, 0);
+
+ var root_child0_child0_child0 = Yoga.Node.create(config);
+ root_child0_child0_child0.setWidth(40);
+ root_child0_child0_child0.setHeight(40);
+ root_child0_child0.insertChild(root_child0_child0_child0, 0);
+
+ var root_child0_child1 = Yoga.Node.create(config);
+ root_child0_child1.setMargin(Yoga.EDGE_RIGHT, 10);
+ root_child0.insertChild(root_child0_child1, 1);
+
+ var root_child0_child1_child0 = Yoga.Node.create(config);
+ root_child0_child1_child0.setWidth(40);
+ root_child0_child1_child0.setHeight(40);
+ root_child0_child1.insertChild(root_child0_child1_child0, 0);
+ root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
+
+ console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
+ console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
+ console.assert(500 === root.getComputedWidth(), "500 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
+ console.assert(500 === root.getComputedHeight(), "500 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
+
+ console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
+ console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
+ console.assert(85 === root_child0.getComputedWidth(), "85 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
+ console.assert(80 === root_child0.getComputedHeight(), "80 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
+
+ console.assert(0 === root_child0_child0.getComputedLeft(), "0 === root_child0_child0.getComputedLeft() (" + root_child0_child0.getComputedLeft() + ")");
+ console.assert(0 === root_child0_child0.getComputedTop(), "0 === root_child0_child0.getComputedTop() (" + root_child0_child0.getComputedTop() + ")");
+ console.assert(40 === root_child0_child0.getComputedWidth(), "40 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
+ console.assert(40 === root_child0_child0.getComputedHeight(), "40 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
+
+ console.assert(0 === root_child0_child0_child0.getComputedLeft(), "0 === root_child0_child0_child0.getComputedLeft() (" + root_child0_child0_child0.getComputedLeft() + ")");
+ console.assert(0 === root_child0_child0_child0.getComputedTop(), "0 === root_child0_child0_child0.getComputedTop() (" + root_child0_child0_child0.getComputedTop() + ")");
+ console.assert(40 === root_child0_child0_child0.getComputedWidth(), "40 === root_child0_child0_child0.getComputedWidth() (" + root_child0_child0_child0.getComputedWidth() + ")");
+ console.assert(40 === root_child0_child0_child0.getComputedHeight(), "40 === root_child0_child0_child0.getComputedHeight() (" + root_child0_child0_child0.getComputedHeight() + ")");
+
+ console.assert(0 === root_child0_child1.getComputedLeft(), "0 === root_child0_child1.getComputedLeft() (" + root_child0_child1.getComputedLeft() + ")");
+ console.assert(40 === root_child0_child1.getComputedTop(), "40 === root_child0_child1.getComputedTop() (" + root_child0_child1.getComputedTop() + ")");
+ console.assert(40 === root_child0_child1.getComputedWidth(), "40 === root_child0_child1.getComputedWidth() (" + root_child0_child1.getComputedWidth() + ")");
+ console.assert(40 === root_child0_child1.getComputedHeight(), "40 === root_child0_child1.getComputedHeight() (" + root_child0_child1.getComputedHeight() + ")");
+
+ console.assert(0 === root_child0_child1_child0.getComputedLeft(), "0 === root_child0_child1_child0.getComputedLeft() (" + root_child0_child1_child0.getComputedLeft() + ")");
+ console.assert(0 === root_child0_child1_child0.getComputedTop(), "0 === root_child0_child1_child0.getComputedTop() (" + root_child0_child1_child0.getComputedTop() + ")");
+ console.assert(40 === root_child0_child1_child0.getComputedWidth(), "40 === root_child0_child1_child0.getComputedWidth() (" + root_child0_child1_child0.getComputedWidth() + ")");
+ console.assert(40 === root_child0_child1_child0.getComputedHeight(), "40 === root_child0_child1_child0.getComputedHeight() (" + root_child0_child1_child0.getComputedHeight() + ")");
+
+ root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
+
+ console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
+ console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
+ console.assert(500 === root.getComputedWidth(), "500 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
+ console.assert(500 === root.getComputedHeight(), "500 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
+
+ console.assert(415 === root_child0.getComputedLeft(), "415 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
+ console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
+ console.assert(85 === root_child0.getComputedWidth(), "85 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
+ console.assert(80 === root_child0.getComputedHeight(), "80 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
+
+ console.assert(45 === root_child0_child0.getComputedLeft(), "45 === root_child0_child0.getComputedLeft() (" + root_child0_child0.getComputedLeft() + ")");
+ console.assert(0 === root_child0_child0.getComputedTop(), "0 === root_child0_child0.getComputedTop() (" + root_child0_child0.getComputedTop() + ")");
+ console.assert(40 === root_child0_child0.getComputedWidth(), "40 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
+ console.assert(40 === root_child0_child0.getComputedHeight(), "40 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
+
+ console.assert(0 === root_child0_child0_child0.getComputedLeft(), "0 === root_child0_child0_child0.getComputedLeft() (" + root_child0_child0_child0.getComputedLeft() + ")");
+ console.assert(0 === root_child0_child0_child0.getComputedTop(), "0 === root_child0_child0_child0.getComputedTop() (" + root_child0_child0_child0.getComputedTop() + ")");
+ console.assert(40 === root_child0_child0_child0.getComputedWidth(), "40 === root_child0_child0_child0.getComputedWidth() (" + root_child0_child0_child0.getComputedWidth() + ")");
+ console.assert(40 === root_child0_child0_child0.getComputedHeight(), "40 === root_child0_child0_child0.getComputedHeight() (" + root_child0_child0_child0.getComputedHeight() + ")");
+
+ console.assert(35 === root_child0_child1.getComputedLeft(), "35 === root_child0_child1.getComputedLeft() (" + root_child0_child1.getComputedLeft() + ")");
+ console.assert(40 === root_child0_child1.getComputedTop(), "40 === root_child0_child1.getComputedTop() (" + root_child0_child1.getComputedTop() + ")");
+ console.assert(40 === root_child0_child1.getComputedWidth(), "40 === root_child0_child1.getComputedWidth() (" + root_child0_child1.getComputedWidth() + ")");
+ console.assert(40 === root_child0_child1.getComputedHeight(), "40 === root_child0_child1.getComputedHeight() (" + root_child0_child1.getComputedHeight() + ")");
+
+ console.assert(0 === root_child0_child1_child0.getComputedLeft(), "0 === root_child0_child1_child0.getComputedLeft() (" + root_child0_child1_child0.getComputedLeft() + ")");
+ console.assert(0 === root_child0_child1_child0.getComputedTop(), "0 === root_child0_child1_child0.getComputedTop() (" + root_child0_child1_child0.getComputedTop() + ")");
+ console.assert(40 === root_child0_child1_child0.getComputedWidth(), "40 === root_child0_child1_child0.getComputedWidth() (" + root_child0_child1_child0.getComputedWidth() + ")");
+ console.assert(40 === root_child0_child1_child0.getComputedHeight(), "40 === root_child0_child1_child0.getComputedHeight() (" + root_child0_child1_child0.getComputedHeight() + ")");
+ } finally {
+ if (typeof root !== "undefined") {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
diff --git a/tests/YGFlexWrapTest.cpp b/tests/YGFlexWrapTest.cpp
index ca8e7780..3f950ec5 100644
--- a/tests/YGFlexWrapTest.cpp
+++ b/tests/YGFlexWrapTest.cpp
@@ -1539,3 +1539,101 @@ TEST(YogaTest, wrapped_column_max_height_flex) {
YGConfigFree(config);
}
+
+TEST(YogaTest, wrap_nodes_with_content_sizing_overflowing_margin) {
+ const YGConfigRef config = YGConfigNew();
+
+ const YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidth(root, 500);
+ YGNodeStyleSetHeight(root, 500);
+
+ const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow);
+ YGNodeStyleSetFlexWrap(root_child0, YGWrapWrap);
+ YGNodeStyleSetWidth(root_child0, 85);
+ YGNodeInsertChild(root, root_child0, 0);
+
+ const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
+ YGNodeInsertChild(root_child0, root_child0_child0, 0);
+
+ const YGNodeRef root_child0_child0_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidth(root_child0_child0_child0, 40);
+ YGNodeStyleSetHeight(root_child0_child0_child0, 40);
+ YGNodeInsertChild(root_child0_child0, root_child0_child0_child0, 0);
+
+ const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetMargin(root_child0_child1, YGEdgeRight, 10);
+ YGNodeInsertChild(root_child0, root_child0_child1, 1);
+
+ const YGNodeRef root_child0_child1_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidth(root_child0_child1_child0, 40);
+ YGNodeStyleSetHeight(root_child0_child1_child0, 40);
+ YGNodeInsertChild(root_child0_child1, root_child0_child1_child0, 0);
+ YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
+ ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(85, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child0));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child0));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0_child0));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child0_child0));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child0_child0));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0_child1));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child1));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child1));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1_child0));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child1_child0));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child1_child0));
+
+ YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
+ ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root));
+
+ ASSERT_FLOAT_EQ(415, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(85, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(45, YGNodeLayoutGetLeft(root_child0_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child0));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child0));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0_child0));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child0_child0));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child0_child0));
+
+ ASSERT_FLOAT_EQ(35, YGNodeLayoutGetLeft(root_child0_child1));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child0_child1));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child1));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child1));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1_child0));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child1_child0));
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child1_child0));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}
diff --git a/yoga/Yoga.c b/yoga/Yoga.c
index dabd4c4e..5fc7610e 100644
--- a/yoga/Yoga.c
+++ b/yoga/Yoga.c
@@ -2109,7 +2109,7 @@ static void YGNodelayoutImpl(const YGNodeRef node,
}
}
- float totalFlexBasis = 0;
+ float totalOuterFlexBasis = 0;
// STEP 3: DETERMINE FLEX BASIS FOR EACH ITEM
for (uint32_t i = 0; i < childCount; i++) {
@@ -2162,11 +2162,14 @@ static void YGNodelayoutImpl(const YGNodeRef node,
}
}
- totalFlexBasis += child->layout.computedFlexBasis;
+ totalOuterFlexBasis +=
+ child->layout.computedFlexBasis + YGNodeMarginForAxis(child, mainAxis, availableInnerWidth);
+ ;
}
- const bool flexBasisOverflows =
- measureModeMainDim == YGMeasureModeUndefined ? false : totalFlexBasis > availableInnerMainDim;
+ const bool flexBasisOverflows = measureModeMainDim == YGMeasureModeUndefined
+ ? false
+ : totalOuterFlexBasis > availableInnerMainDim;
if (isNodeFlexWrap && flexBasisOverflows && measureModeMainDim == YGMeasureModeAtMost) {
measureModeMainDim = YGMeasureModeExactly;
}