Moved YGFloatOptional from C struct to C++ struct
Reviewed By: emilsjolander Differential Revision: D7288555 fbshipit-source-id: f61cc92c8fd0d48d2fc1f4d0e6fcef155f19ff8a
This commit is contained in:
Родитель
ce92b8592b
Коммит
9102ff94e7
|
@ -978,6 +978,10 @@
|
||||||
53D1239F1FBF1EFB001B8A10 /* Yoga-internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 53CBF1851FB4FE80002CBB31 /* Yoga-internal.h */; };
|
53D1239F1FBF1EFB001B8A10 /* Yoga-internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 53CBF1851FB4FE80002CBB31 /* Yoga-internal.h */; };
|
||||||
53D123A01FBF1EFF001B8A10 /* Yoga.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53CBF1871FB4FE80002CBB31 /* Yoga.cpp */; };
|
53D123A01FBF1EFF001B8A10 /* Yoga.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53CBF1871FB4FE80002CBB31 /* Yoga.cpp */; };
|
||||||
53D123A11FBF1EFF001B8A10 /* Yoga.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53CBF1871FB4FE80002CBB31 /* Yoga.cpp */; };
|
53D123A11FBF1EFF001B8A10 /* Yoga.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53CBF1871FB4FE80002CBB31 /* Yoga.cpp */; };
|
||||||
|
53DEF6EA205AE5A0006A3890 /* YGFloatOptional.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53DEF6E6205AE59B006A3890 /* YGFloatOptional.cpp */; };
|
||||||
|
53DEF6EB205AE5A1006A3890 /* YGFloatOptional.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53DEF6E6205AE59B006A3890 /* YGFloatOptional.cpp */; };
|
||||||
|
53DEF6EC205AE5A6006A3890 /* YGFloatOptional.h in Headers */ = {isa = PBXBuildFile; fileRef = 53DEF6E7205AE59C006A3890 /* YGFloatOptional.h */; };
|
||||||
|
53DEF6ED205AE5A7006A3890 /* YGFloatOptional.h in Headers */ = {isa = PBXBuildFile; fileRef = 53DEF6E7205AE59C006A3890 /* YGFloatOptional.h */; };
|
||||||
53EC85E21FDEC75F0051B2B5 /* YGNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53EC85DF1FDEC75A0051B2B5 /* YGNode.cpp */; };
|
53EC85E21FDEC75F0051B2B5 /* YGNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53EC85DF1FDEC75A0051B2B5 /* YGNode.cpp */; };
|
||||||
53EC85E31FDEC75F0051B2B5 /* YGNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53EC85DF1FDEC75A0051B2B5 /* YGNode.cpp */; };
|
53EC85E31FDEC75F0051B2B5 /* YGNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53EC85DF1FDEC75A0051B2B5 /* YGNode.cpp */; };
|
||||||
53EC85E41FDEC7630051B2B5 /* YGNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 53EC85DE1FDEC75A0051B2B5 /* YGNode.h */; };
|
53EC85E41FDEC7630051B2B5 /* YGNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 53EC85DE1FDEC75A0051B2B5 /* YGNode.h */; };
|
||||||
|
@ -2169,6 +2173,8 @@
|
||||||
53CBF1861FB4FE80002CBB31 /* YGEnums.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = YGEnums.cpp; sourceTree = "<group>"; };
|
53CBF1861FB4FE80002CBB31 /* YGEnums.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = YGEnums.cpp; sourceTree = "<group>"; };
|
||||||
53CBF1871FB4FE80002CBB31 /* Yoga.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Yoga.cpp; sourceTree = "<group>"; };
|
53CBF1871FB4FE80002CBB31 /* Yoga.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Yoga.cpp; sourceTree = "<group>"; };
|
||||||
53D123831FBF1D49001B8A10 /* libyoga.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libyoga.a; path = "../../../../../../../../../Library/Developer/Xcode/DerivedData/yoga-hdfifpwsinitsibujacpiefkjfdy/Build/Products/Debug/libyoga.a"; sourceTree = "<group>"; };
|
53D123831FBF1D49001B8A10 /* libyoga.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libyoga.a; path = "../../../../../../../../../Library/Developer/Xcode/DerivedData/yoga-hdfifpwsinitsibujacpiefkjfdy/Build/Products/Debug/libyoga.a"; sourceTree = "<group>"; };
|
||||||
|
53DEF6E6205AE59B006A3890 /* YGFloatOptional.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = YGFloatOptional.cpp; sourceTree = "<group>"; };
|
||||||
|
53DEF6E7205AE59C006A3890 /* YGFloatOptional.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YGFloatOptional.h; sourceTree = "<group>"; };
|
||||||
53EC85DE1FDEC75A0051B2B5 /* YGNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YGNode.h; sourceTree = "<group>"; };
|
53EC85DE1FDEC75A0051B2B5 /* YGNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YGNode.h; sourceTree = "<group>"; };
|
||||||
53EC85DF1FDEC75A0051B2B5 /* YGNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = YGNode.cpp; sourceTree = "<group>"; };
|
53EC85DF1FDEC75A0051B2B5 /* YGNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = YGNode.cpp; sourceTree = "<group>"; };
|
||||||
58114A121AAE854800E7D092 /* RCTPicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTPicker.h; sourceTree = "<group>"; };
|
58114A121AAE854800E7D092 /* RCTPicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTPicker.h; sourceTree = "<group>"; };
|
||||||
|
@ -2349,6 +2355,8 @@
|
||||||
130A77021DF767AF001F9587 /* yoga */ = {
|
130A77021DF767AF001F9587 /* yoga */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
53DEF6E6205AE59B006A3890 /* YGFloatOptional.cpp */,
|
||||||
|
53DEF6E7205AE59C006A3890 /* YGFloatOptional.h */,
|
||||||
5343895E203905B6008E0CB3 /* YGLayout.cpp */,
|
5343895E203905B6008E0CB3 /* YGLayout.cpp */,
|
||||||
5343895F203905B6008E0CB3 /* YGLayout.h */,
|
5343895F203905B6008E0CB3 /* YGLayout.h */,
|
||||||
5352C5722038FF8D00A3B97E /* YGStyle.cpp */,
|
5352C5722038FF8D00A3B97E /* YGStyle.cpp */,
|
||||||
|
@ -3299,6 +3307,7 @@
|
||||||
5376C5E71FC6DDC20083513D /* YGNodePrint.h in Headers */,
|
5376C5E71FC6DDC20083513D /* YGNodePrint.h in Headers */,
|
||||||
3DFE0D191DF8574D00459392 /* Yoga.h in Headers */,
|
3DFE0D191DF8574D00459392 /* Yoga.h in Headers */,
|
||||||
53438965203905C0008E0CB3 /* YGLayout.h in Headers */,
|
53438965203905C0008E0CB3 /* YGLayout.h in Headers */,
|
||||||
|
53DEF6ED205AE5A7006A3890 /* YGFloatOptional.h in Headers */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
@ -3379,6 +3388,7 @@
|
||||||
5376C5E61FC6DDC10083513D /* YGNodePrint.h in Headers */,
|
5376C5E61FC6DDC10083513D /* YGNodePrint.h in Headers */,
|
||||||
133957891DF76D3500EC27BE /* YGMacros.h in Headers */,
|
133957891DF76D3500EC27BE /* YGMacros.h in Headers */,
|
||||||
53438964203905BF008E0CB3 /* YGLayout.h in Headers */,
|
53438964203905BF008E0CB3 /* YGLayout.h in Headers */,
|
||||||
|
53DEF6EC205AE5A6006A3890 /* YGFloatOptional.h in Headers */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
@ -4318,6 +4328,7 @@
|
||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
53DEF6EA205AE5A0006A3890 /* YGFloatOptional.cpp in Sources */,
|
||||||
53D123A01FBF1EFF001B8A10 /* Yoga.cpp in Sources */,
|
53D123A01FBF1EFF001B8A10 /* Yoga.cpp in Sources */,
|
||||||
5352C5752038FF9500A3B97E /* YGStyle.cpp in Sources */,
|
5352C5752038FF9500A3B97E /* YGStyle.cpp in Sources */,
|
||||||
53EC85E21FDEC75F0051B2B5 /* YGNode.cpp in Sources */,
|
53EC85E21FDEC75F0051B2B5 /* YGNode.cpp in Sources */,
|
||||||
|
@ -4332,6 +4343,7 @@
|
||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
53DEF6EB205AE5A1006A3890 /* YGFloatOptional.cpp in Sources */,
|
||||||
53D123A11FBF1EFF001B8A10 /* Yoga.cpp in Sources */,
|
53D123A11FBF1EFF001B8A10 /* Yoga.cpp in Sources */,
|
||||||
5352C5762038FF9700A3B97E /* YGStyle.cpp in Sources */,
|
5352C5762038FF9700A3B97E /* YGStyle.cpp in Sources */,
|
||||||
53EC85E31FDEC75F0051B2B5 /* YGNode.cpp in Sources */,
|
53EC85E31FDEC75F0051B2B5 /* YGNode.cpp in Sources */,
|
||||||
|
|
|
@ -55,7 +55,7 @@ float YGFloatSanitize(const float& val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
float YGUnwrapFloatOptional(const YGFloatOptional& op) {
|
float YGUnwrapFloatOptional(const YGFloatOptional& op) {
|
||||||
return op.isUndefined ? YGUndefined : op.value;
|
return op.isUndefined() ? YGUndefined : op.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool YGFloatOptionalFloatEquals(
|
bool YGFloatOptionalFloatEquals(
|
||||||
|
|
|
@ -113,13 +113,14 @@ inline YGFloatOptional YGResolveValue(const YGValue value, const float parentSiz
|
||||||
switch (value.unit) {
|
switch (value.unit) {
|
||||||
case YGUnitUndefined:
|
case YGUnitUndefined:
|
||||||
case YGUnitAuto:
|
case YGUnitAuto:
|
||||||
return {true, 0};
|
return YGFloatOptional();
|
||||||
case YGUnitPoint:
|
case YGUnitPoint:
|
||||||
return {false, value.value};
|
return YGFloatOptional(value.value);
|
||||||
case YGUnitPercent:
|
case YGUnitPercent:
|
||||||
return {false, static_cast<float>(value.value * parentSize * 0.01)};
|
return YGFloatOptional(
|
||||||
|
static_cast<float>(value.value * parentSize * 0.01));
|
||||||
}
|
}
|
||||||
return {true, 0};
|
return YGFloatOptional();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool YGFlexDirectionIsColumn(const YGFlexDirection flexDirection) {
|
inline bool YGFlexDirectionIsColumn(const YGFlexDirection flexDirection) {
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
/**
|
||||||
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "YGFloatOptional.h"
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
YGFloatOptional::YGFloatOptional(const float& value)
|
||||||
|
: value_(value), isUndefined_(false) {}
|
||||||
|
YGFloatOptional::YGFloatOptional() : value_(0), isUndefined_(true) {}
|
||||||
|
|
||||||
|
float YGFloatOptional::getValue() const {
|
||||||
|
if (isUndefined_) {
|
||||||
|
// Abort, accessing a value of an undefined float optional
|
||||||
|
std::cerr << "Tried to get value of an undefined YGFloatOptional\n";
|
||||||
|
std::exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
return value_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YGFloatOptional::setValue(const float& val) {
|
||||||
|
value_ = val;
|
||||||
|
isUndefined_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool YGFloatOptional::isUndefined() const {
|
||||||
|
return isUndefined_;
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
/**
|
||||||
|
* Copyright (c) 2014-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct YGFloatOptional {
|
||||||
|
private:
|
||||||
|
float value_;
|
||||||
|
bool isUndefined_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
YGFloatOptional(const float& value);
|
||||||
|
YGFloatOptional();
|
||||||
|
|
||||||
|
// Program will terminate if the value of an undefined is accessed. Please
|
||||||
|
// make sure to check if the optional is defined before calling this function.
|
||||||
|
// To check if float optional is defined, use `isUndefined()`.
|
||||||
|
float getValue() const;
|
||||||
|
|
||||||
|
// Sets the value of float optional, and thus isUndefined is assigned false.
|
||||||
|
void setValue(const float& val);
|
||||||
|
|
||||||
|
bool isUndefined() const;
|
||||||
|
};
|
|
@ -500,7 +500,7 @@ YGValue YGNode::resolveFlexBasisPtr() const {
|
||||||
if (flexBasis.unit != YGUnitAuto && flexBasis.unit != YGUnitUndefined) {
|
if (flexBasis.unit != YGUnitAuto && flexBasis.unit != YGUnitUndefined) {
|
||||||
return flexBasis;
|
return flexBasis;
|
||||||
}
|
}
|
||||||
if (!style_.flex.isUndefined && style_.flex.value > 0.0f) {
|
if (!style_.flex.isUndefined() && style_.flex.getValue() > 0.0f) {
|
||||||
return config_->useWebDefaults ? YGValueAuto : YGValueZero;
|
return config_->useWebDefaults ? YGValueAuto : YGValueZero;
|
||||||
}
|
}
|
||||||
return YGValueAuto;
|
return YGValueAuto;
|
||||||
|
@ -592,11 +592,11 @@ float YGNode::resolveFlexGrow() {
|
||||||
if (parent_ == nullptr) {
|
if (parent_ == nullptr) {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
if (!style_.flexGrow.isUndefined) {
|
if (!style_.flexGrow.isUndefined()) {
|
||||||
return style_.flexGrow.value;
|
return style_.flexGrow.getValue();
|
||||||
}
|
}
|
||||||
if (!style_.flex.isUndefined && style_.flex.value > 0.0f) {
|
if (!style_.flex.isUndefined() && style_.flex.getValue() > 0.0f) {
|
||||||
return style_.flex.value;
|
return style_.flex.getValue();
|
||||||
}
|
}
|
||||||
return kDefaultFlexGrow;
|
return kDefaultFlexGrow;
|
||||||
}
|
}
|
||||||
|
@ -605,12 +605,12 @@ float YGNode::resolveFlexShrink() {
|
||||||
if (parent_ == nullptr) {
|
if (parent_ == nullptr) {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
if (!style_.flexShrink.isUndefined) {
|
if (!style_.flexShrink.isUndefined()) {
|
||||||
return style_.flexShrink.value;
|
return style_.flexShrink.getValue();
|
||||||
}
|
}
|
||||||
if (!config_->useWebDefaults && !style_.flex.isUndefined &&
|
if (!config_->useWebDefaults && !style_.flex.isUndefined() &&
|
||||||
style_.flex.value < 0.0f) {
|
style_.flex.getValue() < 0.0f) {
|
||||||
return -style_.flex.value;
|
return -style_.flex.getValue();
|
||||||
}
|
}
|
||||||
return config_->useWebDefaults ? kWebDefaultFlexShrink : kDefaultFlexShrink;
|
return config_->useWebDefaults ? kWebDefaultFlexShrink : kDefaultFlexShrink;
|
||||||
}
|
}
|
||||||
|
@ -653,8 +653,9 @@ float YGNode::getLeadingPadding(
|
||||||
const float widthSize) {
|
const float widthSize) {
|
||||||
if (YGFlexDirectionIsRow(axis) &&
|
if (YGFlexDirectionIsRow(axis) &&
|
||||||
style_.padding[YGEdgeStart].unit != YGUnitUndefined &&
|
style_.padding[YGEdgeStart].unit != YGUnitUndefined &&
|
||||||
!YGResolveValue(style_.padding[YGEdgeStart], widthSize).isUndefined &&
|
!YGResolveValue(style_.padding[YGEdgeStart], widthSize).isUndefined() &&
|
||||||
YGUnwrapFloatOptional(YGResolveValue(style_.padding[YGEdgeStart], widthSize)) > 0.0f) {
|
YGUnwrapFloatOptional(
|
||||||
|
YGResolveValue(style_.padding[YGEdgeStart], widthSize)) > 0.0f) {
|
||||||
return YGUnwrapFloatOptional(YGResolveValue(style_.padding[YGEdgeStart], widthSize));
|
return YGUnwrapFloatOptional(YGResolveValue(style_.padding[YGEdgeStart], widthSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -669,8 +670,9 @@ float YGNode::getTrailingPadding(
|
||||||
const float widthSize) {
|
const float widthSize) {
|
||||||
if (YGFlexDirectionIsRow(axis) &&
|
if (YGFlexDirectionIsRow(axis) &&
|
||||||
style_.padding[YGEdgeEnd].unit != YGUnitUndefined &&
|
style_.padding[YGEdgeEnd].unit != YGUnitUndefined &&
|
||||||
!YGResolveValue(style_.padding[YGEdgeEnd], widthSize).isUndefined &&
|
!YGResolveValue(style_.padding[YGEdgeEnd], widthSize).isUndefined() &&
|
||||||
YGUnwrapFloatOptional(YGResolveValue(style_.padding[YGEdgeEnd], widthSize)) >= 0.0f) {
|
YGUnwrapFloatOptional(
|
||||||
|
YGResolveValue(style_.padding[YGEdgeEnd], widthSize)) >= 0.0f) {
|
||||||
return YGUnwrapFloatOptional(YGResolveValue(style_.padding[YGEdgeEnd], widthSize));
|
return YGUnwrapFloatOptional(YGResolveValue(style_.padding[YGEdgeEnd], widthSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,8 +43,8 @@ static void appendFloatOptionalIfDefined(
|
||||||
string* base,
|
string* base,
|
||||||
const string key,
|
const string key,
|
||||||
const YGFloatOptional num) {
|
const YGFloatOptional num) {
|
||||||
if (!num.isUndefined) {
|
if (!num.isUndefined()) {
|
||||||
appendFormatedString(base, "%s: %g; ", key.c_str(), num.value);
|
appendFormatedString(base, "%s: %g; ", key.c_str(), num.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,6 @@
|
||||||
|
|
||||||
#include "YGStyle.h"
|
#include "YGStyle.h"
|
||||||
|
|
||||||
#define YGFloatOptionalUndefined \
|
|
||||||
{ true, 0 }
|
|
||||||
|
|
||||||
const YGValue kYGValueUndefined = {0, YGUnitUndefined};
|
const YGValue kYGValueUndefined = {0, YGUnitUndefined};
|
||||||
|
|
||||||
const YGValue kYGValueAuto = {YGUndefined, YGUnitAuto};
|
const YGValue kYGValueAuto = {YGUndefined, YGUnitAuto};
|
||||||
|
@ -42,9 +39,9 @@ YGStyle::YGStyle()
|
||||||
flexWrap(YGWrapNoWrap),
|
flexWrap(YGWrapNoWrap),
|
||||||
overflow(YGOverflowVisible),
|
overflow(YGOverflowVisible),
|
||||||
display(YGDisplayFlex),
|
display(YGDisplayFlex),
|
||||||
flex(YGFloatOptionalUndefined),
|
flex(YGFloatOptional()),
|
||||||
flexGrow(YGFloatOptionalUndefined),
|
flexGrow(YGFloatOptional()),
|
||||||
flexShrink(YGFloatOptionalUndefined),
|
flexShrink(YGFloatOptional()),
|
||||||
flexBasis({0, YGUnitAuto}),
|
flexBasis({0, YGUnitAuto}),
|
||||||
margin(kYGDefaultEdgeValuesUnit),
|
margin(kYGDefaultEdgeValuesUnit),
|
||||||
position(kYGDefaultEdgeValuesUnit),
|
position(kYGDefaultEdgeValuesUnit),
|
||||||
|
@ -73,24 +70,25 @@ bool YGStyle::operator==(const YGStyle& style) {
|
||||||
YGValueArrayEqual(maxDimensions, style.maxDimensions);
|
YGValueArrayEqual(maxDimensions, style.maxDimensions);
|
||||||
|
|
||||||
areNonFloatValuesEqual =
|
areNonFloatValuesEqual =
|
||||||
areNonFloatValuesEqual && flex.isUndefined == style.flex.isUndefined;
|
areNonFloatValuesEqual && flex.isUndefined() == style.flex.isUndefined();
|
||||||
if (areNonFloatValuesEqual && !flex.isUndefined && !style.flex.isUndefined) {
|
if (areNonFloatValuesEqual && !flex.isUndefined() &&
|
||||||
|
!style.flex.isUndefined()) {
|
||||||
areNonFloatValuesEqual =
|
areNonFloatValuesEqual =
|
||||||
areNonFloatValuesEqual && flex.value == style.flex.value;
|
areNonFloatValuesEqual && flex.getValue() == style.flex.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
areNonFloatValuesEqual = areNonFloatValuesEqual &&
|
areNonFloatValuesEqual = areNonFloatValuesEqual &&
|
||||||
flexGrow.isUndefined == style.flexGrow.isUndefined;
|
flexGrow.isUndefined() == style.flexGrow.isUndefined();
|
||||||
if (areNonFloatValuesEqual && !flexGrow.isUndefined) {
|
if (areNonFloatValuesEqual && !flexGrow.isUndefined()) {
|
||||||
areNonFloatValuesEqual =
|
areNonFloatValuesEqual = areNonFloatValuesEqual &&
|
||||||
areNonFloatValuesEqual && flexGrow.value == style.flexGrow.value;
|
flexGrow.getValue() == style.flexGrow.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
areNonFloatValuesEqual = areNonFloatValuesEqual &&
|
areNonFloatValuesEqual = areNonFloatValuesEqual &&
|
||||||
flexShrink.isUndefined == style.flexShrink.isUndefined;
|
flexShrink.isUndefined() == style.flexShrink.isUndefined();
|
||||||
if (areNonFloatValuesEqual && !style.flexShrink.isUndefined) {
|
if (areNonFloatValuesEqual && !style.flexShrink.isUndefined()) {
|
||||||
areNonFloatValuesEqual =
|
areNonFloatValuesEqual = areNonFloatValuesEqual &&
|
||||||
areNonFloatValuesEqual && flexShrink.value == style.flexShrink.value;
|
flexShrink.getValue() == style.flexShrink.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(YGFloatIsUndefined(aspectRatio) &&
|
if (!(YGFloatIsUndefined(aspectRatio) &&
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "YGFloatOptional.h"
|
||||||
#include "Yoga-internal.h"
|
#include "Yoga-internal.h"
|
||||||
#include "Yoga.h"
|
#include "Yoga.h"
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
#include "YGNode.h"
|
#include "YGNode.h"
|
||||||
#include "YGNodePrint.h"
|
#include "YGNodePrint.h"
|
||||||
#include "Yoga-internal.h"
|
#include "Yoga-internal.h"
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
|
|
||||||
|
@ -511,16 +510,16 @@ void YGNodeCopyStyle(const YGNodeRef dstNode, const YGNodeRef srcNode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
float YGNodeStyleGetFlexGrow(const YGNodeRef node) {
|
float YGNodeStyleGetFlexGrow(const YGNodeRef node) {
|
||||||
return node->getStyle().flexGrow.isUndefined
|
return node->getStyle().flexGrow.isUndefined()
|
||||||
? kDefaultFlexGrow
|
? kDefaultFlexGrow
|
||||||
: node->getStyle().flexGrow.value;
|
: node->getStyle().flexGrow.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
float YGNodeStyleGetFlexShrink(const YGNodeRef node) {
|
float YGNodeStyleGetFlexShrink(const YGNodeRef node) {
|
||||||
return node->getStyle().flexShrink.isUndefined
|
return node->getStyle().flexShrink.isUndefined()
|
||||||
? (node->getConfig()->useWebDefaults ? kWebDefaultFlexShrink
|
? (node->getConfig()->useWebDefaults ? kWebDefaultFlexShrink
|
||||||
: kDefaultFlexShrink)
|
: kDefaultFlexShrink)
|
||||||
: node->getStyle().flexShrink.value;
|
: node->getStyle().flexShrink.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
#define YG_NODE_STYLE_PROPERTY_SETTER_IMPL( \
|
#define YG_NODE_STYLE_PROPERTY_SETTER_IMPL( \
|
||||||
|
@ -744,9 +743,9 @@ void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) {
|
||||||
if (!YGFloatOptionalFloatEquals(node->getStyle().flex, flex)) {
|
if (!YGFloatOptionalFloatEquals(node->getStyle().flex, flex)) {
|
||||||
YGStyle style = node->getStyle();
|
YGStyle style = node->getStyle();
|
||||||
if (YGFloatIsUndefined(flex)) {
|
if (YGFloatIsUndefined(flex)) {
|
||||||
style.flex = {true, 0};
|
style.flex = YGFloatOptional();
|
||||||
} else {
|
} else {
|
||||||
style.flex = {false, flex};
|
style.flex = YGFloatOptional(flex);
|
||||||
}
|
}
|
||||||
node->setStyle(style);
|
node->setStyle(style);
|
||||||
node->markDirtyAndPropogate();
|
node->markDirtyAndPropogate();
|
||||||
|
@ -755,8 +754,8 @@ void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) {
|
||||||
|
|
||||||
// TODO(T26792433): Change the API to accept YGFloatOptional.
|
// TODO(T26792433): Change the API to accept YGFloatOptional.
|
||||||
float YGNodeStyleGetFlex(const YGNodeRef node) {
|
float YGNodeStyleGetFlex(const YGNodeRef node) {
|
||||||
return node->getStyle().flex.isUndefined ? YGUndefined
|
return node->getStyle().flex.isUndefined() ? YGUndefined
|
||||||
: node->getStyle().flex.value;
|
: node->getStyle().flex.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(T26792433): Change the API to accept YGFloatOptional.
|
// TODO(T26792433): Change the API to accept YGFloatOptional.
|
||||||
|
@ -764,9 +763,9 @@ void YGNodeStyleSetFlexGrow(const YGNodeRef node, const float flexGrow) {
|
||||||
if (!YGFloatOptionalFloatEquals(node->getStyle().flexGrow, flexGrow)) {
|
if (!YGFloatOptionalFloatEquals(node->getStyle().flexGrow, flexGrow)) {
|
||||||
YGStyle style = node->getStyle();
|
YGStyle style = node->getStyle();
|
||||||
if (YGFloatIsUndefined(flexGrow)) {
|
if (YGFloatIsUndefined(flexGrow)) {
|
||||||
style.flexGrow = {true, 0};
|
style.flexGrow = YGFloatOptional();
|
||||||
} else {
|
} else {
|
||||||
style.flexGrow = {false, flexGrow};
|
style.flexGrow = YGFloatOptional(flexGrow);
|
||||||
}
|
}
|
||||||
node->setStyle(style);
|
node->setStyle(style);
|
||||||
node->markDirtyAndPropogate();
|
node->markDirtyAndPropogate();
|
||||||
|
@ -778,9 +777,9 @@ void YGNodeStyleSetFlexShrink(const YGNodeRef node, const float flexShrink) {
|
||||||
if (!YGFloatOptionalFloatEquals(node->getStyle().flexShrink, flexShrink)) {
|
if (!YGFloatOptionalFloatEquals(node->getStyle().flexShrink, flexShrink)) {
|
||||||
YGStyle style = node->getStyle();
|
YGStyle style = node->getStyle();
|
||||||
if (YGFloatIsUndefined(flexShrink)) {
|
if (YGFloatIsUndefined(flexShrink)) {
|
||||||
style.flexShrink = {true, 0};
|
style.flexShrink = YGFloatOptional();
|
||||||
} else {
|
} else {
|
||||||
style.flexShrink = {false, flexShrink};
|
style.flexShrink = YGFloatOptional(flexShrink);
|
||||||
}
|
}
|
||||||
node->setStyle(style);
|
node->setStyle(style);
|
||||||
node->markDirtyAndPropogate();
|
node->markDirtyAndPropogate();
|
||||||
|
@ -1669,13 +1668,15 @@ static float YGNodeCalculateAvailableInnerDim(
|
||||||
// We want to make sure our available height does not violate min and max
|
// We want to make sure our available height does not violate min and max
|
||||||
// constraints
|
// constraints
|
||||||
const YGFloatOptional minDimensionOptional = YGResolveValue(node->getStyle().minDimensions[dimension], parentDim);
|
const YGFloatOptional minDimensionOptional = YGResolveValue(node->getStyle().minDimensions[dimension], parentDim);
|
||||||
const float minInnerDim = minDimensionOptional.isUndefined
|
const float minInnerDim = minDimensionOptional.isUndefined()
|
||||||
? 0.0f
|
? 0.0f
|
||||||
: minDimensionOptional.value - paddingAndBorder;
|
: minDimensionOptional.getValue() - paddingAndBorder;
|
||||||
|
|
||||||
const YGFloatOptional maxDimensionOptional = YGResolveValue(node->getStyle().maxDimensions[dimension], parentDim) ;
|
const YGFloatOptional maxDimensionOptional = YGResolveValue(node->getStyle().maxDimensions[dimension], parentDim) ;
|
||||||
|
|
||||||
const float maxInnerDim = maxDimensionOptional.isUndefined ? FLT_MAX : maxDimensionOptional.value - paddingAndBorder;
|
const float maxInnerDim = maxDimensionOptional.isUndefined()
|
||||||
|
? FLT_MAX
|
||||||
|
: maxDimensionOptional.getValue() - paddingAndBorder;
|
||||||
availableInnerDim =
|
availableInnerDim =
|
||||||
YGFloatMax(YGFloatMin(availableInnerDim, maxInnerDim), minInnerDim);
|
YGFloatMax(YGFloatMin(availableInnerDim, maxInnerDim), minInnerDim);
|
||||||
}
|
}
|
||||||
|
@ -2207,7 +2208,8 @@ static void YGJustifyMainAxis(
|
||||||
if (measureModeMainDim == YGMeasureModeAtMost &&
|
if (measureModeMainDim == YGMeasureModeAtMost &&
|
||||||
collectedFlexItemsValues.remainingFreeSpace > 0) {
|
collectedFlexItemsValues.remainingFreeSpace > 0) {
|
||||||
if (style.minDimensions[dim[mainAxis]].unit != YGUnitUndefined &&
|
if (style.minDimensions[dim[mainAxis]].unit != YGUnitUndefined &&
|
||||||
!YGResolveValue(style.minDimensions[dim[mainAxis]], mainAxisParentSize).isUndefined) {
|
!YGResolveValue(style.minDimensions[dim[mainAxis]], mainAxisParentSize)
|
||||||
|
.isUndefined()) {
|
||||||
collectedFlexItemsValues.remainingFreeSpace = YGFloatMax(
|
collectedFlexItemsValues.remainingFreeSpace = YGFloatMax(
|
||||||
0,
|
0,
|
||||||
YGUnwrapFloatOptional(YGResolveValue(
|
YGUnwrapFloatOptional(YGResolveValue(
|
||||||
|
@ -3713,8 +3715,8 @@ void YGNodeCalculateLayout(
|
||||||
node->getMarginForAxis(YGFlexDirectionRow, parentWidth);
|
node->getMarginForAxis(YGFlexDirectionRow, parentWidth);
|
||||||
widthMeasureMode = YGMeasureModeExactly;
|
widthMeasureMode = YGMeasureModeExactly;
|
||||||
} else if (!YGResolveValue(
|
} else if (!YGResolveValue(
|
||||||
node->getStyle().maxDimensions[YGDimensionWidth],
|
node->getStyle().maxDimensions[YGDimensionWidth], parentWidth)
|
||||||
parentWidth).isUndefined) {
|
.isUndefined()) {
|
||||||
width = YGUnwrapFloatOptional(YGResolveValue(
|
width = YGUnwrapFloatOptional(YGResolveValue(
|
||||||
node->getStyle().maxDimensions[YGDimensionWidth], parentWidth));
|
node->getStyle().maxDimensions[YGDimensionWidth], parentWidth));
|
||||||
widthMeasureMode = YGMeasureModeAtMost;
|
widthMeasureMode = YGMeasureModeAtMost;
|
||||||
|
@ -3732,8 +3734,10 @@ void YGNodeCalculateLayout(
|
||||||
parentHeight)) +
|
parentHeight)) +
|
||||||
node->getMarginForAxis(YGFlexDirectionColumn, parentWidth);
|
node->getMarginForAxis(YGFlexDirectionColumn, parentWidth);
|
||||||
heightMeasureMode = YGMeasureModeExactly;
|
heightMeasureMode = YGMeasureModeExactly;
|
||||||
} else if (!YGResolveValue(node->getStyle().maxDimensions[YGDimensionHeight],
|
} else if (!YGResolveValue(
|
||||||
parentHeight).isUndefined) {
|
node->getStyle().maxDimensions[YGDimensionHeight],
|
||||||
|
parentHeight)
|
||||||
|
.isUndefined()) {
|
||||||
height = YGUnwrapFloatOptional(YGResolveValue(node->getStyle().maxDimensions[YGDimensionHeight], parentHeight));
|
height = YGUnwrapFloatOptional(YGResolveValue(node->getStyle().maxDimensions[YGDimensionHeight], parentHeight));
|
||||||
heightMeasureMode = YGMeasureModeAtMost;
|
heightMeasureMode = YGMeasureModeAtMost;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -42,11 +42,6 @@ typedef struct YGValue {
|
||||||
YGUnit unit;
|
YGUnit unit;
|
||||||
} YGValue;
|
} YGValue;
|
||||||
|
|
||||||
struct YGFloatOptional {
|
|
||||||
bool isUndefined;
|
|
||||||
float value;
|
|
||||||
};
|
|
||||||
|
|
||||||
extern const YGValue YGValueUndefined;
|
extern const YGValue YGValueUndefined;
|
||||||
extern const YGValue YGValueAuto;
|
extern const YGValue YGValueAuto;
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче