Skip to content

Commit ddadca7

Browse files
sammy-SCmeta-codesync[bot]
authored andcommitted
clean up ShadowNode class (#55685)
Summary: Pull Request resolved: #55685 changelog: [internal] Small cleanups: - Renames `updateTraitsIfNeccessary()` (note the typo) to the more descriptive and correctly-spelled `propagateUncullableTraitsFromChildren()`. - Removes the unused `hasBeenPromoted_` member field from ShadowNode. - Removes unnecessary include. - Fixes two typos in comments. Reviewed By: lenaic Differential Revision: D90277059 fbshipit-source-id: 7255345abd8abb668cfe79ff763417c4ebbe8aac
1 parent 58ed78f commit ddadca7

2 files changed

Lines changed: 13 additions & 19 deletions

File tree

packages/react-native/ReactCommon/react/renderer/core/ShadowNode.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
#include "ShadowNode.h"
99
#include "DynamicPropsUtilities.h"
10-
#include "ShadowNodeFragment.h"
1110

1211
#include <react/debug/react_native_assert.h>
1312
#include <react/featureflags/ReactNativeFeatureFlags.h>
@@ -24,7 +23,7 @@ namespace facebook::react {
2423
* Runtime shadow node reference updates should only run from one thread at all
2524
* times to avoid having more than one shadow tree updating the current fiber
2625
* tree simultaneously. This thread_local flag allows enabling the updates for
27-
* choses threads.
26+
* chosen threads.
2827
*/
2928
thread_local bool useRuntimeShadowNodeReferenceUpdateOnThread{false}; // NOLINT
3029

@@ -100,7 +99,7 @@ ShadowNode::ShadowNode(
10099
child->family_->setParent(family_);
101100
}
102101

103-
updateTraitsIfNeccessary();
102+
propagateUncullableTraitsFromChildren();
104103

105104
// The first node of the family gets its state committed automatically.
106105
family_->setMostRecentState(state_);
@@ -129,7 +128,7 @@ ShadowNode::ShadowNode(
129128
for (const auto& child : *children_) {
130129
child->family_->setParent(family_);
131130
}
132-
updateTraitsIfNeccessary();
131+
propagateUncullableTraitsFromChildren();
133132
}
134133
}
135134

@@ -151,7 +150,7 @@ std::shared_ptr<ShadowNode> ShadowNode::clone(
151150
.state = fragment.state});
152151
return clonedNode;
153152
} else {
154-
// TODO: We might need to merge fragment.priops with
153+
// TODO: We might need to merge fragment.props with
155154
// `family.nativeProps_DEPRECATED`.
156155
return componentDescriptor.cloneShadowNode(*this, fragment);
157156
}
@@ -245,7 +244,7 @@ void ShadowNode::appendChild(const std::shared_ptr<const ShadowNode>& child) {
245244
children.push_back(child);
246245

247246
child->family_->setParent(family_);
248-
updateTraitsIfNeccessary();
247+
propagateUncullableTraitsFromChildren();
249248
}
250249

251250
void ShadowNode::replaceChild(
@@ -279,7 +278,7 @@ void ShadowNode::replaceChild(
279278
}
280279

281280
react_native_assert(false && "Child to replace was not found.");
282-
updateTraitsIfNeccessary();
281+
propagateUncullableTraitsFromChildren();
283282
}
284283

285284
void ShadowNode::cloneChildrenIfShared() {
@@ -292,7 +291,7 @@ void ShadowNode::cloneChildrenIfShared() {
292291
*children_);
293292
}
294293

295-
void ShadowNode::updateTraitsIfNeccessary() {
294+
void ShadowNode::propagateUncullableTraitsFromChildren() {
296295
if (ReactNativeFeatureFlags::enableViewCulling()) {
297296
if (traits_.check(ShadowNodeTraits::Trait::Unstable_uncullableView)) {
298297
return;

packages/react-native/ReactCommon/react/renderer/core/ShadowNode.h

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -252,13 +252,13 @@ class ShadowNode : public Sealable, public DebugStringConvertible, public jsi::N
252252
void cloneChildrenIfShared();
253253

254254
/*
255-
* Updates the node's traits based on its children's traits.
256-
* Specifically, if view culling is enabled and any child has the
257-
* Unstable_uncullableView or Unstable_uncullableTrace trait, this node will
258-
* also be marked as uncullable. This ensures that if a child needs to be
259-
* rendered, its parent will be too.
255+
* Propagates uncullable traits from children to this node.
256+
* If view culling is enabled and any child has the Unstable_uncullableView
257+
* or Unstable_uncullableTrace trait, this node will also be marked as
258+
* uncullable. This ensures that if a child needs to be rendered, its parent
259+
* will be too.
260260
*/
261-
void updateTraitsIfNeccessary();
261+
void propagateUncullableTraitsFromChildren();
262262

263263
/*
264264
* Transfer the runtime reference to this `ShadowNode` to a new instance,
@@ -277,11 +277,6 @@ class ShadowNode : public Sealable, public DebugStringConvertible, public jsi::N
277277
*/
278278
mutable std::atomic<bool> hasBeenMounted_{false};
279279

280-
/*
281-
* True if shadow node has been promoted to be the next mounted tree.
282-
*/
283-
mutable bool hasBeenPromoted_{false};
284-
285280
static Props::Shared propsForClonedShadowNode(const ShadowNode &sourceShadowNode, const Props::Shared &props);
286281

287282
protected:

0 commit comments

Comments
 (0)