Skip to content

Commit

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

Differential Revision: D6711991

fbshipit-source-id: 41ad7191bf8df6fe3131106436dc0c87e9dee297
  • Loading branch information
priteshrnandgaonkar authored and facebook-github-bot committed Jan 15, 2018
1 parent 2fe65b0 commit 831a1bb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
6 changes: 6 additions & 0 deletions ReactCommon/yoga/yoga/YGNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -660,3 +660,9 @@ float YGNode::getTrailingPadding(
widthSize),
0.0f);
}

float YGNode::getLeadingPaddingAndBorder(
const YGFlexDirection axis,
const float widthSize) {
return getLeadingPadding(axis, widthSize) + getLeadingBorder(axis);
}
3 changes: 3 additions & 0 deletions ReactCommon/yoga/yoga/YGNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ struct YGNode {
float getTrailingBorder(const YGFlexDirection flexDirection);
float getLeadingPadding(const YGFlexDirection axis, const float widthSize);
float getTrailingPadding(const YGFlexDirection axis, const float widthSize);
float getLeadingPaddingAndBorder(
const YGFlexDirection axis,
const float widthSize);
// Setters

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

static inline float YGNodeLeadingPaddingAndBorder(
const YGNodeRef node,
const YGFlexDirection axis,
const float widthSize) {
return node->getLeadingPadding(axis, widthSize) +
node->getLeadingBorder(axis);
}

static inline float YGNodeTrailingPaddingAndBorder(const YGNodeRef node,
const YGFlexDirection axis,
const float widthSize) {
Expand All @@ -787,8 +779,8 @@ static inline float YGNodeMarginForAxis(const YGNodeRef node,
static inline float YGNodePaddingAndBorderForAxis(const YGNodeRef node,
const YGFlexDirection axis,
const float widthSize) {
return YGNodeLeadingPaddingAndBorder(node, axis, widthSize) +
YGNodeTrailingPaddingAndBorder(node, axis, widthSize);
return node->getLeadingPaddingAndBorder(axis, widthSize) +
YGNodeTrailingPaddingAndBorder(node, axis, widthSize);
}

static inline YGAlign YGNodeAlignItem(const YGNodeRef node, const YGNodeRef child) {
Expand Down Expand Up @@ -1785,11 +1777,11 @@ static void YGNodelayoutImpl(const YGNodeRef node,
YGNodeRef currentAbsoluteChild = nullptr;

const float leadingPaddingAndBorderMain =
YGNodeLeadingPaddingAndBorder(node, mainAxis, parentWidth);
node->getLeadingPaddingAndBorder(mainAxis, parentWidth);
const float trailingPaddingAndBorderMain =
YGNodeTrailingPaddingAndBorder(node, mainAxis, parentWidth);
const float leadingPaddingAndBorderCross =
YGNodeLeadingPaddingAndBorder(node, crossAxis, parentWidth);
node->getLeadingPaddingAndBorder(crossAxis, parentWidth);
const float paddingAndBorderAxisMain = YGNodePaddingAndBorderForAxis(node, mainAxis, parentWidth);
const float paddingAndBorderAxisCross =
YGNodePaddingAndBorderForAxis(node, crossAxis, parentWidth);
Expand Down

0 comments on commit 831a1bb

Please sign in to comment.