Permalink
Browse files

Fix flex within max width constraint

Reviewed By: gkassabli

Differential Revision: D4147199

fbshipit-source-id: feb335eb8687a1b7939ee8cd8649e455e0c069a9
  • Loading branch information...
1 parent 3ee5e97 commit 72d11912f47a699e6dc8c0cda0e47007b2208a54 @emilsjolander emilsjolander committed with Facebook Github Bot Nov 8, 2016
Showing with 30 additions and 0 deletions.
  1. +30 −0 React/CSSLayout/CSSLayout.c
@@ -964,6 +964,16 @@ static void computeChildFlexBasis(const CSSNodeRef node,
childHeightMeasureMode = CSSMeasureModeExactly;
}
+ if (!CSSValueIsUndefined(child->style.maxDimensions[CSSDimensionWidth])) {
+ childWidth = child->style.maxDimensions[CSSDimensionWidth];
+ childWidthMeasureMode = CSSMeasureModeAtMost;
+ }
+
+ if (!CSSValueIsUndefined(child->style.maxDimensions[CSSDimensionHeight])) {
+ childHeight = child->style.maxDimensions[CSSDimensionHeight];
+ childHeightMeasureMode = CSSMeasureModeAtMost;
+ }
+
// Measure the child
layoutNodeInternal(child,
childWidth,
@@ -1670,6 +1680,16 @@ static void layoutNodeImpl(const CSSNodeRef node,
}
}
+ if (!CSSValueIsUndefined(currentRelativeChild->style.maxDimensions[CSSDimensionWidth])) {
+ childWidth = currentRelativeChild->style.maxDimensions[CSSDimensionWidth];
+ childWidthMeasureMode = CSSMeasureModeAtMost;
+ }
+
+ if (!CSSValueIsUndefined(currentRelativeChild->style.maxDimensions[CSSDimensionHeight])) {
+ childHeight = currentRelativeChild->style.maxDimensions[CSSDimensionHeight];
+ childHeightMeasureMode = CSSMeasureModeAtMost;
+ }
+
const bool requiresStretchLayout =
!isStyleDimDefined(currentRelativeChild, crossAxis) &&
getAlignItem(node, currentRelativeChild) == CSSAlignStretch;
@@ -1859,6 +1879,16 @@ static void layoutNodeImpl(const CSSNodeRef node,
getMarginAxis(child, CSSFlexDirectionColumn);
}
+ if (!CSSValueIsUndefined(child->style.maxDimensions[CSSDimensionWidth])) {
+ childWidth = child->style.maxDimensions[CSSDimensionWidth];
+ childWidthMeasureMode = CSSMeasureModeAtMost;
+ }
+
+ if (!CSSValueIsUndefined(child->style.maxDimensions[CSSDimensionHeight])) {
+ childHeight = child->style.maxDimensions[CSSDimensionHeight];
+ childHeightMeasureMode = CSSMeasureModeAtMost;
+ }
+
// If the child defines a definite size for its cross axis, there's
// no need to stretch.
if (!isCrossSizeDefinite) {

0 comments on commit 72d1191

Please sign in to comment.