diff --git a/csharp/tests/Facebook.Yoga/YGPercentageTest.cs b/csharp/tests/Facebook.Yoga/YGPercentageTest.cs
index 2a38c185..7a7f4cc9 100644
--- a/csharp/tests/Facebook.Yoga/YGPercentageTest.cs
+++ b/csharp/tests/Facebook.Yoga/YGPercentageTest.cs
@@ -790,5 +790,170 @@ namespace Facebook.Yoga
YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
}
+ [Test]
+ public void Test_percentage_margin_should_calculate_based_only_on_width()
+ {
+ YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
+
+ YogaNode root = new YogaNode();
+ root.Width = 200f;
+ root.Height = 100f;
+
+ YogaNode root_child0 = new YogaNode();
+ root_child0.FlexGrow = 1f;
+ root_child0.SetMargin(YogaEdge.Left, 10f);
+ root_child0.SetMargin(YogaEdge.Top, 10f);
+ root_child0.SetMargin(YogaEdge.Right, 10f);
+ root_child0.SetMargin(YogaEdge.Bottom, 10f);
+ root.Insert(0, root_child0);
+
+ YogaNode root_child0_child0 = new YogaNode();
+ root_child0_child0.Width = 10f;
+ root_child0_child0.Height = 10f;
+ 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(200f, root.LayoutWidth);
+ Assert.AreEqual(100f, root.LayoutHeight);
+
+ Assert.AreEqual(20f, root_child0.LayoutX);
+ Assert.AreEqual(20f, root_child0.LayoutY);
+ Assert.AreEqual(160f, root_child0.LayoutWidth);
+ Assert.AreEqual(60f, root_child0.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child0_child0.LayoutX);
+ Assert.AreEqual(0f, root_child0_child0.LayoutY);
+ Assert.AreEqual(10f, root_child0_child0.LayoutWidth);
+ Assert.AreEqual(10f, root_child0_child0.LayoutHeight);
+
+ root.StyleDirection = YogaDirection.RTL;
+ root.CalculateLayout();
+
+ Assert.AreEqual(0f, root.LayoutX);
+ Assert.AreEqual(0f, root.LayoutY);
+ Assert.AreEqual(200f, root.LayoutWidth);
+ Assert.AreEqual(100f, root.LayoutHeight);
+
+ Assert.AreEqual(20f, root_child0.LayoutX);
+ Assert.AreEqual(20f, root_child0.LayoutY);
+ Assert.AreEqual(160f, root_child0.LayoutWidth);
+ Assert.AreEqual(60f, root_child0.LayoutHeight);
+
+ Assert.AreEqual(150f, root_child0_child0.LayoutX);
+ Assert.AreEqual(0f, root_child0_child0.LayoutY);
+ Assert.AreEqual(10f, root_child0_child0.LayoutWidth);
+ Assert.AreEqual(10f, root_child0_child0.LayoutHeight);
+
+ YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
+ }
+
+ [Test]
+ public void Test_percentage_padding_should_calculate_based_only_on_width()
+ {
+ YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
+
+ YogaNode root = new YogaNode();
+ root.Width = 200f;
+ root.Height = 100f;
+
+ YogaNode root_child0 = new YogaNode();
+ root_child0.FlexGrow = 1f;
+ root_child0.SetPadding(YogaEdge.Left, 10f);
+ root_child0.SetPadding(YogaEdge.Top, 10f);
+ root_child0.SetPadding(YogaEdge.Right, 10f);
+ root_child0.SetPadding(YogaEdge.Bottom, 10f);
+ root.Insert(0, root_child0);
+
+ YogaNode root_child0_child0 = new YogaNode();
+ root_child0_child0.Width = 10f;
+ root_child0_child0.Height = 10f;
+ 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(200f, root.LayoutWidth);
+ Assert.AreEqual(100f, root.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child0.LayoutX);
+ Assert.AreEqual(0f, root_child0.LayoutY);
+ Assert.AreEqual(200f, root_child0.LayoutWidth);
+ Assert.AreEqual(100f, root_child0.LayoutHeight);
+
+ Assert.AreEqual(20f, root_child0_child0.LayoutX);
+ Assert.AreEqual(20f, root_child0_child0.LayoutY);
+ Assert.AreEqual(10f, root_child0_child0.LayoutWidth);
+ Assert.AreEqual(10f, root_child0_child0.LayoutHeight);
+
+ root.StyleDirection = YogaDirection.RTL;
+ root.CalculateLayout();
+
+ Assert.AreEqual(0f, root.LayoutX);
+ Assert.AreEqual(0f, root.LayoutY);
+ Assert.AreEqual(200f, root.LayoutWidth);
+ Assert.AreEqual(100f, root.LayoutHeight);
+
+ Assert.AreEqual(0f, root_child0.LayoutX);
+ Assert.AreEqual(0f, root_child0.LayoutY);
+ Assert.AreEqual(200f, root_child0.LayoutWidth);
+ Assert.AreEqual(100f, root_child0.LayoutHeight);
+
+ Assert.AreEqual(170f, root_child0_child0.LayoutX);
+ Assert.AreEqual(20f, root_child0_child0.LayoutY);
+ Assert.AreEqual(10f, root_child0_child0.LayoutWidth);
+ Assert.AreEqual(10f, root_child0_child0.LayoutHeight);
+
+ YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
+ }
+
+ [Test]
+ public void Test_percentage_absolute_position()
+ {
+ YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, true);
+
+ YogaNode root = new YogaNode();
+ root.Width = 200f;
+ root.Height = 100f;
+
+ YogaNode root_child0 = new YogaNode();
+ root_child0.PositionType = YogaPositionType.Absolute;
+ root_child0.SetPosition(YogaEdge.Left, 30f);
+ root_child0.SetPosition(YogaEdge.Top, 10f);
+ root_child0.Width = 10f;
+ root_child0.Height = 10f;
+ root.Insert(0, root_child0);
+ root.StyleDirection = YogaDirection.LTR;
+ root.CalculateLayout();
+
+ Assert.AreEqual(0f, root.LayoutX);
+ Assert.AreEqual(0f, root.LayoutY);
+ Assert.AreEqual(200f, root.LayoutWidth);
+ Assert.AreEqual(100f, root.LayoutHeight);
+
+ Assert.AreEqual(60f, root_child0.LayoutX);
+ Assert.AreEqual(10f, root_child0.LayoutY);
+ Assert.AreEqual(10f, root_child0.LayoutWidth);
+ Assert.AreEqual(10f, root_child0.LayoutHeight);
+
+ root.StyleDirection = YogaDirection.RTL;
+ root.CalculateLayout();
+
+ Assert.AreEqual(0f, root.LayoutX);
+ Assert.AreEqual(0f, root.LayoutY);
+ Assert.AreEqual(200f, root.LayoutWidth);
+ Assert.AreEqual(100f, root.LayoutHeight);
+
+ Assert.AreEqual(60f, root_child0.LayoutX);
+ Assert.AreEqual(10f, root_child0.LayoutY);
+ Assert.AreEqual(10f, root_child0.LayoutWidth);
+ Assert.AreEqual(10f, root_child0.LayoutHeight);
+
+ YogaNode.SetExperimentalFeatureEnabled(YogaExperimentalFeature.Rounding, false);
+ }
+
}
}
diff --git a/gentest/fixtures/YGPercentageTest.html b/gentest/fixtures/YGPercentageTest.html
index 0384ecb9..b6eb42ae 100644
--- a/gentest/fixtures/YGPercentageTest.html
+++ b/gentest/fixtures/YGPercentageTest.html
@@ -64,4 +64,23 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/java/tests/com/facebook/yoga/YGPercentageTest.java b/java/tests/com/facebook/yoga/YGPercentageTest.java
index 506b9b6c..2ca53c0f 100644
--- a/java/tests/com/facebook/yoga/YGPercentageTest.java
+++ b/java/tests/com/facebook/yoga/YGPercentageTest.java
@@ -776,4 +776,166 @@ public class YGPercentageTest {
YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
}
+ @Test
+ public void test_percentage_margin_should_calculate_based_only_on_width() {
+ YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
+
+ final YogaNode root = new YogaNode();
+ root.setWidth(200f);
+ root.setHeight(100f);
+
+ final YogaNode root_child0 = new YogaNode();
+ root_child0.setFlexGrow(1f);
+ root_child0.setMargin(YogaEdge.LEFT, 10f);
+ root_child0.setMargin(YogaEdge.TOP, 10f);
+ root_child0.setMargin(YogaEdge.RIGHT, 10f);
+ root_child0.setMargin(YogaEdge.BOTTOM, 10f);
+ root.addChildAt(root_child0, 0);
+
+ final YogaNode root_child0_child0 = new YogaNode();
+ root_child0_child0.setWidth(10f);
+ root_child0_child0.setHeight(10f);
+ 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(200f, root.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(20f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(20f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(160f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(60f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
+ assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f);
+ assertEquals(10f, 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(200f, root.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(20f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(20f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(160f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(60f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(150f, root_child0_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
+ assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f);
+ assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f);
+
+ YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
+ }
+
+ @Test
+ public void test_percentage_padding_should_calculate_based_only_on_width() {
+ YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
+
+ final YogaNode root = new YogaNode();
+ root.setWidth(200f);
+ root.setHeight(100f);
+
+ final YogaNode root_child0 = new YogaNode();
+ root_child0.setFlexGrow(1f);
+ root_child0.setPadding(YogaEdge.LEFT, 10);
+ root_child0.setPadding(YogaEdge.TOP, 10);
+ root_child0.setPadding(YogaEdge.RIGHT, 10);
+ root_child0.setPadding(YogaEdge.BOTTOM, 10);
+ root.addChildAt(root_child0, 0);
+
+ final YogaNode root_child0_child0 = new YogaNode();
+ root_child0_child0.setWidth(10f);
+ root_child0_child0.setHeight(10f);
+ 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(200f, 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(200f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(20f, root_child0_child0.getLayoutX(), 0.0f);
+ assertEquals(20f, root_child0_child0.getLayoutY(), 0.0f);
+ assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f);
+ assertEquals(10f, 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(200f, 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(200f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(170f, root_child0_child0.getLayoutX(), 0.0f);
+ assertEquals(20f, root_child0_child0.getLayoutY(), 0.0f);
+ assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f);
+ assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f);
+
+ YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
+ }
+
+ @Test
+ public void test_percentage_absolute_position() {
+ YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, true);
+
+ final YogaNode root = new YogaNode();
+ root.setWidth(200f);
+ root.setHeight(100f);
+
+ final YogaNode root_child0 = new YogaNode();
+ root_child0.setPositionType(YogaPositionType.ABSOLUTE);
+ root_child0.setPosition(YogaEdge.LEFT, 30f);
+ root_child0.setPosition(YogaEdge.TOP, 10f);
+ root_child0.setWidth(10f);
+ root_child0.setHeight(10f);
+ root.addChildAt(root_child0, 0);
+ root.setDirection(YogaDirection.LTR);
+ root.calculateLayout();
+
+ assertEquals(0f, root.getLayoutX(), 0.0f);
+ assertEquals(0f, root.getLayoutY(), 0.0f);
+ assertEquals(200f, root.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(60f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(10f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
+
+ root.setDirection(YogaDirection.RTL);
+ root.calculateLayout();
+
+ assertEquals(0f, root.getLayoutX(), 0.0f);
+ assertEquals(0f, root.getLayoutY(), 0.0f);
+ assertEquals(200f, root.getLayoutWidth(), 0.0f);
+ assertEquals(100f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(60f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(10f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
+
+ YogaNode.setExperimentalFeatureEnabled(YogaExperimentalFeature.ROUNDING, false);
+ }
+
}
diff --git a/tests/YGPercentageTest.cpp b/tests/YGPercentageTest.cpp
index e6e1bba7..a9ecdfaa 100644
--- a/tests/YGPercentageTest.cpp
+++ b/tests/YGPercentageTest.cpp
@@ -758,3 +758,162 @@ TEST(YogaTest, percentage_multiple_nested_with_padding_margin_and_percentage_val
YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
}
+
+TEST(YogaTest, percentage_margin_should_calculate_based_only_on_width) {
+ YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
+
+ const YGNodeRef root = YGNodeNew();
+ YGNodeStyleSetWidthWithUnit(root, YGPx(200));
+ YGNodeStyleSetHeightWithUnit(root, YGPx(100));
+
+ const YGNodeRef root_child0 = YGNodeNew();
+ YGNodeStyleSetFlexGrow(root_child0, 1);
+ YGNodeStyleSetMarginWithUnit(root_child0, YGEdgeLeft, YGPercent(10));
+ YGNodeStyleSetMarginWithUnit(root_child0, YGEdgeTop, YGPercent(10));
+ YGNodeStyleSetMarginWithUnit(root_child0, YGEdgeRight, YGPercent(10));
+ YGNodeStyleSetMarginWithUnit(root_child0, YGEdgeBottom, YGPercent(10));
+ YGNodeInsertChild(root, root_child0, 0);
+
+ const YGNodeRef root_child0_child0 = YGNodeNew();
+ YGNodeStyleSetWidthWithUnit(root_child0_child0, YGPx(10));
+ YGNodeStyleSetHeightWithUnit(root_child0_child0, YGPx(10));
+ 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(200, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
+
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(160, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
+ ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0));
+ ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0));
+
+ YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
+ ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
+
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(160, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(60, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(150, YGNodeLayoutGetLeft(root_child0_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
+ ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0));
+ ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0));
+
+ YGNodeFreeRecursive(root);
+
+ YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
+}
+
+TEST(YogaTest, percentage_padding_should_calculate_based_only_on_width) {
+ YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
+
+ const YGNodeRef root = YGNodeNew();
+ YGNodeStyleSetWidthWithUnit(root, YGPx(200));
+ YGNodeStyleSetHeightWithUnit(root, YGPx(100));
+
+ const YGNodeRef root_child0 = YGNodeNew();
+ YGNodeStyleSetFlexGrow(root_child0, 1);
+ YGNodeStyleSetPaddingWithUnit(root_child0, YGEdgeLeft, YGPercent(10));
+ YGNodeStyleSetPaddingWithUnit(root_child0, YGEdgeTop, YGPercent(10));
+ YGNodeStyleSetPaddingWithUnit(root_child0, YGEdgeRight, YGPercent(10));
+ YGNodeStyleSetPaddingWithUnit(root_child0, YGEdgeBottom, YGPercent(10));
+ YGNodeInsertChild(root, root_child0, 0);
+
+ const YGNodeRef root_child0_child0 = YGNodeNew();
+ YGNodeStyleSetWidthWithUnit(root_child0_child0, YGPx(10));
+ YGNodeStyleSetHeightWithUnit(root_child0_child0, YGPx(10));
+ 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(200, 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(200, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child0));
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child0));
+ ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0));
+ ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0));
+
+ YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
+ ASSERT_FLOAT_EQ(200, 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(200, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(170, YGNodeLayoutGetLeft(root_child0_child0));
+ ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0_child0));
+ ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0));
+ ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0));
+
+ YGNodeFreeRecursive(root);
+
+ YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
+}
+
+TEST(YogaTest, percentage_absolute_position) {
+ YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, true);
+
+ const YGNodeRef root = YGNodeNew();
+ YGNodeStyleSetWidthWithUnit(root, YGPx(200));
+ YGNodeStyleSetHeightWithUnit(root, YGPx(100));
+
+ const YGNodeRef root_child0 = YGNodeNew();
+ YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
+ YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeLeft, YGPercent(30));
+ YGNodeStyleSetPositionWithUnit(root_child0, YGEdgeTop, YGPercent(10));
+ YGNodeStyleSetWidthWithUnit(root_child0, YGPx(10));
+ YGNodeStyleSetHeightWithUnit(root_child0, YGPx(10));
+ YGNodeInsertChild(root, root_child0, 0);
+ YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
+ ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
+
+ ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
+
+ YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
+ ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
+
+ ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
+
+ YGNodeFreeRecursive(root);
+
+ YGSetExperimentalFeatureEnabled(YGExperimentalFeatureRounding, false);
+}