Permalink
Browse files

BREAKING - Fix sizing of container with child overflowing parent

Reviewed By: mmmulani

Differential Revision: D4182141

fbshipit-source-id: c73fd15d2577ab846fc8a202d529d0e6e1207b75
  • Loading branch information...
emilsjolander authored and facebook-github-bot committed Jan 16, 2017
1 parent 893941e commit 8d2a034f9c18988a6a63726767bddecd0d02424d
Showing with 11 additions and 5 deletions.
  1. +11 −5 ReactCommon/yoga/yoga/Yoga.c
@@ -985,7 +985,9 @@ static inline YGDirection YGNodeResolveDirection(const YGNodeRef node,
static float YGBaseline(const YGNodeRef node) {
if (node->baseline != NULL) {
const float baseline = node->baseline(node, node->layout.measuredDimensions[YGDimensionWidth], node->layout.measuredDimensions[YGDimensionHeight]);
const float baseline = node->baseline(node,
node->layout.measuredDimensions[YGDimensionWidth],
node->layout.measuredDimensions[YGDimensionHeight]);
YG_ASSERT(!YGFloatIsUndefined(baseline), "Expect custom baseline function to not return NaN")
return baseline;
}
@@ -2672,19 +2674,22 @@ static void YGNodelayoutImpl(const YGNodeRef node,
// If the user didn't specify a width or height for the node, set the
// dimensions based on the children.
if (measureModeMainDim == YGMeasureModeUndefined) {
if (measureModeMainDim == YGMeasureModeUndefined ||
(node->style.overflow != YGOverflowScroll && measureModeMainDim == YGMeasureModeAtMost)) {
// Clamp the size to the min/max size, if specified, and make sure it
// doesn't go below the padding and border amount.
node->layout.measuredDimensions[dim[mainAxis]] =
YGNodeBoundAxis(node, mainAxis, maxLineMainDim, mainAxisParentSize, parentWidth);
} else if (measureModeMainDim == YGMeasureModeAtMost) {
} else if (measureModeMainDim == YGMeasureModeAtMost &&
node->style.overflow == YGOverflowScroll) {
node->layout.measuredDimensions[dim[mainAxis]] = fmaxf(
fminf(availableInnerMainDim + paddingAndBorderAxisMain,
YGNodeBoundAxisWithinMinAndMax(node, mainAxis, maxLineMainDim, mainAxisParentSize)),
paddingAndBorderAxisMain);
}
if (measureModeCrossDim == YGMeasureModeUndefined) {
if (measureModeCrossDim == YGMeasureModeUndefined ||
(node->style.overflow != YGOverflowScroll && measureModeCrossDim == YGMeasureModeAtMost)) {
// Clamp the size to the min/max size, if specified, and make sure it
// doesn't go below the padding and border amount.
node->layout.measuredDimensions[dim[crossAxis]] =
@@ -2693,7 +2698,8 @@ static void YGNodelayoutImpl(const YGNodeRef node,
totalLineCrossDim + paddingAndBorderAxisCross,
crossAxisParentSize,
parentWidth);
} else if (measureModeCrossDim == YGMeasureModeAtMost) {
} else if (measureModeCrossDim == YGMeasureModeAtMost &&
node->style.overflow == YGOverflowScroll) {
node->layout.measuredDimensions[dim[crossAxis]] =
fmaxf(fminf(availableInnerCrossDim + paddingAndBorderAxisCross,
YGNodeBoundAxisWithinMinAndMax(node,

2 comments on commit 8d2a034

@oblador

This comment has been minimized.

Show comment
Hide comment
@oblador

oblador Jan 23, 2017

Contributor

👏 💯 🎉

Contributor

oblador replied Jan 23, 2017

👏 💯 🎉

@itinance

This comment has been minimized.

Show comment
Hide comment
@itinance

itinance Feb 3, 2017

Wohooo!!!! Thx!

itinance replied Feb 3, 2017

Wohooo!!!! Thx!

Please sign in to comment.