Fixing using flex in root node
Summary: We should always try to make root node as small as possible, while previously this wasn't functioning this way Reviewed By: emilsjolander Differential Revision: D5071164 fbshipit-source-id: b8afef42477d0ed87d0c9fcfd26349e0a0babd6e
This commit is contained in:
committed by
Facebook Github Bot
parent
49bccf47fa
commit
f2612192c5
10
yoga/Yoga.c
10
yoga/Yoga.c
@@ -525,6 +525,10 @@ void YGNodeCopyStyle(const YGNodeRef dstNode, const YGNodeRef srcNode) {
|
||||
}
|
||||
|
||||
static inline float YGResolveFlexGrow(const YGNodeRef node) {
|
||||
// Root nodes flexGrow should always be 0
|
||||
if (node->parent == NULL) {
|
||||
return 0.0;
|
||||
}
|
||||
if (!YGFloatIsUndefined(node->style.flexGrow)) {
|
||||
return node->style.flexGrow;
|
||||
}
|
||||
@@ -545,6 +549,10 @@ float YGNodeStyleGetFlexShrink(const YGNodeRef node) {
|
||||
}
|
||||
|
||||
static inline float YGNodeResolveFlexShrink(const YGNodeRef node) {
|
||||
// Root nodes flexShrink should always be 0
|
||||
if (node->parent == NULL) {
|
||||
return 0.0;
|
||||
}
|
||||
if (!YGFloatIsUndefined(node->style.flexShrink)) {
|
||||
return node->style.flexShrink;
|
||||
}
|
||||
@@ -2293,7 +2301,7 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
||||
if (!node->config->useLegacyStretchBehaviour &&
|
||||
(totalFlexGrowFactors == 0 || YGResolveFlexGrow(node) == 0)) {
|
||||
// If we don't have any children to flex or we can't flex the node itself,
|
||||
// space we've used is all space we need
|
||||
// space we've used is all space we need. Root node also should be shrunk to minimum
|
||||
availableInnerMainDim = sizeConsumedOnCurrentLine;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user