Skip to content

Commit

Permalink
Fix flex within max width constraint
Browse files Browse the repository at this point in the history
Reviewed By: gkassabli

Differential Revision: D4147199

fbshipit-source-id: feb335eb8687a1b7939ee8cd8649e455e0c069a9
  • Loading branch information
Emil Sjolander authored and Facebook Github Bot committed Nov 8, 2016
1 parent 3ee5e97 commit 72d1191
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions React/CSSLayout/CSSLayout.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 72d1191

Please sign in to comment.