diff --git a/csharp/tests/Facebook.Yoga/YGMinMaxDimensionTest.cs b/csharp/tests/Facebook.Yoga/YGMinMaxDimensionTest.cs
index ee20ba2b..6042fde6 100644
--- a/csharp/tests/Facebook.Yoga/YGMinMaxDimensionTest.cs
+++ b/csharp/tests/Facebook.Yoga/YGMinMaxDimensionTest.cs
@@ -676,6 +676,203 @@ namespace Facebook.Yoga
Assert.AreEqual(20f, root_child0_child0.LayoutHeight);
}
+ [Test]
+ public void Test_flex_root_ignored()
+ {
+ YogaConfig config = new YogaConfig();
+
+ YogaNode root = new YogaNode(config);
+ root.FlexGrow = 1;
+ root.Width = 100;
+ root.MinHeight = 100;
+ root.MaxHeight = 500;
+
+ YogaNode root_child0 = new YogaNode(config);
+ root_child0.FlexGrow = 1;
+ root_child0.FlexBasis = 200;
+ root.Insert(0, root_child0);
+
+ YogaNode root_child1 = new YogaNode(config);
+ root_child1.Height = 100;
+ root.Insert(1, root_child1);
+ root.StyleDirection = YogaDirection.LTR;
+ root.CalculateLayout();
+
+ Assert.AreEqual(0f, root.LayoutX);
+ Assert.AreEqual(0f, root.LayoutY);
+ Assert.AreEqual(100f, root.LayoutWidth);
+ Assert.AreEqual(300f, root.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child0.LayoutX);
+ Assert.AreEqual(0f, root_child0.LayoutY);
+ Assert.AreEqual(100f, root_child0.LayoutWidth);
+ Assert.AreEqual(200f, root_child0.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child1.LayoutX);
+ Assert.AreEqual(200f, root_child1.LayoutY);
+ Assert.AreEqual(100f, root_child1.LayoutWidth);
+ Assert.AreEqual(100f, root_child1.LayoutHeight);
+
+ root.StyleDirection = YogaDirection.RTL;
+ root.CalculateLayout();
+
+ Assert.AreEqual(0f, root.LayoutX);
+ Assert.AreEqual(0f, root.LayoutY);
+ Assert.AreEqual(100f, root.LayoutWidth);
+ Assert.AreEqual(300f, root.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child0.LayoutX);
+ Assert.AreEqual(0f, root_child0.LayoutY);
+ Assert.AreEqual(100f, root_child0.LayoutWidth);
+ Assert.AreEqual(200f, root_child0.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child1.LayoutX);
+ Assert.AreEqual(200f, root_child1.LayoutY);
+ Assert.AreEqual(100f, root_child1.LayoutWidth);
+ Assert.AreEqual(100f, root_child1.LayoutHeight);
+ }
+
+ [Test]
+ public void Test_flex_grow_root_minimized()
+ {
+ YogaConfig config = new YogaConfig();
+
+ YogaNode root = new YogaNode(config);
+ root.Width = 100;
+ root.MinHeight = 100;
+ root.MaxHeight = 500;
+
+ YogaNode root_child0 = new YogaNode(config);
+ root_child0.FlexGrow = 1;
+ root_child0.MinHeight = 100;
+ root_child0.MaxHeight = 500;
+ root.Insert(0, root_child0);
+
+ YogaNode root_child0_child0 = new YogaNode(config);
+ root_child0_child0.FlexGrow = 1;
+ root_child0_child0.FlexBasis = 200;
+ root_child0.Insert(0, root_child0_child0);
+
+ YogaNode root_child0_child1 = new YogaNode(config);
+ root_child0_child1.Height = 100;
+ root_child0.Insert(1, root_child0_child1);
+ root.StyleDirection = YogaDirection.LTR;
+ root.CalculateLayout();
+
+ Assert.AreEqual(0f, root.LayoutX);
+ Assert.AreEqual(0f, root.LayoutY);
+ Assert.AreEqual(100f, root.LayoutWidth);
+ Assert.AreEqual(300f, root.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child0.LayoutX);
+ Assert.AreEqual(0f, root_child0.LayoutY);
+ Assert.AreEqual(100f, root_child0.LayoutWidth);
+ Assert.AreEqual(300f, root_child0.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child0_child0.LayoutX);
+ Assert.AreEqual(0f, root_child0_child0.LayoutY);
+ Assert.AreEqual(100f, root_child0_child0.LayoutWidth);
+ Assert.AreEqual(200f, root_child0_child0.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child0_child1.LayoutX);
+ Assert.AreEqual(200f, root_child0_child1.LayoutY);
+ Assert.AreEqual(100f, root_child0_child1.LayoutWidth);
+ Assert.AreEqual(100f, root_child0_child1.LayoutHeight);
+
+ root.StyleDirection = YogaDirection.RTL;
+ root.CalculateLayout();
+
+ Assert.AreEqual(0f, root.LayoutX);
+ Assert.AreEqual(0f, root.LayoutY);
+ Assert.AreEqual(100f, root.LayoutWidth);
+ Assert.AreEqual(300f, root.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child0.LayoutX);
+ Assert.AreEqual(0f, root_child0.LayoutY);
+ Assert.AreEqual(100f, root_child0.LayoutWidth);
+ Assert.AreEqual(300f, root_child0.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child0_child0.LayoutX);
+ Assert.AreEqual(0f, root_child0_child0.LayoutY);
+ Assert.AreEqual(100f, root_child0_child0.LayoutWidth);
+ Assert.AreEqual(200f, root_child0_child0.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child0_child1.LayoutX);
+ Assert.AreEqual(200f, root_child0_child1.LayoutY);
+ Assert.AreEqual(100f, root_child0_child1.LayoutWidth);
+ Assert.AreEqual(100f, root_child0_child1.LayoutHeight);
+ }
+
+ [Test]
+ public void Test_flex_grow_height_maximized()
+ {
+ YogaConfig config = new YogaConfig();
+
+ YogaNode root = new YogaNode(config);
+ root.Width = 100;
+ root.Height = 500;
+
+ YogaNode root_child0 = new YogaNode(config);
+ root_child0.FlexGrow = 1;
+ root_child0.MinHeight = 100;
+ root_child0.MaxHeight = 500;
+ root.Insert(0, root_child0);
+
+ YogaNode root_child0_child0 = new YogaNode(config);
+ root_child0_child0.FlexGrow = 1;
+ root_child0_child0.FlexBasis = 200;
+ root_child0.Insert(0, root_child0_child0);
+
+ YogaNode root_child0_child1 = new YogaNode(config);
+ root_child0_child1.Height = 100;
+ root_child0.Insert(1, root_child0_child1);
+ root.StyleDirection = YogaDirection.LTR;
+ root.CalculateLayout();
+
+ Assert.AreEqual(0f, root.LayoutX);
+ Assert.AreEqual(0f, root.LayoutY);
+ Assert.AreEqual(100f, root.LayoutWidth);
+ Assert.AreEqual(500f, root.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child0.LayoutX);
+ Assert.AreEqual(0f, root_child0.LayoutY);
+ Assert.AreEqual(100f, root_child0.LayoutWidth);
+ Assert.AreEqual(500f, root_child0.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child0_child0.LayoutX);
+ Assert.AreEqual(0f, root_child0_child0.LayoutY);
+ Assert.AreEqual(100f, root_child0_child0.LayoutWidth);
+ Assert.AreEqual(400f, root_child0_child0.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child0_child1.LayoutX);
+ Assert.AreEqual(400f, root_child0_child1.LayoutY);
+ Assert.AreEqual(100f, root_child0_child1.LayoutWidth);
+ Assert.AreEqual(100f, root_child0_child1.LayoutHeight);
+
+ root.StyleDirection = YogaDirection.RTL;
+ root.CalculateLayout();
+
+ Assert.AreEqual(0f, root.LayoutX);
+ Assert.AreEqual(0f, root.LayoutY);
+ Assert.AreEqual(100f, root.LayoutWidth);
+ Assert.AreEqual(500f, root.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child0.LayoutX);
+ Assert.AreEqual(0f, root_child0.LayoutY);
+ Assert.AreEqual(100f, root_child0.LayoutWidth);
+ Assert.AreEqual(500f, root_child0.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child0_child0.LayoutX);
+ Assert.AreEqual(0f, root_child0_child0.LayoutY);
+ Assert.AreEqual(100f, root_child0_child0.LayoutWidth);
+ Assert.AreEqual(400f, root_child0_child0.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child0_child1.LayoutX);
+ Assert.AreEqual(400f, root_child0_child1.LayoutY);
+ Assert.AreEqual(100f, root_child0_child1.LayoutWidth);
+ Assert.AreEqual(100f, root_child0_child1.LayoutHeight);
+ }
+
[Test]
public void Test_flex_grow_within_constrained_min_row()
{
diff --git a/gentest/fixtures/YGMinMaxDimensionTest.html b/gentest/fixtures/YGMinMaxDimensionTest.html
index 3dcbb6b5..69e29b90 100644
--- a/gentest/fixtures/YGMinMaxDimensionTest.html
+++ b/gentest/fixtures/YGMinMaxDimensionTest.html
@@ -62,6 +62,25 @@
+
diff --git a/java/tests/com/facebook/yoga/YGMinMaxDimensionTest.java b/java/tests/com/facebook/yoga/YGMinMaxDimensionTest.java
index 4485eb3e..d8acba8d 100644
--- a/java/tests/com/facebook/yoga/YGMinMaxDimensionTest.java
+++ b/java/tests/com/facebook/yoga/YGMinMaxDimensionTest.java
@@ -662,6 +662,200 @@ public class YGMinMaxDimensionTest {
assertEquals(20f, root_child0_child0.getLayoutHeight(), 0.0f);
}
+ @Test
+ public void test_flex_root_ignored() {
+ YogaConfig config = new YogaConfig();
+
+ final YogaNode root = new YogaNode(config);
+ root.setFlexGrow(1f);
+ root.setWidth(100f);
+ root.setMinHeight(100f);
+ root.setMaxHeight(500f);
+
+ final YogaNode root_child0 = new YogaNode(config);
+ root_child0.setFlexGrow(1f);
+ root_child0.setFlexBasis(200f);
+ root.addChildAt(root_child0, 0);
+
+ final YogaNode root_child1 = new YogaNode(config);
+ root_child1.setHeight(100f);
+ root.addChildAt(root_child1, 1);
+ 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(300f, 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(200f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(200f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root_child1.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(300f, 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(200f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(200f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(100f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
+ }
+
+ @Test
+ public void test_flex_grow_root_minimized() {
+ YogaConfig config = new YogaConfig();
+
+ final YogaNode root = new YogaNode(config);
+ root.setWidth(100f);
+ root.setMinHeight(100f);
+ root.setMaxHeight(500f);
+
+ final YogaNode root_child0 = new YogaNode(config);
+ root_child0.setFlexGrow(1f);
+ root_child0.setMinHeight(100f);
+ root_child0.setMaxHeight(500f);
+ root.addChildAt(root_child0, 0);
+
+ final YogaNode root_child0_child0 = new YogaNode(config);
+ root_child0_child0.setFlexGrow(1f);
+ root_child0_child0.setFlexBasis(200f);
+ root_child0.addChildAt(root_child0_child0, 0);
+
+ final YogaNode root_child0_child1 = new YogaNode(config);
+ root_child0_child1.setHeight(100f);
+ root_child0.addChildAt(root_child0_child1, 1);
+ 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(300f, 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(300f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
+ assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f);
+ assertEquals(200f, root_child0_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f);
+ assertEquals(200f, root_child0_child1.getLayoutY(), 0.0f);
+ assertEquals(100f, root_child0_child1.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root_child0_child1.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(300f, 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(300f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
+ assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f);
+ assertEquals(200f, root_child0_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f);
+ assertEquals(200f, root_child0_child1.getLayoutY(), 0.0f);
+ assertEquals(100f, root_child0_child1.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f);
+ }
+
+ @Test
+ public void test_flex_grow_height_maximized() {
+ YogaConfig config = new YogaConfig();
+
+ final YogaNode root = new YogaNode(config);
+ root.setWidth(100f);
+ root.setHeight(500f);
+
+ final YogaNode root_child0 = new YogaNode(config);
+ root_child0.setFlexGrow(1f);
+ root_child0.setMinHeight(100f);
+ root_child0.setMaxHeight(500f);
+ root.addChildAt(root_child0, 0);
+
+ final YogaNode root_child0_child0 = new YogaNode(config);
+ root_child0_child0.setFlexGrow(1f);
+ root_child0_child0.setFlexBasis(200f);
+ root_child0.addChildAt(root_child0_child0, 0);
+
+ final YogaNode root_child0_child1 = new YogaNode(config);
+ root_child0_child1.setHeight(100f);
+ root_child0.addChildAt(root_child0_child1, 1);
+ 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(500f, 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(500f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
+ assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f);
+ assertEquals(400f, root_child0_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f);
+ assertEquals(400f, root_child0_child1.getLayoutY(), 0.0f);
+ assertEquals(100f, root_child0_child1.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root_child0_child1.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(500f, 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(500f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
+ assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f);
+ assertEquals(400f, root_child0_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f);
+ assertEquals(400f, root_child0_child1.getLayoutY(), 0.0f);
+ assertEquals(100f, root_child0_child1.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f);
+ }
+
@Test
public void test_flex_grow_within_constrained_min_row() {
YogaConfig config = new YogaConfig();
diff --git a/javascript/tests/Facebook.Yoga/YGMinMaxDimensionTest.js b/javascript/tests/Facebook.Yoga/YGMinMaxDimensionTest.js
index 78fd4238..f3347f7e 100644
--- a/javascript/tests/Facebook.Yoga/YGMinMaxDimensionTest.js
+++ b/javascript/tests/Facebook.Yoga/YGMinMaxDimensionTest.js
@@ -709,6 +709,212 @@ it("flex_grow_within_constrained_max_width", function () {
config.free();
}
});
+it("flex_root_ignored", function () {
+ var config = Yoga.Config.create();
+
+ try {
+ var root = Yoga.Node.create(config);
+ root.setFlexGrow(1);
+ root.setWidth(100);
+ root.setMinHeight(100);
+ root.setMaxHeight(500);
+
+ var root_child0 = Yoga.Node.create(config);
+ root_child0.setFlexGrow(1);
+ root_child0.setFlexBasis(200);
+ root.insertChild(root_child0, 0);
+
+ var root_child1 = Yoga.Node.create(config);
+ root_child1.setHeight(100);
+ root.insertChild(root_child1, 1);
+ 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(300 === root.getComputedHeight(), "300 === 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(200 === root_child0.getComputedHeight(), "200 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
+
+ console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
+ console.assert(200 === root_child1.getComputedTop(), "200 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
+ console.assert(100 === root_child1.getComputedWidth(), "100 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
+ console.assert(100 === root_child1.getComputedHeight(), "100 === root_child1.getComputedHeight() (" + root_child1.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(300 === root.getComputedHeight(), "300 === 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(200 === root_child0.getComputedHeight(), "200 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
+
+ console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
+ console.assert(200 === root_child1.getComputedTop(), "200 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
+ console.assert(100 === root_child1.getComputedWidth(), "100 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
+ console.assert(100 === root_child1.getComputedHeight(), "100 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
+ } finally {
+ if (typeof root !== "undefined") {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
+it("flex_grow_root_minimized", function () {
+ var config = Yoga.Config.create();
+
+ try {
+ var root = Yoga.Node.create(config);
+ root.setWidth(100);
+ root.setMinHeight(100);
+ root.setMaxHeight(500);
+
+ var root_child0 = Yoga.Node.create(config);
+ root_child0.setFlexGrow(1);
+ root_child0.setMinHeight(100);
+ root_child0.setMaxHeight(500);
+ root.insertChild(root_child0, 0);
+
+ var root_child0_child0 = Yoga.Node.create(config);
+ root_child0_child0.setFlexGrow(1);
+ root_child0_child0.setFlexBasis(200);
+ root_child0.insertChild(root_child0_child0, 0);
+
+ var root_child0_child1 = Yoga.Node.create(config);
+ root_child0_child1.setHeight(100);
+ root_child0.insertChild(root_child0_child1, 1);
+ 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(300 === root.getComputedHeight(), "300 === 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(300 === root_child0.getComputedHeight(), "300 === 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(100 === root_child0_child0.getComputedWidth(), "100 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
+ console.assert(200 === root_child0_child0.getComputedHeight(), "200 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
+
+ console.assert(0 === root_child0_child1.getComputedLeft(), "0 === root_child0_child1.getComputedLeft() (" + root_child0_child1.getComputedLeft() + ")");
+ console.assert(200 === root_child0_child1.getComputedTop(), "200 === root_child0_child1.getComputedTop() (" + root_child0_child1.getComputedTop() + ")");
+ console.assert(100 === root_child0_child1.getComputedWidth(), "100 === root_child0_child1.getComputedWidth() (" + root_child0_child1.getComputedWidth() + ")");
+ console.assert(100 === root_child0_child1.getComputedHeight(), "100 === root_child0_child1.getComputedHeight() (" + root_child0_child1.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(300 === root.getComputedHeight(), "300 === 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(300 === root_child0.getComputedHeight(), "300 === 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(100 === root_child0_child0.getComputedWidth(), "100 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
+ console.assert(200 === root_child0_child0.getComputedHeight(), "200 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
+
+ console.assert(0 === root_child0_child1.getComputedLeft(), "0 === root_child0_child1.getComputedLeft() (" + root_child0_child1.getComputedLeft() + ")");
+ console.assert(200 === root_child0_child1.getComputedTop(), "200 === root_child0_child1.getComputedTop() (" + root_child0_child1.getComputedTop() + ")");
+ console.assert(100 === root_child0_child1.getComputedWidth(), "100 === root_child0_child1.getComputedWidth() (" + root_child0_child1.getComputedWidth() + ")");
+ console.assert(100 === root_child0_child1.getComputedHeight(), "100 === root_child0_child1.getComputedHeight() (" + root_child0_child1.getComputedHeight() + ")");
+ } finally {
+ if (typeof root !== "undefined") {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
+it("flex_grow_height_maximized", function () {
+ var config = Yoga.Config.create();
+
+ try {
+ var root = Yoga.Node.create(config);
+ root.setWidth(100);
+ root.setHeight(500);
+
+ var root_child0 = Yoga.Node.create(config);
+ root_child0.setFlexGrow(1);
+ root_child0.setMinHeight(100);
+ root_child0.setMaxHeight(500);
+ root.insertChild(root_child0, 0);
+
+ var root_child0_child0 = Yoga.Node.create(config);
+ root_child0_child0.setFlexGrow(1);
+ root_child0_child0.setFlexBasis(200);
+ root_child0.insertChild(root_child0_child0, 0);
+
+ var root_child0_child1 = Yoga.Node.create(config);
+ root_child0_child1.setHeight(100);
+ root_child0.insertChild(root_child0_child1, 1);
+ 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(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(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
+ console.assert(500 === root_child0.getComputedHeight(), "500 === 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(100 === root_child0_child0.getComputedWidth(), "100 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
+ console.assert(400 === root_child0_child0.getComputedHeight(), "400 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
+
+ console.assert(0 === root_child0_child1.getComputedLeft(), "0 === root_child0_child1.getComputedLeft() (" + root_child0_child1.getComputedLeft() + ")");
+ console.assert(400 === root_child0_child1.getComputedTop(), "400 === root_child0_child1.getComputedTop() (" + root_child0_child1.getComputedTop() + ")");
+ console.assert(100 === root_child0_child1.getComputedWidth(), "100 === root_child0_child1.getComputedWidth() (" + root_child0_child1.getComputedWidth() + ")");
+ console.assert(100 === root_child0_child1.getComputedHeight(), "100 === root_child0_child1.getComputedHeight() (" + root_child0_child1.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(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(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
+ console.assert(500 === root_child0.getComputedHeight(), "500 === 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(100 === root_child0_child0.getComputedWidth(), "100 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
+ console.assert(400 === root_child0_child0.getComputedHeight(), "400 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
+
+ console.assert(0 === root_child0_child1.getComputedLeft(), "0 === root_child0_child1.getComputedLeft() (" + root_child0_child1.getComputedLeft() + ")");
+ console.assert(400 === root_child0_child1.getComputedTop(), "400 === root_child0_child1.getComputedTop() (" + root_child0_child1.getComputedTop() + ")");
+ console.assert(100 === root_child0_child1.getComputedWidth(), "100 === root_child0_child1.getComputedWidth() (" + root_child0_child1.getComputedWidth() + ")");
+ console.assert(100 === root_child0_child1.getComputedHeight(), "100 === root_child0_child1.getComputedHeight() (" + root_child0_child1.getComputedHeight() + ")");
+ } finally {
+ if (typeof root !== "undefined") {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
it("flex_grow_within_constrained_min_row", function () {
var config = Yoga.Config.create();
diff --git a/tests/YGMinMaxDimensionTest.cpp b/tests/YGMinMaxDimensionTest.cpp
index 74f19be1..f6331491 100644
--- a/tests/YGMinMaxDimensionTest.cpp
+++ b/tests/YGMinMaxDimensionTest.cpp
@@ -671,6 +671,203 @@ TEST(YogaTest, flex_grow_within_constrained_max_width) {
YGConfigFree(config);
}
+TEST(YogaTest, flex_root_ignored) {
+ const YGConfigRef config = YGConfigNew();
+
+ const YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetFlexGrow(root, 1);
+ YGNodeStyleSetWidth(root, 100);
+ YGNodeStyleSetMinHeight(root, 100);
+ YGNodeStyleSetMaxHeight(root, 500);
+
+ const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetFlexGrow(root_child0, 1);
+ YGNodeStyleSetFlexBasis(root_child0, 200);
+ YGNodeInsertChild(root, root_child0, 0);
+
+ const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetHeight(root_child1, 100);
+ YGNodeInsertChild(root, root_child1, 1);
+ 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(300, 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(200, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));
+
+ 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(300, 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(200, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}
+
+TEST(YogaTest, flex_grow_root_minimized) {
+ const YGConfigRef config = YGConfigNew();
+
+ const YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidth(root, 100);
+ YGNodeStyleSetMinHeight(root, 100);
+ YGNodeStyleSetMaxHeight(root, 500);
+
+ const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetFlexGrow(root_child0, 1);
+ YGNodeStyleSetMinHeight(root_child0, 100);
+ YGNodeStyleSetMaxHeight(root_child0, 500);
+ YGNodeInsertChild(root, root_child0, 0);
+
+ const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetFlexGrow(root_child0_child0, 1);
+ YGNodeStyleSetFlexBasis(root_child0_child0, 200);
+ YGNodeInsertChild(root_child0, root_child0_child0, 0);
+
+ const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetHeight(root_child0_child1, 100);
+ YGNodeInsertChild(root_child0, root_child0_child1, 1);
+ 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(300, 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(300, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child0));
+ ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0_child0));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1));
+ ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child0_child1));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child1));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1));
+
+ 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(300, 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(300, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child0));
+ ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0_child0));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1));
+ ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child0_child1));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child1));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}
+
+TEST(YogaTest, flex_grow_height_maximized) {
+ const YGConfigRef config = YGConfigNew();
+
+ const YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidth(root, 100);
+ YGNodeStyleSetHeight(root, 500);
+
+ const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetFlexGrow(root_child0, 1);
+ YGNodeStyleSetMinHeight(root_child0, 100);
+ YGNodeStyleSetMaxHeight(root_child0, 500);
+ YGNodeInsertChild(root, root_child0, 0);
+
+ const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetFlexGrow(root_child0_child0, 1);
+ YGNodeStyleSetFlexBasis(root_child0_child0, 200);
+ YGNodeInsertChild(root_child0, root_child0_child0, 0);
+
+ const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetHeight(root_child0_child1, 100);
+ YGNodeInsertChild(root_child0, root_child0_child1, 1);
+ 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(500, 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(500, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child0));
+ ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root_child0_child0));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1));
+ ASSERT_FLOAT_EQ(400, YGNodeLayoutGetTop(root_child0_child1));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child1));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1));
+
+ 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(500, 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(500, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child0));
+ ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root_child0_child0));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1));
+ ASSERT_FLOAT_EQ(400, YGNodeLayoutGetTop(root_child0_child1));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child1));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}
+
TEST(YogaTest, flex_grow_within_constrained_min_row) {
const YGConfigRef config = YGConfigNew();
diff --git a/yoga/Yoga.c b/yoga/Yoga.c
index df48f9da..d610b710 100644
--- a/yoga/Yoga.c
+++ b/yoga/Yoga.c
@@ -525,6 +525,10 @@ void YGNodeCopyStyle(const YGNodeRef dstNode, const YGNodeRef srcNode) {
}
static inline float YGResolveFlexGrow(const YGNodeRef node) {
+ // Root nodes flexGrow should always be 0
+ if (node->parent == NULL) {
+ return 0.0;
+ }
if (!YGFloatIsUndefined(node->style.flexGrow)) {
return node->style.flexGrow;
}
@@ -545,6 +549,10 @@ float YGNodeStyleGetFlexShrink(const YGNodeRef node) {
}
static inline float YGNodeResolveFlexShrink(const YGNodeRef node) {
+ // Root nodes flexShrink should always be 0
+ if (node->parent == NULL) {
+ return 0.0;
+ }
if (!YGFloatIsUndefined(node->style.flexShrink)) {
return node->style.flexShrink;
}
@@ -2293,7 +2301,7 @@ static void YGNodelayoutImpl(const YGNodeRef node,
if (!node->config->useLegacyStretchBehaviour &&
(totalFlexGrowFactors == 0 || YGResolveFlexGrow(node) == 0)) {
// If we don't have any children to flex or we can't flex the node itself,
- // space we've used is all space we need
+ // space we've used is all space we need. Root node also should be shrunk to minimum
availableInnerMainDim = sizeConsumedOnCurrentLine;
}
}