Fix flex-shrink when shrinking to zero size

Reviewed By: gkassabli

Differential Revision: D4036345

fbshipit-source-id: f6848d7a316a694426f761d5e51d972bd379d90e
This commit is contained in:
Emil Sjolander 2016-10-18 09:19:22 -07:00 committed by Facebook Github Bot
parent 1a6b43e67b
commit 0699a30980
1 changed files with 12 additions and 6 deletions

View File

@ -1550,14 +1550,20 @@ static void layoutNodeImpl(const CSSNodeRef node,
if (remainingFreeSpace < 0) {
flexShrinkScaledFactor = -currentRelativeChild->style.flexShrink * childFlexBasis;
// Is this child able to shrink?
if (flexShrinkScaledFactor != 0) {
updatedMainSize = boundAxis(currentRelativeChild,
mainAxis,
childFlexBasis +
remainingFreeSpace / totalFlexShrinkScaledFactors *
flexShrinkScaledFactor);
float childSize;
if (totalFlexShrinkScaledFactors == 0) {
childSize = childFlexBasis + flexShrinkScaledFactor;
} else {
childSize =
childFlexBasis +
(remainingFreeSpace / totalFlexShrinkScaledFactors) *
flexShrinkScaledFactor;
}
updatedMainSize = boundAxis(currentRelativeChild, mainAxis, childSize);
}
} else if (remainingFreeSpace > 0) {
flexGrowFactor = currentRelativeChild->style.flexGrow;