diff --git a/csharp/tests/Facebook.Yoga/YGGapTest.cs b/csharp/tests/Facebook.Yoga/YGGapTest.cs
index fd6ecc84..173e10f0 100644
--- a/csharp/tests/Facebook.Yoga/YGGapTest.cs
+++ b/csharp/tests/Facebook.Yoga/YGGapTest.cs
@@ -1597,6 +1597,74 @@ namespace Facebook.Yoga
Assert.AreEqual(150f, root_child4.LayoutHeight);
}
+ [Test]
+ public void Test_column_gap_determines_parent_width()
+ {
+ YogaConfig config = new YogaConfig();
+
+ YogaNode root = new YogaNode(config);
+ root.FlexDirection = YogaFlexDirection.Row;
+ root.Height = 100;
+ root.ColumnGap = 10;
+
+ YogaNode root_child0 = new YogaNode(config);
+ root_child0.Width = 10;
+ root.Insert(0, root_child0);
+
+ YogaNode root_child1 = new YogaNode(config);
+ root_child1.Width = 20;
+ root.Insert(1, root_child1);
+
+ YogaNode root_child2 = new YogaNode(config);
+ root_child2.Width = 30;
+ root.Insert(2, root_child2);
+ root.StyleDirection = YogaDirection.LTR;
+ root.CalculateLayout();
+
+ Assert.AreEqual(0f, root.LayoutX);
+ Assert.AreEqual(0f, root.LayoutY);
+ Assert.AreEqual(80f, root.LayoutWidth);
+ Assert.AreEqual(100f, root.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child0.LayoutX);
+ Assert.AreEqual(0f, root_child0.LayoutY);
+ Assert.AreEqual(10f, root_child0.LayoutWidth);
+ Assert.AreEqual(100f, root_child0.LayoutHeight);
+
+ Assert.AreEqual(20f, root_child1.LayoutX);
+ Assert.AreEqual(0f, root_child1.LayoutY);
+ Assert.AreEqual(20f, root_child1.LayoutWidth);
+ Assert.AreEqual(100f, root_child1.LayoutHeight);
+
+ Assert.AreEqual(50f, root_child2.LayoutX);
+ Assert.AreEqual(0f, root_child2.LayoutY);
+ Assert.AreEqual(30f, root_child2.LayoutWidth);
+ Assert.AreEqual(100f, root_child2.LayoutHeight);
+
+ root.StyleDirection = YogaDirection.RTL;
+ root.CalculateLayout();
+
+ Assert.AreEqual(0f, root.LayoutX);
+ Assert.AreEqual(0f, root.LayoutY);
+ Assert.AreEqual(80f, root.LayoutWidth);
+ Assert.AreEqual(100f, root.LayoutHeight);
+
+ Assert.AreEqual(70f, root_child0.LayoutX);
+ Assert.AreEqual(0f, root_child0.LayoutY);
+ Assert.AreEqual(10f, root_child0.LayoutWidth);
+ Assert.AreEqual(100f, root_child0.LayoutHeight);
+
+ Assert.AreEqual(40f, root_child1.LayoutX);
+ Assert.AreEqual(0f, root_child1.LayoutY);
+ Assert.AreEqual(20f, root_child1.LayoutWidth);
+ Assert.AreEqual(100f, root_child1.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child2.LayoutX);
+ Assert.AreEqual(0f, root_child2.LayoutY);
+ Assert.AreEqual(30f, root_child2.LayoutWidth);
+ Assert.AreEqual(100f, root_child2.LayoutHeight);
+ }
+
[Test]
public void Test_row_gap_align_items_stretch()
{
@@ -1981,5 +2049,72 @@ namespace Facebook.Yoga
Assert.AreEqual(0f, root_child2.LayoutHeight);
}
+ [Test]
+ public void Test_row_gap_determines_parent_height()
+ {
+ YogaConfig config = new YogaConfig();
+
+ YogaNode root = new YogaNode(config);
+ root.Width = 100;
+ root.RowGap = 10;
+
+ YogaNode root_child0 = new YogaNode(config);
+ root_child0.Height = 10;
+ root.Insert(0, root_child0);
+
+ YogaNode root_child1 = new YogaNode(config);
+ root_child1.Height = 20;
+ root.Insert(1, root_child1);
+
+ YogaNode root_child2 = new YogaNode(config);
+ root_child2.Height = 30;
+ root.Insert(2, root_child2);
+ root.StyleDirection = YogaDirection.LTR;
+ root.CalculateLayout();
+
+ Assert.AreEqual(0f, root.LayoutX);
+ Assert.AreEqual(0f, root.LayoutY);
+ Assert.AreEqual(100f, root.LayoutWidth);
+ Assert.AreEqual(80f, root.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child0.LayoutX);
+ Assert.AreEqual(0f, root_child0.LayoutY);
+ Assert.AreEqual(100f, root_child0.LayoutWidth);
+ Assert.AreEqual(10f, root_child0.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child1.LayoutX);
+ Assert.AreEqual(20f, root_child1.LayoutY);
+ Assert.AreEqual(100f, root_child1.LayoutWidth);
+ Assert.AreEqual(20f, root_child1.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child2.LayoutX);
+ Assert.AreEqual(50f, root_child2.LayoutY);
+ Assert.AreEqual(100f, root_child2.LayoutWidth);
+ Assert.AreEqual(30f, root_child2.LayoutHeight);
+
+ root.StyleDirection = YogaDirection.RTL;
+ root.CalculateLayout();
+
+ Assert.AreEqual(0f, root.LayoutX);
+ Assert.AreEqual(0f, root.LayoutY);
+ Assert.AreEqual(100f, root.LayoutWidth);
+ Assert.AreEqual(80f, root.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child0.LayoutX);
+ Assert.AreEqual(0f, root_child0.LayoutY);
+ Assert.AreEqual(100f, root_child0.LayoutWidth);
+ Assert.AreEqual(10f, root_child0.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child1.LayoutX);
+ Assert.AreEqual(20f, root_child1.LayoutY);
+ Assert.AreEqual(100f, root_child1.LayoutWidth);
+ Assert.AreEqual(20f, root_child1.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child2.LayoutX);
+ Assert.AreEqual(50f, root_child2.LayoutY);
+ Assert.AreEqual(100f, root_child2.LayoutWidth);
+ Assert.AreEqual(30f, root_child2.LayoutHeight);
+ }
+
}
}
diff --git a/gentest/fixtures/YGGapTest.html b/gentest/fixtures/YGGapTest.html
index 7b412256..4bfc7753 100644
--- a/gentest/fixtures/YGGapTest.html
+++ b/gentest/fixtures/YGGapTest.html
@@ -123,6 +123,12 @@
+
+
+
+
diff --git a/java/tests/com/facebook/yoga/YGGapTest.java b/java/tests/com/facebook/yoga/YGGapTest.java
index b22d5656..29d08d8f 100644
--- a/java/tests/com/facebook/yoga/YGGapTest.java
+++ b/java/tests/com/facebook/yoga/YGGapTest.java
@@ -1589,6 +1589,73 @@ public class YGGapTest {
assertEquals(150f, root_child4.getLayoutHeight(), 0.0f);
}
+ @Test
+ public void test_column_gap_determines_parent_width() {
+ YogaConfig config = YogaConfigFactory.create();
+
+ final YogaNode root = createNode(config);
+ root.setFlexDirection(YogaFlexDirection.ROW);
+ root.setHeight(100f);
+ root.setGap(YogaGutter.COLUMN, 10f);
+
+ final YogaNode root_child0 = createNode(config);
+ root_child0.setWidth(10f);
+ root.addChildAt(root_child0, 0);
+
+ final YogaNode root_child1 = createNode(config);
+ root_child1.setWidth(20f);
+ root.addChildAt(root_child1, 1);
+
+ final YogaNode root_child2 = createNode(config);
+ root_child2.setWidth(30f);
+ root.addChildAt(root_child2, 2);
+ root.setDirection(YogaDirection.LTR);
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
+
+ assertEquals(0f, root.getLayoutX(), 0.0f);
+ assertEquals(0f, root.getLayoutY(), 0.0f);
+ assertEquals(80f, root.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(20f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
+
+ assertEquals(50f, root_child2.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
+ assertEquals(30f, root_child2.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root_child2.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(80f, root.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(70f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(40f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(20f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child2.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
+ assertEquals(30f, root_child2.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
+ }
+
@Test
public void test_row_gap_align_items_stretch() {
YogaConfig config = YogaConfigFactory.create();
@@ -1969,6 +2036,72 @@ public class YGGapTest {
assertEquals(0f, root_child2.getLayoutHeight(), 0.0f);
}
+ @Test
+ public void test_row_gap_determines_parent_height() {
+ YogaConfig config = YogaConfigFactory.create();
+
+ final YogaNode root = createNode(config);
+ root.setWidth(100f);
+ root.setGap(YogaGutter.ROW, 10f);
+
+ final YogaNode root_child0 = createNode(config);
+ root_child0.setHeight(10f);
+ root.addChildAt(root_child0, 0);
+
+ final YogaNode root_child1 = createNode(config);
+ root_child1.setHeight(20f);
+ root.addChildAt(root_child1, 1);
+
+ final YogaNode root_child2 = createNode(config);
+ root_child2.setHeight(30f);
+ root.addChildAt(root_child2, 2);
+ root.setDirection(YogaDirection.LTR);
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
+
+ assertEquals(0f, root.getLayoutX(), 0.0f);
+ assertEquals(0f, root.getLayoutY(), 0.0f);
+ assertEquals(100f, root.getLayoutWidth(), 0.0f);
+ assertEquals(80f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(20f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child2.getLayoutX(), 0.0f);
+ assertEquals(50f, root_child2.getLayoutY(), 0.0f);
+ assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
+ assertEquals(30f, root_child2.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(100f, root.getLayoutWidth(), 0.0f);
+ assertEquals(80f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(20f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(20f, root_child1.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child2.getLayoutX(), 0.0f);
+ assertEquals(50f, root_child2.getLayoutY(), 0.0f);
+ assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
+ assertEquals(30f, root_child2.getLayoutHeight(), 0.0f);
+ }
+
private YogaNode createNode(YogaConfig config) {
return mNodeFactory.create(config);
}
diff --git a/javascript/tests/Facebook.Yoga/YGGapTest.js b/javascript/tests/Facebook.Yoga/YGGapTest.js
index 07175f74..d7e37048 100644
--- a/javascript/tests/Facebook.Yoga/YGGapTest.js
+++ b/javascript/tests/Facebook.Yoga/YGGapTest.js
@@ -1642,6 +1642,77 @@ it("column_gap_wrap_align_stretch", function () {
config.free();
}
});
+it("column_gap_determines_parent_width", function () {
+ var config = Yoga.Config.create();
+
+ try {
+ var root = Yoga.Node.create(config);
+ root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
+ root.setHeight(100);
+ root.setGap(Yoga.GUTTER_COLUMN, 10);
+
+ var root_child0 = Yoga.Node.create(config);
+ root_child0.setWidth(10);
+ root.insertChild(root_child0, 0);
+
+ var root_child1 = Yoga.Node.create(config);
+ root_child1.setWidth(20);
+ root.insertChild(root_child1, 1);
+
+ var root_child2 = Yoga.Node.create(config);
+ root_child2.setWidth(30);
+ root.insertChild(root_child2, 2);
+ 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(80 === root.getComputedWidth(), "80 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
+ console.assert(100 === root.getComputedHeight(), "100 === 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(10 === root_child0.getComputedWidth(), "10 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
+ console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
+
+ console.assert(20 === root_child1.getComputedLeft(), "20 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
+ console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
+ console.assert(20 === root_child1.getComputedWidth(), "20 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
+ console.assert(100 === root_child1.getComputedHeight(), "100 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
+
+ console.assert(50 === root_child2.getComputedLeft(), "50 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
+ console.assert(0 === root_child2.getComputedTop(), "0 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
+ console.assert(30 === root_child2.getComputedWidth(), "30 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
+ console.assert(100 === root_child2.getComputedHeight(), "100 === root_child2.getComputedHeight() (" + root_child2.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(80 === root.getComputedWidth(), "80 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
+ console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
+
+ console.assert(70 === root_child0.getComputedLeft(), "70 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
+ console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
+ console.assert(10 === root_child0.getComputedWidth(), "10 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
+ console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
+
+ console.assert(40 === root_child1.getComputedLeft(), "40 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
+ console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
+ console.assert(20 === root_child1.getComputedWidth(), "20 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
+ console.assert(100 === root_child1.getComputedHeight(), "100 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
+
+ console.assert(0 === root_child2.getComputedLeft(), "0 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
+ console.assert(0 === root_child2.getComputedTop(), "0 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
+ console.assert(30 === root_child2.getComputedWidth(), "30 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
+ console.assert(100 === root_child2.getComputedHeight(), "100 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
+ } finally {
+ if (typeof root !== "undefined") {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
it("row_gap_align_items_stretch", function () {
var config = Yoga.Config.create();
@@ -2038,3 +2109,73 @@ it("row_gap_row_wrap_child_margins", function () {
config.free();
}
});
+it("row_gap_determines_parent_height", function () {
+ var config = Yoga.Config.create();
+
+ try {
+ var root = Yoga.Node.create(config);
+ root.setWidth(100);
+ root.setGap(Yoga.GUTTER_ROW, 10);
+
+ var root_child0 = Yoga.Node.create(config);
+ root_child0.setHeight(10);
+ root.insertChild(root_child0, 0);
+
+ var root_child1 = Yoga.Node.create(config);
+ root_child1.setHeight(20);
+ root.insertChild(root_child1, 1);
+
+ var root_child2 = Yoga.Node.create(config);
+ root_child2.setHeight(30);
+ root.insertChild(root_child2, 2);
+ 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(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
+ console.assert(80 === root.getComputedHeight(), "80 === 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(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
+ console.assert(10 === root_child0.getComputedHeight(), "10 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
+
+ console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
+ console.assert(20 === root_child1.getComputedTop(), "20 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
+ console.assert(100 === root_child1.getComputedWidth(), "100 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
+ console.assert(20 === root_child1.getComputedHeight(), "20 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
+
+ console.assert(0 === root_child2.getComputedLeft(), "0 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
+ console.assert(50 === root_child2.getComputedTop(), "50 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
+ console.assert(100 === root_child2.getComputedWidth(), "100 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
+ console.assert(30 === root_child2.getComputedHeight(), "30 === root_child2.getComputedHeight() (" + root_child2.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(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
+ console.assert(80 === root.getComputedHeight(), "80 === 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(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
+ console.assert(10 === root_child0.getComputedHeight(), "10 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
+
+ console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
+ console.assert(20 === root_child1.getComputedTop(), "20 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
+ console.assert(100 === root_child1.getComputedWidth(), "100 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
+ console.assert(20 === root_child1.getComputedHeight(), "20 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
+
+ console.assert(0 === root_child2.getComputedLeft(), "0 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
+ console.assert(50 === root_child2.getComputedTop(), "50 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
+ console.assert(100 === root_child2.getComputedWidth(), "100 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
+ console.assert(30 === root_child2.getComputedHeight(), "30 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
+ } finally {
+ if (typeof root !== "undefined") {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
diff --git a/tests/YGGapTest.cpp b/tests/YGGapTest.cpp
index 982721bc..2fd0c70a 100644
--- a/tests/YGGapTest.cpp
+++ b/tests/YGGapTest.cpp
@@ -1593,6 +1593,74 @@ TEST(YogaTest, column_gap_wrap_align_stretch) {
YGConfigFree(config);
}
+TEST(YogaTest, column_gap_determines_parent_width) {
+ const YGConfigRef config = YGConfigNew();
+
+ const YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
+ YGNodeStyleSetHeight(root, 100);
+ YGNodeStyleSetGap(root, YGGutterColumn, 10);
+
+ const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidth(root_child0, 10);
+ YGNodeInsertChild(root, root_child0, 0);
+
+ const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidth(root_child1, 20);
+ YGNodeInsertChild(root, root_child1, 1);
+
+ const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidth(root_child2, 30);
+ YGNodeInsertChild(root, root_child2, 2);
+ YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
+ ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));
+
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child2));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2));
+ ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child2));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2));
+
+ YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
+ ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
+
+ ASSERT_FLOAT_EQ(70, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2));
+ ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child2));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}
+
TEST(YogaTest, row_gap_align_items_stretch) {
const YGConfigRef config = YGConfigNew();
@@ -1976,3 +2044,70 @@ TEST(YogaTest, row_gap_row_wrap_child_margins) {
YGConfigFree(config);
}
+
+TEST(YogaTest, row_gap_determines_parent_height) {
+ const YGConfigRef config = YGConfigNew();
+
+ const YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidth(root, 100);
+ YGNodeStyleSetGap(root, YGGutterRow, 10);
+
+ const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetHeight(root_child0, 10);
+ YGNodeInsertChild(root, root_child0, 0);
+
+ const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetHeight(root_child1, 20);
+ YGNodeInsertChild(root, root_child1, 1);
+
+ const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetHeight(root_child2, 30);
+ YGNodeInsertChild(root, root_child2, 2);
+ YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child2));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2));
+ ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child2));
+
+ YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child2));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2));
+ ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child2));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}
diff --git a/yoga/Yoga.cpp b/yoga/Yoga.cpp
index 88c77ab8..a66adec1 100644
--- a/yoga/Yoga.cpp
+++ b/yoga/Yoga.cpp
@@ -2540,6 +2540,11 @@ static void YGJustifyMainAxis(
const YGNodeRef child = node->getChild(i);
const YGStyle& childStyle = child->getStyle();
const YGLayout childLayout = child->getLayout();
+ const bool isLastChild = i == collectedFlexItemsValues.endOfLineIndex - 1;
+ // remove the gap if it is the last element of the line
+ if (isLastChild) {
+ betweenMainDim -= gap;
+ }
if (childStyle.display() == YGDisplayNone) {
continue;
}