diff --git a/yoga/Utils.cpp b/yoga/Utils.cpp new file mode 100644 index 00000000..e8c27036 --- /dev/null +++ b/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/yoga/Utils.h b/yoga/Utils.h new file mode 100644 index 00000000..11a908d3 --- /dev/null +++ b/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/yoga/YGNode.cpp b/yoga/YGNode.cpp index f5f66c7c..d09394db 100644 --- a/yoga/YGNode.cpp +++ b/yoga/YGNode.cpp @@ -9,6 +9,7 @@ #include "YGNode.h" #include +#include "Utils.h" void* YGNode::getContext() const { return context_; diff --git a/yoga/Yoga.cpp b/yoga/Yoga.cpp index f4bae13d..c843dc54 100644 --- a/yoga/Yoga.cpp +++ b/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; }