Skip to content

Commit 2b27f1a

Browse files
Moved YGNodeIsFlex as a method on YGNode
Reviewed By: emilsjolander Differential Revision: D6711536 fbshipit-source-id: e60be7da55e3e8d254eb253c141d219a37a76087
1 parent fcf2c7c commit 2b27f1a

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

ReactCommon/yoga/yoga/YGNode.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -590,3 +590,9 @@ float YGNode::resolveFlexShrink() {
590590
}
591591
return config_->useWebDefaults ? kWebDefaultFlexShrink : kDefaultFlexShrink;
592592
}
593+
594+
bool YGNode::isNodeFlexible() {
595+
return (
596+
(style_.positionType == YGPositionTypeRelative) &&
597+
(resolveFlexGrow() != 0 || resolveFlexShrink() != 0));
598+
}

ReactCommon/yoga/yoga/YGNode.h

+6-7
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,11 @@ struct YGNode {
111111
void setLayoutMeasuredDimension(float measuredDimension, int index);
112112
void setLayoutHadOverflow(bool hadOverflow);
113113
void setLayoutDimension(float dimension, int index);
114-
114+
void setLayoutDirection(YGDirection direction);
115+
void setLayoutMargin(float margin, int index);
116+
void setLayoutBorder(float border, int index);
117+
void setLayoutPadding(float padding, int index);
118+
void setLayoutPosition(float position, int index);
115119
void setPosition(
116120
const YGDirection direction,
117121
const float mainSize,
@@ -131,15 +135,10 @@ struct YGNode {
131135
/// Removes the first occurrence of child
132136
bool removeChild(YGNodeRef child);
133137
void removeChild(uint32_t index);
134-
void setLayoutDirection(YGDirection direction);
135-
void setLayoutMargin(float margin, int index);
136-
void setLayoutBorder(float border, int index);
137-
void setLayoutPadding(float padding, int index);
138-
void setLayoutPosition(float position, int index);
139138

140-
// Other methods
141139
void cloneChildrenIfNeeded();
142140
void markDirtyAndPropogate();
143141
float resolveFlexGrow();
144142
float resolveFlexShrink();
143+
bool isNodeFlexible();
145144
};

ReactCommon/yoga/yoga/Yoga.cpp

+2-8
Original file line numberDiff line numberDiff line change
@@ -915,12 +915,6 @@ static float YGBaseline(const YGNodeRef node) {
915915
return baseline + baselineChild->getLayout().position[YGEdgeTop];
916916
}
917917

918-
static inline bool YGNodeIsFlex(const YGNodeRef node) {
919-
return (
920-
node->getStyle().positionType == YGPositionTypeRelative &&
921-
(node->resolveFlexGrow() != 0 || node->resolveFlexShrink() != 0));
922-
}
923-
924918
static bool YGIsBaselineLayout(const YGNodeRef node) {
925919
if (YGFlexDirectionIsColumn(node->getStyle().flexDirection)) {
926920
return false;
@@ -1611,7 +1605,7 @@ static void YGNodeComputeFlexBasisForChildren(
16111605
if (measureModeMainDim == YGMeasureModeExactly) {
16121606
for (auto child : children) {
16131607
if (singleFlexChild != nullptr) {
1614-
if (YGNodeIsFlex(child)) {
1608+
if (child->isNodeFlexible()) {
16151609
// There is already a flexible child, abort
16161610
singleFlexChild = nullptr;
16171611
break;
@@ -2033,7 +2027,7 @@ static void YGNodelayoutImpl(const YGNodeRef node,
20332027
sizeConsumedOnCurrentLine += flexBasisWithMinAndMaxConstraints + childMarginMainAxis;
20342028
itemsOnLine++;
20352029

2036-
if (YGNodeIsFlex(child)) {
2030+
if (child->isNodeFlexible()) {
20372031
totalFlexGrowFactors += child->resolveFlexGrow();
20382032

20392033
// Unlike the grow factor, the shrink factor is scaled relative to the child dimension.

0 commit comments

Comments
 (0)