diff --git a/csharp/tests/Facebook.Yoga/YGPercentageTest.cs b/csharp/tests/Facebook.Yoga/YGPercentageTest.cs
index cca4e2ed..a861f320 100644
--- a/csharp/tests/Facebook.Yoga/YGPercentageTest.cs
+++ b/csharp/tests/Facebook.Yoga/YGPercentageTest.cs
@@ -1146,5 +1146,76 @@ namespace Facebook.Yoga
Assert.AreEqual(50f, root_child0_child0_child1.LayoutHeight);
}
+ [Test]
+ public void Test_percent_absolute_position()
+ {
+ YogaConfig config = new YogaConfig();
+
+ YogaNode root = new YogaNode(config);
+ root.Width = 60;
+ root.Height = 50;
+
+ YogaNode root_child0 = new YogaNode(config);
+ root_child0.FlexDirection = YogaFlexDirection.Row;
+ root_child0.PositionType = YogaPositionType.Absolute;
+ root_child0.Left = 50.Percent();
+ root_child0.Width = 100.Percent();
+ root_child0.Height = 50;
+ root.Insert(0, root_child0);
+
+ YogaNode root_child0_child0 = new YogaNode(config);
+ root_child0_child0.Width = 100.Percent();
+ root_child0.Insert(0, root_child0_child0);
+
+ YogaNode root_child0_child1 = new YogaNode(config);
+ root_child0_child1.Width = 100.Percent();
+ 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(60f, root.LayoutWidth);
+ Assert.AreEqual(50f, root.LayoutHeight);
+
+ Assert.AreEqual(30f, root_child0.LayoutX);
+ Assert.AreEqual(0f, root_child0.LayoutY);
+ Assert.AreEqual(60f, root_child0.LayoutWidth);
+ Assert.AreEqual(50f, root_child0.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child0_child0.LayoutX);
+ Assert.AreEqual(0f, root_child0_child0.LayoutY);
+ Assert.AreEqual(60f, root_child0_child0.LayoutWidth);
+ Assert.AreEqual(50f, root_child0_child0.LayoutHeight);
+
+ Assert.AreEqual(60f, root_child0_child1.LayoutX);
+ Assert.AreEqual(0f, root_child0_child1.LayoutY);
+ Assert.AreEqual(60f, root_child0_child1.LayoutWidth);
+ Assert.AreEqual(50f, root_child0_child1.LayoutHeight);
+
+ root.StyleDirection = YogaDirection.RTL;
+ root.CalculateLayout();
+
+ Assert.AreEqual(0f, root.LayoutX);
+ Assert.AreEqual(0f, root.LayoutY);
+ Assert.AreEqual(60f, root.LayoutWidth);
+ Assert.AreEqual(50f, root.LayoutHeight);
+
+ Assert.AreEqual(30f, root_child0.LayoutX);
+ Assert.AreEqual(0f, root_child0.LayoutY);
+ Assert.AreEqual(60f, root_child0.LayoutWidth);
+ Assert.AreEqual(50f, root_child0.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child0_child0.LayoutX);
+ Assert.AreEqual(0f, root_child0_child0.LayoutY);
+ Assert.AreEqual(60f, root_child0_child0.LayoutWidth);
+ Assert.AreEqual(50f, root_child0_child0.LayoutHeight);
+
+ Assert.AreEqual(-60f, root_child0_child1.LayoutX);
+ Assert.AreEqual(0f, root_child0_child1.LayoutY);
+ Assert.AreEqual(60f, root_child0_child1.LayoutWidth);
+ Assert.AreEqual(50f, root_child0_child1.LayoutHeight);
+ }
+
}
}
diff --git a/gentest/fixtures/YGPercentageTest.html b/gentest/fixtures/YGPercentageTest.html
index 05c33fee..87b3c0a6 100644
--- a/gentest/fixtures/YGPercentageTest.html
+++ b/gentest/fixtures/YGPercentageTest.html
@@ -100,3 +100,10 @@
+
+
diff --git a/java/tests/com/facebook/yoga/YGPercentageTest.java b/java/tests/com/facebook/yoga/YGPercentageTest.java
index f7780c1f..88a19644 100644
--- a/java/tests/com/facebook/yoga/YGPercentageTest.java
+++ b/java/tests/com/facebook/yoga/YGPercentageTest.java
@@ -1126,4 +1126,74 @@ public class YGPercentageTest {
assertEquals(50f, root_child0_child0_child1.getLayoutHeight(), 0.0f);
}
+ @Test
+ public void test_percent_absolute_position() {
+ YogaConfig config = new YogaConfig();
+
+ final YogaNode root = new YogaNode(config);
+ root.setWidth(60f);
+ root.setHeight(50f);
+
+ final YogaNode root_child0 = new YogaNode(config);
+ root_child0.setFlexDirection(YogaFlexDirection.ROW);
+ root_child0.setPositionType(YogaPositionType.ABSOLUTE);
+ root_child0.setPositionPercent(YogaEdge.LEFT, 50f);
+ root_child0.setWidthPercent(100f);
+ root_child0.setHeight(50f);
+ root.addChildAt(root_child0, 0);
+
+ final YogaNode root_child0_child0 = new YogaNode(config);
+ root_child0_child0.setWidthPercent(100f);
+ root_child0.addChildAt(root_child0_child0, 0);
+
+ final YogaNode root_child0_child1 = new YogaNode(config);
+ root_child0_child1.setWidthPercent(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(60f, root.getLayoutWidth(), 0.0f);
+ assertEquals(50f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(30f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
+ assertEquals(60f, root_child0_child0.getLayoutWidth(), 0.0f);
+ assertEquals(50f, root_child0_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(60f, root_child0_child1.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f);
+ assertEquals(60f, root_child0_child1.getLayoutWidth(), 0.0f);
+ assertEquals(50f, 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(60f, root.getLayoutWidth(), 0.0f);
+ assertEquals(50f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(30f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(60f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
+ assertEquals(60f, root_child0_child0.getLayoutWidth(), 0.0f);
+ assertEquals(50f, root_child0_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(-60f, root_child0_child1.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f);
+ assertEquals(60f, root_child0_child1.getLayoutWidth(), 0.0f);
+ assertEquals(50f, root_child0_child1.getLayoutHeight(), 0.0f);
+ }
+
}
diff --git a/javascript/tests/Facebook.Yoga/YGPercentageTest.js b/javascript/tests/Facebook.Yoga/YGPercentageTest.js
index 29c5053c..6f5507ff 100644
--- a/javascript/tests/Facebook.Yoga/YGPercentageTest.js
+++ b/javascript/tests/Facebook.Yoga/YGPercentageTest.js
@@ -1172,3 +1172,73 @@ it("percentage_container_in_wrapping_container", function () {
Yoga.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_MIN_FLEX_FIX, false);
}
});
+it("percent_absolute_position", function () {
+ try {
+ var root = Yoga.Node.create(config);
+ root.setWidth(60);
+ root.setHeight(50);
+
+ var root_child0 = Yoga.Node.create(config);
+ root_child0.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
+ root_child0.setPositionType(Yoga.POSITION_TYPE_ABSOLUTE);
+ root_child0.setPosition(Yoga.EDGE_LEFT, "50%");
+ root_child0.setWidth("100%");
+ root_child0.setHeight(50);
+ root.insertChild(root_child0, 0);
+
+ var root_child0_child0 = Yoga.Node.create(config);
+ root_child0_child0.setWidth("100%");
+ root_child0.insertChild(root_child0_child0, 0);
+
+ var root_child0_child1 = Yoga.Node.create(config);
+ root_child0_child1.setWidth("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(60 === root.getComputedWidth(), "60 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
+ console.assert(50 === root.getComputedHeight(), "50 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
+
+ console.assert(30 === root_child0.getComputedLeft(), "30 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
+ console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
+ console.assert(60 === root_child0.getComputedWidth(), "60 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
+ console.assert(50 === root_child0.getComputedHeight(), "50 === 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(60 === root_child0_child0.getComputedWidth(), "60 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
+ console.assert(50 === root_child0_child0.getComputedHeight(), "50 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
+
+ console.assert(60 === root_child0_child1.getComputedLeft(), "60 === root_child0_child1.getComputedLeft() (" + root_child0_child1.getComputedLeft() + ")");
+ console.assert(0 === root_child0_child1.getComputedTop(), "0 === root_child0_child1.getComputedTop() (" + root_child0_child1.getComputedTop() + ")");
+ console.assert(60 === root_child0_child1.getComputedWidth(), "60 === root_child0_child1.getComputedWidth() (" + root_child0_child1.getComputedWidth() + ")");
+ console.assert(50 === root_child0_child1.getComputedHeight(), "50 === 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(60 === root.getComputedWidth(), "60 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
+ console.assert(50 === root.getComputedHeight(), "50 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
+
+ console.assert(30 === root_child0.getComputedLeft(), "30 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
+ console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
+ console.assert(60 === root_child0.getComputedWidth(), "60 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
+ console.assert(50 === root_child0.getComputedHeight(), "50 === 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(60 === root_child0_child0.getComputedWidth(), "60 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
+ console.assert(50 === root_child0_child0.getComputedHeight(), "50 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
+
+ console.assert(-60 === root_child0_child1.getComputedLeft(), "-60 === root_child0_child1.getComputedLeft() (" + root_child0_child1.getComputedLeft() + ")");
+ console.assert(0 === root_child0_child1.getComputedTop(), "0 === root_child0_child1.getComputedTop() (" + root_child0_child1.getComputedTop() + ")");
+ console.assert(60 === root_child0_child1.getComputedWidth(), "60 === root_child0_child1.getComputedWidth() (" + root_child0_child1.getComputedWidth() + ")");
+ console.assert(50 === root_child0_child1.getComputedHeight(), "50 === root_child0_child1.getComputedHeight() (" + root_child0_child1.getComputedHeight() + ")");
+ } finally {
+ if (typeof root !== "undefined") {
+ root.freeRecursive();
+ }
+ }
+});
diff --git a/tests/YGPercentageTest.cpp b/tests/YGPercentageTest.cpp
index 6d326320..86ee8b78 100644
--- a/tests/YGPercentageTest.cpp
+++ b/tests/YGPercentageTest.cpp
@@ -1140,3 +1140,74 @@ TEST(YogaTest, percentage_container_in_wrapping_container) {
YGConfigFree(config);
}
+
+TEST(YogaTest, percent_absolute_position) {
+ const YGConfigRef config = YGConfigNew();
+
+ const YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidth(root, 60);
+ YGNodeStyleSetHeight(root, 50);
+
+ const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow);
+ YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
+ YGNodeStyleSetPositionPercent(root_child0, YGEdgeLeft, 50);
+ YGNodeStyleSetWidthPercent(root_child0, 100);
+ YGNodeStyleSetHeight(root_child0, 50);
+ YGNodeInsertChild(root, root_child0, 0);
+
+ const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidthPercent(root_child0_child0, 100);
+ YGNodeInsertChild(root_child0, root_child0_child0, 0);
+
+ const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetWidthPercent(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(60, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root));
+
+ ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
+ ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0_child0));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0_child0));
+
+ ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0_child1));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1));
+ ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0_child1));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0_child1));
+
+ YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
+ ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root));
+
+ ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
+ ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0_child0));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0_child0));
+
+ ASSERT_FLOAT_EQ(-60, YGNodeLayoutGetLeft(root_child0_child1));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1));
+ ASSERT_FLOAT_EQ(60, YGNodeLayoutGetWidth(root_child0_child1));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0_child1));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}