Skip to content

Commit

Permalink
Remove deprecated ShadowNode type aliases
Browse files Browse the repository at this point in the history
Summary:
Fix todo and inconsistency across codebase. It's better to have just one way to refer to these types.

Changelog: [Internal]

Reviewed By: philIip

Differential Revision: D37653146

fbshipit-source-id: e82f09caa6cd6eec5512b78f413708d9c04a7a83
  • Loading branch information
javache authored and facebook-github-bot committed Jul 12, 2022
1 parent 53c8fc9 commit 13a0556
Show file tree
Hide file tree
Showing 17 changed files with 188 additions and 187 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ static void testShadowNodeTreeLifeCycleLayoutAnimations(
auto currentRootNode = std::static_pointer_cast<RootShadowNode const>(
emptyRootNode->ShadowNode::clone(ShadowNodeFragment{
ShadowNodeFragment::propsPlaceholder(),
std::make_shared<SharedShadowNodeList>(
SharedShadowNodeList{singleRootChildNode})}));
std::make_shared<ShadowNode::ListOfShared>(
ShadowNode::ListOfShared{singleRootChildNode})}));

// Building an initial view hierarchy.
auto viewTree = buildStubViewTreeWithoutUsingDifferentiator(*emptyRootNode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ bool ComponentDescriptorRegistry::hasComponentDescriptorAt(
return true;
}

SharedShadowNode ComponentDescriptorRegistry::createNode(
ShadowNode::Shared ComponentDescriptorRegistry::createNode(
Tag tag,
std::string const &viewName,
SurfaceId surfaceId,
Expand Down
12 changes: 6 additions & 6 deletions ReactCommon/react/renderer/core/ShadowNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
namespace facebook {
namespace react {

SharedShadowNodeSharedList ShadowNode::emptySharedShadowNodeSharedList() {
ShadowNode::SharedListOfShared ShadowNode::emptySharedShadowNodeSharedList() {
static const auto emptySharedShadowNodeSharedList =
std::make_shared<SharedShadowNodeList>();
std::make_shared<ShadowNode::ListOfShared>();
return emptySharedShadowNodeSharedList;
}

Expand Down Expand Up @@ -131,7 +131,7 @@ ComponentHandle ShadowNode::getComponentHandle() const {
return family_->getComponentHandle();
}

const SharedShadowNodeList &ShadowNode::getChildren() const {
const ShadowNode::ListOfShared &ShadowNode::getChildren() const {
return *children_;
}

Expand Down Expand Up @@ -192,7 +192,7 @@ void ShadowNode::appendChild(const ShadowNode::Shared &child) {

cloneChildrenIfShared();
auto nonConstChildren =
std::const_pointer_cast<SharedShadowNodeList>(children_);
std::const_pointer_cast<ShadowNode::ListOfShared>(children_);
nonConstChildren->push_back(child);

child->family_->setParent(family_);
Expand Down Expand Up @@ -237,7 +237,7 @@ void ShadowNode::cloneChildrenIfShared() {
}

traits_.unset(ShadowNodeTraits::Trait::ChildrenAreShared);
children_ = std::make_shared<SharedShadowNodeList>(*children_);
children_ = std::make_shared<ShadowNode::ListOfShared>(*children_);
}

void ShadowNode::setMounted(bool mounted) const {
Expand Down Expand Up @@ -285,7 +285,7 @@ ShadowNode::Unshared ShadowNode::cloneTree(

childNode = parentNode.clone({
ShadowNodeFragment::propsPlaceholder(),
std::make_shared<SharedShadowNodeList>(children),
std::make_shared<ShadowNode::ListOfShared>(children),
});
}

Expand Down
27 changes: 9 additions & 18 deletions ReactCommon/react/renderer/core/ShadowNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,6 @@ static constexpr const int kShadowNodeChildrenSmallVectorSize = 8;

class ComponentDescriptor;
struct ShadowNodeFragment;
class ShadowNode;

// Deprecated: Use ShadowNode::Shared instead
using SharedShadowNode = std::shared_ptr<const ShadowNode>;
using WeakShadowNode = std::weak_ptr<const ShadowNode>;
using SharedShadowNodeList =
butter::small_vector<SharedShadowNode, kShadowNodeChildrenSmallVectorSize>;
using SharedShadowNodeSharedList = std::shared_ptr<const SharedShadowNodeList>;
using SharedShadowNodeUnsharedList = std::shared_ptr<SharedShadowNodeList>;

class ShadowNode : public Sealable, public DebugStringConvertible {
public:
Expand All @@ -57,7 +48,7 @@ class ShadowNode : public Sealable, public DebugStringConvertible {
int /* childIndex */>,
64>;

static SharedShadowNodeSharedList emptySharedShadowNodeSharedList();
static SharedListOfShared emptySharedShadowNodeSharedList();

/*
* Returns `true` if nodes belong to the same family (they were cloned one
Expand Down Expand Up @@ -103,7 +94,7 @@ class ShadowNode : public Sealable, public DebugStringConvertible {
/*
* Clones the shadow node using stored `cloneFunction`.
*/
ShadowNode::Unshared clone(const ShadowNodeFragment &fragment) const;
Unshared clone(const ShadowNodeFragment &fragment) const;

/*
* Clones the node (and partially the tree starting from the node) by
Expand All @@ -112,10 +103,10 @@ class ShadowNode : public Sealable, public DebugStringConvertible {
*
* Returns `nullptr` if the operation cannot be performed successfully.
*/
ShadowNode::Unshared cloneTree(
Unshared cloneTree(
ShadowNodeFamily const &shadowNodeFamily,
std::function<ShadowNode::Unshared(ShadowNode const &oldShadowNode)> const
&callback) const;
std::function<Unshared(ShadowNode const &oldShadowNode)> const &callback)
const;

#pragma mark - Getters

Expand All @@ -128,7 +119,7 @@ class ShadowNode : public Sealable, public DebugStringConvertible {
ShadowNodeTraits getTraits() const;

SharedProps const &getProps() const;
SharedShadowNodeList const &getChildren() const;
ListOfShared const &getChildren() const;
SharedEventEmitter const &getEventEmitter() const;
Tag getTag() const;
SurfaceId getSurfaceId() const;
Expand Down Expand Up @@ -165,10 +156,10 @@ class ShadowNode : public Sealable, public DebugStringConvertible {

#pragma mark - Mutating Methods

void appendChild(ShadowNode::Shared const &child);
void appendChild(Shared const &child);
void replaceChild(
ShadowNode const &oldChild,
ShadowNode::Shared const &newChild,
Shared const &newChild,
int suggestedIndex = -1);

/*
Expand Down Expand Up @@ -196,7 +187,7 @@ class ShadowNode : public Sealable, public DebugStringConvertible {

protected:
SharedProps props_;
SharedShadowNodeSharedList children_;
SharedListOfShared children_;
State::Shared state_;
int orderIndex_;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ TEST(ComponentDescriptorTest, createShadowNode) {
},
nullptr);

SharedShadowNode node = descriptor->createShadowNode(
ShadowNode::Shared node = descriptor->createShadowNode(
ShadowNodeFragment{
/* .props = */ props,
},
Expand Down Expand Up @@ -69,12 +69,12 @@ TEST(ComponentDescriptorTest, cloneShadowNode) {
/* .eventEmitter = */ nullptr,
},
nullptr);
SharedShadowNode node = descriptor->createShadowNode(
ShadowNode::Shared node = descriptor->createShadowNode(
ShadowNodeFragment{
/* .props = */ props,
},
family);
SharedShadowNode cloned = descriptor->cloneShadowNode(*node, {});
ShadowNode::Shared cloned = descriptor->cloneShadowNode(*node, {});

EXPECT_STREQ(cloned->getComponentName(), "Test");
EXPECT_EQ(cloned->getTag(), 9);
Expand Down Expand Up @@ -104,7 +104,7 @@ TEST(ComponentDescriptorTest, appendChild) {
/* .eventEmitter = */ nullptr,
},
nullptr);
SharedShadowNode node1 = descriptor->createShadowNode(
ShadowNode::Shared node1 = descriptor->createShadowNode(
ShadowNodeFragment{
/* .props = */ props,
},
Expand All @@ -116,7 +116,7 @@ TEST(ComponentDescriptorTest, appendChild) {
/* .eventEmitter = */ nullptr,
},
nullptr);
SharedShadowNode node2 = descriptor->createShadowNode(
ShadowNode::Shared node2 = descriptor->createShadowNode(
ShadowNodeFragment{
/* .props = */ props,
},
Expand All @@ -128,7 +128,7 @@ TEST(ComponentDescriptorTest, appendChild) {
/* .eventEmitter = */ nullptr,
},
nullptr);
SharedShadowNode node3 = descriptor->createShadowNode(
ShadowNode::Shared node3 = descriptor->createShadowNode(
ShadowNodeFragment{
/* .props = */ props,
},
Expand Down
8 changes: 4 additions & 4 deletions ReactCommon/react/renderer/core/tests/ShadowNodeTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ class ShadowNodeTest : public ::testing::Test {
familyABB,
traits);

auto nodeABChildren = std::make_shared<SharedShadowNodeList>(
SharedShadowNodeList{nodeABA_, nodeABB_});
auto nodeABChildren = std::make_shared<ShadowNode::ListOfShared>(
ShadowNode::ListOfShared{nodeABA_, nodeABB_});

auto familyAB = std::make_shared<ShadowNodeFamily>(
ShadowNodeFamilyFragment{
Expand Down Expand Up @@ -120,8 +120,8 @@ class ShadowNodeTest : public ::testing::Test {
familyAC,
traits);

auto nodeAChildren = std::make_shared<SharedShadowNodeList>(
SharedShadowNodeList{nodeAA_, nodeAB_, nodeAC_});
auto nodeAChildren = std::make_shared<ShadowNode::ListOfShared>(
ShadowNode::ListOfShared{nodeAA_, nodeAB_, nodeAC_});

auto familyA = std::make_shared<ShadowNodeFamily>(
ShadowNodeFamilyFragment{
Expand Down
4 changes: 2 additions & 2 deletions ReactCommon/react/renderer/mounting/ShadowTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ static ShadowNode::Unshared progressState(
}

static void updateMountedFlag(
const SharedShadowNodeList &oldChildren,
const SharedShadowNodeList &newChildren) {
const ShadowNode::ListOfShared &oldChildren,
const ShadowNode::ListOfShared &newChildren) {
// This is a simplified version of Diffing algorithm that only updates
// `mounted` flag on `ShadowNode`s. The algorithm sets "mounted" flag before
// "unmounted" to allow `ShadowNode` detect a situation where the node was
Expand Down
Loading

0 comments on commit 13a0556

Please sign in to comment.