mirror of
https://github.com/status-im/react-native.git
synced 2025-02-26 16:10:58 +00:00
Move YGNodeResolveFlexShrink to a method on YGNode
Reviewed By: emilsjolander Differential Revision: D6611418 fbshipit-source-id: 6e5ba39b555d313a967800589891027920112c15
This commit is contained in:
parent
6627d7723c
commit
d85da86dc7
@ -435,3 +435,17 @@ float YGNode::resolveFlexGrow() {
|
|||||||
}
|
}
|
||||||
return kDefaultFlexGrow;
|
return kDefaultFlexGrow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float YGNode::resolveFlexShrink() {
|
||||||
|
if (parent_ == nullptr) {
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
if (!YGFloatIsUndefined(style_.flexShrink)) {
|
||||||
|
return style_.flexShrink;
|
||||||
|
}
|
||||||
|
if (!config_->useWebDefaults && !YGFloatIsUndefined(style_.flex) &&
|
||||||
|
style_.flex < 0.0f) {
|
||||||
|
return -style_.flex;
|
||||||
|
}
|
||||||
|
return config_->useWebDefaults ? kWebDefaultFlexShrink : kDefaultFlexShrink;
|
||||||
|
}
|
||||||
|
@ -123,4 +123,5 @@ struct YGNode {
|
|||||||
void cloneChildrenIfNeeded();
|
void cloneChildrenIfNeeded();
|
||||||
void markDirtyAndPropogate();
|
void markDirtyAndPropogate();
|
||||||
float resolveFlexGrow();
|
float resolveFlexGrow();
|
||||||
|
float resolveFlexShrink();
|
||||||
};
|
};
|
||||||
|
@ -470,23 +470,6 @@ float YGNodeStyleGetFlexShrink(const YGNodeRef node) {
|
|||||||
: node->getStyle().flexShrink;
|
: node->getStyle().flexShrink;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline float YGNodeResolveFlexShrink(const YGNodeRef node) {
|
|
||||||
// Root nodes flexShrink should always be 0
|
|
||||||
if (node->getParent() == nullptr) {
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
if (!YGFloatIsUndefined(node->getStyle().flexShrink)) {
|
|
||||||
return node->getStyle().flexShrink;
|
|
||||||
}
|
|
||||||
if (!node->getConfig()->useWebDefaults &&
|
|
||||||
!YGFloatIsUndefined(node->getStyle().flex) &&
|
|
||||||
node->getStyle().flex < 0.0f) {
|
|
||||||
return -node->getStyle().flex;
|
|
||||||
}
|
|
||||||
return node->getConfig()->useWebDefaults ? kWebDefaultFlexShrink
|
|
||||||
: kDefaultFlexShrink;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define YG_NODE_STYLE_PROPERTY_SETTER_IMPL( \
|
#define YG_NODE_STYLE_PROPERTY_SETTER_IMPL( \
|
||||||
type, name, paramName, instanceName) \
|
type, name, paramName, instanceName) \
|
||||||
void YGNodeStyleSet##name(const YGNodeRef node, const type paramName) { \
|
void YGNodeStyleSet##name(const YGNodeRef node, const type paramName) { \
|
||||||
@ -1021,7 +1004,7 @@ static YGFlexDirection YGFlexDirectionCross(const YGFlexDirection flexDirection,
|
|||||||
static inline bool YGNodeIsFlex(const YGNodeRef node) {
|
static inline bool YGNodeIsFlex(const YGNodeRef node) {
|
||||||
return (
|
return (
|
||||||
node->getStyle().positionType == YGPositionTypeRelative &&
|
node->getStyle().positionType == YGPositionTypeRelative &&
|
||||||
(node->resolveFlexGrow() != 0 || YGNodeResolveFlexShrink(node) != 0));
|
(node->resolveFlexGrow() != 0 || node->resolveFlexShrink() != 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool YGIsBaselineLayout(const YGNodeRef node) {
|
static bool YGIsBaselineLayout(const YGNodeRef node) {
|
||||||
@ -2028,7 +2011,7 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
|||||||
}
|
}
|
||||||
} else if (
|
} else if (
|
||||||
child->resolveFlexGrow() > 0.0f &&
|
child->resolveFlexGrow() > 0.0f &&
|
||||||
YGNodeResolveFlexShrink(child) > 0.0f) {
|
child->resolveFlexShrink() > 0.0f) {
|
||||||
singleFlexChild = child;
|
singleFlexChild = child;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2176,7 +2159,7 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
|||||||
totalFlexGrowFactors += child->resolveFlexGrow();
|
totalFlexGrowFactors += child->resolveFlexGrow();
|
||||||
|
|
||||||
// Unlike the grow factor, the shrink factor is scaled relative to the child dimension.
|
// Unlike the grow factor, the shrink factor is scaled relative to the child dimension.
|
||||||
totalFlexShrinkScaledFactors += -YGNodeResolveFlexShrink(child) *
|
totalFlexShrinkScaledFactors += -child->resolveFlexShrink() *
|
||||||
child->getLayout().computedFlexBasis;
|
child->getLayout().computedFlexBasis;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2296,7 +2279,8 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
|||||||
currentRelativeChild->getLayout().computedFlexBasis));
|
currentRelativeChild->getLayout().computedFlexBasis));
|
||||||
|
|
||||||
if (remainingFreeSpace < 0) {
|
if (remainingFreeSpace < 0) {
|
||||||
flexShrinkScaledFactor = -YGNodeResolveFlexShrink(currentRelativeChild) * childFlexBasis;
|
flexShrinkScaledFactor =
|
||||||
|
-currentRelativeChild->resolveFlexShrink() * childFlexBasis;
|
||||||
|
|
||||||
// Is this child able to shrink?
|
// Is this child able to shrink?
|
||||||
if (flexShrinkScaledFactor != 0) {
|
if (flexShrinkScaledFactor != 0) {
|
||||||
@ -2369,7 +2353,8 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
|||||||
float updatedMainSize = childFlexBasis;
|
float updatedMainSize = childFlexBasis;
|
||||||
|
|
||||||
if (remainingFreeSpace < 0) {
|
if (remainingFreeSpace < 0) {
|
||||||
flexShrinkScaledFactor = -YGNodeResolveFlexShrink(currentRelativeChild) * childFlexBasis;
|
flexShrinkScaledFactor =
|
||||||
|
-currentRelativeChild->resolveFlexShrink() * childFlexBasis;
|
||||||
// Is this child able to shrink?
|
// Is this child able to shrink?
|
||||||
if (flexShrinkScaledFactor != 0) {
|
if (flexShrinkScaledFactor != 0) {
|
||||||
float childSize;
|
float childSize;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user