Skip to content

Commit

Permalink
Changed the return type of YGResolveValueMargin to YGFloatOptional
Browse files Browse the repository at this point in the history
Summary: Changed the return type of YGResolveValueMargin to YGFloatOptional

Reviewed By: emilsjolander

Differential Revision: D7304090

fbshipit-source-id: cbec03a9367cf34976d083ad475d4da0b736e6d2
  • Loading branch information
priteshrnandgaonkar authored and facebook-github-bot committed Apr 3, 2018
1 parent 5730be0 commit 4b760fa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
5 changes: 3 additions & 2 deletions yoga/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,9 @@ inline YGFlexDirection YGResolveFlexDirection(
return flexDirection;
}

static inline float YGResolveValueMargin(
static inline YGFloatOptional YGResolveValueMargin(
const YGValue value,
const float ownerSize) {
return value.unit == YGUnitAuto ? 0 : YGUnwrapFloatOptional(YGResolveValue(value, ownerSize));
return value.unit == YGUnitAuto ? YGFloatOptional(0)
: YGResolveValue(value, ownerSize);
}
14 changes: 8 additions & 6 deletions yoga/YGNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,25 +144,27 @@ float YGNode::getLeadingMargin(
const float widthSize) const {
if (YGFlexDirectionIsRow(axis) &&
style_.margin[YGEdgeStart].unit != YGUnitUndefined) {
return YGResolveValueMargin(style_.margin[YGEdgeStart], widthSize);
return YGUnwrapFloatOptional(
YGResolveValueMargin(style_.margin[YGEdgeStart], widthSize));
}

return YGResolveValueMargin(
return YGUnwrapFloatOptional(YGResolveValueMargin(
*YGComputedEdgeValue(style_.margin, leading[axis], &YGValueZero),
widthSize);
widthSize));
}

float YGNode::getTrailingMargin(
const YGFlexDirection axis,
const float widthSize) const {
if (YGFlexDirectionIsRow(axis) &&
style_.margin[YGEdgeEnd].unit != YGUnitUndefined) {
return YGResolveValueMargin(style_.margin[YGEdgeEnd], widthSize);
return YGUnwrapFloatOptional(
YGResolveValueMargin(style_.margin[YGEdgeEnd], widthSize));
}

return YGResolveValueMargin(
return YGUnwrapFloatOptional(YGResolveValueMargin(
*YGComputedEdgeValue(style_.margin, trailing[axis], &YGValueZero),
widthSize);
widthSize));
}

float YGNode::getMarginForAxis(
Expand Down

0 comments on commit 4b760fa

Please sign in to comment.