diff --git a/gentest/fixtures/YGFlexDirectionTest.html b/gentest/fixtures/YGFlexDirectionTest.html index 4e66e7c3f2..716ca61d19 100644 --- a/gentest/fixtures/YGFlexDirectionTest.html +++ b/gentest/fixtures/YGFlexDirectionTest.html @@ -208,3 +208,195 @@
+ +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
diff --git a/java/tests/com/facebook/yoga/YGFlexDirectionTest.java b/java/tests/com/facebook/yoga/YGFlexDirectionTest.java index b6d357030f..6540e8f0af 100644 --- a/java/tests/com/facebook/yoga/YGFlexDirectionTest.java +++ b/java/tests/com/facebook/yoga/YGFlexDirectionTest.java @@ -2301,6 +2301,2168 @@ public void test_flex_direction_column_reverse_pos_bottom() { assertEquals(0f, root_child0_child2.getLayoutHeight(), 0.0f); } + @Test + public void test_flex_direction_row_reverse_inner_pos_left() { + YogaConfig config = YogaConfigFactory.create(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + + final YogaNode root_child0 = createNode(config); + root_child0.setFlexDirection(YogaFlexDirection.ROW_REVERSE); + root_child0.setPositionType(YogaPositionType.RELATIVE); + root_child0.setWidth(100f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0_child0.setPosition(YogaEdge.LEFT, 10f); + root_child0_child0.setWidth(10f); + root_child0_child0.setHeight(10f); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0_child1.setPositionType(YogaPositionType.RELATIVE); + root_child0_child1.setWidth(10f); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0_child2.setPositionType(YogaPositionType.RELATIVE); + root_child0_child2.setWidth(10f); + root_child0.addChildAt(root_child0_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(10f, 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); + + assertEquals(90f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(10f, 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); + + assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(10f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_flex_direction_row_reverse_inner_pos_right() { + YogaConfig config = YogaConfigFactory.create(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + + final YogaNode root_child0 = createNode(config); + root_child0.setFlexDirection(YogaFlexDirection.ROW_REVERSE); + root_child0.setPositionType(YogaPositionType.RELATIVE); + root_child0.setWidth(100f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0_child0.setPosition(YogaEdge.RIGHT, 10f); + root_child0_child0.setWidth(10f); + root_child0_child0.setHeight(10f); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0_child1.setPositionType(YogaPositionType.RELATIVE); + root_child0_child1.setWidth(10f); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0_child2.setPositionType(YogaPositionType.RELATIVE); + root_child0_child2.setWidth(10f); + root_child0.addChildAt(root_child0_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(80f, 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); + + assertEquals(90f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(80f, 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); + + assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(10f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_flex_direction_col_reverse_inner_pos_top() { + YogaConfig config = YogaConfigFactory.create(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + + final YogaNode root_child0 = createNode(config); + root_child0.setFlexDirection(YogaFlexDirection.COLUMN_REVERSE); + root_child0.setPositionType(YogaPositionType.RELATIVE); + root_child0.setWidth(100f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0_child0.setPosition(YogaEdge.TOP, 10f); + root_child0_child0.setWidth(10f); + root_child0_child0.setHeight(10f); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0_child1.setPositionType(YogaPositionType.RELATIVE); + root_child0_child1.setWidth(10f); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0_child2.setPositionType(YogaPositionType.RELATIVE); + root_child0_child2.setWidth(10f); + root_child0.addChildAt(root_child0_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(10f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(90f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(90f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(90f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_flex_direction_col_reverse_inner_pos_bottom() { + YogaConfig config = YogaConfigFactory.create(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + + final YogaNode root_child0 = createNode(config); + root_child0.setFlexDirection(YogaFlexDirection.COLUMN_REVERSE); + root_child0.setPositionType(YogaPositionType.RELATIVE); + root_child0.setWidth(100f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0_child0.setPosition(YogaEdge.BOTTOM, 10f); + root_child0_child0.setWidth(10f); + root_child0_child0.setHeight(10f); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0_child1.setPositionType(YogaPositionType.RELATIVE); + root_child0_child1.setWidth(10f); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0_child2.setPositionType(YogaPositionType.RELATIVE); + root_child0_child2.setWidth(10f); + root_child0.addChildAt(root_child0_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(80f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(90f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(90f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(90f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutHeight(), 0.0f); + } + + @Test + @Ignore + public void test_flex_direction_row_reverse_inner_pos_start() { + YogaConfig config = YogaConfigFactory.create(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + + final YogaNode root_child0 = createNode(config); + root_child0.setFlexDirection(YogaFlexDirection.ROW_REVERSE); + root_child0.setPositionType(YogaPositionType.RELATIVE); + root_child0.setWidth(100f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0_child0.setPosition(YogaEdge.START, 10f); + root_child0_child0.setWidth(10f); + root_child0_child0.setHeight(10f); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0_child1.setPositionType(YogaPositionType.RELATIVE); + root_child0_child1.setWidth(10f); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0_child2.setPositionType(YogaPositionType.RELATIVE); + root_child0_child2.setWidth(10f); + root_child0.addChildAt(root_child0_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(10f, 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); + + assertEquals(90f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(80f, 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); + + assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(10f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f); + } + + @Test + @Ignore + public void test_flex_direction_row_reverse_inner_pos_end() { + YogaConfig config = YogaConfigFactory.create(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + + final YogaNode root_child0 = createNode(config); + root_child0.setFlexDirection(YogaFlexDirection.ROW_REVERSE); + root_child0.setPositionType(YogaPositionType.RELATIVE); + root_child0.setWidth(100f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0_child0.setPosition(YogaEdge.END, 10f); + root_child0_child0.setWidth(10f); + root_child0_child0.setHeight(10f); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0_child1.setPositionType(YogaPositionType.RELATIVE); + root_child0_child1.setWidth(10f); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0_child2.setPositionType(YogaPositionType.RELATIVE); + root_child0_child2.setWidth(10f); + root_child0.addChildAt(root_child0_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(80f, 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); + + assertEquals(90f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(10f, 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); + + assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(10f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_flex_direction_row_reverse_inner_margin_left() { + YogaConfig config = YogaConfigFactory.create(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + + final YogaNode root_child0 = createNode(config); + root_child0.setFlexDirection(YogaFlexDirection.ROW_REVERSE); + root_child0.setPositionType(YogaPositionType.RELATIVE); + root_child0.setWidth(100f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0_child0.setMargin(YogaEdge.LEFT, 10f); + root_child0_child0.setWidth(10f); + root_child0_child0.setHeight(10f); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0_child1.setPositionType(YogaPositionType.RELATIVE); + root_child0_child1.setWidth(10f); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0_child2.setPositionType(YogaPositionType.RELATIVE); + root_child0_child2.setWidth(10f); + root_child0.addChildAt(root_child0_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(90f, 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); + + assertEquals(90f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(10f, 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); + + assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(10f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_flex_direction_row_reverse_inner_margin_right() { + YogaConfig config = YogaConfigFactory.create(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + + final YogaNode root_child0 = createNode(config); + root_child0.setFlexDirection(YogaFlexDirection.ROW_REVERSE); + root_child0.setPositionType(YogaPositionType.RELATIVE); + root_child0.setWidth(100f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0_child0.setMargin(YogaEdge.RIGHT, 10f); + root_child0_child0.setWidth(10f); + root_child0_child0.setHeight(10f); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0_child1.setPositionType(YogaPositionType.RELATIVE); + root_child0_child1.setWidth(10f); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0_child2.setPositionType(YogaPositionType.RELATIVE); + root_child0_child2.setWidth(10f); + root_child0.addChildAt(root_child0_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(80f, 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); + + assertEquals(90f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(10f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(10f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_flex_direction_col_reverse_inner_margin_top() { + YogaConfig config = YogaConfigFactory.create(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + + final YogaNode root_child0 = createNode(config); + root_child0.setFlexDirection(YogaFlexDirection.COLUMN_REVERSE); + root_child0.setPositionType(YogaPositionType.RELATIVE); + root_child0.setWidth(100f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0_child0.setMargin(YogaEdge.TOP, 10f); + root_child0_child0.setWidth(10f); + root_child0_child0.setHeight(10f); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0_child1.setPositionType(YogaPositionType.RELATIVE); + root_child0_child1.setWidth(10f); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0_child2.setPositionType(YogaPositionType.RELATIVE); + root_child0_child2.setWidth(10f); + root_child0.addChildAt(root_child0_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(90f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(90f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(90f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(90f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(90f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_flex_direction_col_reverse_inner_margin_bottom() { + YogaConfig config = YogaConfigFactory.create(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + + final YogaNode root_child0 = createNode(config); + root_child0.setFlexDirection(YogaFlexDirection.COLUMN_REVERSE); + root_child0.setPositionType(YogaPositionType.RELATIVE); + root_child0.setWidth(100f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0_child0.setMargin(YogaEdge.BOTTOM, 10f); + root_child0_child0.setWidth(10f); + root_child0_child0.setHeight(10f); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0_child1.setPositionType(YogaPositionType.RELATIVE); + root_child0_child1.setWidth(10f); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0_child2.setPositionType(YogaPositionType.RELATIVE); + root_child0_child2.setWidth(10f); + root_child0.addChildAt(root_child0_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(80f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(90f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(80f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(90f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(90f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_flex_direction_row_reverse_inner_marign_start() { + YogaConfig config = YogaConfigFactory.create(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + + final YogaNode root_child0 = createNode(config); + root_child0.setFlexDirection(YogaFlexDirection.ROW_REVERSE); + root_child0.setPositionType(YogaPositionType.RELATIVE); + root_child0.setWidth(100f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0_child0.setMargin(YogaEdge.START, 10f); + root_child0_child0.setWidth(10f); + root_child0_child0.setHeight(10f); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0_child1.setPositionType(YogaPositionType.RELATIVE); + root_child0_child1.setWidth(10f); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0_child2.setPositionType(YogaPositionType.RELATIVE); + root_child0_child2.setWidth(10f); + root_child0.addChildAt(root_child0_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(90f, 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); + + assertEquals(90f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(10f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(10f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_flex_direction_row_reverse_inner_margin_end() { + YogaConfig config = YogaConfigFactory.create(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + + final YogaNode root_child0 = createNode(config); + root_child0.setFlexDirection(YogaFlexDirection.ROW_REVERSE); + root_child0.setPositionType(YogaPositionType.RELATIVE); + root_child0.setWidth(100f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0_child0.setMargin(YogaEdge.END, 10f); + root_child0_child0.setWidth(10f); + root_child0_child0.setHeight(10f); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0_child1.setPositionType(YogaPositionType.RELATIVE); + root_child0_child1.setWidth(10f); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0_child2.setPositionType(YogaPositionType.RELATIVE); + root_child0_child2.setWidth(10f); + root_child0.addChildAt(root_child0_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(80f, 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); + + assertEquals(90f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(10f, 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); + + assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(10f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_flex_direction_row_reverse_inner_border_left() { + YogaConfig config = YogaConfigFactory.create(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + + final YogaNode root_child0 = createNode(config); + root_child0.setFlexDirection(YogaFlexDirection.ROW_REVERSE); + root_child0.setPositionType(YogaPositionType.RELATIVE); + root_child0.setWidth(100f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0_child0.setBorder(YogaEdge.LEFT, 10f); + root_child0_child0.setWidth(10f); + root_child0_child0.setHeight(10f); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0_child1.setPositionType(YogaPositionType.RELATIVE); + root_child0_child1.setWidth(10f); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0_child2.setPositionType(YogaPositionType.RELATIVE); + root_child0_child2.setWidth(10f); + root_child0.addChildAt(root_child0_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(90f, 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); + + assertEquals(90f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(10f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(10f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_flex_direction_row_reverse_inner_border_right() { + YogaConfig config = YogaConfigFactory.create(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + + final YogaNode root_child0 = createNode(config); + root_child0.setFlexDirection(YogaFlexDirection.ROW_REVERSE); + root_child0.setPositionType(YogaPositionType.RELATIVE); + root_child0.setWidth(100f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0_child0.setBorder(YogaEdge.RIGHT, 10f); + root_child0_child0.setWidth(10f); + root_child0_child0.setHeight(10f); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0_child1.setPositionType(YogaPositionType.RELATIVE); + root_child0_child1.setWidth(10f); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0_child2.setPositionType(YogaPositionType.RELATIVE); + root_child0_child2.setWidth(10f); + root_child0.addChildAt(root_child0_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(90f, 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); + + assertEquals(90f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(10f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(10f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_flex_direction_col_reverse_inner_border_top() { + YogaConfig config = YogaConfigFactory.create(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + + final YogaNode root_child0 = createNode(config); + root_child0.setFlexDirection(YogaFlexDirection.COLUMN_REVERSE); + root_child0.setPositionType(YogaPositionType.RELATIVE); + root_child0.setWidth(100f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0_child0.setBorder(YogaEdge.TOP, 10f); + root_child0_child0.setWidth(10f); + root_child0_child0.setHeight(10f); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0_child1.setPositionType(YogaPositionType.RELATIVE); + root_child0_child1.setWidth(10f); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0_child2.setPositionType(YogaPositionType.RELATIVE); + root_child0_child2.setWidth(10f); + root_child0.addChildAt(root_child0_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(90f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(90f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(90f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(90f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(90f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_flex_direction_col_reverse_inner_border_bottom() { + YogaConfig config = YogaConfigFactory.create(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + + final YogaNode root_child0 = createNode(config); + root_child0.setFlexDirection(YogaFlexDirection.COLUMN_REVERSE); + root_child0.setPositionType(YogaPositionType.RELATIVE); + root_child0.setWidth(100f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0_child0.setBorder(YogaEdge.BOTTOM, 10f); + root_child0_child0.setWidth(10f); + root_child0_child0.setHeight(10f); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0_child1.setPositionType(YogaPositionType.RELATIVE); + root_child0_child1.setWidth(10f); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0_child2.setPositionType(YogaPositionType.RELATIVE); + root_child0_child2.setWidth(10f); + root_child0.addChildAt(root_child0_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(90f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(90f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(90f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(90f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(90f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_flex_direction_row_reverse_inner_border_start() { + YogaConfig config = YogaConfigFactory.create(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + + final YogaNode root_child0 = createNode(config); + root_child0.setFlexDirection(YogaFlexDirection.ROW_REVERSE); + root_child0.setPositionType(YogaPositionType.RELATIVE); + root_child0.setWidth(100f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0_child0.setBorder(YogaEdge.LEFT, 10f); + root_child0_child0.setWidth(10f); + root_child0_child0.setHeight(10f); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0_child1.setPositionType(YogaPositionType.RELATIVE); + root_child0_child1.setWidth(10f); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0_child2.setPositionType(YogaPositionType.RELATIVE); + root_child0_child2.setWidth(10f); + root_child0.addChildAt(root_child0_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(90f, 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); + + assertEquals(90f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(10f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(10f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_flex_direction_row_reverse_inner_border_end() { + YogaConfig config = YogaConfigFactory.create(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + + final YogaNode root_child0 = createNode(config); + root_child0.setFlexDirection(YogaFlexDirection.ROW_REVERSE); + root_child0.setPositionType(YogaPositionType.RELATIVE); + root_child0.setWidth(100f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0_child0.setBorder(YogaEdge.RIGHT, 10f); + root_child0_child0.setWidth(10f); + root_child0_child0.setHeight(10f); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0_child1.setPositionType(YogaPositionType.RELATIVE); + root_child0_child1.setWidth(10f); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0_child2.setPositionType(YogaPositionType.RELATIVE); + root_child0_child2.setWidth(10f); + root_child0.addChildAt(root_child0_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(90f, 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); + + assertEquals(90f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(10f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(10f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_flex_direction_row_reverse_inner_padding_left() { + YogaConfig config = YogaConfigFactory.create(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + + final YogaNode root_child0 = createNode(config); + root_child0.setFlexDirection(YogaFlexDirection.ROW_REVERSE); + root_child0.setPositionType(YogaPositionType.RELATIVE); + root_child0.setWidth(100f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0_child0.setPadding(YogaEdge.LEFT, 10); + root_child0_child0.setWidth(10f); + root_child0_child0.setHeight(10f); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0_child1.setPositionType(YogaPositionType.RELATIVE); + root_child0_child1.setWidth(10f); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0_child2.setPositionType(YogaPositionType.RELATIVE); + root_child0_child2.setWidth(10f); + root_child0.addChildAt(root_child0_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(90f, 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); + + assertEquals(90f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(10f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(10f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_flex_direction_row_reverse_inner_padding_right() { + YogaConfig config = YogaConfigFactory.create(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + + final YogaNode root_child0 = createNode(config); + root_child0.setFlexDirection(YogaFlexDirection.ROW_REVERSE); + root_child0.setPositionType(YogaPositionType.RELATIVE); + root_child0.setWidth(100f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0_child0.setPadding(YogaEdge.RIGHT, 10); + root_child0_child0.setWidth(10f); + root_child0_child0.setHeight(10f); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0_child1.setPositionType(YogaPositionType.RELATIVE); + root_child0_child1.setWidth(10f); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0_child2.setPositionType(YogaPositionType.RELATIVE); + root_child0_child2.setWidth(10f); + root_child0.addChildAt(root_child0_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(90f, 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); + + assertEquals(90f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(10f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(10f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_flex_direction_col_reverse_inner_padding_top() { + YogaConfig config = YogaConfigFactory.create(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + + final YogaNode root_child0 = createNode(config); + root_child0.setFlexDirection(YogaFlexDirection.COLUMN_REVERSE); + root_child0.setPositionType(YogaPositionType.RELATIVE); + root_child0.setWidth(100f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0_child0.setPadding(YogaEdge.TOP, 10); + root_child0_child0.setWidth(10f); + root_child0_child0.setHeight(10f); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0_child1.setPositionType(YogaPositionType.RELATIVE); + root_child0_child1.setWidth(10f); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0_child2.setPositionType(YogaPositionType.RELATIVE); + root_child0_child2.setWidth(10f); + root_child0.addChildAt(root_child0_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(90f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(90f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(90f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(90f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(90f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_flex_direction_col_reverse_inner_padding_bottom() { + YogaConfig config = YogaConfigFactory.create(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + + final YogaNode root_child0 = createNode(config); + root_child0.setFlexDirection(YogaFlexDirection.COLUMN_REVERSE); + root_child0.setPositionType(YogaPositionType.RELATIVE); + root_child0.setWidth(100f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0_child0.setPadding(YogaEdge.BOTTOM, 10); + root_child0_child0.setWidth(10f); + root_child0_child0.setHeight(10f); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0_child1.setPositionType(YogaPositionType.RELATIVE); + root_child0_child1.setWidth(10f); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0_child2.setPositionType(YogaPositionType.RELATIVE); + root_child0_child2.setWidth(10f); + root_child0.addChildAt(root_child0_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(90f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(90f, root_child0_child0.getLayoutX(), 0.0f); + assertEquals(90f, root_child0_child0.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(90f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(90f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_flex_direction_row_reverse_inner_padding_start() { + YogaConfig config = YogaConfigFactory.create(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + + final YogaNode root_child0 = createNode(config); + root_child0.setFlexDirection(YogaFlexDirection.ROW_REVERSE); + root_child0.setPositionType(YogaPositionType.RELATIVE); + root_child0.setWidth(100f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0_child0.setPadding(YogaEdge.START, 10); + root_child0_child0.setWidth(10f); + root_child0_child0.setHeight(10f); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0_child1.setPositionType(YogaPositionType.RELATIVE); + root_child0_child1.setWidth(10f); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0_child2.setPositionType(YogaPositionType.RELATIVE); + root_child0_child2.setWidth(10f); + root_child0.addChildAt(root_child0_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(90f, 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); + + assertEquals(90f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(10f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(10f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_flex_direction_row_reverse_inner_padding_end() { + YogaConfig config = YogaConfigFactory.create(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(100f); + root.setHeight(100f); + + final YogaNode root_child0 = createNode(config); + root_child0.setFlexDirection(YogaFlexDirection.ROW_REVERSE); + root_child0.setPositionType(YogaPositionType.RELATIVE); + root_child0.setWidth(100f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child0_child0 = createNode(config); + root_child0_child0.setPositionType(YogaPositionType.ABSOLUTE); + root_child0_child0.setPadding(YogaEdge.END, 10); + root_child0_child0.setWidth(10f); + root_child0_child0.setHeight(10f); + root_child0.addChildAt(root_child0_child0, 0); + + final YogaNode root_child0_child1 = createNode(config); + root_child0_child1.setPositionType(YogaPositionType.RELATIVE); + root_child0_child1.setWidth(10f); + root_child0.addChildAt(root_child0_child1, 1); + + final YogaNode root_child0_child2 = createNode(config); + root_child0_child2.setPositionType(YogaPositionType.RELATIVE); + root_child0_child2.setWidth(10f); + root_child0.addChildAt(root_child0_child2, 2); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(90f, 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); + + assertEquals(90f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(80f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f); + + root.setDirection(YogaDirection.RTL); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(100f, root.getLayoutWidth(), 0.0f); + assertEquals(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(10f, root_child0_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0_child0.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child1.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f); + + assertEquals(10f, root_child0_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child0_child2.getLayoutY(), 0.0f); + assertEquals(10f, root_child0_child2.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0_child2.getLayoutHeight(), 0.0f); + } + private YogaNode createNode(YogaConfig config) { return mNodeFactory.create(config); } diff --git a/javascript/tests/generated/YGFlexDirectionTest.test.ts b/javascript/tests/generated/YGFlexDirectionTest.test.ts index 80e2af16ec..6d7e30d463 100644 --- a/javascript/tests/generated/YGFlexDirectionTest.test.ts +++ b/javascript/tests/generated/YGFlexDirectionTest.test.ts @@ -2481,3 +2481,2307 @@ test('flex_direction_column_reverse_pos_bottom', () => { config.free(); } }); +test('flex_direction_row_reverse_inner_pos_left', () => { + const config = Yoga.Config.create(); + let root; + + config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true); + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setPositionType(PositionType.Relative); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setPosition(Edge.Left, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setPositionType(PositionType.Relative); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setPositionType(PositionType.Relative); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(10); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(10); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_inner_pos_right', () => { + const config = Yoga.Config.create(); + let root; + + config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true); + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setPositionType(PositionType.Relative); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setPosition(Edge.Right, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setPositionType(PositionType.Relative); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setPositionType(PositionType.Relative); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(80); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(80); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_col_reverse_inner_pos_top', () => { + const config = Yoga.Config.create(); + let root; + + config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true); + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.ColumnReverse); + root_child0.setPositionType(PositionType.Relative); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setPosition(Edge.Top, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setPositionType(PositionType.Relative); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setPositionType(PositionType.Relative); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(10); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(10); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(90); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_col_reverse_inner_pos_bottom', () => { + const config = Yoga.Config.create(); + let root; + + config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true); + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.ColumnReverse); + root_child0.setPositionType(PositionType.Relative); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setPosition(Edge.Bottom, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setPositionType(PositionType.Relative); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setPositionType(PositionType.Relative); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(80); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(80); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(90); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test.skip('flex_direction_row_reverse_inner_pos_start', () => { + const config = Yoga.Config.create(); + let root; + + config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true); + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setPositionType(PositionType.Relative); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setPosition(Edge.Start, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setPositionType(PositionType.Relative); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setPositionType(PositionType.Relative); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(10); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(80); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test.skip('flex_direction_row_reverse_inner_pos_end', () => { + const config = Yoga.Config.create(); + let root; + + config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true); + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setPositionType(PositionType.Relative); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setPosition(Edge.End, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setPositionType(PositionType.Relative); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setPositionType(PositionType.Relative); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(80); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(10); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_inner_margin_left', () => { + const config = Yoga.Config.create(); + let root; + + config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true); + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setPositionType(PositionType.Relative); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setMargin(Edge.Left, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setPositionType(PositionType.Relative); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setPositionType(PositionType.Relative); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(10); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_inner_margin_right', () => { + const config = Yoga.Config.create(); + let root; + + config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true); + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setPositionType(PositionType.Relative); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setMargin(Edge.Right, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setPositionType(PositionType.Relative); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setPositionType(PositionType.Relative); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(80); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_col_reverse_inner_margin_top', () => { + const config = Yoga.Config.create(); + let root; + + config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true); + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.ColumnReverse); + root_child0.setPositionType(PositionType.Relative); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setMargin(Edge.Top, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setPositionType(PositionType.Relative); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setPositionType(PositionType.Relative); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(90); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(90); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(90); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_col_reverse_inner_margin_bottom', () => { + const config = Yoga.Config.create(); + let root; + + config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true); + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.ColumnReverse); + root_child0.setPositionType(PositionType.Relative); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setMargin(Edge.Bottom, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setPositionType(PositionType.Relative); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setPositionType(PositionType.Relative); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(80); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(80); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(90); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_inner_marign_start', () => { + const config = Yoga.Config.create(); + let root; + + config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true); + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setPositionType(PositionType.Relative); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setMargin(Edge.Start, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setPositionType(PositionType.Relative); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setPositionType(PositionType.Relative); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_inner_margin_end', () => { + const config = Yoga.Config.create(); + let root; + + config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true); + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setPositionType(PositionType.Relative); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setMargin(Edge.End, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setPositionType(PositionType.Relative); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setPositionType(PositionType.Relative); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(80); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(10); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_inner_border_left', () => { + const config = Yoga.Config.create(); + let root; + + config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true); + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setPositionType(PositionType.Relative); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setBorder(Edge.Left, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setPositionType(PositionType.Relative); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setPositionType(PositionType.Relative); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_inner_border_right', () => { + const config = Yoga.Config.create(); + let root; + + config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true); + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setPositionType(PositionType.Relative); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setBorder(Edge.Right, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setPositionType(PositionType.Relative); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setPositionType(PositionType.Relative); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_col_reverse_inner_border_top', () => { + const config = Yoga.Config.create(); + let root; + + config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true); + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.ColumnReverse); + root_child0.setPositionType(PositionType.Relative); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setBorder(Edge.Top, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setPositionType(PositionType.Relative); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setPositionType(PositionType.Relative); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(90); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(90); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(90); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_col_reverse_inner_border_bottom', () => { + const config = Yoga.Config.create(); + let root; + + config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true); + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.ColumnReverse); + root_child0.setPositionType(PositionType.Relative); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setBorder(Edge.Bottom, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setPositionType(PositionType.Relative); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setPositionType(PositionType.Relative); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(90); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(90); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(90); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_inner_border_start', () => { + const config = Yoga.Config.create(); + let root; + + config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true); + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setPositionType(PositionType.Relative); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setBorder(Edge.Left, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setPositionType(PositionType.Relative); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setPositionType(PositionType.Relative); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_inner_border_end', () => { + const config = Yoga.Config.create(); + let root; + + config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true); + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setPositionType(PositionType.Relative); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setBorder(Edge.Right, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setPositionType(PositionType.Relative); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setPositionType(PositionType.Relative); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_inner_padding_left', () => { + const config = Yoga.Config.create(); + let root; + + config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true); + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setPositionType(PositionType.Relative); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setPadding(Edge.Left, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setPositionType(PositionType.Relative); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setPositionType(PositionType.Relative); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_inner_padding_right', () => { + const config = Yoga.Config.create(); + let root; + + config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true); + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setPositionType(PositionType.Relative); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setPadding(Edge.Right, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setPositionType(PositionType.Relative); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setPositionType(PositionType.Relative); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_col_reverse_inner_padding_top', () => { + const config = Yoga.Config.create(); + let root; + + config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true); + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.ColumnReverse); + root_child0.setPositionType(PositionType.Relative); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setPadding(Edge.Top, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setPositionType(PositionType.Relative); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setPositionType(PositionType.Relative); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(90); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(90); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(90); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_col_reverse_inner_padding_bottom', () => { + const config = Yoga.Config.create(); + let root; + + config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true); + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.ColumnReverse); + root_child0.setPositionType(PositionType.Relative); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setPadding(Edge.Bottom, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setPositionType(PositionType.Relative); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setPositionType(PositionType.Relative); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(90); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(0); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(90); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(100); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(0); + + expect(root_child0_child2.getComputedLeft()).toBe(90); + expect(root_child0_child2.getComputedTop()).toBe(100); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(0); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_inner_padding_start', () => { + const config = Yoga.Config.create(); + let root; + + config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true); + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setPositionType(PositionType.Relative); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setPadding(Edge.Start, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setPositionType(PositionType.Relative); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setPositionType(PositionType.Relative); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('flex_direction_row_reverse_inner_padding_end', () => { + const config = Yoga.Config.create(); + let root; + + config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true); + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(100); + root.setHeight(100); + + const root_child0 = Yoga.Node.create(config); + root_child0.setFlexDirection(FlexDirection.RowReverse); + root_child0.setPositionType(PositionType.Relative); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child0_child0 = Yoga.Node.create(config); + root_child0_child0.setPositionType(PositionType.Absolute); + root_child0_child0.setPadding(Edge.End, 10); + root_child0_child0.setWidth(10); + root_child0_child0.setHeight(10); + root_child0.insertChild(root_child0_child0, 0); + + const root_child0_child1 = Yoga.Node.create(config); + root_child0_child1.setPositionType(PositionType.Relative); + root_child0_child1.setWidth(10); + root_child0.insertChild(root_child0_child1, 1); + + const root_child0_child2 = Yoga.Node.create(config); + root_child0_child2.setPositionType(PositionType.Relative); + root_child0_child2.setWidth(10); + root_child0.insertChild(root_child0_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(90); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(90); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(80); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(100); + expect(root.getComputedHeight()).toBe(100); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child0_child0.getComputedLeft()).toBe(0); + expect(root_child0_child0.getComputedTop()).toBe(0); + expect(root_child0_child0.getComputedWidth()).toBe(10); + expect(root_child0_child0.getComputedHeight()).toBe(10); + + expect(root_child0_child1.getComputedLeft()).toBe(0); + expect(root_child0_child1.getComputedTop()).toBe(0); + expect(root_child0_child1.getComputedWidth()).toBe(10); + expect(root_child0_child1.getComputedHeight()).toBe(100); + + expect(root_child0_child2.getComputedLeft()).toBe(10); + expect(root_child0_child2.getComputedTop()).toBe(0); + expect(root_child0_child2.getComputedWidth()).toBe(10); + expect(root_child0_child2.getComputedHeight()).toBe(100); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/tests/generated/YGFlexDirectionTest.cpp b/tests/generated/YGFlexDirectionTest.cpp index 703e5724d2..f9d5417ea8 100644 --- a/tests/generated/YGFlexDirectionTest.cpp +++ b/tests/generated/YGFlexDirectionTest.cpp @@ -2316,3 +2316,2191 @@ TEST(YogaTest, flex_direction_column_reverse_pos_bottom) { YGConfigFree(config); } + +TEST(YogaTest, flex_direction_row_reverse_inner_pos_left) { + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true); + + const YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRowReverse); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child0_child0, YGEdgeLeft, 10); + YGNodeStyleSetWidth(root_child0_child0, 10); + YGNodeStyleSetHeight(root_child0_child0, 10); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child1, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child1, 10); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + const YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child2, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child2, 10); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(10, 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)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(10, 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)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, flex_direction_row_reverse_inner_pos_right) { + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true); + + const YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRowReverse); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child0_child0, YGEdgeRight, 10); + YGNodeStyleSetWidth(root_child0_child0, 10); + YGNodeStyleSetHeight(root_child0_child0, 10); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child1, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child1, 10); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + const YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child2, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child2, 10); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(80, 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)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(80, 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)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, flex_direction_col_reverse_inner_pos_top) { + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true); + + const YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionColumnReverse); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child0_child0, YGEdgeTop, 10); + YGNodeStyleSetWidth(root_child0_child0, 10); + YGNodeStyleSetHeight(root_child0_child0, 10); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child1, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child1, 10); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + const YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child2, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child2, 10); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(10, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(90, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, flex_direction_col_reverse_inner_pos_bottom) { + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true); + + const YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionColumnReverse); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child0_child0, YGEdgeBottom, 10); + YGNodeStyleSetWidth(root_child0_child0, 10); + YGNodeStyleSetHeight(root_child0_child0, 10); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child1, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child1, 10); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + const YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child2, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child2, 10); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(80, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(90, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, flex_direction_row_reverse_inner_pos_start) { + GTEST_SKIP(); + + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true); + + const YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRowReverse); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child0_child0, YGEdgeStart, 10); + YGNodeStyleSetWidth(root_child0_child0, 10); + YGNodeStyleSetHeight(root_child0_child0, 10); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child1, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child1, 10); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + const YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child2, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child2, 10); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(10, 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)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(80, 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)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, flex_direction_row_reverse_inner_pos_end) { + GTEST_SKIP(); + + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true); + + const YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRowReverse); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeAbsolute); + YGNodeStyleSetPosition(root_child0_child0, YGEdgeEnd, 10); + YGNodeStyleSetWidth(root_child0_child0, 10); + YGNodeStyleSetHeight(root_child0_child0, 10); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child1, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child1, 10); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + const YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child2, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child2, 10); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(80, 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)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(10, 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)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, flex_direction_row_reverse_inner_margin_left) { + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true); + + const YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRowReverse); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeAbsolute); + YGNodeStyleSetMargin(root_child0_child0, YGEdgeLeft, 10); + YGNodeStyleSetWidth(root_child0_child0, 10); + YGNodeStyleSetHeight(root_child0_child0, 10); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child1, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child1, 10); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + const YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child2, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child2, 10); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(90, 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)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(10, 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)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, flex_direction_row_reverse_inner_margin_right) { + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true); + + const YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRowReverse); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeAbsolute); + YGNodeStyleSetMargin(root_child0_child0, YGEdgeRight, 10); + YGNodeStyleSetWidth(root_child0_child0, 10); + YGNodeStyleSetHeight(root_child0_child0, 10); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child1, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child1, 10); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + const YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child2, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child2, 10); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(80, 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)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(10, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, flex_direction_col_reverse_inner_margin_top) { + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true); + + const YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionColumnReverse); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeAbsolute); + YGNodeStyleSetMargin(root_child0_child0, YGEdgeTop, 10); + YGNodeStyleSetWidth(root_child0_child0, 10); + YGNodeStyleSetHeight(root_child0_child0, 10); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child1, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child1, 10); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + const YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child2, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child2, 10); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(90, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(90, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, flex_direction_col_reverse_inner_margin_bottom) { + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true); + + const YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionColumnReverse); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeAbsolute); + YGNodeStyleSetMargin(root_child0_child0, YGEdgeBottom, 10); + YGNodeStyleSetWidth(root_child0_child0, 10); + YGNodeStyleSetHeight(root_child0_child0, 10); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child1, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child1, 10); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + const YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child2, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child2, 10); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(80, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(90, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, flex_direction_row_reverse_inner_marign_start) { + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true); + + const YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRowReverse); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeAbsolute); + YGNodeStyleSetMargin(root_child0_child0, YGEdgeStart, 10); + YGNodeStyleSetWidth(root_child0_child0, 10); + YGNodeStyleSetHeight(root_child0_child0, 10); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child1, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child1, 10); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + const YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child2, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child2, 10); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(90, 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)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(10, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, flex_direction_row_reverse_inner_margin_end) { + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true); + + const YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRowReverse); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeAbsolute); + YGNodeStyleSetMargin(root_child0_child0, YGEdgeEnd, 10); + YGNodeStyleSetWidth(root_child0_child0, 10); + YGNodeStyleSetHeight(root_child0_child0, 10); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child1, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child1, 10); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + const YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child2, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child2, 10); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(80, 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)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(10, 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)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, flex_direction_row_reverse_inner_border_left) { + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true); + + const YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRowReverse); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeAbsolute); + YGNodeStyleSetBorder(root_child0_child0, YGEdgeLeft, 10); + YGNodeStyleSetWidth(root_child0_child0, 10); + YGNodeStyleSetHeight(root_child0_child0, 10); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child1, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child1, 10); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + const YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child2, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child2, 10); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(90, 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)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(10, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, flex_direction_row_reverse_inner_border_right) { + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true); + + const YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRowReverse); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeAbsolute); + YGNodeStyleSetBorder(root_child0_child0, YGEdgeRight, 10); + YGNodeStyleSetWidth(root_child0_child0, 10); + YGNodeStyleSetHeight(root_child0_child0, 10); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child1, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child1, 10); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + const YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child2, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child2, 10); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(90, 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)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(10, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, flex_direction_col_reverse_inner_border_top) { + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true); + + const YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionColumnReverse); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeAbsolute); + YGNodeStyleSetBorder(root_child0_child0, YGEdgeTop, 10); + YGNodeStyleSetWidth(root_child0_child0, 10); + YGNodeStyleSetHeight(root_child0_child0, 10); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child1, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child1, 10); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + const YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child2, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child2, 10); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(90, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(90, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, flex_direction_col_reverse_inner_border_bottom) { + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true); + + const YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionColumnReverse); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeAbsolute); + YGNodeStyleSetBorder(root_child0_child0, YGEdgeBottom, 10); + YGNodeStyleSetWidth(root_child0_child0, 10); + YGNodeStyleSetHeight(root_child0_child0, 10); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child1, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child1, 10); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + const YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child2, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child2, 10); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(90, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(90, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, flex_direction_row_reverse_inner_border_start) { + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true); + + const YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRowReverse); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeAbsolute); + YGNodeStyleSetBorder(root_child0_child0, YGEdgeLeft, 10); + YGNodeStyleSetWidth(root_child0_child0, 10); + YGNodeStyleSetHeight(root_child0_child0, 10); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child1, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child1, 10); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + const YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child2, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child2, 10); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(90, 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)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(10, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, flex_direction_row_reverse_inner_border_end) { + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true); + + const YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRowReverse); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeAbsolute); + YGNodeStyleSetBorder(root_child0_child0, YGEdgeRight, 10); + YGNodeStyleSetWidth(root_child0_child0, 10); + YGNodeStyleSetHeight(root_child0_child0, 10); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child1, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child1, 10); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + const YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child2, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child2, 10); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(90, 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)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(10, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, flex_direction_row_reverse_inner_padding_left) { + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true); + + const YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRowReverse); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root_child0_child0, YGEdgeLeft, 10); + YGNodeStyleSetWidth(root_child0_child0, 10); + YGNodeStyleSetHeight(root_child0_child0, 10); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child1, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child1, 10); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + const YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child2, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child2, 10); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(90, 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)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(10, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, flex_direction_row_reverse_inner_padding_right) { + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true); + + const YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRowReverse); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root_child0_child0, YGEdgeRight, 10); + YGNodeStyleSetWidth(root_child0_child0, 10); + YGNodeStyleSetHeight(root_child0_child0, 10); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child1, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child1, 10); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + const YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child2, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child2, 10); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(90, 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)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(10, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, flex_direction_col_reverse_inner_padding_top) { + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true); + + const YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionColumnReverse); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root_child0_child0, YGEdgeTop, 10); + YGNodeStyleSetWidth(root_child0_child0, 10); + YGNodeStyleSetHeight(root_child0_child0, 10); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child1, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child1, 10); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + const YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child2, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child2, 10); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(90, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(90, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, flex_direction_col_reverse_inner_padding_bottom) { + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true); + + const YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionColumnReverse); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root_child0_child0, YGEdgeBottom, 10); + YGNodeStyleSetWidth(root_child0_child0, 10); + YGNodeStyleSetHeight(root_child0_child0, 10); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child1, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child1, 10); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + const YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child2, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child2, 10); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(90, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(90, YGNodeLayoutGetLeft(root_child0_child0)); + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetTop(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, flex_direction_row_reverse_inner_padding_start) { + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true); + + const YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRowReverse); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root_child0_child0, YGEdgeStart, 10); + YGNodeStyleSetWidth(root_child0_child0, 10); + YGNodeStyleSetHeight(root_child0_child0, 10); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child1, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child1, 10); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + const YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child2, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child2, 10); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(90, 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)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(10, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, flex_direction_row_reverse_inner_padding_end) { + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true); + + const YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 100); + YGNodeStyleSetHeight(root, 100); + + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRowReverse); + YGNodeStyleSetPositionType(root_child0, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root_child0_child0, YGEdgeEnd, 10); + YGNodeStyleSetWidth(root_child0_child0, 10); + YGNodeStyleSetHeight(root_child0_child0, 10); + YGNodeInsertChild(root_child0, root_child0_child0, 0); + + const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child1, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child1, 10); + YGNodeInsertChild(root_child0, root_child0_child1, 1); + + const YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root_child0_child2, YGPositionTypeRelative); + YGNodeStyleSetWidth(root_child0_child2, 10); + YGNodeInsertChild(root_child0, root_child0_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(90, 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)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(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(10, YGNodeLayoutGetWidth(root_child0_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0_child0)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1)); + + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/yoga/algorithm/CalculateLayout.cpp b/yoga/algorithm/CalculateLayout.cpp index 22997719ae..c1026c9adc 100644 --- a/yoga/algorithm/CalculateLayout.cpp +++ b/yoga/algorithm/CalculateLayout.cpp @@ -448,19 +448,17 @@ static void layoutAbsoluteChild( depth, generationCount); - if (child->isInlineEndPositionDefined(mainAxis, direction) && - !child->isInlineStartPositionDefined(mainAxis, direction)) { + if (child->isFlexEndPositionDefined(mainAxis) && + !child->isFlexStartPositionDefined(mainAxis)) { child->setLayoutPosition( node->getLayout().measuredDimension(dimension(mainAxis)) - child->getLayout().measuredDimension(dimension(mainAxis)) - - node->getInlineEndBorder(mainAxis, direction) - - child->getInlineEndMargin( - mainAxis, direction, isMainAxisRow ? width : height) - - child->getInlineEndPosition( - mainAxis, direction, isMainAxisRow ? width : height), + node->getFlexEndBorder(mainAxis, direction) - + child->getFlexEndMargin(mainAxis, isMainAxisRow ? width : height) - + child->getFlexEndPosition(mainAxis, isMainAxisRow ? width : height), flexStartEdge(mainAxis)); } else if ( - !child->isInlineStartPositionDefined(mainAxis, direction) && + !child->isFlexStartPositionDefined(mainAxis) && node->getStyle().justifyContent() == Justify::Center) { child->setLayoutPosition( (node->getLayout().measuredDimension(dimension(mainAxis)) - @@ -468,7 +466,7 @@ static void layoutAbsoluteChild( 2.0f, flexStartEdge(mainAxis)); } else if ( - !child->isInlineStartPositionDefined(mainAxis, direction) && + !child->isFlexStartPositionDefined(mainAxis) && node->getStyle().justifyContent() == Justify::FlexEnd) { child->setLayoutPosition( (node->getLayout().measuredDimension(dimension(mainAxis)) - @@ -477,34 +475,31 @@ static void layoutAbsoluteChild( } else if ( node->getConfig()->isExperimentalFeatureEnabled( ExperimentalFeature::AbsolutePercentageAgainstPaddingEdge) && - child->isInlineStartPositionDefined(mainAxis, direction)) { + child->isFlexStartPositionDefined(mainAxis)) { child->setLayoutPosition( - child->getInlineStartPosition( + child->getFlexStartPosition( mainAxis, - direction, node->getLayout().measuredDimension(dimension(mainAxis))) + - node->getInlineStartBorder(mainAxis, direction) + - child->getInlineStartMargin( + node->getFlexStartBorder(mainAxis, direction) + + child->getFlexStartMargin( mainAxis, - direction, node->getLayout().measuredDimension(dimension(mainAxis))), flexStartEdge(mainAxis)); } - if (child->isInlineEndPositionDefined(crossAxis, direction) && - !child->isInlineStartPositionDefined(crossAxis, direction)) { + if (child->isFlexEndPositionDefined(crossAxis) && + !child->isFlexStartPositionDefined(crossAxis)) { child->setLayoutPosition( node->getLayout().measuredDimension(dimension(crossAxis)) - child->getLayout().measuredDimension(dimension(crossAxis)) - - node->getInlineEndBorder(crossAxis, direction) - - child->getInlineEndMargin( - crossAxis, direction, isMainAxisRow ? height : width) - - child->getInlineEndPosition( - crossAxis, direction, isMainAxisRow ? height : width), + node->getFlexEndBorder(crossAxis, direction) - + child->getFlexEndMargin(crossAxis, isMainAxisRow ? height : width) - + child->getFlexEndPosition( + crossAxis, isMainAxisRow ? height : width), flexStartEdge(crossAxis)); } else if ( - !child->isInlineStartPositionDefined(crossAxis, direction) && + !child->isFlexStartPositionDefined(crossAxis) && resolveChildAlignment(node, child) == Align::Center) { child->setLayoutPosition( (node->getLayout().measuredDimension(dimension(crossAxis)) - @@ -512,7 +507,7 @@ static void layoutAbsoluteChild( 2.0f, flexStartEdge(crossAxis)); } else if ( - !child->isInlineStartPositionDefined(crossAxis, direction) && + !child->isFlexStartPositionDefined(crossAxis) && ((resolveChildAlignment(node, child) == Align::FlexEnd) ^ (node->getStyle().flexWrap() == Wrap::WrapReverse))) { child->setLayoutPosition( @@ -522,16 +517,14 @@ static void layoutAbsoluteChild( } else if ( node->getConfig()->isExperimentalFeatureEnabled( ExperimentalFeature::AbsolutePercentageAgainstPaddingEdge) && - child->isInlineStartPositionDefined(crossAxis, direction)) { + child->isFlexStartPositionDefined(crossAxis)) { child->setLayoutPosition( - child->getInlineStartPosition( + child->getFlexStartPosition( crossAxis, - direction, node->getLayout().measuredDimension(dimension(crossAxis))) + - node->getInlineStartBorder(crossAxis, direction) + - child->getInlineStartMargin( + node->getFlexStartBorder(crossAxis, direction) + + child->getFlexStartMargin( crossAxis, - direction, node->getLayout().measuredDimension(dimension(crossAxis))), flexStartEdge(crossAxis)); } diff --git a/yoga/node/Node.cpp b/yoga/node/Node.cpp index 3a458d1ccb..e13274cf9b 100644 --- a/yoga/node/Node.cpp +++ b/yoga/node/Node.cpp @@ -99,6 +99,15 @@ YGEdge Node::getInlineEndEdgeUsingErrata( : inlineEndEdge(flexDirection, direction); } +bool Node::isFlexStartPositionDefined(FlexDirection axis) const { + const YGEdge startEdge = flexStartEdge(axis); + auto leadingPosition = isRow(axis) + ? computeEdgeValueForRow(style_.position(), YGEdgeStart, startEdge) + : computeEdgeValueForColumn(style_.position(), startEdge); + + return leadingPosition.isDefined(); +} + bool Node::isInlineStartPositionDefined(FlexDirection axis, Direction direction) const { const YGEdge startEdge = getInlineStartEdgeUsingErrata(axis, direction); @@ -109,6 +118,15 @@ bool Node::isInlineStartPositionDefined(FlexDirection axis, Direction direction) return leadingPosition.isDefined(); } +bool Node::isFlexEndPositionDefined(FlexDirection axis) const { + const YGEdge endEdge = flexEndEdge(axis); + auto trailingPosition = isRow(axis) + ? computeEdgeValueForRow(style_.position(), YGEdgeEnd, endEdge) + : computeEdgeValueForColumn(style_.position(), endEdge); + + return !trailingPosition.isUndefined(); +} + bool Node::isInlineEndPositionDefined(FlexDirection axis, Direction direction) const { const YGEdge endEdge = getInlineEndEdgeUsingErrata(axis, direction); @@ -119,6 +137,15 @@ bool Node::isInlineEndPositionDefined(FlexDirection axis, Direction direction) return trailingPosition.isDefined(); } +float Node::getFlexStartPosition(FlexDirection axis, float axisSize) const { + const YGEdge startEdge = flexStartEdge(axis); + auto leadingPosition = isRow(axis) + ? computeEdgeValueForRow(style_.position(), YGEdgeStart, startEdge) + : computeEdgeValueForColumn(style_.position(), startEdge); + + return resolveValue(leadingPosition, axisSize).unwrapOrDefault(0.0f); +} + float Node::getInlineStartPosition( FlexDirection axis, Direction direction, @@ -131,6 +158,15 @@ float Node::getInlineStartPosition( return resolveValue(leadingPosition, axisSize).unwrapOrDefault(0.0f); } +float Node::getFlexEndPosition(FlexDirection axis, float axisSize) const { + const YGEdge endEdge = flexEndEdge(axis); + auto trailingPosition = isRow(axis) + ? computeEdgeValueForRow(style_.position(), YGEdgeEnd, endEdge) + : computeEdgeValueForColumn(style_.position(), endEdge); + + return resolveValue(trailingPosition, axisSize).unwrapOrDefault(0.0f); +} + float Node::getInlineEndPosition( FlexDirection axis, Direction direction, @@ -143,6 +179,15 @@ float Node::getInlineEndPosition( return resolveValue(trailingPosition, axisSize).unwrapOrDefault(0.0f); } +float Node::getFlexStartMargin(FlexDirection axis, float widthSize) const { + const YGEdge startEdge = flexStartEdge(axis); + auto leadingMargin = isRow(axis) + ? computeEdgeValueForRow(style_.margin(), YGEdgeStart, startEdge) + : computeEdgeValueForColumn(style_.margin(), startEdge); + + return resolveValue(leadingMargin, widthSize).unwrapOrDefault(0.0f); +} + float Node::getInlineStartMargin( FlexDirection axis, Direction direction, @@ -155,6 +200,15 @@ float Node::getInlineStartMargin( return resolveValue(leadingMargin, widthSize).unwrapOrDefault(0.0f); } +float Node::getFlexEndMargin(FlexDirection axis, float widthSize) const { + const YGEdge endEdge = flexEndEdge(axis); + auto trailingMargin = isRow(axis) + ? computeEdgeValueForRow(style_.margin(), YGEdgeEnd, endEdge) + : computeEdgeValueForColumn(style_.margin(), endEdge); + + return resolveValue(trailingMargin, widthSize).unwrapOrDefault(0.0f); +} + float Node::getInlineEndMargin( FlexDirection axis, Direction direction, diff --git a/yoga/node/Node.h b/yoga/node/Node.h index 005459434d..0069f69bd2 100644 --- a/yoga/node/Node.h +++ b/yoga/node/Node.h @@ -199,22 +199,28 @@ class YG_EXPORT Node : public ::YGNode { YGEdge edge); // Methods related to positions, margin, padding and border + bool isFlexStartPositionDefined(FlexDirection axis) const; bool isInlineStartPositionDefined(FlexDirection axis, Direction direction) const; + bool isFlexEndPositionDefined(FlexDirection axis) const; bool isInlineEndPositionDefined(FlexDirection axis, Direction direction) const; + float getFlexStartPosition(FlexDirection axis, float axisSize) const; float getInlineStartPosition( FlexDirection axis, Direction direction, float axisSize) const; + float getFlexEndPosition(FlexDirection axis, float axisSize) const; float getInlineEndPosition( FlexDirection axis, Direction direction, float axisSize) const; + float getFlexStartMargin(FlexDirection axis, float widthSize) const; float getInlineStartMargin( FlexDirection axis, Direction direction, float widthSize) const; + float getFlexEndMargin(FlexDirection axis, float widthSize) const; float getInlineEndMargin( FlexDirection axis, Direction direction,