Skip to content

Commit

Permalink
Resolve direction function is now as a method on YGNode
Browse files Browse the repository at this point in the history
Reviewed By: emilsjolander

Differential Revision: D6711755

fbshipit-source-id: a0e80596e10f0c7fb7a31b75377da4db846c4bbb
  • Loading branch information
priteshrnandgaonkar authored and facebook-github-bot committed Jan 15, 2018
1 parent 8208858 commit 7f94bff
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
9 changes: 9 additions & 0 deletions ReactCommon/yoga/yoga/YGNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,15 @@ void YGNode::resolveDimension() {
}
}

YGDirection YGNode::resolveDirection(const YGDirection parentDirection) {
if (style_.direction == YGDirectionInherit) {
return parentDirection > YGDirectionInherit ? parentDirection
: YGDirectionLTR;
} else {
return style_.direction;
}
}

void YGNode::clearChildren() {
children_.clear();
children_.shrink_to_fit();
Expand Down
1 change: 1 addition & 0 deletions ReactCommon/yoga/yoga/YGNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ struct YGNode {
YGValue marginTrailingValue(const YGFlexDirection axis) const;
YGValue resolveFlexBasisPtr() const;
void resolveDimension();
YGDirection resolveDirection(const YGDirection parentDirection);
void clearChildren();
/// Replaces the occurrences of oldChild with newChild
void replaceChild(YGNodeRef oldChild, YGNodeRef newChild);
Expand Down
14 changes: 2 additions & 12 deletions ReactCommon/yoga/yoga/Yoga.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -837,15 +837,6 @@ static inline YGAlign YGNodeAlignItem(const YGNodeRef node, const YGNodeRef chil
return align;
}

static inline YGDirection YGNodeResolveDirection(const YGNodeRef node,
const YGDirection parentDirection) {
if (node->getStyle().direction == YGDirectionInherit) {
return parentDirection > YGDirectionInherit ? parentDirection : YGDirectionLTR;
} else {
return node->getStyle().direction;
}
}

static float YGBaseline(const YGNodeRef node) {
if (node->getBaseline() != nullptr) {
const float baseline = node->getBaseline()(
Expand Down Expand Up @@ -1602,8 +1593,7 @@ static void YGNodeComputeFlexBasisForChildren(
}
if (performLayout) {
// Set the initial position (relative to the parent).
const YGDirection childDirection =
YGNodeResolveDirection(child, direction);
const YGDirection childDirection = child->resolveDirection(direction);
const float mainDim = YGFlexDirectionIsRow(mainAxis)
? availableInnerWidth
: availableInnerHeight;
Expand Down Expand Up @@ -1744,7 +1734,7 @@ static void YGNodelayoutImpl(const YGNodeRef node,
"YGMeasureModeUndefined");

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

const YGFlexDirection flexRowDirection = YGResolveFlexDirection(YGFlexDirectionRow, direction);
Expand Down

0 comments on commit 7f94bff

Please sign in to comment.