Reorder members in Node.h
(#1529)
Summary: X-link: https://github.com/facebook/react-native/pull/41994 Pull Request resolved: https://github.com/facebook/yoga/pull/1529 Reorganizes the header according to common C++ convnetions. Public first, then private. Constructors, then functions, then member variables. Reviewed By: joevilches Differential Revision: D52106056 fbshipit-source-id: 0095cf7caa58dc79c1803b3b231911e4fc66ddaf
This commit is contained in:
committed by
Facebook GitHub Bot
parent
1f391dfc50
commit
c5edcb3d3a
112
yoga/node/Node.h
112
yoga/node/Node.h
@@ -29,65 +29,9 @@ struct YGNode {};
|
|||||||
namespace facebook::yoga {
|
namespace facebook::yoga {
|
||||||
|
|
||||||
class YG_EXPORT Node : public ::YGNode {
|
class YG_EXPORT Node : public ::YGNode {
|
||||||
private:
|
|
||||||
bool hasNewLayout_ : 1 = true;
|
|
||||||
bool isReferenceBaseline_ : 1 = false;
|
|
||||||
bool isDirty_ : 1 = false;
|
|
||||||
NodeType nodeType_ : bitCount<NodeType>() = NodeType::Default;
|
|
||||||
void* context_ = nullptr;
|
|
||||||
YGMeasureFunc measureFunc_ = {nullptr};
|
|
||||||
YGBaselineFunc baselineFunc_ = {nullptr};
|
|
||||||
YGPrintFunc printFunc_ = {nullptr};
|
|
||||||
YGDirtiedFunc dirtiedFunc_ = nullptr;
|
|
||||||
Style style_ = {};
|
|
||||||
LayoutResults layout_ = {};
|
|
||||||
size_t lineIndex_ = 0;
|
|
||||||
Node* owner_ = nullptr;
|
|
||||||
std::vector<Node*> children_ = {};
|
|
||||||
const Config* config_;
|
|
||||||
std::array<Style::Length, 2> resolvedDimensions_ = {
|
|
||||||
{value::undefined(), value::undefined()}};
|
|
||||||
|
|
||||||
float relativePosition(
|
|
||||||
FlexDirection axis,
|
|
||||||
Direction direction,
|
|
||||||
const float axisSize) const;
|
|
||||||
|
|
||||||
Edge getInlineStartEdgeUsingErrata(
|
|
||||||
FlexDirection flexDirection,
|
|
||||||
Direction direction) const;
|
|
||||||
Edge getInlineEndEdgeUsingErrata(
|
|
||||||
FlexDirection flexDirection,
|
|
||||||
Direction direction) const;
|
|
||||||
Edge getFlexStartRelativeEdgeUsingErrata(
|
|
||||||
FlexDirection flexDirection,
|
|
||||||
Direction direction) const;
|
|
||||||
Edge getFlexEndRelativeEdgeUsingErrata(
|
|
||||||
FlexDirection flexDirection,
|
|
||||||
Direction direction) const;
|
|
||||||
|
|
||||||
void useWebDefaults() {
|
|
||||||
style_.setFlexDirection(FlexDirection::Row);
|
|
||||||
style_.setAlignContent(Align::Stretch);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <auto Field>
|
|
||||||
Style::Length computeEdgeValueForColumn(Edge edge) const;
|
|
||||||
|
|
||||||
template <auto Field>
|
|
||||||
Style::Length computeEdgeValueForRow(Edge rowEdge, Edge edge) const;
|
|
||||||
|
|
||||||
// DANGER DANGER DANGER!
|
|
||||||
// If the node assigned to has children, we'd either have to deallocate
|
|
||||||
// them (potentially incorrect) or ignore them (danger of leaks). Only ever
|
|
||||||
// use this after checking that there are no children.
|
|
||||||
// DO NOT CHANGE THE VISIBILITY OF THIS METHOD!
|
|
||||||
Node& operator=(Node&&) = default;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Node();
|
Node();
|
||||||
explicit Node(const Config* config);
|
explicit Node(const Config* config);
|
||||||
~Node() = default; // cleanup of owner/children relationships in YGNodeFree
|
|
||||||
|
|
||||||
Node(Node&&);
|
Node(Node&&);
|
||||||
|
|
||||||
@@ -181,11 +125,6 @@ class YG_EXPORT Node : public ::YGNode {
|
|||||||
return owner_;
|
return owner_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deprecated, use getOwner() instead.
|
|
||||||
Node* getParent() const {
|
|
||||||
return getOwner();
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::vector<Node*>& getChildren() const {
|
const std::vector<Node*>& getChildren() const {
|
||||||
return children_;
|
return children_;
|
||||||
}
|
}
|
||||||
@@ -393,6 +332,57 @@ class YG_EXPORT Node : public ::YGNode {
|
|||||||
float resolveFlexShrink() const;
|
float resolveFlexShrink() const;
|
||||||
bool isNodeFlexible();
|
bool isNodeFlexible();
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Used to allow resetting the node
|
||||||
|
Node& operator=(Node&&) = default;
|
||||||
|
|
||||||
|
float relativePosition(
|
||||||
|
FlexDirection axis,
|
||||||
|
Direction direction,
|
||||||
|
const float axisSize) const;
|
||||||
|
|
||||||
|
Edge getInlineStartEdgeUsingErrata(
|
||||||
|
FlexDirection flexDirection,
|
||||||
|
Direction direction) const;
|
||||||
|
Edge getInlineEndEdgeUsingErrata(
|
||||||
|
FlexDirection flexDirection,
|
||||||
|
Direction direction) const;
|
||||||
|
Edge getFlexStartRelativeEdgeUsingErrata(
|
||||||
|
FlexDirection flexDirection,
|
||||||
|
Direction direction) const;
|
||||||
|
Edge getFlexEndRelativeEdgeUsingErrata(
|
||||||
|
FlexDirection flexDirection,
|
||||||
|
Direction direction) const;
|
||||||
|
|
||||||
|
void useWebDefaults() {
|
||||||
|
style_.setFlexDirection(FlexDirection::Row);
|
||||||
|
style_.setAlignContent(Align::Stretch);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <auto Field>
|
||||||
|
Style::Length computeEdgeValueForColumn(Edge edge) const;
|
||||||
|
|
||||||
|
template <auto Field>
|
||||||
|
Style::Length computeEdgeValueForRow(Edge rowEdge, Edge edge) const;
|
||||||
|
|
||||||
|
bool hasNewLayout_ : 1 = true;
|
||||||
|
bool isReferenceBaseline_ : 1 = false;
|
||||||
|
bool isDirty_ : 1 = false;
|
||||||
|
NodeType nodeType_ : bitCount<NodeType>() = NodeType::Default;
|
||||||
|
void* context_ = nullptr;
|
||||||
|
YGMeasureFunc measureFunc_ = {nullptr};
|
||||||
|
YGBaselineFunc baselineFunc_ = {nullptr};
|
||||||
|
YGPrintFunc printFunc_ = {nullptr};
|
||||||
|
YGDirtiedFunc dirtiedFunc_ = nullptr;
|
||||||
|
Style style_ = {};
|
||||||
|
LayoutResults layout_ = {};
|
||||||
|
size_t lineIndex_ = 0;
|
||||||
|
Node* owner_ = nullptr;
|
||||||
|
std::vector<Node*> children_ = {};
|
||||||
|
const Config* config_;
|
||||||
|
std::array<Style::Length, 2> resolvedDimensions_ = {
|
||||||
|
{value::undefined(), value::undefined()}};
|
||||||
};
|
};
|
||||||
|
|
||||||
inline Node* resolveRef(const YGNodeRef ref) {
|
inline Node* resolveRef(const YGNodeRef ref) {
|
||||||
|
Reference in New Issue
Block a user