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