Make the return type of YGNodeBoundAxisWithinMinAndMax to YGFloatOptional
Summary: Make the return type of YGNodeBoundAxisWithinMinAndMax to YGFloatOptional Reviewed By: emilsjolander Differential Revision: D7323382 fbshipit-source-id: 8e3eb4f3744b5f3f9e2b353f56184905f7557191
This commit is contained in:
committed by
Facebook Github Bot
parent
bb139d3f91
commit
a3642541d0
@@ -68,3 +68,25 @@ YGFloatOptional YGFloatOptional::operator+(const YGFloatOptional& op) {
|
|||||||
}
|
}
|
||||||
return YGFloatOptional();
|
return YGFloatOptional();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool YGFloatOptional::operator>(const YGFloatOptional& op) const {
|
||||||
|
if (isUndefined_ || op.isUndefined_) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return value_ > op.value_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool YGFloatOptional::operator<(const YGFloatOptional& op) const {
|
||||||
|
if (isUndefined_ || op.isUndefined_) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return value_ < op.value_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool YGFloatOptional::operator>=(const YGFloatOptional& op) const {
|
||||||
|
return *this == op ? true : *this > op;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool YGFloatOptional::operator<=(const YGFloatOptional& op) const {
|
||||||
|
return *this == op ? true : *this < op;
|
||||||
|
}
|
||||||
|
@@ -25,6 +25,10 @@ struct YGFloatOptional {
|
|||||||
const bool& isUndefined() const;
|
const bool& isUndefined() const;
|
||||||
|
|
||||||
YGFloatOptional operator+(const YGFloatOptional& op);
|
YGFloatOptional operator+(const YGFloatOptional& op);
|
||||||
|
bool operator>(const YGFloatOptional& op) const;
|
||||||
|
bool operator<(const YGFloatOptional& op) const;
|
||||||
|
bool operator>=(const YGFloatOptional& op) const;
|
||||||
|
bool operator<=(const YGFloatOptional& op) const;
|
||||||
bool operator==(const YGFloatOptional& op) const;
|
bool operator==(const YGFloatOptional& op) const;
|
||||||
bool operator!=(const YGFloatOptional& op) const;
|
bool operator!=(const YGFloatOptional& op) const;
|
||||||
|
|
||||||
|
@@ -1117,36 +1117,35 @@ static inline bool YGNodeIsLayoutDimDefined(const YGNodeRef node, const YGFlexDi
|
|||||||
return !YGFloatIsUndefined(value) && value >= 0.0f;
|
return !YGFloatIsUndefined(value) && value >= 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
static float YGNodeBoundAxisWithinMinAndMax(const YGNodeRef node,
|
static YGFloatOptional YGNodeBoundAxisWithinMinAndMax(
|
||||||
const YGFlexDirection axis,
|
const YGNodeRef node,
|
||||||
const float value,
|
const YGFlexDirection& axis,
|
||||||
const float axisSize) {
|
const float& value,
|
||||||
float min = YGUndefined;
|
const float& axisSize) {
|
||||||
float max = YGUndefined;
|
YGFloatOptional min;
|
||||||
|
YGFloatOptional max;
|
||||||
|
|
||||||
if (YGFlexDirectionIsColumn(axis)) {
|
if (YGFlexDirectionIsColumn(axis)) {
|
||||||
min = YGUnwrapFloatOptional(YGResolveValue(
|
min = YGResolveValue(
|
||||||
node->getStyle().minDimensions[YGDimensionHeight], axisSize));
|
node->getStyle().minDimensions[YGDimensionHeight], axisSize);
|
||||||
max = YGUnwrapFloatOptional(YGResolveValue(
|
max = YGResolveValue(
|
||||||
node->getStyle().maxDimensions[YGDimensionHeight], axisSize));
|
node->getStyle().maxDimensions[YGDimensionHeight], axisSize);
|
||||||
} else if (YGFlexDirectionIsRow(axis)) {
|
} else if (YGFlexDirectionIsRow(axis)) {
|
||||||
min = YGUnwrapFloatOptional(YGResolveValue(
|
min = YGResolveValue(
|
||||||
node->getStyle().minDimensions[YGDimensionWidth], axisSize));
|
node->getStyle().minDimensions[YGDimensionWidth], axisSize);
|
||||||
max = YGUnwrapFloatOptional(YGResolveValue(
|
max = YGResolveValue(
|
||||||
node->getStyle().maxDimensions[YGDimensionWidth], axisSize));
|
node->getStyle().maxDimensions[YGDimensionWidth], axisSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
float boundValue = value;
|
if (!max.isUndefined() && max.getValue() >= 0 && value > max.getValue()) {
|
||||||
|
return max;
|
||||||
if (!YGFloatIsUndefined(max) && max >= 0.0f && boundValue > max) {
|
|
||||||
boundValue = max;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!YGFloatIsUndefined(min) && min >= 0.0f && boundValue < min) {
|
if (!min.isUndefined() && min.getValue() >= 0 && value < min.getValue()) {
|
||||||
boundValue = min;
|
return min;
|
||||||
}
|
}
|
||||||
|
|
||||||
return boundValue;
|
return YGFloatOptional(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Like YGNodeBoundAxisWithinMinAndMax but also ensures that the value doesn't go
|
// Like YGNodeBoundAxisWithinMinAndMax but also ensures that the value doesn't go
|
||||||
@@ -1158,7 +1157,8 @@ static inline float YGNodeBoundAxis(const YGNodeRef node,
|
|||||||
const float axisSize,
|
const float axisSize,
|
||||||
const float widthSize) {
|
const float widthSize) {
|
||||||
return YGFloatMax(
|
return YGFloatMax(
|
||||||
YGNodeBoundAxisWithinMinAndMax(node, axis, value, axisSize),
|
YGUnwrapFloatOptional(
|
||||||
|
YGNodeBoundAxisWithinMinAndMax(node, axis, value, axisSize)),
|
||||||
YGNodePaddingAndBorderForAxis(node, axis, widthSize));
|
YGNodePaddingAndBorderForAxis(node, axis, widthSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1876,11 +1876,11 @@ static YGCollectFlexItemsRowValues YGCalculateCollectFlexItemsRowValues(
|
|||||||
const float childMarginMainAxis =
|
const float childMarginMainAxis =
|
||||||
child->getMarginForAxis(mainAxis, availableInnerWidth);
|
child->getMarginForAxis(mainAxis, availableInnerWidth);
|
||||||
const float flexBasisWithMinAndMaxConstraints =
|
const float flexBasisWithMinAndMaxConstraints =
|
||||||
YGNodeBoundAxisWithinMinAndMax(
|
YGUnwrapFloatOptional(YGNodeBoundAxisWithinMinAndMax(
|
||||||
child,
|
child,
|
||||||
mainAxis,
|
mainAxis,
|
||||||
child->getLayout().computedFlexBasis,
|
child->getLayout().computedFlexBasis,
|
||||||
mainAxisownerSize);
|
mainAxisownerSize));
|
||||||
|
|
||||||
// If this is a multi-line flow and this item pushes us over the
|
// If this is a multi-line flow and this item pushes us over the
|
||||||
// available size, we've
|
// available size, we've
|
||||||
@@ -1952,11 +1952,11 @@ 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 = YGNodeBoundAxisWithinMinAndMax(
|
childFlexBasis = YGUnwrapFloatOptional(YGNodeBoundAxisWithinMinAndMax(
|
||||||
currentRelativeChild,
|
currentRelativeChild,
|
||||||
mainAxis,
|
mainAxis,
|
||||||
currentRelativeChild->getLayout().computedFlexBasis,
|
currentRelativeChild->getLayout().computedFlexBasis,
|
||||||
mainAxisownerSize);
|
mainAxisownerSize));
|
||||||
float updatedMainSize = childFlexBasis;
|
float updatedMainSize = childFlexBasis;
|
||||||
|
|
||||||
if (!YGFloatIsUndefined(collectedFlexItemsValues.remainingFreeSpace) &&
|
if (!YGFloatIsUndefined(collectedFlexItemsValues.remainingFreeSpace) &&
|
||||||
@@ -2127,11 +2127,11 @@ static void YGDistributeFreeSpaceFirstPass(
|
|||||||
float deltaFreeSpace = 0;
|
float deltaFreeSpace = 0;
|
||||||
|
|
||||||
for (auto currentRelativeChild : collectedFlexItemsValues.relativeChildren) {
|
for (auto currentRelativeChild : collectedFlexItemsValues.relativeChildren) {
|
||||||
float childFlexBasis = YGNodeBoundAxisWithinMinAndMax(
|
float childFlexBasis = YGUnwrapFloatOptional(YGNodeBoundAxisWithinMinAndMax(
|
||||||
currentRelativeChild,
|
currentRelativeChild,
|
||||||
mainAxis,
|
mainAxis,
|
||||||
currentRelativeChild->getLayout().computedFlexBasis,
|
currentRelativeChild->getLayout().computedFlexBasis,
|
||||||
mainAxisownerSize);
|
mainAxisownerSize));
|
||||||
|
|
||||||
if (collectedFlexItemsValues.remainingFreeSpace < 0) {
|
if (collectedFlexItemsValues.remainingFreeSpace < 0) {
|
||||||
flexShrinkScaledFactor =
|
flexShrinkScaledFactor =
|
||||||
@@ -3217,8 +3217,8 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
|||||||
YGFloatMax(
|
YGFloatMax(
|
||||||
YGFloatMin(
|
YGFloatMin(
|
||||||
availableInnerMainDim + paddingAndBorderAxisMain,
|
availableInnerMainDim + paddingAndBorderAxisMain,
|
||||||
YGNodeBoundAxisWithinMinAndMax(
|
YGUnwrapFloatOptional(YGNodeBoundAxisWithinMinAndMax(
|
||||||
node, mainAxis, maxLineMainDim, mainAxisownerSize)),
|
node, mainAxis, maxLineMainDim, mainAxisownerSize))),
|
||||||
paddingAndBorderAxisMain),
|
paddingAndBorderAxisMain),
|
||||||
dim[mainAxis]);
|
dim[mainAxis]);
|
||||||
}
|
}
|
||||||
@@ -3245,11 +3245,11 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
|||||||
YGFloatMax(
|
YGFloatMax(
|
||||||
YGFloatMin(
|
YGFloatMin(
|
||||||
availableInnerCrossDim + paddingAndBorderAxisCross,
|
availableInnerCrossDim + paddingAndBorderAxisCross,
|
||||||
YGNodeBoundAxisWithinMinAndMax(
|
YGUnwrapFloatOptional(YGNodeBoundAxisWithinMinAndMax(
|
||||||
node,
|
node,
|
||||||
crossAxis,
|
crossAxis,
|
||||||
totalLineCrossDim + paddingAndBorderAxisCross,
|
totalLineCrossDim + paddingAndBorderAxisCross,
|
||||||
crossAxisownerSize)),
|
crossAxisownerSize))),
|
||||||
paddingAndBorderAxisCross),
|
paddingAndBorderAxisCross),
|
||||||
dim[crossAxis]);
|
dim[crossAxis]);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user