`YGNodeBoundAxisWithinMinAndMax` accepts `YGFloatOptional`

Summary:
@public

Saves some calls to `.unwrap()`

Reviewed By: SidharthGuglani

Differential Revision: D13209153

fbshipit-source-id: 5658586e91496085f39b3522db6364aaeafcfe2f
This commit is contained in:
David Aurelio 2018-12-06 07:35:10 -08:00 committed by Facebook Github Bot
parent 94ab9b429c
commit f9c575e352
1 changed files with 21 additions and 16 deletions

View File

@ -1209,7 +1209,7 @@ static inline bool YGNodeIsLayoutDimDefined(
static YGFloatOptional YGNodeBoundAxisWithinMinAndMax(
const YGNodeRef node,
const YGFlexDirection axis,
const float value,
const YGFloatOptional value,
const float axisSize) {
YGFloatOptional min;
YGFloatOptional max;
@ -1226,15 +1226,15 @@ static YGFloatOptional YGNodeBoundAxisWithinMinAndMax(
node->getStyle().maxDimensions[YGDimensionWidth], axisSize);
}
if (max >= YGFloatOptional{0} && YGFloatOptional{value} > max) {
if (max >= YGFloatOptional{0} && value > max) {
return max;
}
if (min >= YGFloatOptional{0} && YGFloatOptional{value} < min) {
if (min >= YGFloatOptional{0} && value < min) {
return min;
}
return YGFloatOptional{value};
return value;
}
// Like YGNodeBoundAxisWithinMinAndMax but also ensures that the value doesn't
@ -1246,7 +1246,9 @@ static inline float YGNodeBoundAxis(
const float axisSize,
const float widthSize) {
return YGFloatMax(
(YGNodeBoundAxisWithinMinAndMax(node, axis, value, axisSize)).unwrap(),
(YGNodeBoundAxisWithinMinAndMax(
node, axis, YGFloatOptional{value}, axisSize))
.unwrap(),
YGNodePaddingAndBorderForAxis(node, axis, widthSize));
}
@ -2014,7 +2016,7 @@ static YGCollectFlexItemsRowValues YGCalculateCollectFlexItemsRowValues(
(YGNodeBoundAxisWithinMinAndMax(
child,
mainAxis,
(child->getLayout().computedFlexBasis).unwrap(),
child->getLayout().computedFlexBasis,
mainAxisownerSize))
.unwrap();
@ -2089,13 +2091,12 @@ static float YGDistributeFreeSpaceSecondPass(
const bool isNodeFlexWrap = node->getStyle().flexWrap != YGWrapNoWrap;
for (auto currentRelativeChild : collectedFlexItemsValues.relativeChildren) {
childFlexBasis =
(YGNodeBoundAxisWithinMinAndMax(
currentRelativeChild,
mainAxis,
(currentRelativeChild->getLayout().computedFlexBasis).unwrap(),
mainAxisownerSize))
.unwrap();
childFlexBasis = (YGNodeBoundAxisWithinMinAndMax(
currentRelativeChild,
mainAxis,
currentRelativeChild->getLayout().computedFlexBasis,
mainAxisownerSize))
.unwrap();
float updatedMainSize = childFlexBasis;
if (!YGFloatIsUndefined(collectedFlexItemsValues.remainingFreeSpace) &&
@ -2273,7 +2274,7 @@ static void YGDistributeFreeSpaceFirstPass(
(YGNodeBoundAxisWithinMinAndMax(
currentRelativeChild,
mainAxis,
(currentRelativeChild->getLayout().computedFlexBasis).unwrap(),
currentRelativeChild->getLayout().computedFlexBasis,
mainAxisownerSize))
.unwrap();
@ -3454,7 +3455,10 @@ static void YGNodelayoutImpl(
YGFloatMin(
availableInnerMainDim + paddingAndBorderAxisMain,
(YGNodeBoundAxisWithinMinAndMax(
node, mainAxis, maxLineMainDim, mainAxisownerSize))
node,
mainAxis,
YGFloatOptional{maxLineMainDim},
mainAxisownerSize))
.unwrap()),
paddingAndBorderAxisMain),
dim[mainAxis]);
@ -3484,7 +3488,8 @@ static void YGNodelayoutImpl(
(YGNodeBoundAxisWithinMinAndMax(
node,
crossAxis,
totalLineCrossDim + paddingAndBorderAxisCross,
YGFloatOptional{totalLineCrossDim +
paddingAndBorderAxisCross},
crossAxisownerSize))
.unwrap()),
paddingAndBorderAxisCross),