Move utility functions to utils file
Summary: Move utility functions to utils file Reviewed By: emilsjolander Differential Revision: D6682933 fbshipit-source-id: 0fd90fdaf5ca4f9b7a11cbd15d8c54c7d0ce8a03
This commit is contained in:
committed by
Facebook Github Bot
parent
dc6ed89bfa
commit
47543c8fba
23
yoga/Utils.cpp
Normal file
23
yoga/Utils.cpp
Normal file
@@ -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;
|
||||||
|
}
|
17
yoga/Utils.h
Normal file
17
yoga/Utils.h
Normal file
@@ -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);
|
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include "YGNode.h"
|
#include "YGNode.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include "Utils.h"
|
||||||
|
|
||||||
void* YGNode::getContext() const {
|
void* YGNode::getContext() const {
|
||||||
return context_;
|
return context_;
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
#include "Yoga.h"
|
#include "Yoga.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include "Utils.h"
|
||||||
#include "YGNode.h"
|
#include "YGNode.h"
|
||||||
#include "YGNodePrint.h"
|
#include "YGNodePrint.h"
|
||||||
#include "Yoga-internal.h"
|
#include "Yoga-internal.h"
|
||||||
@@ -749,19 +750,6 @@ bool YGLayoutNodeInternal(const YGNodeRef node,
|
|||||||
const char *reason,
|
const char *reason,
|
||||||
const YGConfigRef config);
|
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) {
|
bool YGFloatsEqual(const float a, const float b) {
|
||||||
if (YGFloatIsUndefined(a)) {
|
if (YGFloatIsUndefined(a)) {
|
||||||
return YGFloatIsUndefined(b);
|
return YGFloatIsUndefined(b);
|
||||||
@@ -794,10 +782,6 @@ static const std::array<YGEdge, 4> pos = {{
|
|||||||
static const std::array<YGDimension, 4> dim = {
|
static const std::array<YGDimension, 4> dim = {
|
||||||
{YGDimensionHeight, YGDimensionHeight, YGDimensionWidth, YGDimensionWidth}};
|
{YGDimensionHeight, YGDimensionHeight, YGDimensionWidth, YGDimensionWidth}};
|
||||||
|
|
||||||
bool YGFlexDirectionIsRow(const YGFlexDirection flexDirection) {
|
|
||||||
return flexDirection == YGFlexDirectionRow || flexDirection == YGFlexDirectionRowReverse;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline bool YGFlexDirectionIsColumn(const YGFlexDirection flexDirection) {
|
static inline bool YGFlexDirectionIsColumn(const YGFlexDirection flexDirection) {
|
||||||
return flexDirection == YGFlexDirectionColumn || flexDirection == YGFlexDirectionColumnReverse;
|
return flexDirection == YGFlexDirectionColumn || flexDirection == YGFlexDirectionColumnReverse;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user