Do not stretch auto margined nodes
This commit is contained in:
@@ -150,6 +150,27 @@ TEST(YogaTest, dont_measure_when_min_equals_max_percentages) {
|
|||||||
YGNodeFreeRecursive(root);
|
YGNodeFreeRecursive(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TEST(YogaTest, measure_nodes_with_margin_auto_and_stretch) {
|
||||||
|
const YGNodeRef root = YGNodeNew();
|
||||||
|
YGNodeStyleSetWidth(root, 500);
|
||||||
|
YGNodeStyleSetHeight(root, 500);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0 = YGNodeNew();
|
||||||
|
YGNodeSetMeasureFunc(root_child0, _measure);
|
||||||
|
YGNodeStyleSetMarginAuto(root_child0, YGEdgeLeft);
|
||||||
|
YGNodeInsertChild(root, root_child0, 0);
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
EXPECT_EQ(490, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
EXPECT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||||
|
EXPECT_EQ(10, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
EXPECT_EQ(10, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
}
|
||||||
|
|
||||||
TEST(YogaTest, dont_measure_when_min_equals_max_mixed_width_percent) {
|
TEST(YogaTest, dont_measure_when_min_equals_max_mixed_width_percent) {
|
||||||
const YGNodeRef root = YGNodeNew();
|
const YGNodeRef root = YGNodeNew();
|
||||||
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
|
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
|
||||||
|
@@ -2293,7 +2293,9 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
|||||||
availableInnerCrossDim) &&
|
availableInnerCrossDim) &&
|
||||||
measureModeCrossDim == YGMeasureModeExactly &&
|
measureModeCrossDim == YGMeasureModeExactly &&
|
||||||
!(isNodeFlexWrap && flexBasisOverflows) &&
|
!(isNodeFlexWrap && flexBasisOverflows) &&
|
||||||
YGNodeAlignItem(node, currentRelativeChild) == YGAlignStretch) {
|
YGNodeAlignItem(node, currentRelativeChild) == YGAlignStretch &&
|
||||||
|
YGMarginLeadingValue(currentRelativeChild, crossAxis)->unit != YGUnitAuto &&
|
||||||
|
YGMarginTrailingValue(currentRelativeChild, crossAxis)->unit != YGUnitAuto) {
|
||||||
childCrossSize = availableInnerCrossDim;
|
childCrossSize = availableInnerCrossDim;
|
||||||
childCrossMeasureMode = YGMeasureModeExactly;
|
childCrossMeasureMode = YGMeasureModeExactly;
|
||||||
} else if (!YGNodeIsStyleDimDefined(currentRelativeChild,
|
} else if (!YGNodeIsStyleDimDefined(currentRelativeChild,
|
||||||
@@ -2329,7 +2331,9 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
|||||||
|
|
||||||
const bool requiresStretchLayout =
|
const bool requiresStretchLayout =
|
||||||
!YGNodeIsStyleDimDefined(currentRelativeChild, crossAxis, availableInnerCrossDim) &&
|
!YGNodeIsStyleDimDefined(currentRelativeChild, crossAxis, availableInnerCrossDim) &&
|
||||||
YGNodeAlignItem(node, currentRelativeChild) == YGAlignStretch;
|
YGNodeAlignItem(node, currentRelativeChild) == YGAlignStretch &&
|
||||||
|
YGMarginLeadingValue(currentRelativeChild, crossAxis)->unit != YGUnitAuto &&
|
||||||
|
YGMarginTrailingValue(currentRelativeChild, crossAxis)->unit != YGUnitAuto;
|
||||||
|
|
||||||
const float childWidth = isMainAxisRow ? childMainSize : childCrossSize;
|
const float childWidth = isMainAxisRow ? childMainSize : childCrossSize;
|
||||||
const float childHeight = !isMainAxisRow ? childMainSize : childCrossSize;
|
const float childHeight = !isMainAxisRow ? childMainSize : childCrossSize;
|
||||||
|
Reference in New Issue
Block a user