Changed the type of return value of getLeadingPosition to YGFloatOptional

Reviewed By: emilsjolander

Differential Revision: D7344367

fbshipit-source-id: 0f5a667ca357b2ce056c86763aa3e9e4c54b82f0
This commit is contained in:
Pritesh Nandgaonkar 2018-04-04 07:55:42 -07:00 committed by Facebook Github Bot
parent 0186ccf006
commit f3c2ab306c
3 changed files with 21 additions and 15 deletions

View File

@ -85,14 +85,14 @@ std::array<YGValue, 2> YGNode::getResolvedDimensions() const {
return resolvedDimensions_;
}
float YGNode::getLeadingPosition(
const YGFlexDirection axis,
const float axisSize) const {
YGFloatOptional YGNode::getLeadingPosition(
const YGFlexDirection& axis,
const float& axisSize) const {
if (YGFlexDirectionIsRow(axis)) {
const YGValue* leadingPosition =
YGComputedEdgeValue(style_.position, YGEdgeStart, &YGValueUndefined);
if (leadingPosition->unit != YGUnitUndefined) {
return YGUnwrapFloatOptional(YGResolveValue(*leadingPosition, axisSize));
return YGResolveValue(*leadingPosition, axisSize);
}
}
@ -100,8 +100,8 @@ float YGNode::getLeadingPosition(
YGComputedEdgeValue(style_.position, leading[axis], &YGValueUndefined);
return leadingPosition->unit == YGUnitUndefined
? 0.0f
: YGUnwrapFloatOptional(YGResolveValue(*leadingPosition, axisSize));
? YGFloatOptional(0)
: YGResolveValue(*leadingPosition, axisSize);
}
float YGNode::getTrailingPosition(
@ -343,8 +343,9 @@ void YGNode::setLayoutDimension(float dimension, int index) {
float YGNode::relativePosition(
const YGFlexDirection axis,
const float axisSize) {
return isLeadingPositionDefined(axis) ? getLeadingPosition(axis, axisSize)
: -getTrailingPosition(axis, axisSize);
return isLeadingPositionDefined(axis)
? YGUnwrapFloatOptional(getLeadingPosition(axis, axisSize))
: -getTrailingPosition(axis, axisSize);
}
void YGNode::setPosition(

View File

@ -85,7 +85,8 @@ struct YGNode {
YGValue getResolvedDimension(int index);
// Methods related to positions, margin, padding and border
float getLeadingPosition(const YGFlexDirection axis, const float axisSize) const;
YGFloatOptional getLeadingPosition(const YGFlexDirection& axis,
const float& axisSize) const;
bool isLeadingPositionDefined(const YGFlexDirection axis) const;
bool isTrailingPosDefined(const YGFlexDirection axis) const;
float getTrailingPosition(const YGFlexDirection axis, const float axisSize) const;

View File

@ -1408,7 +1408,8 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node,
childWidth = node->getLayout().measuredDimensions[YGDimensionWidth] -
(node->getLeadingBorder(YGFlexDirectionRow) +
node->getTrailingBorder(YGFlexDirectionRow)) -
(child->getLeadingPosition(YGFlexDirectionRow, width) +
(YGUnwrapFloatOptional(
child->getLeadingPosition(YGFlexDirectionRow, width)) +
child->getTrailingPosition(YGFlexDirectionRow, width));
childWidth = YGNodeBoundAxis(child, YGFlexDirectionRow, childWidth, width, width);
}
@ -1427,7 +1428,8 @@ static void YGNodeAbsoluteLayoutChild(const YGNodeRef node,
childHeight = node->getLayout().measuredDimensions[YGDimensionHeight] -
(node->getLeadingBorder(YGFlexDirectionColumn) +
node->getTrailingBorder(YGFlexDirectionColumn)) -
(child->getLeadingPosition(YGFlexDirectionColumn, height) +
(YGUnwrapFloatOptional(
child->getLeadingPosition(YGFlexDirectionColumn, height)) +
child->getTrailingPosition(YGFlexDirectionColumn, height));
childHeight = YGNodeBoundAxis(child, YGFlexDirectionColumn, childHeight, height, width);
}
@ -2390,7 +2392,8 @@ static void YGJustifyMainAxis(
// defined, we override the position to whatever the user said
// (and margin/border).
child->setLayoutPosition(
child->getLeadingPosition(mainAxis, availableInnerMainDim) +
YGUnwrapFloatOptional(
child->getLeadingPosition(mainAxis, availableInnerMainDim)) +
node->getLeadingBorder(mainAxis) +
child->getLeadingMargin(mainAxis, availableInnerWidth),
pos[mainAxis]);
@ -2893,7 +2896,8 @@ static void YGNodelayoutImpl(const YGNodeRef node,
child->isLeadingPositionDefined(crossAxis);
if (isChildLeadingPosDefined) {
child->setLayoutPosition(
child->getLeadingPosition(crossAxis, availableInnerCrossDim) +
YGUnwrapFloatOptional(child->getLeadingPosition(
crossAxis, availableInnerCrossDim)) +
node->getLeadingBorder(crossAxis) +
child->getLeadingMargin(crossAxis, availableInnerWidth),
pos[crossAxis]);
@ -3178,8 +3182,8 @@ static void YGNodelayoutImpl(const YGNodeRef node,
case YGAlignBaseline: {
child->setLayoutPosition(
currentLead + maxAscentForCurrentLine - YGBaseline(child) +
child->getLeadingPosition(
YGFlexDirectionColumn, availableInnerCrossDim),
YGUnwrapFloatOptional(child->getLeadingPosition(
YGFlexDirectionColumn, availableInnerCrossDim)),
YGEdgeTop);
break;