|
| 1 | +diff --git a/node_modules/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp b/node_modules/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp |
| 2 | +index 3618474..ab5b828 100644 |
| 3 | +--- a/node_modules/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp |
| 4 | ++++ b/node_modules/react-native/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp |
| 5 | +@@ -476,16 +476,19 @@ static void zeroOutLayoutRecursively(yoga::Node* const node) { |
| 6 | + } |
| 7 | + |
| 8 | + static void cleanupContentsNodesRecursively(yoga::Node* const node) { |
| 9 | +- for (auto child : node->getChildren()) { |
| 10 | +- if (child->style().display() == Display::Contents) { |
| 11 | +- child->getLayout() = {}; |
| 12 | +- child->setLayoutDimension(0, Dimension::Width); |
| 13 | +- child->setLayoutDimension(0, Dimension::Height); |
| 14 | +- child->setHasNewLayout(true); |
| 15 | +- child->setDirty(false); |
| 16 | +- child->cloneChildrenIfNeeded(); |
| 17 | +- |
| 18 | +- cleanupContentsNodesRecursively(child); |
| 19 | ++ if (node->hasContentsChildren()) [[unlikely]] { |
| 20 | ++ node->cloneContentsChildrenIfNeeded(); |
| 21 | ++ for (auto child : node->getChildren()) { |
| 22 | ++ if (child->style().display() == Display::Contents) { |
| 23 | ++ child->getLayout() = {}; |
| 24 | ++ child->setLayoutDimension(0, Dimension::Width); |
| 25 | ++ child->setLayoutDimension(0, Dimension::Height); |
| 26 | ++ child->setHasNewLayout(true); |
| 27 | ++ child->setDirty(false); |
| 28 | ++ child->cloneChildrenIfNeeded(); |
| 29 | ++ |
| 30 | ++ cleanupContentsNodesRecursively(child); |
| 31 | ++ } |
| 32 | + } |
| 33 | + } |
| 34 | + } |
| 35 | +diff --git a/node_modules/react-native/ReactCommon/yoga/yoga/node/Node.cpp b/node_modules/react-native/ReactCommon/yoga/yoga/node/Node.cpp |
| 36 | +index dce42fb..f1bc5e8 100644 |
| 37 | +--- a/node_modules/react-native/ReactCommon/yoga/yoga/node/Node.cpp |
| 38 | ++++ b/node_modules/react-native/ReactCommon/yoga/yoga/node/Node.cpp |
| 39 | +@@ -181,6 +181,17 @@ void Node::setDirty(bool isDirty) { |
| 40 | + } |
| 41 | + } |
| 42 | + |
| 43 | ++void Node::setChildren(const std::vector<Node*>& children) { |
| 44 | ++ children_ = children; |
| 45 | ++ |
| 46 | ++ contentsChildrenCount_ = 0; |
| 47 | ++ for (const auto& child : children) { |
| 48 | ++ if (child->style().display() == Display::Contents) { |
| 49 | ++ contentsChildrenCount_++; |
| 50 | ++ } |
| 51 | ++ } |
| 52 | ++} |
| 53 | ++ |
| 54 | + bool Node::removeChild(Node* child) { |
| 55 | + auto p = std::find(children_.begin(), children_.end(), child); |
| 56 | + if (p != children_.end()) { |
| 57 | +@@ -379,6 +390,23 @@ void Node::cloneChildrenIfNeeded() { |
| 58 | + if (child->getOwner() != this) { |
| 59 | + child = resolveRef(config_->cloneNode(child, this, i)); |
| 60 | + child->setOwner(this); |
| 61 | ++ |
| 62 | ++ if (child->hasContentsChildren()) [[unlikely]] { |
| 63 | ++ child->cloneContentsChildrenIfNeeded(); |
| 64 | ++ } |
| 65 | ++ } |
| 66 | ++ i += 1; |
| 67 | ++ } |
| 68 | ++} |
| 69 | ++ |
| 70 | ++void Node::cloneContentsChildrenIfNeeded() { |
| 71 | ++ size_t i = 0; |
| 72 | ++ for (Node*& child : children_) { |
| 73 | ++ if (child->style().display() == Display::Contents && |
| 74 | ++ child->getOwner() != this) { |
| 75 | ++ child = resolveRef(config_->cloneNode(child, this, i)); |
| 76 | ++ child->setOwner(this); |
| 77 | ++ child->cloneChildrenIfNeeded(); |
| 78 | + } |
| 79 | + i += 1; |
| 80 | + } |
| 81 | +diff --git a/node_modules/react-native/ReactCommon/yoga/yoga/node/Node.h b/node_modules/react-native/ReactCommon/yoga/yoga/node/Node.h |
| 82 | +index 5ae7d43..3454d54 100644 |
| 83 | +--- a/node_modules/react-native/ReactCommon/yoga/yoga/node/Node.h |
| 84 | ++++ b/node_modules/react-native/ReactCommon/yoga/yoga/node/Node.h |
| 85 | +@@ -96,6 +96,10 @@ class YG_EXPORT Node : public ::YGNode { |
| 86 | + return config_->hasErrata(errata); |
| 87 | + } |
| 88 | + |
| 89 | ++ bool hasContentsChildren() const { |
| 90 | ++ return contentsChildrenCount_ != 0; |
| 91 | ++ } |
| 92 | ++ |
| 93 | + YGDirtiedFunc getDirtiedFunc() const { |
| 94 | + return dirtiedFunc_; |
| 95 | + } |
| 96 | +@@ -244,15 +248,12 @@ class YG_EXPORT Node : public ::YGNode { |
| 97 | + owner_ = owner; |
| 98 | + } |
| 99 | + |
| 100 | +- void setChildren(const std::vector<Node*>& children) { |
| 101 | +- children_ = children; |
| 102 | +- } |
| 103 | +- |
| 104 | + // TODO: rvalue override for setChildren |
| 105 | + |
| 106 | + void setConfig(Config* config); |
| 107 | + |
| 108 | + void setDirty(bool isDirty); |
| 109 | ++ void setChildren(const std::vector<Node*>& children); |
| 110 | + void setLayoutLastOwnerDirection(Direction direction); |
| 111 | + void setLayoutComputedFlexBasis(FloatOptional computedFlexBasis); |
| 112 | + void setLayoutComputedFlexBasisGeneration( |
| 113 | +@@ -286,6 +287,7 @@ class YG_EXPORT Node : public ::YGNode { |
| 114 | + void removeChild(size_t index); |
| 115 | + |
| 116 | + void cloneChildrenIfNeeded(); |
| 117 | ++ void cloneContentsChildrenIfNeeded(); |
| 118 | + void markDirtyAndPropagate(); |
| 119 | + float resolveFlexGrow() const; |
| 120 | + float resolveFlexShrink() const; |
0 commit comments