2 * Copyright (c) 2014-present, Facebook, Inc.
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
13 #include "Yoga-internal.h"
21 YGMeasureFunc measure_;
22 YGBaselineFunc baseline_;
23 YGDirtiedFunc dirtied_;
32 std::array<YGValue, 2> resolvedDimensions_;
34 YGFloatOptional relativePosition(
35 const YGFlexDirection& axis,
36 const float& axisSize) const;
41 explicit YGNode(const YGConfigRef newConfig);
42 YGNode(const YGNode& node);
43 YGNode& operator=(const YGNode& node);
49 YGMeasureFunc measure,
50 YGBaselineFunc baseline,
51 YGDirtiedFunc dirtied,
53 const YGLayout& layout,
56 const YGVector& children,
60 std::array<YGValue, 2> resolvedDimensions);
63 void* getContext() const;
64 YGPrintFunc getPrintFunc() const;
65 bool getHasNewLayout() const;
66 YGNodeType getNodeType() const;
67 YGMeasureFunc getMeasure() const;
68 YGBaselineFunc getBaseline() const;
69 YGDirtiedFunc getDirtied() const;
70 // For Performance reasons passing as reference.
72 // For Performance reasons passing as reference.
73 YGLayout& getLayout();
74 uint32_t getLineIndex() const;
75 // returns the YGNodeRef that owns this YGNode. An owner is used to identify
76 // the YogaTree that a YGNode belongs to.
77 // This method will return the parent of the YGNode when a YGNode only belongs
78 // to one YogaTree or nullptr when the YGNode is shared between two or more
80 YGNodeRef getOwner() const;
81 YGVector getChildren() const;
82 uint32_t getChildrenCount() const;
83 YGNodeRef getChild(uint32_t index) const;
84 YGNodeRef getNextChild() const;
85 YGConfigRef getConfig() const;
87 std::array<YGValue, 2> getResolvedDimensions() const;
88 YGValue getResolvedDimension(int index);
90 // Methods related to positions, margin, padding and border
91 YGFloatOptional getLeadingPosition(const YGFlexDirection& axis,
92 const float& axisSize) const;
93 bool isLeadingPositionDefined(const YGFlexDirection& axis) const;
94 bool isTrailingPosDefined(const YGFlexDirection& axis) const;
95 YGFloatOptional getTrailingPosition(
96 const YGFlexDirection& axis,
97 const float& axisSize) const;
98 YGFloatOptional getLeadingMargin(
99 const YGFlexDirection& axis,
100 const float& widthSize) const;
101 YGFloatOptional getTrailingMargin(
102 const YGFlexDirection& axis,
103 const float& widthSize) const;
104 float getLeadingBorder(const YGFlexDirection& flexDirection) const;
105 float getTrailingBorder(const YGFlexDirection& flexDirection) const;
106 YGFloatOptional getLeadingPadding(
107 const YGFlexDirection& axis,
108 const float& widthSize) const;
109 YGFloatOptional getTrailingPadding(
110 const YGFlexDirection& axis,
111 const float& widthSize) const;
112 YGFloatOptional getLeadingPaddingAndBorder(
113 const YGFlexDirection& axis,
114 const float& widthSize) const;
115 YGFloatOptional getTrailingPaddingAndBorder(
116 const YGFlexDirection& axis,
117 const float& widthSize) const;
118 YGFloatOptional getMarginForAxis(
119 const YGFlexDirection& axis,
120 const float& widthSize) const;
123 void setContext(void* context);
124 void setPrintFunc(YGPrintFunc printFunc);
125 void setHasNewLayout(bool hasNewLayout);
126 void setNodeType(YGNodeType nodeTye);
127 void setMeasureFunc(YGMeasureFunc measureFunc);
128 void setBaseLineFunc(YGBaselineFunc baseLineFunc);
129 void setDirtiedFunc(YGDirtiedFunc dirtiedFunc);
130 void setStyle(const YGStyle& style);
131 void setStyleFlexDirection(YGFlexDirection direction);
132 void setStyleAlignContent(YGAlign alignContent);
133 void setLayout(const YGLayout& layout);
134 void setLineIndex(uint32_t lineIndex);
135 void setOwner(YGNodeRef owner);
136 void setChildren(const YGVector& children);
137 void setNextChild(YGNodeRef nextChild);
138 void setConfig(YGConfigRef config);
139 void setDirty(bool isDirty);
140 void setLayoutLastOwnerDirection(YGDirection direction);
141 void setLayoutComputedFlexBasis(const YGFloatOptional& computedFlexBasis);
142 void setLayoutComputedFlexBasisGeneration(
143 uint32_t computedFlexBasisGeneration);
144 void setLayoutMeasuredDimension(float measuredDimension, int index);
145 void setLayoutHadOverflow(bool hadOverflow);
146 void setLayoutDimension(float dimension, int index);
147 void setLayoutDirection(YGDirection direction);
148 void setLayoutMargin(float margin, int index);
149 void setLayoutBorder(float border, int index);
150 void setLayoutPadding(float padding, int index);
151 void setLayoutPosition(float position, int index);
153 const YGDirection direction,
154 const float mainSize,
155 const float crossSize,
156 const float ownerWidth);
157 void setAndPropogateUseLegacyFlag(bool useLegacyFlag);
158 void setLayoutDoesLegacyFlagAffectsLayout(bool doesLegacyFlagAffectsLayout);
159 void setLayoutDidUseLegacyFlag(bool didUseLegacyFlag);
160 void markDirtyAndPropogateDownwards();
163 YGValue marginLeadingValue(const YGFlexDirection axis) const;
164 YGValue marginTrailingValue(const YGFlexDirection axis) const;
165 YGValue resolveFlexBasisPtr() const;
166 void resolveDimension();
167 YGDirection resolveDirection(const YGDirection ownerDirection);
168 void clearChildren();
169 /// Replaces the occurrences of oldChild with newChild
170 void replaceChild(YGNodeRef oldChild, YGNodeRef newChild);
171 void replaceChild(YGNodeRef child, uint32_t index);
172 void insertChild(YGNodeRef child, uint32_t index);
173 /// Removes the first occurrence of child
174 bool removeChild(YGNodeRef child);
175 void removeChild(uint32_t index);
177 void cloneChildrenIfNeeded();
178 void markDirtyAndPropogate();
179 float resolveFlexGrow();
180 float resolveFlexShrink();
181 bool isNodeFlexible();
182 bool didUseLegacyFlag();
183 bool isLayoutTreeEqualToNode(const YGNode& node) const;