diff --git a/gentest/fixtures/YGAlignContentTest.html b/gentest/fixtures/YGAlignContentTest.html index 509649eaaa..e9708c8134 100644 --- a/gentest/fixtures/YGAlignContentTest.html +++ b/gentest/fixtures/YGAlignContentTest.html @@ -396,3 +396,39 @@
+ +
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
diff --git a/java/tests/com/facebook/yoga/YGAlignContentTest.java b/java/tests/com/facebook/yoga/YGAlignContentTest.java index 1f757de2f0..c296249163 100644 --- a/java/tests/com/facebook/yoga/YGAlignContentTest.java +++ b/java/tests/com/facebook/yoga/YGAlignContentTest.java @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<<75aa9390813e51550d9760c37e59de0c>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGAlignContentTest.html */ @@ -4601,6 +4601,485 @@ public void test_align_content_space_around_and_align_items_flex_start_with_flex assertEquals(50f, root_child2.getLayoutHeight(), 0.0f); } + @Test + public void test_align_content_flex_start_stretch_doesnt_influence_line_box_dim() { + YogaConfig config = YogaConfigFactory.create(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true); + + final YogaNode root = createNode(config); + root.setFlexDirection(YogaFlexDirection.ROW); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 20); + root.setPadding(YogaEdge.TOP, 20); + root.setPadding(YogaEdge.RIGHT, 20); + root.setPadding(YogaEdge.BOTTOM, 20); + root.setWidth(400f); + + final YogaNode root_child0 = createNode(config); + root_child0.setMargin(YogaEdge.RIGHT, 20f); + root_child0.setWidth(100f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setFlexDirection(YogaFlexDirection.ROW); + root_child1.setWrap(YogaWrap.WRAP); + root_child1.setFlexGrow(1f); + root_child1.setFlexShrink(1f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child1_child0 = createNode(config); + root_child1_child0.setMargin(YogaEdge.RIGHT, 20f); + root_child1_child0.setWidth(30f); + root_child1_child0.setHeight(30f); + root_child1.addChildAt(root_child1_child0, 0); + + final YogaNode root_child1_child1 = createNode(config); + root_child1_child1.setMargin(YogaEdge.RIGHT, 20f); + root_child1_child1.setWidth(30f); + root_child1_child1.setHeight(30f); + root_child1.addChildAt(root_child1_child1, 1); + + final YogaNode root_child1_child2 = createNode(config); + root_child1_child2.setMargin(YogaEdge.RIGHT, 20f); + root_child1_child2.setWidth(30f); + root_child1_child2.setHeight(30f); + root_child1.addChildAt(root_child1_child2, 2); + + final YogaNode root_child1_child3 = createNode(config); + root_child1_child3.setMargin(YogaEdge.RIGHT, 20f); + root_child1_child3.setWidth(30f); + root_child1_child3.setHeight(30f); + root_child1.addChildAt(root_child1_child3, 3); + + final YogaNode root_child1_child4 = createNode(config); + root_child1_child4.setMargin(YogaEdge.RIGHT, 20f); + root_child1_child4.setWidth(30f); + root_child1_child4.setHeight(30f); + root_child1.addChildAt(root_child1_child4, 4); + + final YogaNode root_child2 = createNode(config); + root_child2.setMargin(YogaEdge.LEFT, 20f); + root_child2.setWidth(50f); + root_child2.setHeight(50f); + root.addChildAt(root_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(400f, root.getLayoutWidth(), 0.0f); + assertEquals(140f, root.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0.getLayoutX(), 0.0f); + assertEquals(20f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(140f, root_child1.getLayoutX(), 0.0f); + assertEquals(20f, root_child1.getLayoutY(), 0.0f); + assertEquals(170f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f); + assertEquals(30f, root_child1_child0.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child1_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child1.getLayoutY(), 0.0f); + assertEquals(30f, root_child1_child1.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1_child1.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child2.getLayoutY(), 0.0f); + assertEquals(30f, root_child1_child2.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1_child3.getLayoutX(), 0.0f); + assertEquals(30f, root_child1_child3.getLayoutY(), 0.0f); + assertEquals(30f, root_child1_child3.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1_child3.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child1_child4.getLayoutX(), 0.0f); + assertEquals(30f, root_child1_child4.getLayoutY(), 0.0f); + assertEquals(30f, root_child1_child4.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1_child4.getLayoutHeight(), 0.0f); + + assertEquals(330f, root_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child2.getLayoutY(), 0.0f); + assertEquals(50f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(50f, root_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(400f, root.getLayoutWidth(), 0.0f); + assertEquals(140f, root.getLayoutHeight(), 0.0f); + + assertEquals(260f, root_child0.getLayoutX(), 0.0f); + assertEquals(20f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(90f, root_child1.getLayoutX(), 0.0f); + assertEquals(20f, root_child1.getLayoutY(), 0.0f); + assertEquals(170f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child1_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f); + assertEquals(30f, root_child1_child0.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1_child0.getLayoutHeight(), 0.0f); + + assertEquals(70f, root_child1_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child1.getLayoutY(), 0.0f); + assertEquals(30f, root_child1_child1.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1_child1.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child1_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child2.getLayoutY(), 0.0f); + assertEquals(30f, root_child1_child2.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1_child2.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child1_child3.getLayoutX(), 0.0f); + assertEquals(30f, root_child1_child3.getLayoutY(), 0.0f); + assertEquals(30f, root_child1_child3.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1_child3.getLayoutHeight(), 0.0f); + + assertEquals(70f, root_child1_child4.getLayoutX(), 0.0f); + assertEquals(30f, root_child1_child4.getLayoutY(), 0.0f); + assertEquals(30f, root_child1_child4.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1_child4.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child2.getLayoutY(), 0.0f); + assertEquals(50f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_align_content_stretch_stretch_does_influence_line_box_dim() { + YogaConfig config = YogaConfigFactory.create(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true); + + final YogaNode root = createNode(config); + root.setFlexDirection(YogaFlexDirection.ROW); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 20); + root.setPadding(YogaEdge.TOP, 20); + root.setPadding(YogaEdge.RIGHT, 20); + root.setPadding(YogaEdge.BOTTOM, 20); + root.setWidth(400f); + + final YogaNode root_child0 = createNode(config); + root_child0.setMargin(YogaEdge.RIGHT, 20f); + root_child0.setWidth(100f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setFlexDirection(YogaFlexDirection.ROW); + root_child1.setAlignContent(YogaAlign.STRETCH); + root_child1.setWrap(YogaWrap.WRAP); + root_child1.setFlexGrow(1f); + root_child1.setFlexShrink(1f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child1_child0 = createNode(config); + root_child1_child0.setMargin(YogaEdge.RIGHT, 20f); + root_child1_child0.setWidth(30f); + root_child1_child0.setHeight(30f); + root_child1.addChildAt(root_child1_child0, 0); + + final YogaNode root_child1_child1 = createNode(config); + root_child1_child1.setMargin(YogaEdge.RIGHT, 20f); + root_child1_child1.setWidth(30f); + root_child1_child1.setHeight(30f); + root_child1.addChildAt(root_child1_child1, 1); + + final YogaNode root_child1_child2 = createNode(config); + root_child1_child2.setMargin(YogaEdge.RIGHT, 20f); + root_child1_child2.setWidth(30f); + root_child1_child2.setHeight(30f); + root_child1.addChildAt(root_child1_child2, 2); + + final YogaNode root_child1_child3 = createNode(config); + root_child1_child3.setMargin(YogaEdge.RIGHT, 20f); + root_child1_child3.setWidth(30f); + root_child1_child3.setHeight(30f); + root_child1.addChildAt(root_child1_child3, 3); + + final YogaNode root_child1_child4 = createNode(config); + root_child1_child4.setMargin(YogaEdge.RIGHT, 20f); + root_child1_child4.setWidth(30f); + root_child1_child4.setHeight(30f); + root_child1.addChildAt(root_child1_child4, 4); + + final YogaNode root_child2 = createNode(config); + root_child2.setMargin(YogaEdge.LEFT, 20f); + root_child2.setWidth(50f); + root_child2.setHeight(50f); + root.addChildAt(root_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(400f, root.getLayoutWidth(), 0.0f); + assertEquals(140f, root.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0.getLayoutX(), 0.0f); + assertEquals(20f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(140f, root_child1.getLayoutX(), 0.0f); + assertEquals(20f, root_child1.getLayoutY(), 0.0f); + assertEquals(170f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f); + assertEquals(30f, root_child1_child0.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child1_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child1.getLayoutY(), 0.0f); + assertEquals(30f, root_child1_child1.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1_child1.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child2.getLayoutY(), 0.0f); + assertEquals(30f, root_child1_child2.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1_child3.getLayoutX(), 0.0f); + assertEquals(50f, root_child1_child3.getLayoutY(), 0.0f); + assertEquals(30f, root_child1_child3.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1_child3.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child1_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child1_child4.getLayoutY(), 0.0f); + assertEquals(30f, root_child1_child4.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1_child4.getLayoutHeight(), 0.0f); + + assertEquals(330f, root_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child2.getLayoutY(), 0.0f); + assertEquals(50f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(50f, root_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(400f, root.getLayoutWidth(), 0.0f); + assertEquals(140f, root.getLayoutHeight(), 0.0f); + + assertEquals(260f, root_child0.getLayoutX(), 0.0f); + assertEquals(20f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(90f, root_child1.getLayoutX(), 0.0f); + assertEquals(20f, root_child1.getLayoutY(), 0.0f); + assertEquals(170f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child1_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f); + assertEquals(30f, root_child1_child0.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1_child0.getLayoutHeight(), 0.0f); + + assertEquals(70f, root_child1_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child1.getLayoutY(), 0.0f); + assertEquals(30f, root_child1_child1.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1_child1.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child1_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child2.getLayoutY(), 0.0f); + assertEquals(30f, root_child1_child2.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1_child2.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child1_child3.getLayoutX(), 0.0f); + assertEquals(50f, root_child1_child3.getLayoutY(), 0.0f); + assertEquals(30f, root_child1_child3.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1_child3.getLayoutHeight(), 0.0f); + + assertEquals(70f, root_child1_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child1_child4.getLayoutY(), 0.0f); + assertEquals(30f, root_child1_child4.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1_child4.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child2.getLayoutY(), 0.0f); + assertEquals(50f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child2.getLayoutHeight(), 0.0f); + } + + @Test + public void test_align_content_space_evenly_stretch_does_influence_line_box_dim() { + YogaConfig config = YogaConfigFactory.create(); + config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true); + + final YogaNode root = createNode(config); + root.setFlexDirection(YogaFlexDirection.ROW); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setPadding(YogaEdge.LEFT, 20); + root.setPadding(YogaEdge.TOP, 20); + root.setPadding(YogaEdge.RIGHT, 20); + root.setPadding(YogaEdge.BOTTOM, 20); + root.setWidth(400f); + + final YogaNode root_child0 = createNode(config); + root_child0.setMargin(YogaEdge.RIGHT, 20f); + root_child0.setWidth(100f); + root_child0.setHeight(100f); + root.addChildAt(root_child0, 0); + + final YogaNode root_child1 = createNode(config); + root_child1.setFlexDirection(YogaFlexDirection.ROW); + root_child1.setAlignContent(YogaAlign.STRETCH); + root_child1.setWrap(YogaWrap.WRAP); + root_child1.setFlexGrow(1f); + root_child1.setFlexShrink(1f); + root.addChildAt(root_child1, 1); + + final YogaNode root_child1_child0 = createNode(config); + root_child1_child0.setMargin(YogaEdge.RIGHT, 20f); + root_child1_child0.setWidth(30f); + root_child1_child0.setHeight(30f); + root_child1.addChildAt(root_child1_child0, 0); + + final YogaNode root_child1_child1 = createNode(config); + root_child1_child1.setMargin(YogaEdge.RIGHT, 20f); + root_child1_child1.setWidth(30f); + root_child1_child1.setHeight(30f); + root_child1.addChildAt(root_child1_child1, 1); + + final YogaNode root_child1_child2 = createNode(config); + root_child1_child2.setMargin(YogaEdge.RIGHT, 20f); + root_child1_child2.setWidth(30f); + root_child1_child2.setHeight(30f); + root_child1.addChildAt(root_child1_child2, 2); + + final YogaNode root_child1_child3 = createNode(config); + root_child1_child3.setMargin(YogaEdge.RIGHT, 20f); + root_child1_child3.setWidth(30f); + root_child1_child3.setHeight(30f); + root_child1.addChildAt(root_child1_child3, 3); + + final YogaNode root_child1_child4 = createNode(config); + root_child1_child4.setMargin(YogaEdge.RIGHT, 20f); + root_child1_child4.setWidth(30f); + root_child1_child4.setHeight(30f); + root_child1.addChildAt(root_child1_child4, 4); + + final YogaNode root_child2 = createNode(config); + root_child2.setMargin(YogaEdge.LEFT, 20f); + root_child2.setWidth(50f); + root_child2.setHeight(50f); + root.addChildAt(root_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(400f, root.getLayoutWidth(), 0.0f); + assertEquals(140f, root.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child0.getLayoutX(), 0.0f); + assertEquals(20f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(140f, root_child1.getLayoutX(), 0.0f); + assertEquals(20f, root_child1.getLayoutY(), 0.0f); + assertEquals(170f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f); + assertEquals(30f, root_child1_child0.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1_child0.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child1_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child1.getLayoutY(), 0.0f); + assertEquals(30f, root_child1_child1.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1_child1.getLayoutHeight(), 0.0f); + + assertEquals(100f, root_child1_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child2.getLayoutY(), 0.0f); + assertEquals(30f, root_child1_child2.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1_child2.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child1_child3.getLayoutX(), 0.0f); + assertEquals(50f, root_child1_child3.getLayoutY(), 0.0f); + assertEquals(30f, root_child1_child3.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1_child3.getLayoutHeight(), 0.0f); + + assertEquals(50f, root_child1_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child1_child4.getLayoutY(), 0.0f); + assertEquals(30f, root_child1_child4.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1_child4.getLayoutHeight(), 0.0f); + + assertEquals(330f, root_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child2.getLayoutY(), 0.0f); + assertEquals(50f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(50f, root_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(400f, root.getLayoutWidth(), 0.0f); + assertEquals(140f, root.getLayoutHeight(), 0.0f); + + assertEquals(260f, root_child0.getLayoutX(), 0.0f); + assertEquals(20f, root_child0.getLayoutY(), 0.0f); + assertEquals(100f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child0.getLayoutHeight(), 0.0f); + + assertEquals(90f, root_child1.getLayoutX(), 0.0f); + assertEquals(20f, root_child1.getLayoutY(), 0.0f); + assertEquals(170f, root_child1.getLayoutWidth(), 0.0f); + assertEquals(100f, root_child1.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child1_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f); + assertEquals(30f, root_child1_child0.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1_child0.getLayoutHeight(), 0.0f); + + assertEquals(70f, root_child1_child1.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child1.getLayoutY(), 0.0f); + assertEquals(30f, root_child1_child1.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1_child1.getLayoutHeight(), 0.0f); + + assertEquals(20f, root_child1_child2.getLayoutX(), 0.0f); + assertEquals(0f, root_child1_child2.getLayoutY(), 0.0f); + assertEquals(30f, root_child1_child2.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1_child2.getLayoutHeight(), 0.0f); + + assertEquals(120f, root_child1_child3.getLayoutX(), 0.0f); + assertEquals(50f, root_child1_child3.getLayoutY(), 0.0f); + assertEquals(30f, root_child1_child3.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1_child3.getLayoutHeight(), 0.0f); + + assertEquals(70f, root_child1_child4.getLayoutX(), 0.0f); + assertEquals(50f, root_child1_child4.getLayoutY(), 0.0f); + assertEquals(30f, root_child1_child4.getLayoutWidth(), 0.0f); + assertEquals(30f, root_child1_child4.getLayoutHeight(), 0.0f); + + assertEquals(40f, root_child2.getLayoutX(), 0.0f); + assertEquals(20f, root_child2.getLayoutY(), 0.0f); + assertEquals(50f, root_child2.getLayoutWidth(), 0.0f); + assertEquals(50f, root_child2.getLayoutHeight(), 0.0f); + } + private YogaNode createNode(YogaConfig config) { return mNodeFactory.create(config); } diff --git a/javascript/tests/generated/YGAlignContentTest.test.ts b/javascript/tests/generated/YGAlignContentTest.test.ts index c67e5db60b..8ab60ca1f1 100644 --- a/javascript/tests/generated/YGAlignContentTest.test.ts +++ b/javascript/tests/generated/YGAlignContentTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<90f151e3c55d956805a9f44153f87ad0>> + * @generated SignedSource<> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGAlignContentTest.html */ @@ -4931,3 +4931,500 @@ test('align_content_space_around_and_align_items_flex_start_with_flex_wrap', () config.free(); } }); +test('align_content_flex_start_stretch_doesnt_influence_line_box_dim', () => { + const config = Yoga.Config.create(); + let root; + + config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true); + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 20); + root.setPadding(Edge.Top, 20); + root.setPadding(Edge.Right, 20); + root.setPadding(Edge.Bottom, 20); + root.setWidth(400); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Right, 20); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexDirection(FlexDirection.Row); + root_child1.setFlexWrap(Wrap.Wrap); + root_child1.setFlexGrow(1); + root_child1.setFlexShrink(1); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setMargin(Edge.Right, 20); + root_child1_child0.setWidth(30); + root_child1_child0.setHeight(30); + root_child1.insertChild(root_child1_child0, 0); + + const root_child1_child1 = Yoga.Node.create(config); + root_child1_child1.setMargin(Edge.Right, 20); + root_child1_child1.setWidth(30); + root_child1_child1.setHeight(30); + root_child1.insertChild(root_child1_child1, 1); + + const root_child1_child2 = Yoga.Node.create(config); + root_child1_child2.setMargin(Edge.Right, 20); + root_child1_child2.setWidth(30); + root_child1_child2.setHeight(30); + root_child1.insertChild(root_child1_child2, 2); + + const root_child1_child3 = Yoga.Node.create(config); + root_child1_child3.setMargin(Edge.Right, 20); + root_child1_child3.setWidth(30); + root_child1_child3.setHeight(30); + root_child1.insertChild(root_child1_child3, 3); + + const root_child1_child4 = Yoga.Node.create(config); + root_child1_child4.setMargin(Edge.Right, 20); + root_child1_child4.setWidth(30); + root_child1_child4.setHeight(30); + root_child1.insertChild(root_child1_child4, 4); + + const root_child2 = Yoga.Node.create(config); + root_child2.setMargin(Edge.Left, 20); + root_child2.setWidth(50); + root_child2.setHeight(50); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(140); + + expect(root_child0.getComputedLeft()).toBe(20); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(140); + expect(root_child1.getComputedTop()).toBe(20); + expect(root_child1.getComputedWidth()).toBe(170); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(30); + expect(root_child1_child0.getComputedHeight()).toBe(30); + + expect(root_child1_child1.getComputedLeft()).toBe(50); + expect(root_child1_child1.getComputedTop()).toBe(0); + expect(root_child1_child1.getComputedWidth()).toBe(30); + expect(root_child1_child1.getComputedHeight()).toBe(30); + + expect(root_child1_child2.getComputedLeft()).toBe(100); + expect(root_child1_child2.getComputedTop()).toBe(0); + expect(root_child1_child2.getComputedWidth()).toBe(30); + expect(root_child1_child2.getComputedHeight()).toBe(30); + + expect(root_child1_child3.getComputedLeft()).toBe(0); + expect(root_child1_child3.getComputedTop()).toBe(30); + expect(root_child1_child3.getComputedWidth()).toBe(30); + expect(root_child1_child3.getComputedHeight()).toBe(30); + + expect(root_child1_child4.getComputedLeft()).toBe(50); + expect(root_child1_child4.getComputedTop()).toBe(30); + expect(root_child1_child4.getComputedWidth()).toBe(30); + expect(root_child1_child4.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(330); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(140); + + expect(root_child0.getComputedLeft()).toBe(260); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(90); + expect(root_child1.getComputedTop()).toBe(20); + expect(root_child1.getComputedWidth()).toBe(170); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child1_child0.getComputedLeft()).toBe(120); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(30); + expect(root_child1_child0.getComputedHeight()).toBe(30); + + expect(root_child1_child1.getComputedLeft()).toBe(70); + expect(root_child1_child1.getComputedTop()).toBe(0); + expect(root_child1_child1.getComputedWidth()).toBe(30); + expect(root_child1_child1.getComputedHeight()).toBe(30); + + expect(root_child1_child2.getComputedLeft()).toBe(20); + expect(root_child1_child2.getComputedTop()).toBe(0); + expect(root_child1_child2.getComputedWidth()).toBe(30); + expect(root_child1_child2.getComputedHeight()).toBe(30); + + expect(root_child1_child3.getComputedLeft()).toBe(120); + expect(root_child1_child3.getComputedTop()).toBe(30); + expect(root_child1_child3.getComputedWidth()).toBe(30); + expect(root_child1_child3.getComputedHeight()).toBe(30); + + expect(root_child1_child4.getComputedLeft()).toBe(70); + expect(root_child1_child4.getComputedTop()).toBe(30); + expect(root_child1_child4.getComputedWidth()).toBe(30); + expect(root_child1_child4.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(40); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_stretch_stretch_does_influence_line_box_dim', () => { + const config = Yoga.Config.create(); + let root; + + config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true); + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 20); + root.setPadding(Edge.Top, 20); + root.setPadding(Edge.Right, 20); + root.setPadding(Edge.Bottom, 20); + root.setWidth(400); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Right, 20); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexDirection(FlexDirection.Row); + root_child1.setAlignContent(Align.Stretch); + root_child1.setFlexWrap(Wrap.Wrap); + root_child1.setFlexGrow(1); + root_child1.setFlexShrink(1); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setMargin(Edge.Right, 20); + root_child1_child0.setWidth(30); + root_child1_child0.setHeight(30); + root_child1.insertChild(root_child1_child0, 0); + + const root_child1_child1 = Yoga.Node.create(config); + root_child1_child1.setMargin(Edge.Right, 20); + root_child1_child1.setWidth(30); + root_child1_child1.setHeight(30); + root_child1.insertChild(root_child1_child1, 1); + + const root_child1_child2 = Yoga.Node.create(config); + root_child1_child2.setMargin(Edge.Right, 20); + root_child1_child2.setWidth(30); + root_child1_child2.setHeight(30); + root_child1.insertChild(root_child1_child2, 2); + + const root_child1_child3 = Yoga.Node.create(config); + root_child1_child3.setMargin(Edge.Right, 20); + root_child1_child3.setWidth(30); + root_child1_child3.setHeight(30); + root_child1.insertChild(root_child1_child3, 3); + + const root_child1_child4 = Yoga.Node.create(config); + root_child1_child4.setMargin(Edge.Right, 20); + root_child1_child4.setWidth(30); + root_child1_child4.setHeight(30); + root_child1.insertChild(root_child1_child4, 4); + + const root_child2 = Yoga.Node.create(config); + root_child2.setMargin(Edge.Left, 20); + root_child2.setWidth(50); + root_child2.setHeight(50); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(140); + + expect(root_child0.getComputedLeft()).toBe(20); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(140); + expect(root_child1.getComputedTop()).toBe(20); + expect(root_child1.getComputedWidth()).toBe(170); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(30); + expect(root_child1_child0.getComputedHeight()).toBe(30); + + expect(root_child1_child1.getComputedLeft()).toBe(50); + expect(root_child1_child1.getComputedTop()).toBe(0); + expect(root_child1_child1.getComputedWidth()).toBe(30); + expect(root_child1_child1.getComputedHeight()).toBe(30); + + expect(root_child1_child2.getComputedLeft()).toBe(100); + expect(root_child1_child2.getComputedTop()).toBe(0); + expect(root_child1_child2.getComputedWidth()).toBe(30); + expect(root_child1_child2.getComputedHeight()).toBe(30); + + expect(root_child1_child3.getComputedLeft()).toBe(0); + expect(root_child1_child3.getComputedTop()).toBe(50); + expect(root_child1_child3.getComputedWidth()).toBe(30); + expect(root_child1_child3.getComputedHeight()).toBe(30); + + expect(root_child1_child4.getComputedLeft()).toBe(50); + expect(root_child1_child4.getComputedTop()).toBe(50); + expect(root_child1_child4.getComputedWidth()).toBe(30); + expect(root_child1_child4.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(330); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(140); + + expect(root_child0.getComputedLeft()).toBe(260); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(90); + expect(root_child1.getComputedTop()).toBe(20); + expect(root_child1.getComputedWidth()).toBe(170); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child1_child0.getComputedLeft()).toBe(120); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(30); + expect(root_child1_child0.getComputedHeight()).toBe(30); + + expect(root_child1_child1.getComputedLeft()).toBe(70); + expect(root_child1_child1.getComputedTop()).toBe(0); + expect(root_child1_child1.getComputedWidth()).toBe(30); + expect(root_child1_child1.getComputedHeight()).toBe(30); + + expect(root_child1_child2.getComputedLeft()).toBe(20); + expect(root_child1_child2.getComputedTop()).toBe(0); + expect(root_child1_child2.getComputedWidth()).toBe(30); + expect(root_child1_child2.getComputedHeight()).toBe(30); + + expect(root_child1_child3.getComputedLeft()).toBe(120); + expect(root_child1_child3.getComputedTop()).toBe(50); + expect(root_child1_child3.getComputedWidth()).toBe(30); + expect(root_child1_child3.getComputedHeight()).toBe(30); + + expect(root_child1_child4.getComputedLeft()).toBe(70); + expect(root_child1_child4.getComputedTop()).toBe(50); + expect(root_child1_child4.getComputedWidth()).toBe(30); + expect(root_child1_child4.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(40); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); +test('align_content_space_evenly_stretch_does_influence_line_box_dim', () => { + const config = Yoga.Config.create(); + let root; + + config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true); + + try { + root = Yoga.Node.create(config); + root.setFlexDirection(FlexDirection.Row); + root.setPositionType(PositionType.Absolute); + root.setPadding(Edge.Left, 20); + root.setPadding(Edge.Top, 20); + root.setPadding(Edge.Right, 20); + root.setPadding(Edge.Bottom, 20); + root.setWidth(400); + + const root_child0 = Yoga.Node.create(config); + root_child0.setMargin(Edge.Right, 20); + root_child0.setWidth(100); + root_child0.setHeight(100); + root.insertChild(root_child0, 0); + + const root_child1 = Yoga.Node.create(config); + root_child1.setFlexDirection(FlexDirection.Row); + root_child1.setAlignContent(Align.Stretch); + root_child1.setFlexWrap(Wrap.Wrap); + root_child1.setFlexGrow(1); + root_child1.setFlexShrink(1); + root.insertChild(root_child1, 1); + + const root_child1_child0 = Yoga.Node.create(config); + root_child1_child0.setMargin(Edge.Right, 20); + root_child1_child0.setWidth(30); + root_child1_child0.setHeight(30); + root_child1.insertChild(root_child1_child0, 0); + + const root_child1_child1 = Yoga.Node.create(config); + root_child1_child1.setMargin(Edge.Right, 20); + root_child1_child1.setWidth(30); + root_child1_child1.setHeight(30); + root_child1.insertChild(root_child1_child1, 1); + + const root_child1_child2 = Yoga.Node.create(config); + root_child1_child2.setMargin(Edge.Right, 20); + root_child1_child2.setWidth(30); + root_child1_child2.setHeight(30); + root_child1.insertChild(root_child1_child2, 2); + + const root_child1_child3 = Yoga.Node.create(config); + root_child1_child3.setMargin(Edge.Right, 20); + root_child1_child3.setWidth(30); + root_child1_child3.setHeight(30); + root_child1.insertChild(root_child1_child3, 3); + + const root_child1_child4 = Yoga.Node.create(config); + root_child1_child4.setMargin(Edge.Right, 20); + root_child1_child4.setWidth(30); + root_child1_child4.setHeight(30); + root_child1.insertChild(root_child1_child4, 4); + + const root_child2 = Yoga.Node.create(config); + root_child2.setMargin(Edge.Left, 20); + root_child2.setWidth(50); + root_child2.setHeight(50); + root.insertChild(root_child2, 2); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(140); + + expect(root_child0.getComputedLeft()).toBe(20); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(140); + expect(root_child1.getComputedTop()).toBe(20); + expect(root_child1.getComputedWidth()).toBe(170); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child1_child0.getComputedLeft()).toBe(0); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(30); + expect(root_child1_child0.getComputedHeight()).toBe(30); + + expect(root_child1_child1.getComputedLeft()).toBe(50); + expect(root_child1_child1.getComputedTop()).toBe(0); + expect(root_child1_child1.getComputedWidth()).toBe(30); + expect(root_child1_child1.getComputedHeight()).toBe(30); + + expect(root_child1_child2.getComputedLeft()).toBe(100); + expect(root_child1_child2.getComputedTop()).toBe(0); + expect(root_child1_child2.getComputedWidth()).toBe(30); + expect(root_child1_child2.getComputedHeight()).toBe(30); + + expect(root_child1_child3.getComputedLeft()).toBe(0); + expect(root_child1_child3.getComputedTop()).toBe(50); + expect(root_child1_child3.getComputedWidth()).toBe(30); + expect(root_child1_child3.getComputedHeight()).toBe(30); + + expect(root_child1_child4.getComputedLeft()).toBe(50); + expect(root_child1_child4.getComputedTop()).toBe(50); + expect(root_child1_child4.getComputedWidth()).toBe(30); + expect(root_child1_child4.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(330); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(400); + expect(root.getComputedHeight()).toBe(140); + + expect(root_child0.getComputedLeft()).toBe(260); + expect(root_child0.getComputedTop()).toBe(20); + expect(root_child0.getComputedWidth()).toBe(100); + expect(root_child0.getComputedHeight()).toBe(100); + + expect(root_child1.getComputedLeft()).toBe(90); + expect(root_child1.getComputedTop()).toBe(20); + expect(root_child1.getComputedWidth()).toBe(170); + expect(root_child1.getComputedHeight()).toBe(100); + + expect(root_child1_child0.getComputedLeft()).toBe(120); + expect(root_child1_child0.getComputedTop()).toBe(0); + expect(root_child1_child0.getComputedWidth()).toBe(30); + expect(root_child1_child0.getComputedHeight()).toBe(30); + + expect(root_child1_child1.getComputedLeft()).toBe(70); + expect(root_child1_child1.getComputedTop()).toBe(0); + expect(root_child1_child1.getComputedWidth()).toBe(30); + expect(root_child1_child1.getComputedHeight()).toBe(30); + + expect(root_child1_child2.getComputedLeft()).toBe(20); + expect(root_child1_child2.getComputedTop()).toBe(0); + expect(root_child1_child2.getComputedWidth()).toBe(30); + expect(root_child1_child2.getComputedHeight()).toBe(30); + + expect(root_child1_child3.getComputedLeft()).toBe(120); + expect(root_child1_child3.getComputedTop()).toBe(50); + expect(root_child1_child3.getComputedWidth()).toBe(30); + expect(root_child1_child3.getComputedHeight()).toBe(30); + + expect(root_child1_child4.getComputedLeft()).toBe(70); + expect(root_child1_child4.getComputedTop()).toBe(50); + expect(root_child1_child4.getComputedWidth()).toBe(30); + expect(root_child1_child4.getComputedHeight()).toBe(30); + + expect(root_child2.getComputedLeft()).toBe(40); + expect(root_child2.getComputedTop()).toBe(20); + expect(root_child2.getComputedWidth()).toBe(50); + expect(root_child2.getComputedHeight()).toBe(50); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/tests/generated/YGAlignContentTest.cpp b/tests/generated/YGAlignContentTest.cpp index 22792c5242..b491f8f9f2 100644 --- a/tests/generated/YGAlignContentTest.cpp +++ b/tests/generated/YGAlignContentTest.cpp @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. * * clang-format off - * @generated SignedSource<> + * @generated SignedSource<<7756efeafb66f705aecda51d7d361f2f>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGAlignContentTest.html */ @@ -4641,3 +4641,485 @@ TEST(YogaTest, align_content_space_around_and_align_items_flex_start_with_flex_w YGConfigFree(config); } + +TEST(YogaTest, align_content_flex_start_stretch_doesnt_influence_line_box_dim) { + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true); + + const YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 20); + YGNodeStyleSetPadding(root, YGEdgeTop, 20); + YGNodeStyleSetPadding(root, YGEdgeRight, 20); + YGNodeStyleSetPadding(root, YGEdgeBottom, 20); + YGNodeStyleSetWidth(root, 400); + + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMargin(root_child0, YGEdgeRight, 20); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetFlexDirection(root_child1, YGFlexDirectionRow); + YGNodeStyleSetFlexWrap(root_child1, YGWrapWrap); + YGNodeStyleSetFlexGrow(root_child1, 1); + YGNodeStyleSetFlexShrink(root_child1, 1); + YGNodeInsertChild(root, root_child1, 1); + + const YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMargin(root_child1_child0, YGEdgeRight, 20); + YGNodeStyleSetWidth(root_child1_child0, 30); + YGNodeStyleSetHeight(root_child1_child0, 30); + YGNodeInsertChild(root_child1, root_child1_child0, 0); + + const YGNodeRef root_child1_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetMargin(root_child1_child1, YGEdgeRight, 20); + YGNodeStyleSetWidth(root_child1_child1, 30); + YGNodeStyleSetHeight(root_child1_child1, 30); + YGNodeInsertChild(root_child1, root_child1_child1, 1); + + const YGNodeRef root_child1_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetMargin(root_child1_child2, YGEdgeRight, 20); + YGNodeStyleSetWidth(root_child1_child2, 30); + YGNodeStyleSetHeight(root_child1_child2, 30); + YGNodeInsertChild(root_child1, root_child1_child2, 2); + + const YGNodeRef root_child1_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetMargin(root_child1_child3, YGEdgeRight, 20); + YGNodeStyleSetWidth(root_child1_child3, 30); + YGNodeStyleSetHeight(root_child1_child3, 30); + YGNodeInsertChild(root_child1, root_child1_child3, 3); + + const YGNodeRef root_child1_child4 = YGNodeNewWithConfig(config); + YGNodeStyleSetMargin(root_child1_child4, YGEdgeRight, 20); + YGNodeStyleSetWidth(root_child1_child4, 30); + YGNodeStyleSetHeight(root_child1_child4, 30); + YGNodeInsertChild(root_child1, root_child1_child4, 4); + + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetMargin(root_child2, YGEdgeLeft, 20); + YGNodeStyleSetWidth(root_child2, 50); + YGNodeStyleSetHeight(root_child2, 50); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(170, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child0)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1_child0)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1_child1)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child2)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1_child2)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child1_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1_child3)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1_child4)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child1_child4)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1_child4)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1_child4)); + + ASSERT_FLOAT_EQ(330, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(260, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(170, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child1_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child0)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1_child0)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1_child0)); + + ASSERT_FLOAT_EQ(70, YGNodeLayoutGetLeft(root_child1_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1_child1)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child1_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child2)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1_child2)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1_child2)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child1_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child1_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1_child3)); + + ASSERT_FLOAT_EQ(70, YGNodeLayoutGetLeft(root_child1_child4)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child1_child4)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1_child4)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1_child4)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, align_content_stretch_stretch_does_influence_line_box_dim) { + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true); + + const YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 20); + YGNodeStyleSetPadding(root, YGEdgeTop, 20); + YGNodeStyleSetPadding(root, YGEdgeRight, 20); + YGNodeStyleSetPadding(root, YGEdgeBottom, 20); + YGNodeStyleSetWidth(root, 400); + + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMargin(root_child0, YGEdgeRight, 20); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetFlexDirection(root_child1, YGFlexDirectionRow); + YGNodeStyleSetAlignContent(root_child1, YGAlignStretch); + YGNodeStyleSetFlexWrap(root_child1, YGWrapWrap); + YGNodeStyleSetFlexGrow(root_child1, 1); + YGNodeStyleSetFlexShrink(root_child1, 1); + YGNodeInsertChild(root, root_child1, 1); + + const YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMargin(root_child1_child0, YGEdgeRight, 20); + YGNodeStyleSetWidth(root_child1_child0, 30); + YGNodeStyleSetHeight(root_child1_child0, 30); + YGNodeInsertChild(root_child1, root_child1_child0, 0); + + const YGNodeRef root_child1_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetMargin(root_child1_child1, YGEdgeRight, 20); + YGNodeStyleSetWidth(root_child1_child1, 30); + YGNodeStyleSetHeight(root_child1_child1, 30); + YGNodeInsertChild(root_child1, root_child1_child1, 1); + + const YGNodeRef root_child1_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetMargin(root_child1_child2, YGEdgeRight, 20); + YGNodeStyleSetWidth(root_child1_child2, 30); + YGNodeStyleSetHeight(root_child1_child2, 30); + YGNodeInsertChild(root_child1, root_child1_child2, 2); + + const YGNodeRef root_child1_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetMargin(root_child1_child3, YGEdgeRight, 20); + YGNodeStyleSetWidth(root_child1_child3, 30); + YGNodeStyleSetHeight(root_child1_child3, 30); + YGNodeInsertChild(root_child1, root_child1_child3, 3); + + const YGNodeRef root_child1_child4 = YGNodeNewWithConfig(config); + YGNodeStyleSetMargin(root_child1_child4, YGEdgeRight, 20); + YGNodeStyleSetWidth(root_child1_child4, 30); + YGNodeStyleSetHeight(root_child1_child4, 30); + YGNodeInsertChild(root_child1, root_child1_child4, 4); + + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetMargin(root_child2, YGEdgeLeft, 20); + YGNodeStyleSetWidth(root_child2, 50); + YGNodeStyleSetHeight(root_child2, 50); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(170, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child0)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1_child0)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1_child1)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child2)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1_child2)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1_child3)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1_child4)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1_child4)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1_child4)); + + ASSERT_FLOAT_EQ(330, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(260, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(170, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child1_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child0)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1_child0)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1_child0)); + + ASSERT_FLOAT_EQ(70, YGNodeLayoutGetLeft(root_child1_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1_child1)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child1_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child2)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1_child2)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1_child2)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child1_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1_child3)); + + ASSERT_FLOAT_EQ(70, YGNodeLayoutGetLeft(root_child1_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1_child4)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1_child4)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1_child4)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} + +TEST(YogaTest, align_content_space_evenly_stretch_does_influence_line_box_dim) { + const YGConfigRef config = YGConfigNew(); + YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true); + + const YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetPadding(root, YGEdgeLeft, 20); + YGNodeStyleSetPadding(root, YGEdgeTop, 20); + YGNodeStyleSetPadding(root, YGEdgeRight, 20); + YGNodeStyleSetPadding(root, YGEdgeBottom, 20); + YGNodeStyleSetWidth(root, 400); + + const YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMargin(root_child0, YGEdgeRight, 20); + YGNodeStyleSetWidth(root_child0, 100); + YGNodeStyleSetHeight(root_child0, 100); + YGNodeInsertChild(root, root_child0, 0); + + const YGNodeRef root_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetFlexDirection(root_child1, YGFlexDirectionRow); + YGNodeStyleSetAlignContent(root_child1, YGAlignStretch); + YGNodeStyleSetFlexWrap(root_child1, YGWrapWrap); + YGNodeStyleSetFlexGrow(root_child1, 1); + YGNodeStyleSetFlexShrink(root_child1, 1); + YGNodeInsertChild(root, root_child1, 1); + + const YGNodeRef root_child1_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetMargin(root_child1_child0, YGEdgeRight, 20); + YGNodeStyleSetWidth(root_child1_child0, 30); + YGNodeStyleSetHeight(root_child1_child0, 30); + YGNodeInsertChild(root_child1, root_child1_child0, 0); + + const YGNodeRef root_child1_child1 = YGNodeNewWithConfig(config); + YGNodeStyleSetMargin(root_child1_child1, YGEdgeRight, 20); + YGNodeStyleSetWidth(root_child1_child1, 30); + YGNodeStyleSetHeight(root_child1_child1, 30); + YGNodeInsertChild(root_child1, root_child1_child1, 1); + + const YGNodeRef root_child1_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetMargin(root_child1_child2, YGEdgeRight, 20); + YGNodeStyleSetWidth(root_child1_child2, 30); + YGNodeStyleSetHeight(root_child1_child2, 30); + YGNodeInsertChild(root_child1, root_child1_child2, 2); + + const YGNodeRef root_child1_child3 = YGNodeNewWithConfig(config); + YGNodeStyleSetMargin(root_child1_child3, YGEdgeRight, 20); + YGNodeStyleSetWidth(root_child1_child3, 30); + YGNodeStyleSetHeight(root_child1_child3, 30); + YGNodeInsertChild(root_child1, root_child1_child3, 3); + + const YGNodeRef root_child1_child4 = YGNodeNewWithConfig(config); + YGNodeStyleSetMargin(root_child1_child4, YGEdgeRight, 20); + YGNodeStyleSetWidth(root_child1_child4, 30); + YGNodeStyleSetHeight(root_child1_child4, 30); + YGNodeInsertChild(root_child1, root_child1_child4, 4); + + const YGNodeRef root_child2 = YGNodeNewWithConfig(config); + YGNodeStyleSetMargin(root_child2, YGEdgeLeft, 20); + YGNodeStyleSetWidth(root_child2, 50); + YGNodeStyleSetHeight(root_child2, 50); + YGNodeInsertChild(root, root_child2, 2); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(170, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child0)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1_child0)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1_child0)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1_child1)); + + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child2)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1_child2)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1_child2)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1_child3)); + + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1_child4)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1_child4)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1_child4)); + + ASSERT_FLOAT_EQ(330, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child2)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(140, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(260, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); + + ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child1)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child1)); + ASSERT_FLOAT_EQ(170, YGNodeLayoutGetWidth(root_child1)); + ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child1_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child0)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1_child0)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1_child0)); + + ASSERT_FLOAT_EQ(70, YGNodeLayoutGetLeft(root_child1_child1)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1_child1)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1_child1)); + + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child1_child2)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child2)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1_child2)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1_child2)); + + ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child1_child3)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1_child3)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1_child3)); + + ASSERT_FLOAT_EQ(70, YGNodeLayoutGetLeft(root_child1_child4)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1_child4)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetWidth(root_child1_child4)); + ASSERT_FLOAT_EQ(30, YGNodeLayoutGetHeight(root_child1_child4)); + + ASSERT_FLOAT_EQ(40, YGNodeLayoutGetLeft(root_child2)); + ASSERT_FLOAT_EQ(20, YGNodeLayoutGetTop(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2)); + ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child2)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/yoga/algorithm/CalculateLayout.cpp b/yoga/algorithm/CalculateLayout.cpp index 8b645b9971..ea7a090317 100644 --- a/yoga/algorithm/CalculateLayout.cpp +++ b/yoga/algorithm/CalculateLayout.cpp @@ -1743,8 +1743,9 @@ static void calculateLayoutImpl( float leadPerLine = 0; float currentLead = leadingPaddingAndBorderCross; - const float unclampedCrossDim = - node->styleDefinesDimension(crossAxis, crossAxisownerSize) + const float unclampedCrossDim = sizingModeCrossDim == SizingMode::StretchFit + ? availableInnerCrossDim + paddingAndBorderAxisCross + : node->styleDefinesDimension(crossAxis, crossAxisownerSize) ? yoga::resolveValue( node->getResolvedDimension(dimension(crossAxis)), crossAxisownerSize)