Changed the return type of trailing padding to YGFloatOptional

Reviewed By: emilsjolander

Differential Revision: D7339712

fbshipit-source-id: 483c5886838c14b17cb731c81abb9fc80f519956
This commit is contained in:
Pritesh Nandgaonkar 2018-04-04 07:55:34 -07:00 committed by Facebook Github Bot
parent 51f5cd4810
commit ee0d621d2a
3 changed files with 19 additions and 13 deletions

View File

@ -671,22 +671,21 @@ YGFloatOptional YGNode::getLeadingPadding(
return YGFloatOptionalMax(resolvedValue, YGFloatOptional(0.0f)); return YGFloatOptionalMax(resolvedValue, YGFloatOptional(0.0f));
} }
float YGNode::getTrailingPadding( YGFloatOptional YGNode::getTrailingPadding(
const YGFlexDirection axis, const YGFlexDirection& axis,
const float widthSize) const { const float& widthSize) const {
if (YGFlexDirectionIsRow(axis) && if (YGFlexDirectionIsRow(axis) &&
style_.padding[YGEdgeEnd].unit != YGUnitUndefined && style_.padding[YGEdgeEnd].unit != YGUnitUndefined &&
!YGResolveValue(style_.padding[YGEdgeEnd], widthSize).isUndefined() && !YGResolveValue(style_.padding[YGEdgeEnd], widthSize).isUndefined() &&
YGUnwrapFloatOptional( YGResolveValue(style_.padding[YGEdgeEnd], widthSize).getValue() >= 0.0f) {
YGResolveValue(style_.padding[YGEdgeEnd], widthSize)) >= 0.0f) { return YGResolveValue(style_.padding[YGEdgeEnd], widthSize);
return YGUnwrapFloatOptional(YGResolveValue(style_.padding[YGEdgeEnd], widthSize));
} }
float resolvedValue = YGUnwrapFloatOptional(YGResolveValue( YGFloatOptional resolvedValue = YGResolveValue(
*YGComputedEdgeValue(style_.padding, trailing[axis], &YGValueZero), *YGComputedEdgeValue(style_.padding, trailing[axis], &YGValueZero),
widthSize)); widthSize);
return YGFloatMax(resolvedValue, 0.0f); return YGFloatOptionalMax(resolvedValue, YGFloatOptional(0.0f));
} }
float YGNode::getLeadingPaddingAndBorder( float YGNode::getLeadingPaddingAndBorder(
@ -699,7 +698,8 @@ float YGNode::getLeadingPaddingAndBorder(
float YGNode::getTrailingPaddingAndBorder( float YGNode::getTrailingPaddingAndBorder(
const YGFlexDirection axis, const YGFlexDirection axis,
const float widthSize) const { const float widthSize) const {
return getTrailingPadding(axis, widthSize) + getTrailingBorder(axis); return YGUnwrapFloatOptional(getTrailingPadding(axis, widthSize)) +
getTrailingBorder(axis);
} }
bool YGNode::didUseLegacyFlag() { bool YGNode::didUseLegacyFlag() {

View File

@ -96,7 +96,9 @@ struct YGNode {
YGFloatOptional getLeadingPadding( YGFloatOptional getLeadingPadding(
const YGFlexDirection& axis, const YGFlexDirection& axis,
const float& widthSize) const; const float& widthSize) const;
float getTrailingPadding(const YGFlexDirection axis, const float widthSize) const; YGFloatOptional getTrailingPadding(
const YGFlexDirection& axis,
const float& widthSize) const;
float getLeadingPaddingAndBorder( float getLeadingPaddingAndBorder(
const YGFlexDirection axis, const YGFlexDirection axis,
const float widthSize) const; const float widthSize) const;

View File

@ -2577,13 +2577,17 @@ static void YGNodelayoutImpl(const YGNodeRef node,
node->getLeadingPadding(flexRowDirection, ownerWidth)), node->getLeadingPadding(flexRowDirection, ownerWidth)),
YGEdgeStart); YGEdgeStart);
node->setLayoutPadding( node->setLayoutPadding(
node->getTrailingPadding(flexRowDirection, ownerWidth), YGEdgeEnd); YGUnwrapFloatOptional(
node->getTrailingPadding(flexRowDirection, ownerWidth)),
YGEdgeEnd);
node->setLayoutPadding( node->setLayoutPadding(
YGUnwrapFloatOptional( YGUnwrapFloatOptional(
node->getLeadingPadding(flexColumnDirection, ownerWidth)), node->getLeadingPadding(flexColumnDirection, ownerWidth)),
YGEdgeTop); YGEdgeTop);
node->setLayoutPadding( node->setLayoutPadding(
node->getTrailingPadding(flexColumnDirection, ownerWidth), YGEdgeBottom); YGUnwrapFloatOptional(
node->getTrailingPadding(flexColumnDirection, ownerWidth)),
YGEdgeBottom);
if (node->getMeasure() != nullptr) { if (node->getMeasure() != nullptr) {
YGNodeWithMeasureFuncSetMeasuredDimensions(node, YGNodeWithMeasureFuncSetMeasuredDimensions(node,