`YGNodeBoundAxisWithinMinAndMax` accepts `YGFloatOptional`
Summary: @public Saves some calls to `.unwrap()` Reviewed By: SidharthGuglani Differential Revision: D13439600 fbshipit-source-id: ce0f6bad9a0709e9d64e23d8349bc2423b9b2ad4
This commit is contained in:
parent
3e3972628c
commit
05d90c3013
|
@ -1212,7 +1212,7 @@ static inline bool YGNodeIsLayoutDimDefined(
|
||||||
static YGFloatOptional YGNodeBoundAxisWithinMinAndMax(
|
static YGFloatOptional YGNodeBoundAxisWithinMinAndMax(
|
||||||
const YGNodeRef node,
|
const YGNodeRef node,
|
||||||
const YGFlexDirection axis,
|
const YGFlexDirection axis,
|
||||||
const float value,
|
const YGFloatOptional value,
|
||||||
const float axisSize) {
|
const float axisSize) {
|
||||||
YGFloatOptional min;
|
YGFloatOptional min;
|
||||||
YGFloatOptional max;
|
YGFloatOptional max;
|
||||||
|
@ -1229,15 +1229,15 @@ static YGFloatOptional YGNodeBoundAxisWithinMinAndMax(
|
||||||
node->getStyle().maxDimensions[YGDimensionWidth], axisSize);
|
node->getStyle().maxDimensions[YGDimensionWidth], axisSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!max.isUndefined() && max.unwrap() >= 0 && value > max.unwrap()) {
|
if (max >= YGFloatOptional{0} && value > max) {
|
||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!min.isUndefined() && min.unwrap() >= 0 && value < min.unwrap()) {
|
if (min >= YGFloatOptional{0} && value < min) {
|
||||||
return min;
|
return min;
|
||||||
}
|
}
|
||||||
|
|
||||||
return YGFloatOptional(value);
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Like YGNodeBoundAxisWithinMinAndMax but also ensures that the value doesn't
|
// Like YGNodeBoundAxisWithinMinAndMax but also ensures that the value doesn't
|
||||||
|
@ -1249,7 +1249,9 @@ static inline float YGNodeBoundAxis(
|
||||||
const float axisSize,
|
const float axisSize,
|
||||||
const float widthSize) {
|
const float widthSize) {
|
||||||
return YGFloatMax(
|
return YGFloatMax(
|
||||||
YGNodeBoundAxisWithinMinAndMax(node, axis, value, axisSize).unwrap(),
|
YGNodeBoundAxisWithinMinAndMax(
|
||||||
|
node, axis, YGFloatOptional{value}, axisSize)
|
||||||
|
.unwrap(),
|
||||||
YGNodePaddingAndBorderForAxis(node, axis, widthSize));
|
YGNodePaddingAndBorderForAxis(node, axis, widthSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2021,7 +2023,7 @@ static YGCollectFlexItemsRowValues YGCalculateCollectFlexItemsRowValues(
|
||||||
YGNodeBoundAxisWithinMinAndMax(
|
YGNodeBoundAxisWithinMinAndMax(
|
||||||
child,
|
child,
|
||||||
mainAxis,
|
mainAxis,
|
||||||
child->getLayout().computedFlexBasis.unwrap(),
|
child->getLayout().computedFlexBasis,
|
||||||
mainAxisownerSize)
|
mainAxisownerSize)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
@ -2096,13 +2098,12 @@ static float YGDistributeFreeSpaceSecondPass(
|
||||||
const bool isNodeFlexWrap = node->getStyle().flexWrap != YGWrapNoWrap;
|
const bool isNodeFlexWrap = node->getStyle().flexWrap != YGWrapNoWrap;
|
||||||
|
|
||||||
for (auto currentRelativeChild : collectedFlexItemsValues.relativeChildren) {
|
for (auto currentRelativeChild : collectedFlexItemsValues.relativeChildren) {
|
||||||
childFlexBasis =
|
childFlexBasis = YGNodeBoundAxisWithinMinAndMax(
|
||||||
YGNodeBoundAxisWithinMinAndMax(
|
currentRelativeChild,
|
||||||
currentRelativeChild,
|
mainAxis,
|
||||||
mainAxis,
|
currentRelativeChild->getLayout().computedFlexBasis,
|
||||||
currentRelativeChild->getLayout().computedFlexBasis.unwrap(),
|
mainAxisownerSize)
|
||||||
mainAxisownerSize)
|
.unwrap();
|
||||||
.unwrap();
|
|
||||||
float updatedMainSize = childFlexBasis;
|
float updatedMainSize = childFlexBasis;
|
||||||
|
|
||||||
if (!YGFloatIsUndefined(collectedFlexItemsValues.remainingFreeSpace) &&
|
if (!YGFloatIsUndefined(collectedFlexItemsValues.remainingFreeSpace) &&
|
||||||
|
@ -2280,7 +2281,7 @@ static void YGDistributeFreeSpaceFirstPass(
|
||||||
YGNodeBoundAxisWithinMinAndMax(
|
YGNodeBoundAxisWithinMinAndMax(
|
||||||
currentRelativeChild,
|
currentRelativeChild,
|
||||||
mainAxis,
|
mainAxis,
|
||||||
currentRelativeChild->getLayout().computedFlexBasis.unwrap(),
|
currentRelativeChild->getLayout().computedFlexBasis,
|
||||||
mainAxisownerSize)
|
mainAxisownerSize)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
@ -3458,7 +3459,10 @@ static void YGNodelayoutImpl(
|
||||||
YGFloatMin(
|
YGFloatMin(
|
||||||
availableInnerMainDim + paddingAndBorderAxisMain,
|
availableInnerMainDim + paddingAndBorderAxisMain,
|
||||||
YGNodeBoundAxisWithinMinAndMax(
|
YGNodeBoundAxisWithinMinAndMax(
|
||||||
node, mainAxis, maxLineMainDim, mainAxisownerSize)
|
node,
|
||||||
|
mainAxis,
|
||||||
|
YGFloatOptional{maxLineMainDim},
|
||||||
|
mainAxisownerSize)
|
||||||
.unwrap()),
|
.unwrap()),
|
||||||
paddingAndBorderAxisMain),
|
paddingAndBorderAxisMain),
|
||||||
dim[mainAxis]);
|
dim[mainAxis]);
|
||||||
|
@ -3488,7 +3492,8 @@ static void YGNodelayoutImpl(
|
||||||
YGNodeBoundAxisWithinMinAndMax(
|
YGNodeBoundAxisWithinMinAndMax(
|
||||||
node,
|
node,
|
||||||
crossAxis,
|
crossAxis,
|
||||||
totalLineCrossDim + paddingAndBorderAxisCross,
|
YGFloatOptional{totalLineCrossDim +
|
||||||
|
paddingAndBorderAxisCross},
|
||||||
crossAxisownerSize)
|
crossAxisownerSize)
|
||||||
.unwrap()),
|
.unwrap()),
|
||||||
paddingAndBorderAxisCross),
|
paddingAndBorderAxisCross),
|
||||||
|
|
Loading…
Reference in New Issue