Skip to content

Commit

Permalink
Moved trailing padding and border function as a method on YGNode
Browse files Browse the repository at this point in the history
Reviewed By: emilsjolander

Differential Revision: D6899571

fbshipit-source-id: 7f686e8771d5a94aae502191516557b20c557d7c
  • Loading branch information
priteshrnandgaonkar authored and facebook-github-bot committed Feb 6, 2018
1 parent 9daa174 commit 1475fc4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
6 changes: 6 additions & 0 deletions ReactCommon/yoga/yoga/YGNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,12 @@ float YGNode::getLeadingPaddingAndBorder(
return getLeadingPadding(axis, widthSize) + getLeadingBorder(axis);
}

float YGNode::getTrailingPaddingAndBorder(
const YGFlexDirection axis,
const float widthSize) {
return getTrailingPadding(axis, widthSize) + getTrailingBorder(axis);
}

bool YGNode::didUseLegacyFlag() {
bool didUseLegacyFlag = layout_.didUseLegacyFlag;
if (didUseLegacyFlag) {
Expand Down
3 changes: 3 additions & 0 deletions ReactCommon/yoga/yoga/YGNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ struct YGNode {
float getLeadingPaddingAndBorder(
const YGFlexDirection axis,
const float widthSize);
float getTrailingPaddingAndBorder(
const YGFlexDirection axis,
const float widthSize);
// Setters

void setContext(void* context);
Expand Down
11 changes: 2 additions & 9 deletions ReactCommon/yoga/yoga/Yoga.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -797,13 +797,6 @@ static const std::array<YGEdge, 4> pos = {{
static const std::array<YGDimension, 4> dim = {
{YGDimensionHeight, YGDimensionHeight, YGDimensionWidth, YGDimensionWidth}};

static inline float YGNodeTrailingPaddingAndBorder(const YGNodeRef node,
const YGFlexDirection axis,
const float widthSize) {
return node->getTrailingPadding(axis, widthSize) +
node->getTrailingBorder(axis);
}

static inline float YGNodeMarginForAxis(const YGNodeRef node,
const YGFlexDirection axis,
const float widthSize) {
Expand All @@ -815,7 +808,7 @@ static inline float YGNodePaddingAndBorderForAxis(const YGNodeRef node,
const YGFlexDirection axis,
const float widthSize) {
return node->getLeadingPaddingAndBorder(axis, widthSize) +
YGNodeTrailingPaddingAndBorder(node, axis, widthSize);
node->getTrailingPaddingAndBorder(axis, widthSize);
}

static inline YGAlign YGNodeAlignItem(const YGNodeRef node, const YGNodeRef child) {
Expand Down Expand Up @@ -2202,7 +2195,7 @@ static void YGJustifyMainAxis(
}
}
collectedFlexItemsValues.mainDim +=
YGNodeTrailingPaddingAndBorder(node, mainAxis, parentWidth);
node->getTrailingPaddingAndBorder(mainAxis, parentWidth);
}

//
Expand Down

0 comments on commit 1475fc4

Please sign in to comment.