Skip to content

Commit 72d1191

Browse files
Emil SjolanderFacebook Github Bot
authored andcommitted
Fix flex within max width constraint
Reviewed By: gkassabli Differential Revision: D4147199 fbshipit-source-id: feb335eb8687a1b7939ee8cd8649e455e0c069a9
1 parent 3ee5e97 commit 72d1191

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

React/CSSLayout/CSSLayout.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,16 @@ static void computeChildFlexBasis(const CSSNodeRef node,
964964
childHeightMeasureMode = CSSMeasureModeExactly;
965965
}
966966

967+
if (!CSSValueIsUndefined(child->style.maxDimensions[CSSDimensionWidth])) {
968+
childWidth = child->style.maxDimensions[CSSDimensionWidth];
969+
childWidthMeasureMode = CSSMeasureModeAtMost;
970+
}
971+
972+
if (!CSSValueIsUndefined(child->style.maxDimensions[CSSDimensionHeight])) {
973+
childHeight = child->style.maxDimensions[CSSDimensionHeight];
974+
childHeightMeasureMode = CSSMeasureModeAtMost;
975+
}
976+
967977
// Measure the child
968978
layoutNodeInternal(child,
969979
childWidth,
@@ -1670,6 +1680,16 @@ static void layoutNodeImpl(const CSSNodeRef node,
16701680
}
16711681
}
16721682

1683+
if (!CSSValueIsUndefined(currentRelativeChild->style.maxDimensions[CSSDimensionWidth])) {
1684+
childWidth = currentRelativeChild->style.maxDimensions[CSSDimensionWidth];
1685+
childWidthMeasureMode = CSSMeasureModeAtMost;
1686+
}
1687+
1688+
if (!CSSValueIsUndefined(currentRelativeChild->style.maxDimensions[CSSDimensionHeight])) {
1689+
childHeight = currentRelativeChild->style.maxDimensions[CSSDimensionHeight];
1690+
childHeightMeasureMode = CSSMeasureModeAtMost;
1691+
}
1692+
16731693
const bool requiresStretchLayout =
16741694
!isStyleDimDefined(currentRelativeChild, crossAxis) &&
16751695
getAlignItem(node, currentRelativeChild) == CSSAlignStretch;
@@ -1859,6 +1879,16 @@ static void layoutNodeImpl(const CSSNodeRef node,
18591879
getMarginAxis(child, CSSFlexDirectionColumn);
18601880
}
18611881

1882+
if (!CSSValueIsUndefined(child->style.maxDimensions[CSSDimensionWidth])) {
1883+
childWidth = child->style.maxDimensions[CSSDimensionWidth];
1884+
childWidthMeasureMode = CSSMeasureModeAtMost;
1885+
}
1886+
1887+
if (!CSSValueIsUndefined(child->style.maxDimensions[CSSDimensionHeight])) {
1888+
childHeight = child->style.maxDimensions[CSSDimensionHeight];
1889+
childHeightMeasureMode = CSSMeasureModeAtMost;
1890+
}
1891+
18621892
// If the child defines a definite size for its cross axis, there's
18631893
// no need to stretch.
18641894
if (!isCrossSizeDefinite) {

0 commit comments

Comments
 (0)