mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fabric: Remove eventEmitter from ShadowNodeFragment
Summary: As part of the plan is splitting ShadowNodeFragment into two parts. ShadowNodeFamilyFragment is already in place. This diff removes use of `ShadowNodeFragment::eventEmitter` and goes over all call sites to change it to `ShadowNodeFamilyFragment::surfaceId`. Changelog: [Internal] Reviewed By: shergin Differential Revision: D19146697 fbshipit-source-id: 22cae5404b0f3098feb86c0437a4aa256d5b773e
This commit is contained in:
committed by
Facebook Github Bot
parent
97f1c053b3
commit
61f7639d38
@@ -74,7 +74,6 @@ RootShadowNode::Unshared RootShadowNode::clone(
|
||||
|
||||
childNode = parentNode.clone({
|
||||
ShadowNodeFragment::propsPlaceholder(),
|
||||
ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
std::make_shared<SharedShadowNodeList>(children),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ class ConcreteComponentDescriptor : public ComponentDescriptor {
|
||||
ShadowNodeFamilyFragment const &familyFragment) const override {
|
||||
assert(std::dynamic_pointer_cast<const ConcreteProps>(fragment.props));
|
||||
assert(std::dynamic_pointer_cast<const ConcreteEventEmitter>(
|
||||
fragment.eventEmitter));
|
||||
familyFragment.eventEmitter));
|
||||
|
||||
auto family = std::make_shared<ShadowNodeFamily>(familyFragment, *this);
|
||||
|
||||
|
||||
@@ -74,9 +74,6 @@ ShadowNode::ShadowNode(
|
||||
: sourceShadowNode.getMostRecentState()),
|
||||
family_(sourceShadowNode.family_),
|
||||
traits_(sourceShadowNode.traits_) {
|
||||
// `eventEmitter` cannot be changed with cloning.
|
||||
assert(
|
||||
fragment.eventEmitter == ShadowNodeFragment::eventEmitterPlaceholder());
|
||||
|
||||
assert(props_);
|
||||
assert(children_);
|
||||
|
||||
@@ -15,11 +15,6 @@ Props::Shared const &ShadowNodeFragment::propsPlaceholder() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
EventEmitter::Shared const &ShadowNodeFragment::eventEmitterPlaceholder() {
|
||||
static auto &instance = *new EventEmitter::Shared();
|
||||
return instance;
|
||||
}
|
||||
|
||||
ShadowNode::SharedListOfShared const &
|
||||
ShadowNodeFragment::childrenPlaceholder() {
|
||||
static auto &instance = *new ShadowNode::SharedListOfShared();
|
||||
@@ -40,14 +35,12 @@ using Value = ShadowNodeFragment::Value;
|
||||
|
||||
Value::Value(ShadowNodeFragment const &fragment)
|
||||
: props_(fragment.props),
|
||||
eventEmitter_(fragment.eventEmitter),
|
||||
children_(fragment.children),
|
||||
localData_(fragment.localData),
|
||||
state_(fragment.state) {}
|
||||
|
||||
Value::operator ShadowNodeFragment() const {
|
||||
return ShadowNodeFragment{
|
||||
props_, eventEmitter_, children_, localData_, state_};
|
||||
return ShadowNodeFragment{props_, children_, localData_, state_};
|
||||
}
|
||||
|
||||
} // namespace react
|
||||
|
||||
@@ -28,7 +28,6 @@ namespace react {
|
||||
*/
|
||||
struct ShadowNodeFragment {
|
||||
Props::Shared const &props = propsPlaceholder();
|
||||
EventEmitter::Shared const &eventEmitter = eventEmitterPlaceholder();
|
||||
ShadowNode::SharedListOfShared const &children = childrenPlaceholder();
|
||||
LocalData::Shared const &localData = localDataPlaceholder();
|
||||
State::Shared const &state = statePlaceholder();
|
||||
@@ -39,7 +38,6 @@ struct ShadowNodeFragment {
|
||||
* be changed.
|
||||
*/
|
||||
static Props::Shared const &propsPlaceholder();
|
||||
static EventEmitter::Shared const &eventEmitterPlaceholder();
|
||||
static ShadowNode::SharedListOfShared const &childrenPlaceholder();
|
||||
static LocalData::Shared const &localDataPlaceholder();
|
||||
static State::Shared const &statePlaceholder();
|
||||
@@ -63,7 +61,6 @@ struct ShadowNodeFragment {
|
||||
|
||||
private:
|
||||
Props::Shared const props_;
|
||||
EventEmitter::Shared const eventEmitter_;
|
||||
ShadowNode::SharedListOfShared const children_;
|
||||
LocalData::Shared const localData_;
|
||||
State::Shared const state_;
|
||||
|
||||
@@ -26,7 +26,6 @@ TEST(ComponentDescriptorTest, createShadowNode) {
|
||||
SharedShadowNode node = descriptor->createShadowNode(
|
||||
ShadowNodeFragment{
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ descriptor->createEventEmitter(0, 9),
|
||||
},
|
||||
ShadowNodeFamilyFragment{
|
||||
/* .tag = */ 9,
|
||||
@@ -52,7 +51,6 @@ TEST(ComponentDescriptorTest, cloneShadowNode) {
|
||||
SharedShadowNode node = descriptor->createShadowNode(
|
||||
ShadowNodeFragment{
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ descriptor->createEventEmitter(0, 9),
|
||||
},
|
||||
ShadowNodeFamilyFragment{
|
||||
/* .tag = */ 9,
|
||||
@@ -78,7 +76,6 @@ TEST(ComponentDescriptorTest, appendChild) {
|
||||
SharedShadowNode node1 = descriptor->createShadowNode(
|
||||
ShadowNodeFragment{
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ descriptor->createEventEmitter(0, 1),
|
||||
},
|
||||
ShadowNodeFamilyFragment{
|
||||
/* .tag = */ 1,
|
||||
@@ -88,7 +85,6 @@ TEST(ComponentDescriptorTest, appendChild) {
|
||||
SharedShadowNode node2 = descriptor->createShadowNode(
|
||||
ShadowNodeFragment{
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ descriptor->createEventEmitter(0, 2),
|
||||
},
|
||||
ShadowNodeFamilyFragment{
|
||||
/* .tag = */ 2,
|
||||
@@ -98,7 +94,6 @@ TEST(ComponentDescriptorTest, appendChild) {
|
||||
SharedShadowNode node3 = descriptor->createShadowNode(
|
||||
ShadowNodeFragment{
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ descriptor->createEventEmitter(0, 3),
|
||||
},
|
||||
ShadowNodeFamilyFragment{
|
||||
/* .tag = */ 3,
|
||||
|
||||
@@ -28,7 +28,6 @@ TEST(ShadowNodeTest, handleShadowNodeCreation) {
|
||||
auto node = std::make_shared<TestShadowNode>(
|
||||
ShadowNodeFragment{
|
||||
/* .props = */ std::make_shared<const TestProps>(),
|
||||
/* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
/* .children = */ ShadowNode::emptySharedShadowNodeSharedList(),
|
||||
},
|
||||
family,
|
||||
@@ -59,7 +58,6 @@ TEST(ShadowNodeTest, handleShadowNodeSimpleCloning) {
|
||||
auto node = std::make_shared<TestShadowNode>(
|
||||
ShadowNodeFragment{
|
||||
/* .props = */ std::make_shared<const TestProps>(),
|
||||
/* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
/* .children = */ ShadowNode::emptySharedShadowNodeSharedList(),
|
||||
},
|
||||
family,
|
||||
@@ -86,7 +84,6 @@ TEST(ShadowNodeTest, handleShadowNodeMutation) {
|
||||
auto node1 = std::make_shared<TestShadowNode>(
|
||||
ShadowNodeFragment{
|
||||
/* .props = */ std::make_shared<const TestProps>(),
|
||||
/* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
/* .children = */ ShadowNode::emptySharedShadowNodeSharedList(),
|
||||
},
|
||||
family1,
|
||||
@@ -101,7 +98,6 @@ TEST(ShadowNodeTest, handleShadowNodeMutation) {
|
||||
auto node2 = std::make_shared<TestShadowNode>(
|
||||
ShadowNodeFragment{
|
||||
/* .props = */ std::make_shared<const TestProps>(),
|
||||
/* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
/* .children = */ ShadowNode::emptySharedShadowNodeSharedList(),
|
||||
},
|
||||
family2,
|
||||
@@ -116,7 +112,6 @@ TEST(ShadowNodeTest, handleShadowNodeMutation) {
|
||||
auto node3 = std::make_shared<TestShadowNode>(
|
||||
ShadowNodeFragment{
|
||||
/* .props = */ std::make_shared<const TestProps>(),
|
||||
/* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
/* .children = */ ShadowNode::emptySharedShadowNodeSharedList(),
|
||||
},
|
||||
family3,
|
||||
@@ -164,7 +159,6 @@ TEST(ShadowNodeTest, handleCloneFunction) {
|
||||
auto firstNode = std::make_shared<TestShadowNode>(
|
||||
ShadowNodeFragment{
|
||||
/* .props = */ std::make_shared<const TestProps>(),
|
||||
/* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
/* .children = */ ShadowNode::emptySharedShadowNodeSharedList(),
|
||||
},
|
||||
family,
|
||||
@@ -207,7 +201,6 @@ TEST(ShadowNodeTest, handleLocalData) {
|
||||
auto firstNode = std::make_shared<TestShadowNode>(
|
||||
ShadowNodeFragment{
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
/* .children = */ ShadowNode::emptySharedShadowNodeSharedList(),
|
||||
},
|
||||
family,
|
||||
@@ -215,7 +208,6 @@ TEST(ShadowNodeTest, handleLocalData) {
|
||||
auto secondNode = std::make_shared<TestShadowNode>(
|
||||
ShadowNodeFragment{
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
/* .children = */ ShadowNode::emptySharedShadowNodeSharedList(),
|
||||
},
|
||||
family,
|
||||
@@ -223,7 +215,6 @@ TEST(ShadowNodeTest, handleLocalData) {
|
||||
auto thirdNode = std::make_shared<TestShadowNode>(
|
||||
ShadowNodeFragment{
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
/* .children = */ ShadowNode::emptySharedShadowNodeSharedList(),
|
||||
},
|
||||
family,
|
||||
@@ -272,7 +263,6 @@ TEST(ShadowNodeTest, handleBacktracking) {
|
||||
auto nodeAA = std::make_shared<TestShadowNode>(
|
||||
ShadowNodeFragment{
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
/* .children = */ ShadowNode::emptySharedShadowNodeSharedList(),
|
||||
},
|
||||
familyAA,
|
||||
@@ -288,7 +278,6 @@ TEST(ShadowNodeTest, handleBacktracking) {
|
||||
auto nodeABA = std::make_shared<TestShadowNode>(
|
||||
ShadowNodeFragment{
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
/* .children = */ ShadowNode::emptySharedShadowNodeSharedList(),
|
||||
},
|
||||
familyABA,
|
||||
@@ -304,7 +293,6 @@ TEST(ShadowNodeTest, handleBacktracking) {
|
||||
auto nodeABB = std::make_shared<TestShadowNode>(
|
||||
ShadowNodeFragment{
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
/* .children = */ ShadowNode::emptySharedShadowNodeSharedList(),
|
||||
},
|
||||
familyABB,
|
||||
@@ -320,7 +308,6 @@ TEST(ShadowNodeTest, handleBacktracking) {
|
||||
auto nodeABC = std::make_shared<TestShadowNode>(
|
||||
ShadowNodeFragment{
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
/* .children = */ ShadowNode::emptySharedShadowNodeSharedList(),
|
||||
},
|
||||
familyABC,
|
||||
@@ -339,7 +326,6 @@ TEST(ShadowNodeTest, handleBacktracking) {
|
||||
auto nodeAB = std::make_shared<TestShadowNode>(
|
||||
ShadowNodeFragment{
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
/* .children = */ nodeABChildren,
|
||||
},
|
||||
familyAB,
|
||||
@@ -355,7 +341,6 @@ TEST(ShadowNodeTest, handleBacktracking) {
|
||||
auto nodeAC = std::make_shared<TestShadowNode>(
|
||||
ShadowNodeFragment{
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
/* .children = */ ShadowNode::emptySharedShadowNodeSharedList(),
|
||||
},
|
||||
familyAC,
|
||||
@@ -374,7 +359,6 @@ TEST(ShadowNodeTest, handleBacktracking) {
|
||||
auto nodeA = std::make_shared<TestShadowNode>(
|
||||
ShadowNodeFragment{
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
/* .children = */ nodeAChildren,
|
||||
},
|
||||
familyA,
|
||||
@@ -390,7 +374,6 @@ TEST(ShadowNodeTest, handleBacktracking) {
|
||||
auto nodeZ = std::make_shared<TestShadowNode>(
|
||||
ShadowNodeFragment{
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
/* .children = */ ShadowNode::emptySharedShadowNodeSharedList(),
|
||||
},
|
||||
familyZ,
|
||||
|
||||
@@ -106,7 +106,6 @@ ShadowTree::ShadowTree(
|
||||
rootComponentDescriptor.createShadowNode(
|
||||
ShadowNodeFragment{
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ noopEventEmitter,
|
||||
},
|
||||
{surfaceId, surfaceId, noopEventEmitter}));
|
||||
|
||||
@@ -211,8 +210,6 @@ void ShadowTree::commitEmptyTree() const {
|
||||
*oldRootShadowNode,
|
||||
ShadowNodeFragment{
|
||||
/* .props = */ ShadowNodeFragment::propsPlaceholder(),
|
||||
/* .eventEmitter = */
|
||||
ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
/* .children = */ ShadowNode::emptySharedShadowNodeSharedList(),
|
||||
});
|
||||
});
|
||||
|
||||
@@ -51,7 +51,6 @@ StubViewTree stubViewTreeFromShadowNode(ShadowNode const &rootShadowNode) {
|
||||
|
||||
auto emptyRootShadowNode = rootShadowNode.clone(
|
||||
ShadowNodeFragment{ShadowNodeFragment::propsPlaceholder(),
|
||||
ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
ShadowNode::emptySharedShadowNodeSharedList()});
|
||||
|
||||
auto stubViewTree = StubViewTree(ShadowView(*emptyRootShadowNode));
|
||||
|
||||
@@ -171,12 +171,11 @@ SharedShadowNode ComponentDescriptorRegistry::createNode(
|
||||
auto const props =
|
||||
componentDescriptor.cloneProps(nullptr, RawProps(propsDynamic));
|
||||
auto const state = componentDescriptor.createInitialState(
|
||||
ShadowNodeFragment{props, eventEmitter}, surfaceId);
|
||||
ShadowNodeFragment{props}, surfaceId);
|
||||
|
||||
return componentDescriptor.createShadowNode(
|
||||
{
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ eventEmitter,
|
||||
/* .children = */ ShadowNodeFragment::childrenPlaceholder(),
|
||||
/* .localData = */ ShadowNodeFragment::localDataPlaceholder(),
|
||||
/* .state = */ state,
|
||||
|
||||
@@ -180,8 +180,6 @@ void Scheduler::renderTemplateToSurface(
|
||||
*oldRootShadowNode,
|
||||
ShadowNodeFragment{
|
||||
/* .props = */ ShadowNodeFragment::propsPlaceholder(),
|
||||
/* .eventEmitter = */
|
||||
ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
/* .children = */
|
||||
std::make_shared<SharedShadowNodeList>(
|
||||
SharedShadowNodeList{tree}),
|
||||
|
||||
@@ -36,7 +36,7 @@ SharedShadowNode UIManager::createNode(
|
||||
componentDescriptor.createEventEmitter(std::move(eventTarget), tag);
|
||||
auto const props = componentDescriptor.cloneProps(nullptr, rawProps);
|
||||
auto const state = componentDescriptor.createInitialState(
|
||||
ShadowNodeFragment{props, eventEmitter}, surfaceId);
|
||||
ShadowNodeFragment{props}, surfaceId);
|
||||
|
||||
auto shadowNode = componentDescriptor.createShadowNode(
|
||||
ShadowNodeFragment{
|
||||
@@ -47,7 +47,6 @@ SharedShadowNode UIManager::createNode(
|
||||
? componentDescriptor.cloneProps(
|
||||
props, RawProps(folly::dynamic::object("name", name)))
|
||||
: props,
|
||||
/* .eventEmitter = */ eventEmitter,
|
||||
/* .children = */ ShadowNodeFragment::childrenPlaceholder(),
|
||||
/* .localData = */ ShadowNodeFragment::localDataPlaceholder(),
|
||||
/* .state = */ state,
|
||||
@@ -88,7 +87,6 @@ SharedShadowNode UIManager::cloneNode(
|
||||
rawProps ? componentDescriptor.cloneProps(
|
||||
shadowNode->getProps(), *rawProps)
|
||||
: ShadowNodeFragment::propsPlaceholder(),
|
||||
/* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
/* .children = */ children,
|
||||
});
|
||||
|
||||
@@ -115,8 +113,6 @@ void UIManager::completeSurface(
|
||||
*oldRootShadowNode,
|
||||
ShadowNodeFragment{
|
||||
/* .props = */ ShadowNodeFragment::propsPlaceholder(),
|
||||
/* .eventEmitter = */
|
||||
ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
/* .children = */ rootChildren,
|
||||
});
|
||||
});
|
||||
@@ -205,8 +201,6 @@ void UIManager::updateState(
|
||||
shadowNode, [&](ShadowNode const &oldShadowNode) {
|
||||
return oldShadowNode.clone({
|
||||
/* .props = */ ShadowNodeFragment::propsPlaceholder(),
|
||||
/* .eventEmitter = */
|
||||
ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
/* .children = */ ShadowNodeFragment::childrenPlaceholder(),
|
||||
/* .localData = */
|
||||
ShadowNodeFragment::localDataPlaceholder(),
|
||||
|
||||
Reference in New Issue
Block a user