mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
clean up ShadowNode class (#55685)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/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
This commit is contained in:
1 parent
58ed78fec1
commit
ddadca7a19
2 files changed
+13
-19
No files matched your search
@@ -7,7 +7,6 @@
|
||||
|
||||
#include "ShadowNode.h"
|
||||
#include "DynamicPropsUtilities.h"
|
||||
#include "ShadowNodeFragment.h"
|
||||
|
||||
#include <react/debug/react_native_assert.h>
|
||||
#include <react/featureflags/ReactNativeFeatureFlags.h>
|
||||
@@ -24,7 +23,7 @@ namespace facebook::react {
|
||||
* Runtime shadow node reference updates should only run from one thread at all
|
||||
* times to avoid having more than one shadow tree updating the current fiber
|
||||
* tree simultaneously. This thread_local flag allows enabling the updates for
|
||||
* choses threads.
|
||||
* chosen threads.
|
||||
*/
|
||||
thread_local bool useRuntimeShadowNodeReferenceUpdateOnThread{false}; // NOLINT
|
||||
|
||||
@@ -100,7 +99,7 @@ ShadowNode::ShadowNode(
|
||||
child->family_->setParent(family_);
|
||||
}
|
||||
|
||||
updateTraitsIfNeccessary();
|
||||
propagateUncullableTraitsFromChildren();
|
||||
|
||||
// The first node of the family gets its state committed automatically.
|
||||
family_->setMostRecentState(state_);
|
||||
@@ -129,7 +128,7 @@ ShadowNode::ShadowNode(
|
||||
for (const auto& child : *children_) {
|
||||
child->family_->setParent(family_);
|
||||
}
|
||||
updateTraitsIfNeccessary();
|
||||
propagateUncullableTraitsFromChildren();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,7 +150,7 @@ std::shared_ptr<ShadowNode> ShadowNode::clone(
|
||||
.state = fragment.state});
|
||||
return clonedNode;
|
||||
} else {
|
||||
// TODO: We might need to merge fragment.priops with
|
||||
// TODO: We might need to merge fragment.props with
|
||||
// `family.nativeProps_DEPRECATED`.
|
||||
return componentDescriptor.cloneShadowNode(*this, fragment);
|
||||
}
|
||||
@@ -245,7 +244,7 @@ void ShadowNode::appendChild(const std::shared_ptr<const ShadowNode>& child) {
|
||||
children.push_back(child);
|
||||
|
||||
child->family_->setParent(family_);
|
||||
updateTraitsIfNeccessary();
|
||||
propagateUncullableTraitsFromChildren();
|
||||
}
|
||||
|
||||
void ShadowNode::replaceChild(
|
||||
@@ -279,7 +278,7 @@ void ShadowNode::replaceChild(
|
||||
}
|
||||
|
||||
react_native_assert(false && "Child to replace was not found.");
|
||||
updateTraitsIfNeccessary();
|
||||
propagateUncullableTraitsFromChildren();
|
||||
}
|
||||
|
||||
void ShadowNode::cloneChildrenIfShared() {
|
||||
@@ -292,7 +291,7 @@ void ShadowNode::cloneChildrenIfShared() {
|
||||
*children_);
|
||||
}
|
||||
|
||||
void ShadowNode::updateTraitsIfNeccessary() {
|
||||
void ShadowNode::propagateUncullableTraitsFromChildren() {
|
||||
if (ReactNativeFeatureFlags::enableViewCulling()) {
|
||||
if (traits_.check(ShadowNodeTraits::Trait::Unstable_uncullableView)) {
|
||||
return;
|
||||
|
||||
@@ -252,13 +252,13 @@ class ShadowNode : public Sealable, public DebugStringConvertible, public jsi::N
|
||||
void cloneChildrenIfShared();
|
||||
|
||||
/*
|
||||
* Updates the node's traits based on its children's traits.
|
||||
* Specifically, if view culling is enabled and any child has the
|
||||
* Unstable_uncullableView or Unstable_uncullableTrace trait, this node will
|
||||
* also be marked as uncullable. This ensures that if a child needs to be
|
||||
* rendered, its parent will be too.
|
||||
* Propagates uncullable traits from children to this node.
|
||||
* If view culling is enabled and any child has the Unstable_uncullableView
|
||||
* or Unstable_uncullableTrace trait, this node will also be marked as
|
||||
* uncullable. This ensures that if a child needs to be rendered, its parent
|
||||
* will be too.
|
||||
*/
|
||||
void updateTraitsIfNeccessary();
|
||||
void propagateUncullableTraitsFromChildren();
|
||||
|
||||
/*
|
||||
* Transfer the runtime reference to this `ShadowNode` to a new instance,
|
||||
@@ -277,11 +277,6 @@ class ShadowNode : public Sealable, public DebugStringConvertible, public jsi::N
|
||||
*/
|
||||
mutable std::atomic<bool> hasBeenMounted_{false};
|
||||
|
||||
/*
|
||||
* True if shadow node has been promoted to be the next mounted tree.
|
||||
*/
|
||||
mutable bool hasBeenPromoted_{false};
|
||||
|
||||
static Props::Shared propsForClonedShadowNode(const ShadowNode &sourceShadowNode, const Props::Shared &props);
|
||||
|
||||
protected:
|
||||
|
||||
Reference in new issue
Block a user