diff --git a/csharp/tests/Facebook.Yoga/YGSizeOverflowTest.cs b/csharp/tests/Facebook.Yoga/YGSizeOverflowTest.cs
new file mode 100644
index 00000000..01610e86
--- /dev/null
+++ b/csharp/tests/Facebook.Yoga/YGSizeOverflowTest.cs
@@ -0,0 +1,177 @@
+/**
+ * Copyright (c) 2014-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ */
+
+ // @Generated by gentest/gentest.rb from gentest/fixtures/YGSizeOverflowTest.html
+
+using System;
+using NUnit.Framework;
+
+namespace Facebook.Yoga
+{
+ [TestFixture]
+ public class YGSizeOverflowTest
+ {
+ [Test]
+ public void Test_nested_overflowing_child()
+ {
+ YogaNode root = new YogaNode();
+ root.Width = 100;
+ root.Height = 100;
+
+ YogaNode root_child0 = new YogaNode();
+ root.Insert(0, root_child0);
+
+ YogaNode root_child0_child0 = new YogaNode();
+ root_child0_child0.Width = 200;
+ root_child0_child0.Height = 200;
+ root_child0.Insert(0, root_child0_child0);
+ root.StyleDirection = YogaDirection.LTR;
+ root.CalculateLayout();
+
+ Assert.AreEqual(0f, root.LayoutX);
+ Assert.AreEqual(0f, root.LayoutY);
+ Assert.AreEqual(100f, root.LayoutWidth);
+ Assert.AreEqual(100f, 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_child0_child0.LayoutX);
+ Assert.AreEqual(0f, root_child0_child0.LayoutY);
+ Assert.AreEqual(200f, root_child0_child0.LayoutWidth);
+ Assert.AreEqual(200f, root_child0_child0.LayoutHeight);
+
+ root.StyleDirection = YogaDirection.RTL;
+ root.CalculateLayout();
+
+ Assert.AreEqual(0f, root.LayoutX);
+ Assert.AreEqual(0f, root.LayoutY);
+ Assert.AreEqual(100f, root.LayoutWidth);
+ Assert.AreEqual(100f, 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(-100f, root_child0_child0.LayoutX);
+ Assert.AreEqual(0f, root_child0_child0.LayoutY);
+ Assert.AreEqual(200f, root_child0_child0.LayoutWidth);
+ Assert.AreEqual(200f, root_child0_child0.LayoutHeight);
+ }
+
+ [Test]
+ public void Test_nested_overflowing_child_in_constraint_parent()
+ {
+ YogaNode root = new YogaNode();
+ root.Width = 100;
+ root.Height = 100;
+
+ YogaNode root_child0 = new YogaNode();
+ root_child0.Width = 100;
+ root_child0.Height = 100;
+ root.Insert(0, root_child0);
+
+ YogaNode root_child0_child0 = new YogaNode();
+ root_child0_child0.Width = 200;
+ root_child0_child0.Height = 200;
+ root_child0.Insert(0, root_child0_child0);
+ root.StyleDirection = YogaDirection.LTR;
+ root.CalculateLayout();
+
+ Assert.AreEqual(0f, root.LayoutX);
+ Assert.AreEqual(0f, root.LayoutY);
+ Assert.AreEqual(100f, root.LayoutWidth);
+ Assert.AreEqual(100f, root.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child0.LayoutX);
+ Assert.AreEqual(0f, root_child0.LayoutY);
+ Assert.AreEqual(100f, root_child0.LayoutWidth);
+ Assert.AreEqual(100f, root_child0.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child0_child0.LayoutX);
+ Assert.AreEqual(0f, root_child0_child0.LayoutY);
+ Assert.AreEqual(200f, root_child0_child0.LayoutWidth);
+ Assert.AreEqual(200f, root_child0_child0.LayoutHeight);
+
+ root.StyleDirection = YogaDirection.RTL;
+ root.CalculateLayout();
+
+ Assert.AreEqual(0f, root.LayoutX);
+ Assert.AreEqual(0f, root.LayoutY);
+ Assert.AreEqual(100f, root.LayoutWidth);
+ Assert.AreEqual(100f, root.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child0.LayoutX);
+ Assert.AreEqual(0f, root_child0.LayoutY);
+ Assert.AreEqual(100f, root_child0.LayoutWidth);
+ Assert.AreEqual(100f, root_child0.LayoutHeight);
+
+ Assert.AreEqual(-100f, root_child0_child0.LayoutX);
+ Assert.AreEqual(0f, root_child0_child0.LayoutY);
+ Assert.AreEqual(200f, root_child0_child0.LayoutWidth);
+ Assert.AreEqual(200f, root_child0_child0.LayoutHeight);
+ }
+
+ [Test]
+ public void Test_parent_wrap_child_size_overflowing_parent()
+ {
+ YogaNode root = new YogaNode();
+ root.Width = 100;
+ root.Height = 100;
+
+ YogaNode root_child0 = new YogaNode();
+ root_child0.Width = 100;
+ root.Insert(0, root_child0);
+
+ YogaNode root_child0_child0 = new YogaNode();
+ root_child0_child0.Width = 100;
+ root_child0_child0.Height = 200;
+ root_child0.Insert(0, root_child0_child0);
+ root.StyleDirection = YogaDirection.LTR;
+ root.CalculateLayout();
+
+ Assert.AreEqual(0f, root.LayoutX);
+ Assert.AreEqual(0f, root.LayoutY);
+ Assert.AreEqual(100f, root.LayoutWidth);
+ Assert.AreEqual(100f, 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_child0_child0.LayoutX);
+ Assert.AreEqual(0f, root_child0_child0.LayoutY);
+ Assert.AreEqual(100f, root_child0_child0.LayoutWidth);
+ Assert.AreEqual(200f, root_child0_child0.LayoutHeight);
+
+ root.StyleDirection = YogaDirection.RTL;
+ root.CalculateLayout();
+
+ Assert.AreEqual(0f, root.LayoutX);
+ Assert.AreEqual(0f, root.LayoutY);
+ Assert.AreEqual(100f, root.LayoutWidth);
+ Assert.AreEqual(100f, 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_child0_child0.LayoutX);
+ Assert.AreEqual(0f, root_child0_child0.LayoutY);
+ Assert.AreEqual(100f, root_child0_child0.LayoutWidth);
+ Assert.AreEqual(200f, root_child0_child0.LayoutHeight);
+ }
+
+ }
+}
diff --git a/gentest/fixtures/YGSizeOverflowTest.html b/gentest/fixtures/YGSizeOverflowTest.html
new file mode 100644
index 00000000..9b99a711
--- /dev/null
+++ b/gentest/fixtures/YGSizeOverflowTest.html
@@ -0,0 +1,17 @@
+
+
+
+
+
diff --git a/java/tests/com/facebook/yoga/YGSizeOverflowTest.java b/java/tests/com/facebook/yoga/YGSizeOverflowTest.java
new file mode 100644
index 00000000..b72f83d8
--- /dev/null
+++ b/java/tests/com/facebook/yoga/YGSizeOverflowTest.java
@@ -0,0 +1,172 @@
+/**
+ * Copyright (c) 2014-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ */
+
+ // @Generated by gentest/gentest.rb from gentest/fixtures/YGSizeOverflowTest.html
+
+package com.facebook.yoga;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class YGSizeOverflowTest {
+ @Test
+ public void test_nested_overflowing_child() {
+ final YogaNode root = new YogaNode();
+ root.setWidth(100f);
+ root.setHeight(100f);
+
+ final YogaNode root_child0 = new YogaNode();
+ root.addChildAt(root_child0, 0);
+
+ final YogaNode root_child0_child0 = new YogaNode();
+ root_child0_child0.setWidth(200f);
+ root_child0_child0.setHeight(200f);
+ root_child0.addChildAt(root_child0_child0, 0);
+ root.setDirection(YogaDirection.LTR);
+ root.calculateLayout();
+
+ assertEquals(0f, root.getLayoutX(), 0.0f);
+ assertEquals(0f, root.getLayoutY(), 0.0f);
+ assertEquals(100f, 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(100f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
+ assertEquals(200f, root_child0_child0.getLayoutWidth(), 0.0f);
+ assertEquals(200f, root_child0_child0.getLayoutHeight(), 0.0f);
+
+ root.setDirection(YogaDirection.RTL);
+ root.calculateLayout();
+
+ assertEquals(0f, root.getLayoutX(), 0.0f);
+ assertEquals(0f, root.getLayoutY(), 0.0f);
+ assertEquals(100f, 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(100f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(200f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(-100f, root_child0_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
+ assertEquals(200f, root_child0_child0.getLayoutWidth(), 0.0f);
+ assertEquals(200f, root_child0_child0.getLayoutHeight(), 0.0f);
+ }
+
+ @Test
+ public void test_nested_overflowing_child_in_constraint_parent() {
+ final YogaNode root = new YogaNode();
+ root.setWidth(100f);
+ root.setHeight(100f);
+
+ final YogaNode root_child0 = new YogaNode();
+ root_child0.setWidth(100f);
+ root_child0.setHeight(100f);
+ root.addChildAt(root_child0, 0);
+
+ final YogaNode root_child0_child0 = new YogaNode();
+ root_child0_child0.setWidth(200f);
+ root_child0_child0.setHeight(200f);
+ root_child0.addChildAt(root_child0_child0, 0);
+ root.setDirection(YogaDirection.LTR);
+ root.calculateLayout();
+
+ assertEquals(0f, root.getLayoutX(), 0.0f);
+ assertEquals(0f, root.getLayoutY(), 0.0f);
+ assertEquals(100f, 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(100f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
+ assertEquals(200f, root_child0_child0.getLayoutWidth(), 0.0f);
+ assertEquals(200f, root_child0_child0.getLayoutHeight(), 0.0f);
+
+ root.setDirection(YogaDirection.RTL);
+ root.calculateLayout();
+
+ assertEquals(0f, root.getLayoutX(), 0.0f);
+ assertEquals(0f, root.getLayoutY(), 0.0f);
+ assertEquals(100f, 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(100f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(-100f, root_child0_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
+ assertEquals(200f, root_child0_child0.getLayoutWidth(), 0.0f);
+ assertEquals(200f, root_child0_child0.getLayoutHeight(), 0.0f);
+ }
+
+ @Test
+ public void test_parent_wrap_child_size_overflowing_parent() {
+ final YogaNode root = new YogaNode();
+ root.setWidth(100f);
+ root.setHeight(100f);
+
+ final YogaNode root_child0 = new YogaNode();
+ root_child0.setWidth(100f);
+ root.addChildAt(root_child0, 0);
+
+ final YogaNode root_child0_child0 = new YogaNode();
+ root_child0_child0.setWidth(100f);
+ root_child0_child0.setHeight(200f);
+ root_child0.addChildAt(root_child0_child0, 0);
+ root.setDirection(YogaDirection.LTR);
+ root.calculateLayout();
+
+ assertEquals(0f, root.getLayoutX(), 0.0f);
+ assertEquals(0f, root.getLayoutY(), 0.0f);
+ assertEquals(100f, 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(100f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(200f, 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);
+
+ root.setDirection(YogaDirection.RTL);
+ root.calculateLayout();
+
+ assertEquals(0f, root.getLayoutX(), 0.0f);
+ assertEquals(0f, root.getLayoutY(), 0.0f);
+ assertEquals(100f, 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(100f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(200f, 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);
+ }
+
+}
diff --git a/javascript/tests/Facebook.Yoga/YGSizeOverflowTest.js b/javascript/tests/Facebook.Yoga/YGSizeOverflowTest.js
new file mode 100644
index 00000000..6882eb45
--- /dev/null
+++ b/javascript/tests/Facebook.Yoga/YGSizeOverflowTest.js
@@ -0,0 +1,172 @@
+/**
+ * Copyright (c) 2014-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ */
+
+ // @Generated by gentest/gentest.rb from gentest/fixtures/YGSizeOverflowTest.html
+
+var Yoga = Yoga || require("../../sources/entry-" + process.env.TEST_ENTRY);
+
+it("nested_overflowing_child", function () {
+ var root = Yoga.Node.create();
+ root.setWidth(100);
+ root.setHeight(100);
+
+ var root_child0 = Yoga.Node.create();
+ root.insertChild(root_child0, 0);
+
+ var root_child0_child0 = Yoga.Node.create();
+ root_child0_child0.setWidth(200);
+ root_child0_child0.setHeight(200);
+ root_child0.insertChild(root_child0_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(100 === root.getComputedWidth(), "100 === 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(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_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(200 === root_child0_child0.getComputedWidth(), "200 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
+ console.assert(200 === root_child0_child0.getComputedHeight(), "200 === root_child0_child0.getComputedHeight() (" + root_child0_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(100 === root.getComputedWidth(), "100 === 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(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(-100 === root_child0_child0.getComputedLeft(), "-100 === 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(200 === root_child0_child0.getComputedWidth(), "200 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
+ console.assert(200 === root_child0_child0.getComputedHeight(), "200 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
+
+ if (typeof root !== "undefined")
+ root.freeRecursive();
+
+ (typeof gc !== "undefined") && gc();
+ console.assert(0 === Yoga.getInstanceCount(), "0 === Yoga.getInstanceCount() (" + Yoga.getInstanceCount() + ")");
+});
+it("nested_overflowing_child_in_constraint_parent", function () {
+ var root = Yoga.Node.create();
+ root.setWidth(100);
+ root.setHeight(100);
+
+ var root_child0 = Yoga.Node.create();
+ root_child0.setWidth(100);
+ root_child0.setHeight(100);
+ root.insertChild(root_child0, 0);
+
+ var root_child0_child0 = Yoga.Node.create();
+ root_child0_child0.setWidth(200);
+ root_child0_child0.setHeight(200);
+ root_child0.insertChild(root_child0_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(100 === root.getComputedWidth(), "100 === 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(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
+ console.assert(100 === root_child0.getComputedHeight(), "100 === 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(200 === root_child0_child0.getComputedWidth(), "200 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
+ console.assert(200 === root_child0_child0.getComputedHeight(), "200 === root_child0_child0.getComputedHeight() (" + root_child0_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(100 === root.getComputedWidth(), "100 === 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(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
+ console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
+
+ console.assert(-100 === root_child0_child0.getComputedLeft(), "-100 === 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(200 === root_child0_child0.getComputedWidth(), "200 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
+ console.assert(200 === root_child0_child0.getComputedHeight(), "200 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
+
+ if (typeof root !== "undefined")
+ root.freeRecursive();
+
+ (typeof gc !== "undefined") && gc();
+ console.assert(0 === Yoga.getInstanceCount(), "0 === Yoga.getInstanceCount() (" + Yoga.getInstanceCount() + ")");
+});
+it("parent_wrap_child_size_overflowing_parent", function () {
+ var root = Yoga.Node.create();
+ root.setWidth(100);
+ root.setHeight(100);
+
+ var root_child0 = Yoga.Node.create();
+ root_child0.setWidth(100);
+ root.insertChild(root_child0, 0);
+
+ var root_child0_child0 = Yoga.Node.create();
+ root_child0_child0.setWidth(100);
+ root_child0_child0.setHeight(200);
+ root_child0.insertChild(root_child0_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(100 === root.getComputedWidth(), "100 === 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(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_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() + ")");
+
+ 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(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(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_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() + ")");
+
+ if (typeof root !== "undefined")
+ root.freeRecursive();
+
+ (typeof gc !== "undefined") && gc();
+ console.assert(0 === Yoga.getInstanceCount(), "0 === Yoga.getInstanceCount() (" + Yoga.getInstanceCount() + ")");
+});
diff --git a/tests/YGSizeOverflowTest.cpp b/tests/YGSizeOverflowTest.cpp
new file mode 100644
index 00000000..c8873cb6
--- /dev/null
+++ b/tests/YGSizeOverflowTest.cpp
@@ -0,0 +1,163 @@
+/**
+ * Copyright (c) 2014-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ */
+
+ // @Generated by gentest/gentest.rb from gentest/fixtures/YGSizeOverflowTest.html
+
+#include
+#include
+
+TEST(YogaTest, nested_overflowing_child) {
+ const YGNodeRef root = YGNodeNew();
+ YGNodeStyleSetWidth(root, 100);
+ YGNodeStyleSetHeight(root, 100);
+
+ const YGNodeRef root_child0 = YGNodeNew();
+ YGNodeInsertChild(root, root_child0, 0);
+
+ const YGNodeRef root_child0_child0 = YGNodeNew();
+ YGNodeStyleSetWidth(root_child0_child0, 200);
+ YGNodeStyleSetHeight(root_child0_child0, 200);
+ YGNodeInsertChild(root_child0, root_child0_child0, 0);
+ 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(100, 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_child0_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
+ ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0_child0));
+ ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0_child0));
+
+ 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(100, 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(-100, YGNodeLayoutGetLeft(root_child0_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
+ ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0_child0));
+ ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0_child0));
+
+ YGNodeFreeRecursive(root);
+}
+
+TEST(YogaTest, nested_overflowing_child_in_constraint_parent) {
+ const YGNodeRef root = YGNodeNew();
+ YGNodeStyleSetWidth(root, 100);
+ YGNodeStyleSetHeight(root, 100);
+
+ const YGNodeRef root_child0 = YGNodeNew();
+ YGNodeStyleSetWidth(root_child0, 100);
+ YGNodeStyleSetHeight(root_child0, 100);
+ YGNodeInsertChild(root, root_child0, 0);
+
+ const YGNodeRef root_child0_child0 = YGNodeNew();
+ YGNodeStyleSetWidth(root_child0_child0, 200);
+ YGNodeStyleSetHeight(root_child0_child0, 200);
+ YGNodeInsertChild(root_child0, root_child0_child0, 0);
+ 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(100, 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(100, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
+ ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0_child0));
+ ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0_child0));
+
+ 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(100, 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(100, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(-100, YGNodeLayoutGetLeft(root_child0_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
+ ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0_child0));
+ ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root_child0_child0));
+
+ YGNodeFreeRecursive(root);
+}
+
+TEST(YogaTest, parent_wrap_child_size_overflowing_parent) {
+ const YGNodeRef root = YGNodeNew();
+ YGNodeStyleSetWidth(root, 100);
+ YGNodeStyleSetHeight(root, 100);
+
+ const YGNodeRef root_child0 = YGNodeNew();
+ YGNodeStyleSetWidth(root_child0, 100);
+ YGNodeInsertChild(root, root_child0, 0);
+
+ const YGNodeRef root_child0_child0 = YGNodeNew();
+ YGNodeStyleSetWidth(root_child0_child0, 100);
+ YGNodeStyleSetHeight(root_child0_child0, 200);
+ YGNodeInsertChild(root_child0, root_child0_child0, 0);
+ 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(100, 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_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));
+
+ 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(100, 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_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));
+
+ YGNodeFreeRecursive(root);
+}
diff --git a/yoga/Yoga.c b/yoga/Yoga.c
index 18df466b..faf9c5c2 100644
--- a/yoga/Yoga.c
+++ b/yoga/Yoga.c
@@ -985,7 +985,9 @@ static inline YGDirection YGNodeResolveDirection(const YGNodeRef node,
static float YGBaseline(const YGNodeRef node) {
if (node->baseline != NULL) {
- const float baseline = node->baseline(node, node->layout.measuredDimensions[YGDimensionWidth], node->layout.measuredDimensions[YGDimensionHeight]);
+ const float baseline = node->baseline(node,
+ node->layout.measuredDimensions[YGDimensionWidth],
+ node->layout.measuredDimensions[YGDimensionHeight]);
YG_ASSERT(!YGFloatIsUndefined(baseline), "Expect custom baseline function to not return NaN")
return baseline;
}
@@ -2672,19 +2674,22 @@ static void YGNodelayoutImpl(const YGNodeRef node,
// If the user didn't specify a width or height for the node, set the
// dimensions based on the children.
- if (measureModeMainDim == YGMeasureModeUndefined) {
+ if (measureModeMainDim == YGMeasureModeUndefined ||
+ (node->style.overflow != YGOverflowScroll && measureModeMainDim == YGMeasureModeAtMost)) {
// Clamp the size to the min/max size, if specified, and make sure it
// doesn't go below the padding and border amount.
node->layout.measuredDimensions[dim[mainAxis]] =
YGNodeBoundAxis(node, mainAxis, maxLineMainDim, mainAxisParentSize, parentWidth);
- } else if (measureModeMainDim == YGMeasureModeAtMost) {
+ } else if (measureModeMainDim == YGMeasureModeAtMost &&
+ node->style.overflow == YGOverflowScroll) {
node->layout.measuredDimensions[dim[mainAxis]] = fmaxf(
fminf(availableInnerMainDim + paddingAndBorderAxisMain,
YGNodeBoundAxisWithinMinAndMax(node, mainAxis, maxLineMainDim, mainAxisParentSize)),
paddingAndBorderAxisMain);
}
- if (measureModeCrossDim == YGMeasureModeUndefined) {
+ if (measureModeCrossDim == YGMeasureModeUndefined ||
+ (node->style.overflow != YGOverflowScroll && measureModeCrossDim == YGMeasureModeAtMost)) {
// Clamp the size to the min/max size, if specified, and make sure it
// doesn't go below the padding and border amount.
node->layout.measuredDimensions[dim[crossAxis]] =
@@ -2693,7 +2698,8 @@ static void YGNodelayoutImpl(const YGNodeRef node,
totalLineCrossDim + paddingAndBorderAxisCross,
crossAxisParentSize,
parentWidth);
- } else if (measureModeCrossDim == YGMeasureModeAtMost) {
+ } else if (measureModeCrossDim == YGMeasureModeAtMost &&
+ node->style.overflow == YGOverflowScroll) {
node->layout.measuredDimensions[dim[crossAxis]] =
fmaxf(fminf(availableInnerCrossDim + paddingAndBorderAxisCross,
YGNodeBoundAxisWithinMinAndMax(node,