diff --git a/React/React.xcodeproj/project.pbxproj b/React/React.xcodeproj/project.pbxproj index a96223df6e0846..b86520c24f5577 100644 --- a/React/React.xcodeproj/project.pbxproj +++ b/React/React.xcodeproj/project.pbxproj @@ -954,6 +954,10 @@ 3DFE0D1C1DF8575800459392 /* Yoga.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 130A77081DF767AF001F9587 /* Yoga.h */; }; 3EDCA8A51D3591E700450C31 /* RCTErrorInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 3EDCA8A41D3591E700450C31 /* RCTErrorInfo.m */; }; 5335D5411FE81A4700883D58 /* RCTShadowView.m in Sources */ = {isa = PBXBuildFile; fileRef = 5335D5401FE81A4700883D58 /* RCTShadowView.m */; }; + 53756E3B2004FFFA00FBBD99 /* Utils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53756E372004FFF700FBBD99 /* Utils.cpp */; }; + 53756E3C2004FFFC00FBBD99 /* Utils.h in Headers */ = {isa = PBXBuildFile; fileRef = 53756E382004FFF700FBBD99 /* Utils.h */; }; + 53756E3D2004FFFE00FBBD99 /* Utils.h in Headers */ = {isa = PBXBuildFile; fileRef = 53756E382004FFF700FBBD99 /* Utils.h */; }; + 53756E3E2005000300FBBD99 /* Utils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53756E372004FFF700FBBD99 /* Utils.cpp */; }; 5376C5E41FC6DDBC0083513D /* YGNodePrint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5376C5E11FC6DDB20083513D /* YGNodePrint.cpp */; }; 5376C5E51FC6DDBD0083513D /* YGNodePrint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5376C5E11FC6DDB20083513D /* YGNodePrint.cpp */; }; 5376C5E61FC6DDC10083513D /* YGNodePrint.h in Headers */ = {isa = PBXBuildFile; fileRef = 5376C5E01FC6DDB20083513D /* YGNodePrint.h */; }; @@ -2133,6 +2137,8 @@ 3EDCA8A31D3591E700450C31 /* RCTErrorInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTErrorInfo.h; sourceTree = ""; }; 3EDCA8A41D3591E700450C31 /* RCTErrorInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTErrorInfo.m; sourceTree = ""; }; 5335D5401FE81A4700883D58 /* RCTShadowView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTShadowView.m; sourceTree = ""; }; + 53756E372004FFF700FBBD99 /* Utils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Utils.cpp; sourceTree = ""; }; + 53756E382004FFF700FBBD99 /* Utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Utils.h; sourceTree = ""; }; 5376C5E01FC6DDB20083513D /* YGNodePrint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YGNodePrint.h; sourceTree = ""; }; 5376C5E11FC6DDB20083513D /* YGNodePrint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = YGNodePrint.cpp; sourceTree = ""; }; 53CBF1851FB4FE80002CBB31 /* Yoga-internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Yoga-internal.h"; sourceTree = ""; }; @@ -2315,6 +2321,8 @@ 130A77021DF767AF001F9587 /* yoga */ = { isa = PBXGroup; children = ( + 53756E372004FFF700FBBD99 /* Utils.cpp */, + 53756E382004FFF700FBBD99 /* Utils.h */, 53EC85DF1FDEC75A0051B2B5 /* YGNode.cpp */, 53EC85DE1FDEC75A0051B2B5 /* YGNode.h */, 5376C5E11FC6DDB20083513D /* YGNodePrint.cpp */, @@ -3240,6 +3248,7 @@ 53D1239F1FBF1EFB001B8A10 /* Yoga-internal.h in Headers */, 3DFE0D161DF8574D00459392 /* YGEnums.h in Headers */, 3DFE0D171DF8574D00459392 /* YGMacros.h in Headers */, + 53756E3D2004FFFE00FBBD99 /* Utils.h in Headers */, 5376C5E71FC6DDC20083513D /* YGNodePrint.h in Headers */, 3DFE0D191DF8574D00459392 /* Yoga.h in Headers */, ); @@ -3318,6 +3327,7 @@ 53D1239E1FBF1EFB001B8A10 /* Yoga-internal.h in Headers */, 133957881DF76D3500EC27BE /* YGEnums.h in Headers */, 1339578B1DF76D3500EC27BE /* Yoga.h in Headers */, + 53756E3C2004FFFC00FBBD99 /* Utils.h in Headers */, 5376C5E61FC6DDC10083513D /* YGNodePrint.h in Headers */, 133957891DF76D3500EC27BE /* YGMacros.h in Headers */, ); @@ -4257,6 +4267,7 @@ 53D123A01FBF1EFF001B8A10 /* Yoga.cpp in Sources */, 53EC85E21FDEC75F0051B2B5 /* YGNode.cpp in Sources */, 53D1239A1FBF1EF2001B8A10 /* YGEnums.cpp in Sources */, + 53756E3B2004FFFA00FBBD99 /* Utils.cpp in Sources */, 5376C5E41FC6DDBC0083513D /* YGNodePrint.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -4268,6 +4279,7 @@ 53D123A11FBF1EFF001B8A10 /* Yoga.cpp in Sources */, 53EC85E31FDEC75F0051B2B5 /* YGNode.cpp in Sources */, 53D1239B1FBF1EF4001B8A10 /* YGEnums.cpp in Sources */, + 53756E3E2005000300FBBD99 /* Utils.cpp in Sources */, 5376C5E51FC6DDBD0083513D /* YGNodePrint.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/ReactCommon/yoga/yoga/Utils.cpp b/ReactCommon/yoga/yoga/Utils.cpp new file mode 100644 index 00000000000000..e8c270366f119c --- /dev/null +++ b/ReactCommon/yoga/yoga/Utils.cpp @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +#include "Utils.h" + +bool YGValueEqual(const YGValue a, const YGValue b) { + if (a.unit != b.unit) { + return false; + } + + if (a.unit == YGUnitUndefined || + (std::isnan(a.value) && std::isnan(b.value))) { + return true; + } + + return fabs(a.value - b.value) < 0.0001f; +} diff --git a/ReactCommon/yoga/yoga/Utils.h b/ReactCommon/yoga/yoga/Utils.h new file mode 100644 index 00000000000000..11a908d37db0a9 --- /dev/null +++ b/ReactCommon/yoga/yoga/Utils.h @@ -0,0 +1,17 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +#include "Yoga-internal.h" + +inline bool YGFlexDirectionIsRow(const YGFlexDirection flexDirection) { + return flexDirection == YGFlexDirectionRow || + flexDirection == YGFlexDirectionRowReverse; +} + +bool YGValueEqual(const YGValue a, const YGValue b); diff --git a/ReactCommon/yoga/yoga/YGNode.cpp b/ReactCommon/yoga/yoga/YGNode.cpp index f5f66c7cd2279a..d09394dbd3f0ab 100644 --- a/ReactCommon/yoga/yoga/YGNode.cpp +++ b/ReactCommon/yoga/yoga/YGNode.cpp @@ -9,6 +9,7 @@ #include "YGNode.h" #include +#include "Utils.h" void* YGNode::getContext() const { return context_; diff --git a/ReactCommon/yoga/yoga/Yoga.cpp b/ReactCommon/yoga/yoga/Yoga.cpp index f4bae13ddb30e8..c843dc54e8cc47 100644 --- a/ReactCommon/yoga/yoga/Yoga.cpp +++ b/ReactCommon/yoga/yoga/Yoga.cpp @@ -10,6 +10,7 @@ #include "Yoga.h" #include #include +#include "Utils.h" #include "YGNode.h" #include "YGNodePrint.h" #include "Yoga-internal.h" @@ -749,19 +750,6 @@ bool YGLayoutNodeInternal(const YGNodeRef node, const char *reason, const YGConfigRef config); -bool YGValueEqual(const YGValue a, const YGValue b) { - if (a.unit != b.unit) { - return false; - } - - if (a.unit == YGUnitUndefined || - (std::isnan(a.value) && std::isnan(b.value))) { - return true; - } - - return fabs(a.value - b.value) < 0.0001f; -} - bool YGFloatsEqual(const float a, const float b) { if (YGFloatIsUndefined(a)) { return YGFloatIsUndefined(b); @@ -794,10 +782,6 @@ static const std::array pos = {{ static const std::array dim = { {YGDimensionHeight, YGDimensionHeight, YGDimensionWidth, YGDimensionWidth}}; -bool YGFlexDirectionIsRow(const YGFlexDirection flexDirection) { - return flexDirection == YGFlexDirectionRow || flexDirection == YGFlexDirectionRowReverse; -} - static inline bool YGFlexDirectionIsColumn(const YGFlexDirection flexDirection) { return flexDirection == YGFlexDirectionColumn || flexDirection == YGFlexDirectionColumnReverse; }