Breaking: size_t indices (#1366)

Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1366

X-link: https://github.com/facebook/react-native/pull/39371

Yoga's public API exposes indices most often as `uint32_t`, with exception of clone callbacks which are `int32_t`. Yoga internally represents these indices as `size_t` when dealing with the child vector, and this is the true index.

This changes the API to consistently be `size_t`. This should not be breaking for most users, but will cause breaks where:

1. Users set a clone node callback (I think this should be rare. RN uses it, but only because it relies on a separate private API).
2. Callers of `YGNodeGetChildCount()` are assigning to an int with less width than `size_t` and have strong warnings enabled.
3. Using a newer Yoga binary with older source, since we are not preserving ABI compatibility (Yoga in general does not aim to be ABI stable between major versions, only ABI safe for a given set of sources).

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D49130914

fbshipit-source-id: 6a004c160c4c50f68047b108508fd437156f5fac
This commit is contained in:
Nick Gerleman
2023-09-11 19:51:40 -07:00
committed by Facebook GitHub Bot
parent 26f2b28eca
commit 776065d7c7
14 changed files with 60 additions and 66 deletions

View File

@@ -362,7 +362,7 @@ static void YGTransferLayoutOutputsRecursive(
YGNodeSetHasNewLayout(root, false); YGNodeSetHasNewLayout(root, false);
for (uint32_t i = 0; i < YGNodeGetChildCount(root); i++) { for (size_t i = 0; i < YGNodeGetChildCount(root); i++) {
YGTransferLayoutOutputsRecursive( YGTransferLayoutOutputsRecursive(
env, thiz, YGNodeGetChild(root, i), layoutContext); env, thiz, YGNodeGetChild(root, i), layoutContext);
} }

View File

@@ -5,8 +5,6 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
// @Generated by gentest/gentest.rb from gentest/fixtures/YGDisplayTest.html
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <yoga/Yoga.h> #include <yoga/Yoga.h>
#include <yoga/config/Config.h> #include <yoga/config/Config.h>
@@ -23,10 +21,10 @@ struct ConfigCloningTest : public ::testing::Test {
void TearDown() override; void TearDown() override;
static yoga::Node clonedNode; static yoga::Node clonedNode;
static YGNodeRef cloneNode(YGNodeConstRef, YGNodeConstRef, int) { static YGNodeRef cloneNode(YGNodeConstRef, YGNodeConstRef, size_t) {
return &clonedNode; return &clonedNode;
} }
static YGNodeRef doNotClone(YGNodeConstRef, YGNodeConstRef, int) { static YGNodeRef doNotClone(YGNodeConstRef, YGNodeConstRef, size_t) {
return nullptr; return nullptr;
} }
}; };
@@ -54,7 +52,7 @@ TEST_F(
TEST_F(ConfigCloningTest, can_clone_with_context) { TEST_F(ConfigCloningTest, can_clone_with_context) {
config->setCloneNodeCallback( config->setCloneNodeCallback(
[](YGNodeConstRef, YGNodeConstRef, int, void* context) { [](YGNodeConstRef, YGNodeConstRef, size_t, void* context) {
return (YGNodeRef) context; return (YGNodeRef) context;
}); });

View File

@@ -9,10 +9,10 @@
#include <yoga/Yoga.h> #include <yoga/Yoga.h>
static std::vector<YGNodeRef> getChildren(YGNodeRef const node) { static std::vector<YGNodeRef> getChildren(YGNodeRef const node) {
const uint32_t count = YGNodeGetChildCount(node); const auto count = YGNodeGetChildCount(node);
std::vector<YGNodeRef> children; std::vector<YGNodeRef> children;
children.reserve(count); children.reserve(count);
for (uint32_t i = 0; i < count; i++) { for (size_t i = 0; i < count; i++) {
children.push_back(YGNodeGetChild(node, i)); children.push_back(YGNodeGetChild(node, i));
} }
return children; return children;

View File

@@ -216,8 +216,8 @@ YOGA_EXPORT void YGNodeFree(const YGNodeRef nodeRef) {
node->setOwner(nullptr); node->setOwner(nullptr);
} }
const uint32_t childCount = YGNodeGetChildCount(node); const size_t childCount = node->getChildCount();
for (uint32_t i = 0; i < childCount; i++) { for (size_t i = 0; i < childCount; i++) {
auto child = node->getChild(i); auto child = node->getChild(i);
child->setOwner(nullptr); child->setOwner(nullptr);
} }
@@ -236,8 +236,8 @@ YOGA_EXPORT void YGNodeFreeRecursiveWithCleanupFunc(
YGNodeCleanupFunc cleanup) { YGNodeCleanupFunc cleanup) {
const auto root = resolveRef(rootRef); const auto root = resolveRef(rootRef);
uint32_t skipped = 0; size_t skipped = 0;
while (YGNodeGetChildCount(root) > skipped) { while (root->getChildCount() > skipped) {
const auto child = root->getChild(skipped); const auto child = root->getChild(skipped);
if (child->getOwner() != root) { if (child->getOwner() != root) {
// Don't free shared nodes that we don't own. // Don't free shared nodes that we don't own.
@@ -297,7 +297,7 @@ YOGA_EXPORT bool YGNodeIsReferenceBaseline(YGNodeConstRef node) {
YOGA_EXPORT void YGNodeInsertChild( YOGA_EXPORT void YGNodeInsertChild(
const YGNodeRef ownerRef, const YGNodeRef ownerRef,
const YGNodeRef childRef, const YGNodeRef childRef,
const uint32_t index) { const size_t index) {
auto owner = resolveRef(ownerRef); auto owner = resolveRef(ownerRef);
auto child = resolveRef(childRef); auto child = resolveRef(childRef);
@@ -319,7 +319,7 @@ YOGA_EXPORT void YGNodeInsertChild(
YOGA_EXPORT void YGNodeSwapChild( YOGA_EXPORT void YGNodeSwapChild(
const YGNodeRef ownerRef, const YGNodeRef ownerRef,
const YGNodeRef childRef, const YGNodeRef childRef,
const uint32_t index) { const size_t index) {
auto owner = resolveRef(ownerRef); auto owner = resolveRef(ownerRef);
auto child = resolveRef(childRef); auto child = resolveRef(childRef);
@@ -333,7 +333,7 @@ YOGA_EXPORT void YGNodeRemoveChild(
auto owner = resolveRef(ownerRef); auto owner = resolveRef(ownerRef);
auto excludedChild = resolveRef(excludedChildRef); auto excludedChild = resolveRef(excludedChildRef);
if (YGNodeGetChildCount(owner) == 0) { if (owner->getChildCount() == 0) {
// This is an empty set. Nothing to remove. // This is an empty set. Nothing to remove.
return; return;
} }
@@ -354,7 +354,7 @@ YOGA_EXPORT void YGNodeRemoveChild(
YOGA_EXPORT void YGNodeRemoveAllChildren(const YGNodeRef ownerRef) { YOGA_EXPORT void YGNodeRemoveAllChildren(const YGNodeRef ownerRef) {
auto owner = resolveRef(ownerRef); auto owner = resolveRef(ownerRef);
const uint32_t childCount = YGNodeGetChildCount(owner); const size_t childCount = owner->getChildCount();
if (childCount == 0) { if (childCount == 0) {
// This is an empty set already. Nothing to do. // This is an empty set already. Nothing to do.
return; return;
@@ -363,7 +363,7 @@ YOGA_EXPORT void YGNodeRemoveAllChildren(const YGNodeRef ownerRef) {
if (firstChild->getOwner() == owner) { if (firstChild->getOwner() == owner) {
// If the first child has this node as its owner, we assume that this child // If the first child has this node as its owner, we assume that this child
// set is unique. // set is unique.
for (uint32_t i = 0; i < childCount; i++) { for (size_t i = 0; i < childCount; i++) {
yoga::Node* oldChild = owner->getChild(i); yoga::Node* oldChild = owner->getChild(i);
oldChild->setLayout({}); // layout is no longer valid oldChild->setLayout({}); // layout is no longer valid
oldChild->setOwner(nullptr); oldChild->setOwner(nullptr);
@@ -381,7 +381,7 @@ YOGA_EXPORT void YGNodeRemoveAllChildren(const YGNodeRef ownerRef) {
YOGA_EXPORT void YGNodeSetChildren( YOGA_EXPORT void YGNodeSetChildren(
const YGNodeRef ownerRef, const YGNodeRef ownerRef,
const YGNodeRef* childrenRefs, const YGNodeRef* childrenRefs,
const uint32_t count) { const size_t count) {
auto owner = resolveRef(ownerRef); auto owner = resolveRef(ownerRef);
auto children = reinterpret_cast<yoga::Node* const*>(childrenRefs); auto children = reinterpret_cast<yoga::Node* const*>(childrenRefs);
@@ -391,7 +391,7 @@ YOGA_EXPORT void YGNodeSetChildren(
const std::vector<yoga::Node*> childrenVector = {children, children + count}; const std::vector<yoga::Node*> childrenVector = {children, children + count};
if (childrenVector.size() == 0) { if (childrenVector.size() == 0) {
if (YGNodeGetChildCount(owner) > 0) { if (owner->getChildCount() > 0) {
for (auto* child : owner->getChildren()) { for (auto* child : owner->getChildren()) {
child->setLayout({}); child->setLayout({});
child->setOwner(nullptr); child->setOwner(nullptr);
@@ -400,7 +400,7 @@ YOGA_EXPORT void YGNodeSetChildren(
owner->markDirtyAndPropagate(); owner->markDirtyAndPropagate();
} }
} else { } else {
if (YGNodeGetChildCount(owner) > 0) { if (owner->getChildCount() > 0) {
for (auto* oldChild : owner->getChildren()) { for (auto* oldChild : owner->getChildren()) {
// Our new children may have nodes in common with the old children. We // Our new children may have nodes in common with the old children. We
// don't reset these common nodes. // don't reset these common nodes.
@@ -420,7 +420,7 @@ YOGA_EXPORT void YGNodeSetChildren(
} }
YOGA_EXPORT YGNodeRef YOGA_EXPORT YGNodeRef
YGNodeGetChild(const YGNodeRef nodeRef, const uint32_t index) { YGNodeGetChild(const YGNodeRef nodeRef, const size_t index) {
const auto node = resolveRef(nodeRef); const auto node = resolveRef(nodeRef);
if (index < node->getChildren().size()) { if (index < node->getChildren().size()) {
@@ -429,8 +429,8 @@ YGNodeGetChild(const YGNodeRef nodeRef, const uint32_t index) {
return nullptr; return nullptr;
} }
YOGA_EXPORT uint32_t YGNodeGetChildCount(const YGNodeConstRef node) { YOGA_EXPORT size_t YGNodeGetChildCount(const YGNodeConstRef node) {
return static_cast<uint32_t>(resolveRef(node)->getChildren().size()); return resolveRef(node)->getChildren().size();
} }
YOGA_EXPORT YGNodeRef YGNodeGetOwner(const YGNodeRef node) { YOGA_EXPORT YGNodeRef YGNodeGetOwner(const YGNodeRef node) {

View File

@@ -9,6 +9,7 @@
#include <stdarg.h> #include <stdarg.h>
#include <stdbool.h> #include <stdbool.h>
#include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include <yoga/YGEnums.h> #include <yoga/YGEnums.h>
@@ -47,7 +48,7 @@ typedef int (*YGLogger)(
typedef YGNodeRef (*YGCloneNodeFunc)( typedef YGNodeRef (*YGCloneNodeFunc)(
YGNodeConstRef oldNode, YGNodeConstRef oldNode,
YGNodeConstRef owner, YGNodeConstRef owner,
int childIndex); size_t childIndex);
// YGNode // YGNode
WIN_EXPORT YGNodeRef YGNodeNew(void); WIN_EXPORT YGNodeRef YGNodeNew(void);
@@ -63,23 +64,20 @@ WIN_EXPORT void YGNodeReset(YGNodeRef node);
WIN_EXPORT void YGNodeInsertChild( WIN_EXPORT void YGNodeInsertChild(
YGNodeRef node, YGNodeRef node,
YGNodeRef child, YGNodeRef child,
uint32_t index); size_t index);
WIN_EXPORT void YGNodeSwapChild( WIN_EXPORT void YGNodeSwapChild(YGNodeRef node, YGNodeRef child, size_t index);
YGNodeRef node,
YGNodeRef child,
uint32_t index);
WIN_EXPORT void YGNodeRemoveChild(YGNodeRef node, YGNodeRef child); WIN_EXPORT void YGNodeRemoveChild(YGNodeRef node, YGNodeRef child);
WIN_EXPORT void YGNodeRemoveAllChildren(YGNodeRef node); WIN_EXPORT void YGNodeRemoveAllChildren(YGNodeRef node);
WIN_EXPORT YGNodeRef YGNodeGetChild(YGNodeRef node, uint32_t index); WIN_EXPORT YGNodeRef YGNodeGetChild(YGNodeRef node, size_t index);
WIN_EXPORT YGNodeRef YGNodeGetOwner(YGNodeRef node); WIN_EXPORT YGNodeRef YGNodeGetOwner(YGNodeRef node);
WIN_EXPORT YGNodeRef YGNodeGetParent(YGNodeRef node); WIN_EXPORT YGNodeRef YGNodeGetParent(YGNodeRef node);
WIN_EXPORT uint32_t YGNodeGetChildCount(YGNodeConstRef node); WIN_EXPORT size_t YGNodeGetChildCount(YGNodeConstRef node);
WIN_EXPORT void YGNodeSetChildren( WIN_EXPORT void YGNodeSetChildren(
YGNodeRef owner, YGNodeRef owner,
const YGNodeRef* children, const YGNodeRef* children,
uint32_t count); size_t count);
WIN_EXPORT void YGNodeSetIsReferenceBaseline( WIN_EXPORT void YGNodeSetIsReferenceBaseline(
YGNodeRef node, YGNodeRef node,

View File

@@ -34,8 +34,8 @@ float calculateBaseline(const yoga::Node* node, void* layoutContext) {
} }
yoga::Node* baselineChild = nullptr; yoga::Node* baselineChild = nullptr;
const uint32_t childCount = YGNodeGetChildCount(node); const size_t childCount = node->getChildCount();
for (uint32_t i = 0; i < childCount; i++) { for (size_t i = 0; i < childCount; i++) {
auto child = node->getChild(i); auto child = node->getChild(i);
if (child->getLineIndex() > 0) { if (child->getLineIndex() > 0) {
break; break;

View File

@@ -965,8 +965,8 @@ static CollectFlexItemsRowValues calculateCollectFlexItemsRowValues(
const float mainAxisownerSize, const float mainAxisownerSize,
const float availableInnerWidth, const float availableInnerWidth,
const float availableInnerMainDim, const float availableInnerMainDim,
const uint32_t startOfLineIndex, const size_t startOfLineIndex,
const uint32_t lineCount) { const size_t lineCount) {
CollectFlexItemsRowValues flexAlgoRowMeasurement = {}; CollectFlexItemsRowValues flexAlgoRowMeasurement = {};
flexAlgoRowMeasurement.relativeChildren.reserve(node->getChildren().size()); flexAlgoRowMeasurement.relativeChildren.reserve(node->getChildren().size());
@@ -977,7 +977,7 @@ static CollectFlexItemsRowValues calculateCollectFlexItemsRowValues(
const float gap = node->getGapForAxis(mainAxis, availableInnerWidth).unwrap(); const float gap = node->getGapForAxis(mainAxis, availableInnerWidth).unwrap();
// Add items to the current line until it's full or we run out of items. // Add items to the current line until it's full or we run out of items.
uint32_t endOfLineIndex = startOfLineIndex; size_t endOfLineIndex = startOfLineIndex;
for (; endOfLineIndex < node->getChildren().size(); endOfLineIndex++) { for (; endOfLineIndex < node->getChildren().size(); endOfLineIndex++) {
auto child = node->getChild(endOfLineIndex); auto child = node->getChild(endOfLineIndex);
if (child->getStyle().display() == YGDisplayNone || if (child->getStyle().display() == YGDisplayNone ||
@@ -1408,7 +1408,7 @@ static void resolveFlexibleLength(
static void YGJustifyMainAxis( static void YGJustifyMainAxis(
yoga::Node* const node, yoga::Node* const node,
CollectFlexItemsRowValues& collectedFlexItemsValues, CollectFlexItemsRowValues& collectedFlexItemsValues,
const uint32_t startOfLineIndex, const size_t startOfLineIndex,
const YGFlexDirection mainAxis, const YGFlexDirection mainAxis,
const YGFlexDirection crossAxis, const YGFlexDirection crossAxis,
const YGMeasureMode measureModeMainDim, const YGMeasureMode measureModeMainDim,
@@ -1456,8 +1456,7 @@ static void YGJustifyMainAxis(
} }
int numberOfAutoMarginsOnCurrentLine = 0; int numberOfAutoMarginsOnCurrentLine = 0;
for (uint32_t i = startOfLineIndex; for (size_t i = startOfLineIndex; i < collectedFlexItemsValues.endOfLineIndex;
i < collectedFlexItemsValues.endOfLineIndex;
i++) { i++) {
auto child = node->getChild(i); auto child = node->getChild(i);
if (child->getStyle().positionType() != YGPositionTypeAbsolute) { if (child->getStyle().positionType() != YGPositionTypeAbsolute) {
@@ -1517,8 +1516,7 @@ static void YGJustifyMainAxis(
float maxAscentForCurrentLine = 0; float maxAscentForCurrentLine = 0;
float maxDescentForCurrentLine = 0; float maxDescentForCurrentLine = 0;
bool isNodeBaselineLayout = isBaselineLayout(node); bool isNodeBaselineLayout = isBaselineLayout(node);
for (uint32_t i = startOfLineIndex; for (size_t i = startOfLineIndex; i < collectedFlexItemsValues.endOfLineIndex;
i < collectedFlexItemsValues.endOfLineIndex;
i++) { i++) {
const auto child = node->getChild(i); const auto child = node->getChild(i);
const Style& childStyle = child->getStyle(); const Style& childStyle = child->getStyle();
@@ -1906,11 +1904,11 @@ static void calculateLayoutImpl(
// STEP 4: COLLECT FLEX ITEMS INTO FLEX LINES // STEP 4: COLLECT FLEX ITEMS INTO FLEX LINES
// Indexes of children that represent the first and last items in the line. // Indexes of children that represent the first and last items in the line.
uint32_t startOfLineIndex = 0; size_t startOfLineIndex = 0;
uint32_t endOfLineIndex = 0; size_t endOfLineIndex = 0;
// Number of lines. // Number of lines.
uint32_t lineCount = 0; size_t lineCount = 0;
// Accumulated cross dimensions of all lines so far. // Accumulated cross dimensions of all lines so far.
float totalLineCrossDim = 0; float totalLineCrossDim = 0;
@@ -2093,7 +2091,7 @@ static void calculateLayoutImpl(
// STEP 7: CROSS-AXIS ALIGNMENT // STEP 7: CROSS-AXIS ALIGNMENT
// We can skip child alignment if we're just measuring the container. // We can skip child alignment if we're just measuring the container.
if (performLayout) { if (performLayout) {
for (uint32_t i = startOfLineIndex; i < endOfLineIndex; i++) { for (size_t i = startOfLineIndex; i < endOfLineIndex; i++) {
const auto child = node->getChild(i); const auto child = node->getChild(i);
if (child->getStyle().display() == YGDisplayNone) { if (child->getStyle().display() == YGDisplayNone) {
continue; continue;
@@ -2291,10 +2289,10 @@ static void calculateLayoutImpl(
break; break;
} }
} }
uint32_t endIndex = 0; size_t endIndex = 0;
for (uint32_t i = 0; i < lineCount; i++) { for (size_t i = 0; i < lineCount; i++) {
const uint32_t startIndex = endIndex; const size_t startIndex = endIndex;
uint32_t ii; size_t ii;
// compute the line's height and find the endIndex // compute the line's height and find the endIndex
float lineHeight = 0; float lineHeight = 0;
@@ -2537,7 +2535,7 @@ static void calculateLayoutImpl(
// As we only wrapped in normal direction yet, we need to reverse the // As we only wrapped in normal direction yet, we need to reverse the
// positions on wrap-reverse. // positions on wrap-reverse.
if (performLayout && node->getStyle().flexWrap() == YGWrapWrapReverse) { if (performLayout && node->getStyle().flexWrap() == YGWrapWrapReverse) {
for (uint32_t i = 0; i < childCount; i++) { for (size_t i = 0; i < childCount; i++) {
const auto child = node->getChild(i); const auto child = node->getChild(i);
if (child->getStyle().positionType() != YGPositionTypeAbsolute) { if (child->getStyle().positionType() != YGPositionTypeAbsolute) {
child->setLayoutPosition( child->setLayoutPosition(
@@ -2586,7 +2584,7 @@ static void calculateLayoutImpl(
// Set trailing position if necessary. // Set trailing position if necessary.
if (needsMainTrailingPos || needsCrossTrailingPos) { if (needsMainTrailingPos || needsCrossTrailingPos) {
for (uint32_t i = 0; i < childCount; i++) { for (size_t i = 0; i < childCount; i++) {
const auto child = node->getChild(i); const auto child = node->getChild(i);
if (child->getStyle().display() == YGDisplayNone) { if (child->getStyle().display() == YGDisplayNone) {
continue; continue;
@@ -2710,7 +2708,7 @@ bool calculateLayoutInternal(
cachedResults = &layout->cachedLayout; cachedResults = &layout->cachedLayout;
} else { } else {
// Try to use the measurement cache. // Try to use the measurement cache.
for (uint32_t i = 0; i < layout->nextCachedMeasurementsIndex; i++) { for (size_t i = 0; i < layout->nextCachedMeasurementsIndex; i++) {
if (canUseCachedMeasurement( if (canUseCachedMeasurement(
widthMeasureMode, widthMeasureMode,
availableWidth, availableWidth,

View File

@@ -39,11 +39,11 @@ namespace facebook::yoga {
// and/or grow. // and/or grow.
struct CollectFlexItemsRowValues { struct CollectFlexItemsRowValues {
uint32_t itemsOnLine; size_t itemsOnLine;
float sizeConsumedOnCurrentLine; float sizeConsumedOnCurrentLine;
float totalFlexGrowFactors; float totalFlexGrowFactors;
float totalFlexShrinkScaledFactors; float totalFlexShrinkScaledFactors;
uint32_t endOfLineIndex; size_t endOfLineIndex;
std::vector<yoga::Node*> relativeChildren; std::vector<yoga::Node*> relativeChildren;
float remainingFreeSpace; float remainingFreeSpace;
// The size of the mainDim for the row after considering size, padding, margin // The size of the mainDim for the row after considering size, padding, margin

View File

@@ -125,8 +125,8 @@ void roundLayoutResultsToPixelGrid(
absoluteNodeTop, pointScaleFactor, false, textRounding), absoluteNodeTop, pointScaleFactor, false, textRounding),
YGDimensionHeight); YGDimensionHeight);
const uint32_t childCount = YGNodeGetChildCount(node); const size_t childCount = node->getChildCount();
for (uint32_t i = 0; i < childCount; i++) { for (size_t i = 0; i < childCount; i++) {
roundLayoutResultsToPixelGrid( roundLayoutResultsToPixelGrid(
node->getChild(i), pointScaleFactor, absoluteNodeLeft, absoluteNodeTop); node->getChild(i), pointScaleFactor, absoluteNodeLeft, absoluteNodeTop);
} }

View File

@@ -131,7 +131,7 @@ void Config::setCloneNodeCallback(std::nullptr_t) {
YGNodeRef Config::cloneNode( YGNodeRef Config::cloneNode(
YGNodeConstRef node, YGNodeConstRef node,
YGNodeConstRef owner, YGNodeConstRef owner,
int childIndex, size_t childIndex,
void* cloneContext) const { void* cloneContext) const {
YGNodeRef clone = nullptr; YGNodeRef clone = nullptr;
if (cloneNodeCallback_.noContext != nullptr) { if (cloneNodeCallback_.noContext != nullptr) {

View File

@@ -34,7 +34,7 @@ using LogWithContextFn = int (*)(
using CloneWithContextFn = YGNodeRef (*)( using CloneWithContextFn = YGNodeRef (*)(
YGNodeConstRef node, YGNodeConstRef node,
YGNodeConstRef owner, YGNodeConstRef owner,
int childIndex, size_t childIndex,
void* cloneContext); void* cloneContext);
#pragma pack(push) #pragma pack(push)
@@ -92,7 +92,7 @@ public:
YGNodeRef cloneNode( YGNodeRef cloneNode(
YGNodeConstRef node, YGNodeConstRef node,
YGNodeConstRef owner, YGNodeConstRef owner,
int childIndex, size_t childIndex,
void* cloneContext) const; void* cloneContext) const;
private: private:

View File

@@ -227,9 +227,9 @@ void nodeToString(
} }
appendFormattedString(str, ">"); appendFormattedString(str, ">");
const uint32_t childCount = static_cast<uint32_t>(node->getChildren().size()); const size_t childCount = node->getChildCount();
if (options & YGPrintOptionsChildren && childCount > 0) { if (options & YGPrintOptionsChildren && childCount > 0) {
for (uint32_t i = 0; i < childCount; i++) { for (size_t i = 0; i < childCount; i++) {
appendFormattedString(str, "\n"); appendFormattedString(str, "\n");
nodeToString(str, node->getChild(i), options, level + 1); nodeToString(str, node->getChild(i), options, level + 1);
} }

View File

@@ -484,7 +484,7 @@ YOGA_EXPORT void Node::clearChildren() {
// Other Methods // Other Methods
void Node::cloneChildrenIfNeeded(void* cloneContext) { void Node::cloneChildrenIfNeeded(void* cloneContext) {
int i = 0; size_t i = 0;
for (Node*& child : children_) { for (Node*& child : children_) {
if (child->getOwner() != this) { if (child->getOwner() != this) {
child = resolveRef(config_->cloneNode(child, this, i, cloneContext)); child = resolveRef(config_->cloneNode(child, this, i, cloneContext));

View File

@@ -68,7 +68,7 @@ private:
YGDirtiedFunc dirtied_ = nullptr; YGDirtiedFunc dirtied_ = nullptr;
Style style_ = {}; Style style_ = {};
LayoutResults layout_ = {}; LayoutResults layout_ = {};
uint32_t lineIndex_ = 0; size_t lineIndex_ = 0;
Node* owner_ = nullptr; Node* owner_ = nullptr;
std::vector<Node*> children_ = {}; std::vector<Node*> children_ = {};
Config* config_; Config* config_;
@@ -146,7 +146,7 @@ public:
const LayoutResults& getLayout() const { return layout_; } const LayoutResults& getLayout() const { return layout_; }
uint32_t getLineIndex() const { return lineIndex_; } size_t getLineIndex() const { return lineIndex_; }
bool isReferenceBaseline() const { return flags_.isReferenceBaseline; } bool isReferenceBaseline() const { return flags_.isReferenceBaseline; }
@@ -276,7 +276,7 @@ public:
void setLayout(const LayoutResults& layout) { layout_ = layout; } void setLayout(const LayoutResults& layout) { layout_ = layout; }
void setLineIndex(uint32_t lineIndex) { lineIndex_ = lineIndex; } void setLineIndex(size_t lineIndex) { lineIndex_ = lineIndex; }
void setIsReferenceBaseline(bool isReferenceBaseline) { void setIsReferenceBaseline(bool isReferenceBaseline) {
flags_.isReferenceBaseline = isReferenceBaseline; flags_.isReferenceBaseline = isReferenceBaseline;