Remove the use of YGUnwrapOptional from YGConstrainedMaxSizeForMode
Reviewed By: emilsjolander Differential Revision: D7322743 fbshipit-source-id: d825c60bcdc9ecdc0c784a215dc6b1b8a7a7860e
This commit is contained in:
parent
2ace555972
commit
dbb2c6b0fd
|
@ -10,8 +10,16 @@
|
|||
#include <iostream>
|
||||
#include "Yoga.h"
|
||||
|
||||
YGFloatOptional::YGFloatOptional(const float& value)
|
||||
: value_(value), isUndefined_(false) {}
|
||||
YGFloatOptional::YGFloatOptional(const float& value) {
|
||||
if (YGFloatIsUndefined(value)) {
|
||||
isUndefined_ = true;
|
||||
value_ = 0;
|
||||
} else {
|
||||
value_ = value;
|
||||
isUndefined_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
YGFloatOptional::YGFloatOptional() : value_(0), isUndefined_(true) {}
|
||||
|
||||
const float& YGFloatOptional::getValue() const {
|
||||
|
@ -53,3 +61,10 @@ bool YGFloatOptional::operator==(const float& val) const {
|
|||
bool YGFloatOptional::operator!=(const float& val) const {
|
||||
return !(*this == val);
|
||||
}
|
||||
|
||||
YGFloatOptional YGFloatOptional::operator+(const YGFloatOptional& op) {
|
||||
if (!isUndefined_ && !op.isUndefined_) {
|
||||
return YGFloatOptional(value_ + op.value_);
|
||||
}
|
||||
return YGFloatOptional();
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ struct YGFloatOptional {
|
|||
|
||||
const bool& isUndefined() const;
|
||||
|
||||
YGFloatOptional operator+(const YGFloatOptional& op);
|
||||
bool operator==(const YGFloatOptional& op) const;
|
||||
bool operator!=(const YGFloatOptional& op) const;
|
||||
|
||||
|
|
|
@ -167,6 +167,7 @@ float YGNode::getTrailingMargin(
|
|||
widthSize));
|
||||
}
|
||||
|
||||
// TODO: Make its return type to YGFloatOptional
|
||||
float YGNode::getMarginForAxis(
|
||||
const YGFlexDirection axis,
|
||||
const float widthSize) const {
|
||||
|
|
|
@ -1178,19 +1178,21 @@ static void YGConstrainMaxSizeForMode(const YGNodeRef node,
|
|||
const float ownerWidth,
|
||||
YGMeasureMode *mode,
|
||||
float *size) {
|
||||
const float maxSize =
|
||||
YGUnwrapFloatOptional(YGResolveValue(
|
||||
node->getStyle().maxDimensions[dim[axis]], ownerAxisSize)) +
|
||||
node->getMarginForAxis(axis, ownerWidth);
|
||||
const YGFloatOptional maxSize =
|
||||
YGResolveValue(
|
||||
node->getStyle().maxDimensions[dim[axis]], ownerAxisSize) +
|
||||
YGFloatOptional(node->getMarginForAxis(axis, ownerWidth));
|
||||
switch (*mode) {
|
||||
case YGMeasureModeExactly:
|
||||
case YGMeasureModeAtMost:
|
||||
*size = (YGFloatIsUndefined(maxSize) || *size < maxSize) ? *size : maxSize;
|
||||
*size = (maxSize.isUndefined() || *size < maxSize.getValue())
|
||||
? *size
|
||||
: maxSize.getValue();
|
||||
break;
|
||||
case YGMeasureModeUndefined:
|
||||
if (!YGFloatIsUndefined(maxSize)) {
|
||||
if (!maxSize.isUndefined()) {
|
||||
*mode = YGMeasureModeAtMost;
|
||||
*size = maxSize;
|
||||
*size = maxSize.getValue();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue