Fabric: remove LocalData from ShadowNode

Summary:
LocalData isn't used by any components. We've moved towards State.
Changelog: [internal]

Reviewed By: mdvacca

Differential Revision: D19250732

fbshipit-source-id: dd23a723c5392632165798f6365ea107b37b54cd
This commit is contained in:
Samuel Susla 2020-01-20 05:46:03 -08:00 коммит произвёл Facebook Github Bot
Родитель 5a94471650
Коммит 9948fbdeec
4 изменённых файлов: 1 добавлений и 60 удалений

Просмотреть файл

@ -142,10 +142,6 @@ State::Shared ShadowNode::getMostRecentState() const {
return ShadowNodeFragment::statePlaceholder();
}
SharedLocalData ShadowNode::getLocalData() const {
return localData_;
}
void ShadowNode::sealRecursive() const {
if (getSealed()) {
return;
@ -206,11 +202,6 @@ void ShadowNode::replaceChild(
assert(false && "Child to replace was not found.");
}
void ShadowNode::setLocalData(const SharedLocalData &localData) {
ensureUnsealed();
localData_ = localData;
}
void ShadowNode::cloneChildrenIfShared() {
if (!traits_.check(ShadowNodeTraits::Trait::ChildrenAreShared)) {
return;

Просмотреть файл

@ -13,7 +13,6 @@
#include <better/small_vector.h>
#include <react/core/EventEmitter.h>
#include <react/core/LocalData.h>
#include <react/core/Props.h>
#include <react/core/ReactPrimitives.h>
#include <react/core/Sealable.h>
@ -126,14 +125,6 @@ class ShadowNode : public virtual Sealable,
*/
State::Shared getMostRecentState() const;
/*
* Returns a local data associated with the node.
* `LocalData` object might be used for data exchange between native view and
* shadow node instances.
* Concrete type of the object depends on concrete type of the `ShadowNode`.
*/
SharedLocalData getLocalData() const;
void sealRecursive() const;
#pragma mark - Mutating Methods
@ -144,12 +135,6 @@ class ShadowNode : public virtual Sealable,
ShadowNode::Shared const &newChild,
int suggestedIndex = -1);
/*
* Sets local data associated with the node.
* The node must be unsealed at this point.
*/
void setLocalData(const SharedLocalData &localData);
/*
* Performs all side effects associated with mounting/unmounting in one place.
* This is not `virtual` on purpose, do not override this.
@ -187,7 +172,6 @@ class ShadowNode : public virtual Sealable,
protected:
SharedProps props_;
SharedShadowNodeSharedList children_;
SharedLocalData localData_;
State::Shared state_;
private:

Просмотреть файл

@ -204,14 +204,6 @@ TEST_F(ShadowNodeTest, handleShadowNodeMutation) {
EXPECT_TRUE(nodeAB_->getSealed());
EXPECT_TRUE(nodeABArevision2->getSealed());
EXPECT_TRUE(nodeABB_->getSealed());
// No more mutation after sealing.
EXPECT_THROW(nodeABArevision2->setLocalData(nullptr), std::runtime_error);
auto nodeABArevision3 =
std::make_shared<TestShadowNode>(*nodeABArevision2, ShadowNodeFragment{});
nodeABArevision3->setLocalData(nullptr);
EXPECT_EQ(nodeABArevision3->getLocalData(), nullptr);
}
TEST_F(ShadowNodeTest, handleCloneFunction) {
@ -230,32 +222,6 @@ TEST_F(ShadowNodeTest, handleCloneFunction) {
EXPECT_EQ(nodeAB_->getProps(), nodeABClone->getProps());
}
TEST_F(ShadowNodeTest, handleLocalData) {
auto localData42 = std::make_shared<TestLocalData>();
localData42->setNumber(42);
auto anotherLocalData42 = std::make_shared<TestLocalData>();
anotherLocalData42->setNumber(42);
auto localDataOver9000 = std::make_shared<TestLocalData>();
localDataOver9000->setNumber(9001);
auto props = std::make_shared<const TestProps>();
nodeAA_->setLocalData(localData42);
nodeAB_->setLocalData(localData42);
nodeAC_->setLocalData(localDataOver9000);
// LocalData object are compared by pointer, not by value.
EXPECT_EQ(nodeAA_->getLocalData(), nodeAB_->getLocalData());
EXPECT_NE(nodeAA_->getLocalData(), nodeAC_->getLocalData());
nodeAB_->setLocalData(anotherLocalData42);
EXPECT_NE(nodeAA_->getLocalData(), nodeAB_->getLocalData());
// LocalData cannot be changed for sealed shadow node.
nodeAB_->sealRecursive();
EXPECT_ANY_THROW(nodeAB_->setLocalData(localDataOver9000));
}
TEST_F(ShadowNodeTest, handleBacktracking) {
// Negative case:
auto ancestors1 = nodeZ_->getAncestors(*nodeA_);

Просмотреть файл

@ -26,7 +26,7 @@ ShadowView::ShadowView(const ShadowNode &shadowNode)
props(shadowNode.getProps()),
eventEmitter(shadowNode.getEventEmitter()),
layoutMetrics(layoutMetricsFromShadowNode(shadowNode)),
localData(shadowNode.getLocalData()),
localData({}),
state(shadowNode.getState()) {}
bool ShadowView::operator==(const ShadowView &rhs) const {