Skip to content

Commit 2fe65b0

Browse files
priteshrnandgaonkarfacebook-github-bot
authored andcommittedJan 15, 2018
Move trailing padding function as a method on YGNode
Reviewed By: emilsjolander Differential Revision: D6711897 fbshipit-source-id: fa2e1a8e31242358a6e94aef51368e2c2c58b79d
1 parent bd7bf94 commit 2fe65b0

File tree

3 files changed

+19
-21
lines changed

3 files changed

+19
-21
lines changed
 

‎ReactCommon/yoga/yoga/YGNode.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -645,3 +645,18 @@ float YGNode::getLeadingPadding(
645645
widthSize),
646646
0.0f);
647647
}
648+
649+
float YGNode::getTrailingPadding(
650+
const YGFlexDirection axis,
651+
const float widthSize) {
652+
if (YGFlexDirectionIsRow(axis) &&
653+
style_.padding[YGEdgeEnd].unit != YGUnitUndefined &&
654+
YGResolveValue(style_.padding[YGEdgeEnd], widthSize) >= 0.0f) {
655+
return YGResolveValue(style_.padding[YGEdgeEnd], widthSize);
656+
}
657+
return fmaxf(
658+
YGResolveValue(
659+
*YGComputedEdgeValue(style_.padding, trailing[axis], &YGValueZero),
660+
widthSize),
661+
0.0f);
662+
}

‎ReactCommon/yoga/yoga/YGNode.h

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ struct YGNode {
8989
float getLeadingBorder(const YGFlexDirection flexDirection);
9090
float getTrailingBorder(const YGFlexDirection flexDirection);
9191
float getLeadingPadding(const YGFlexDirection axis, const float widthSize);
92+
float getTrailingPadding(const YGFlexDirection axis, const float widthSize);
9293
// Setters
9394

9495
void setContext(void* context);

‎ReactCommon/yoga/yoga/Yoga.cpp

+3-21
Original file line numberDiff line numberDiff line change
@@ -762,23 +762,6 @@ static const std::array<YGEdge, 4> pos = {{
762762
static const std::array<YGDimension, 4> dim = {
763763
{YGDimensionHeight, YGDimensionHeight, YGDimensionWidth, YGDimensionWidth}};
764764

765-
static float YGNodeTrailingPadding(const YGNodeRef node,
766-
const YGFlexDirection axis,
767-
const float widthSize) {
768-
if (YGFlexDirectionIsRow(axis) &&
769-
node->getStyle().padding[YGEdgeEnd].unit != YGUnitUndefined &&
770-
YGResolveValue(node->getStyle().padding[YGEdgeEnd], widthSize) >= 0.0f) {
771-
return YGResolveValue(node->getStyle().padding[YGEdgeEnd], widthSize);
772-
}
773-
774-
return fmaxf(
775-
YGResolveValue(
776-
*YGComputedEdgeValue(
777-
node->getStyle().padding, trailing[axis], &YGValueZero),
778-
widthSize),
779-
0.0f);
780-
}
781-
782765
static inline float YGNodeLeadingPaddingAndBorder(
783766
const YGNodeRef node,
784767
const YGFlexDirection axis,
@@ -790,7 +773,7 @@ static inline float YGNodeLeadingPaddingAndBorder(
790773
static inline float YGNodeTrailingPaddingAndBorder(const YGNodeRef node,
791774
const YGFlexDirection axis,
792775
const float widthSize) {
793-
return YGNodeTrailingPadding(node, axis, widthSize) +
776+
return node->getTrailingPadding(axis, widthSize) +
794777
node->getTrailingBorder(axis);
795778
}
796779

@@ -1741,12 +1724,11 @@ static void YGNodelayoutImpl(const YGNodeRef node,
17411724
node->setLayoutPadding(
17421725
node->getLeadingPadding(flexRowDirection, parentWidth), YGEdgeStart);
17431726
node->setLayoutPadding(
1744-
YGNodeTrailingPadding(node, flexRowDirection, parentWidth), YGEdgeEnd);
1727+
node->getTrailingPadding(flexRowDirection, parentWidth), YGEdgeEnd);
17451728
node->setLayoutPadding(
17461729
node->getLeadingPadding(flexColumnDirection, parentWidth), YGEdgeTop);
17471730
node->setLayoutPadding(
1748-
YGNodeTrailingPadding(node, flexColumnDirection, parentWidth),
1749-
YGEdgeBottom);
1731+
node->getTrailingPadding(flexColumnDirection, parentWidth), YGEdgeBottom);
17501732

17511733
if (node->getMeasure() != nullptr) {
17521734
YGNodeWithMeasureFuncSetMeasuredDimensions(node,

0 commit comments

Comments
 (0)