Skip to content

Commit 7f94bff

Browse files
Resolve direction function is now as a method on YGNode
Reviewed By: emilsjolander Differential Revision: D6711755 fbshipit-source-id: a0e80596e10f0c7fb7a31b75377da4db846c4bbb
1 parent 8208858 commit 7f94bff

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

ReactCommon/yoga/yoga/YGNode.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,15 @@ void YGNode::resolveDimension() {
510510
}
511511
}
512512

513+
YGDirection YGNode::resolveDirection(const YGDirection parentDirection) {
514+
if (style_.direction == YGDirectionInherit) {
515+
return parentDirection > YGDirectionInherit ? parentDirection
516+
: YGDirectionLTR;
517+
} else {
518+
return style_.direction;
519+
}
520+
}
521+
513522
void YGNode::clearChildren() {
514523
children_.clear();
515524
children_.shrink_to_fit();

ReactCommon/yoga/yoga/YGNode.h

+1
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ struct YGNode {
129129
YGValue marginTrailingValue(const YGFlexDirection axis) const;
130130
YGValue resolveFlexBasisPtr() const;
131131
void resolveDimension();
132+
YGDirection resolveDirection(const YGDirection parentDirection);
132133
void clearChildren();
133134
/// Replaces the occurrences of oldChild with newChild
134135
void replaceChild(YGNodeRef oldChild, YGNodeRef newChild);

ReactCommon/yoga/yoga/Yoga.cpp

+2-12
Original file line numberDiff line numberDiff line change
@@ -837,15 +837,6 @@ static inline YGAlign YGNodeAlignItem(const YGNodeRef node, const YGNodeRef chil
837837
return align;
838838
}
839839

840-
static inline YGDirection YGNodeResolveDirection(const YGNodeRef node,
841-
const YGDirection parentDirection) {
842-
if (node->getStyle().direction == YGDirectionInherit) {
843-
return parentDirection > YGDirectionInherit ? parentDirection : YGDirectionLTR;
844-
} else {
845-
return node->getStyle().direction;
846-
}
847-
}
848-
849840
static float YGBaseline(const YGNodeRef node) {
850841
if (node->getBaseline() != nullptr) {
851842
const float baseline = node->getBaseline()(
@@ -1602,8 +1593,7 @@ static void YGNodeComputeFlexBasisForChildren(
16021593
}
16031594
if (performLayout) {
16041595
// Set the initial position (relative to the parent).
1605-
const YGDirection childDirection =
1606-
YGNodeResolveDirection(child, direction);
1596+
const YGDirection childDirection = child->resolveDirection(direction);
16071597
const float mainDim = YGFlexDirectionIsRow(mainAxis)
16081598
? availableInnerWidth
16091599
: availableInnerHeight;
@@ -1744,7 +1734,7 @@ static void YGNodelayoutImpl(const YGNodeRef node,
17441734
"YGMeasureModeUndefined");
17451735

17461736
// Set the resolved resolution in the node's layout.
1747-
const YGDirection direction = YGNodeResolveDirection(node, parentDirection);
1737+
const YGDirection direction = node->resolveDirection(parentDirection);
17481738
node->setLayoutDirection(direction);
17491739

17501740
const YGFlexDirection flexRowDirection = YGResolveFlexDirection(YGFlexDirectionRow, direction);

0 commit comments

Comments
 (0)