diff --git a/tests/generated/YGMinMaxDimensionTest.cpp b/tests/generated/YGMinMaxDimensionTest.cpp index 693bd132e5..4ca13ac0fc 100644 --- a/tests/generated/YGMinMaxDimensionTest.cpp +++ b/tests/generated/YGMinMaxDimensionTest.cpp @@ -1352,3 +1352,102 @@ TEST(YogaTest, min_max_percent_no_width_height) { YGConfigFree(config); } +TEST(YogaTest, Auto_Height_Min_Height) { + YGNodeRef node = nullptr; + YGNodeRef root = nullptr; + YGConfigRef config = nullptr; + config = YGConfigNew(); + root = YGNodeNewWithConfig(config); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetFlexWrap(root, YGWrapWrap); + YGNodeStyleSetWidth(root, 200); + YGNodeStyleSetHeightAuto(root); + YGNodeStyleSetMinHeight(root, 120); + YGNodeStyleSetMaxHeight(root, 240); + YGNodeStyleSetFlexBasisAuto(root); + YGNodeStyleSetJustifyContent(root, YGJustifyFlexStart); + YGNodeStyleSetAlignItems(root, YGAlignFlexStart); + YGNodeStyleSetAlignContent(root, YGAlignFlexStart); + for (size_t i = 0; i < 3; i++) { + node = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(node, 100); + YGNodeStyleSetHeight(node, 100); + YGNodeInsertChild(root, node, i); // index start from 0 + } + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + YGNodeFreeRecursive(root); + YGConfigFree(config); +} +TEST(YogaTest, Auto_Width_Min_Width) { + YGNodeRef node = nullptr; + YGNodeRef root = nullptr; + YGConfigRef config = nullptr; + config = YGConfigNew(); + root = YGNodeNewWithConfig(config); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionColumn); + YGNodeStyleSetFlexWrap(root, YGWrapWrap); + YGNodeStyleSetWidthAuto(root); + YGNodeStyleSetHeight(root, 200); + YGNodeStyleSetMinWidth(root, 120); + YGNodeStyleSetFlexBasisAuto(root); + YGNodeStyleSetJustifyContent(root, YGJustifyFlexStart); + YGNodeStyleSetAlignItems(root, YGAlignFlexStart); + YGNodeStyleSetAlignContent(root, YGAlignFlexStart); + for (size_t i = 0; i < 3; i++) { + node = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(node, 100); + YGNodeStyleSetHeight(node, 100); + YGNodeInsertChild(root, node, i); // index start from 0 + } + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); + ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root)); + YGNodeFreeRecursive(root); + YGConfigFree(config); +} +TEST(YogaTest, Child_Auto_Width_Min_Width) { + YGNodeRef node = nullptr; + YGNodeRef root = nullptr; + YGConfigRef config = nullptr; + config = YGConfigNew(); + root = YGNodeNewWithConfig(config); + YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow); + YGNodeStyleSetFlexWrap(root, YGWrapWrap); + YGNodeStyleSetWidth(root, 500); + YGNodeStyleSetHeight(root, 500); + YGNodeStyleSetFlexBasisAuto(root); + YGNodeStyleSetJustifyContent(root, YGJustifyFlexStart); + YGNodeStyleSetAlignItems(root, YGAlignFlexStart); + YGNodeStyleSetAlignContent(root, YGAlignFlexStart); + for (size_t i = 0; i < 2; i++) { + node = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(node, 100); + YGNodeStyleSetHeight(node, 100); + YGNodeInsertChild(root, node, i); // index start from 0 + } + node = YGNodeNewWithConfig(config); + YGNodeStyleSetWidthAuto(node); + YGNodeStyleSetHeight(node, 200); + YGNodeStyleSetMinWidth(node, 120); + YGNodeInsertChild(root, node, 2); // index start from 0 + YGNodeStyleSetFlexDirection(node, YGFlexDirectionColumn); + YGNodeStyleSetFlexWrap(node, YGWrapWrap); + for (size_t i = 0; i < 3; i++) { + YGNodeRef node1 = YGNodeNewWithConfig(config); + YGNodeStyleSetWidth(node1, 100); + YGNodeStyleSetHeight(node1, 100); + YGNodeInsertChild(node, node1, i); // index start from 0 + } + YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); + node = YGNodeGetChild(root, 2); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(node)); + ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(node)); + YGNodeFreeRecursive(root); + YGConfigFree(config); +} diff --git a/yoga/algorithm/CalculateLayout.cpp b/yoga/algorithm/CalculateLayout.cpp index 25665dafc5..c0748646e7 100644 --- a/yoga/algorithm/CalculateLayout.cpp +++ b/yoga/algorithm/CalculateLayout.cpp @@ -1571,12 +1571,9 @@ static void calculateLayoutImpl( // Clamp to the min/max size specified on the container. flexLine.layout.crossDim = - boundAxis( - node, - crossAxis, + yoga::maxOrDefined( flexLine.layout.crossDim + paddingAndBorderAxisCross, - crossAxisownerSize, - ownerWidth) - + paddingAndBorderForAxis(node, crossAxis, ownerWidth)) - paddingAndBorderAxisCross; // STEP 7: CROSS-AXIS ALIGNMENT