diff --git a/gentest/fixtures/YGMinMaxDimensionTest.html b/gentest/fixtures/YGMinMaxDimensionTest.html index 0f41dad074..d0513f55f2 100644 --- a/gentest/fixtures/YGMinMaxDimensionTest.html +++ b/gentest/fixtures/YGMinMaxDimensionTest.html @@ -37,7 +37,8 @@
-
+
@@ -126,3 +127,9 @@
+ +
+
+ Lorem ipsum sdafhasdfkjlasdhlkajsfhasldkfhasdlkahsdflkjasdhflaksdfasdlkjhasdlfjahsdfljkasdhalsdfhas dolor sit amet +
+
diff --git a/java/tests/generated/com/facebook/yoga/YGMinMaxDimensionTest.java b/java/tests/generated/com/facebook/yoga/YGMinMaxDimensionTest.java index 0f86664b37..1e25907bfb 100644 --- a/java/tests/generated/com/facebook/yoga/YGMinMaxDimensionTest.java +++ b/java/tests/generated/com/facebook/yoga/YGMinMaxDimensionTest.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<<19cdc4fc9425af726b656ef628bab8af>> + * @generated SignedSource<<399bb599fce869e5c09ea1d193c1e486>> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGMinMaxDimensionTest.html */ @@ -1315,6 +1315,47 @@ public void test_min_max_percent_no_width_height() { assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); } + @Test + public void test_min_width_leaf_node_bigger_than_width() { + YogaConfig config = YogaConfigFactory.create(); + + final YogaNode root = createNode(config); + root.setPositionType(YogaPositionType.ABSOLUTE); + root.setWidth(200f); + + final YogaNode root_child0 = createNode(config); + root_child0.setWidth(200f); + root_child0.setMinWidth(10000f); + root.addChildAt(root_child0, 0); + root_child0.setData("Lorem ipsum sdafhasdfkjlasdhlkajsfhasldkfhasdlkahsdflkjasdhflaksdfasdlkjhasdlfjahsdfljkasdhalsdfhas dolor sit amet"); + root_child0.setMeasureFunction(new TestUtils.intrinsicMeasureFunction()); + root.setDirection(YogaDirection.LTR); + root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED); + + assertEquals(0f, root.getLayoutX(), 0.0f); + assertEquals(0f, root.getLayoutY(), 0.0f); + assertEquals(200f, root.getLayoutWidth(), 0.0f); + assertEquals(10f, root.getLayoutHeight(), 0.0f); + + assertEquals(0f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10000f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.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(200f, root.getLayoutWidth(), 0.0f); + assertEquals(10f, root.getLayoutHeight(), 0.0f); + + assertEquals(-9800f, root_child0.getLayoutX(), 0.0f); + assertEquals(0f, root_child0.getLayoutY(), 0.0f); + assertEquals(10000f, root_child0.getLayoutWidth(), 0.0f); + assertEquals(10f, root_child0.getLayoutHeight(), 0.0f); + } + private YogaNode createNode(YogaConfig config) { return mNodeFactory.create(config); } diff --git a/javascript/tests/generated/YGMinMaxDimensionTest.test.ts b/javascript/tests/generated/YGMinMaxDimensionTest.test.ts index dfe3773f5e..582e3915b7 100644 --- a/javascript/tests/generated/YGMinMaxDimensionTest.test.ts +++ b/javascript/tests/generated/YGMinMaxDimensionTest.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<<1bd782301afbab34ed3c9a296c3ecaa6>> + * @generated SignedSource<> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGMinMaxDimensionTest.html */ @@ -1444,3 +1444,48 @@ test('min_max_percent_no_width_height', () => { config.free(); } }); +test('min_width_leaf_node_bigger_than_width', () => { + const config = Yoga.Config.create(); + let root; + + try { + root = Yoga.Node.create(config); + root.setPositionType(PositionType.Absolute); + root.setWidth(200); + + const root_child0 = Yoga.Node.create(config); + root_child0.setWidth(200); + root_child0.setMinWidth(10000); + root.insertChild(root_child0, 0); + root_child0.setMeasureFunc(instrinsicSizeMeasureFunc.bind("Lorem ipsum sdafhasdfkjlasdhlkajsfhasldkfhasdlkahsdflkjasdhflaksdfasdlkjhasdlfjahsdfljkasdhalsdfhas dolor sit amet")); + root.calculateLayout(undefined, undefined, Direction.LTR); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(10); + + expect(root_child0.getComputedLeft()).toBe(0); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10000); + expect(root_child0.getComputedHeight()).toBe(10); + + root.calculateLayout(undefined, undefined, Direction.RTL); + + expect(root.getComputedLeft()).toBe(0); + expect(root.getComputedTop()).toBe(0); + expect(root.getComputedWidth()).toBe(200); + expect(root.getComputedHeight()).toBe(10); + + expect(root_child0.getComputedLeft()).toBe(-9800); + expect(root_child0.getComputedTop()).toBe(0); + expect(root_child0.getComputedWidth()).toBe(10000); + expect(root_child0.getComputedHeight()).toBe(10); + } finally { + if (typeof root !== 'undefined') { + root.freeRecursive(); + } + + config.free(); + } +}); diff --git a/tests/generated/YGMinMaxDimensionTest.cpp b/tests/generated/YGMinMaxDimensionTest.cpp index bbb4b40a92..a1709039c6 100644 --- a/tests/generated/YGMinMaxDimensionTest.cpp +++ b/tests/generated/YGMinMaxDimensionTest.cpp @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. * * clang-format off - * @generated SignedSource<<0054f2d41727e7a0707701c6d7640cb6>> + * @generated SignedSource<> * generated by gentest/gentest-driver.ts from gentest/fixtures/YGMinMaxDimensionTest.html */ @@ -1328,3 +1328,45 @@ TEST(YogaTest, min_max_percent_no_width_height) { YGConfigFree(config); } + +TEST(YogaTest, min_width_leaf_node_bigger_than_width) { + YGConfigRef config = YGConfigNew(); + + YGNodeRef root = YGNodeNewWithConfig(config); + YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); + YGNodeStyleSetWidth(root, 200); + + YGNodeRef root_child0 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(root_child0, 200); + YGNodeStyleSetMinWidth(root_child0, 10000); + YGNodeInsertChild(root, root_child0, 0); + YGNodeSetContext(root_child0, (void*)"Lorem ipsum sdafhasdfkjlasdhlkajsfhasldkfhasdlkahsdflkjasdhflaksdfasdlkjhasdlfjahsdfljkasdhalsdfhas dolor sit amet"); + YGNodeSetMeasureFunc(root_child0, &facebook::yoga::test::IntrinsicSizeMeasure); + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10000, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); + + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); + + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root)); + + ASSERT_FLOAT_EQ(-9800, YGNodeLayoutGetLeft(root_child0)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); + ASSERT_FLOAT_EQ(10000, YGNodeLayoutGetWidth(root_child0)); + ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0)); + + YGNodeFreeRecursive(root); + + YGConfigFree(config); +} diff --git a/yoga/algorithm/CalculateLayout.cpp b/yoga/algorithm/CalculateLayout.cpp index 36184745e2..bf55de9ce7 100644 --- a/yoga/algorithm/CalculateLayout.cpp +++ b/yoga/algorithm/CalculateLayout.cpp @@ -325,9 +325,23 @@ static void measureNodeWithMeasureFunc( // Measure the text under the current constraints. const YGSize measuredSize = node->measure( - innerWidth, + isUndefined(innerWidth) ? innerWidth + : boundAxis( + node, + FlexDirection::Row, + direction, + innerWidth, + ownerWidth, + ownerWidth), measureMode(widthSizingMode), - innerHeight, + isUndefined(innerHeight) ? innerHeight + : boundAxis( + node, + FlexDirection::Column, + direction, + innerHeight, + ownerHeight, + ownerWidth), measureMode(heightSizingMode)); layoutMarkerData.measureCallbacks += 1;