From f9c5bf8bee8c3ded8d373cac918f1bedb34cc13b Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Thu, 19 Dec 2019 13:45:35 -0800 Subject: [PATCH] Fabric: Remove tag 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::tag` and goes over all call sites to change it to `ShadowNodeFamilyFragment::tag`. Changelog: [Internal] Reviewed By: shergin Differential Revision: D19115781 fbshipit-source-id: 6ab3464a063c220d0924bf5a69b75449ca178650 --- .../fabric/components/root/RootShadowNode.cpp | 2 - .../componentdescriptor/ComponentDescriptor.h | 3 +- .../ConcreteComponentDescriptor.h | 8 +- .../fabric/core/shadownode/ShadowNode.cpp | 3 +- .../core/shadownode/ShadowNodeFragment.cpp | 9 +- .../core/shadownode/ShadowNodeFragment.h | 3 - .../core/tests/ComponentDescriptorTest.cpp | 87 ++++++++++++------- .../fabric/core/tests/ShadowNodeTest.cpp | 17 ---- ReactCommon/fabric/mounting/ShadowTree.cpp | 14 +-- ReactCommon/fabric/mounting/stubs/stubs.cpp | 3 +- .../uimanager/ComponentDescriptorRegistry.cpp | 21 ++--- ReactCommon/fabric/uimanager/Scheduler.cpp | 31 ++++--- ReactCommon/fabric/uimanager/UIManager.cpp | 37 ++++---- 13 files changed, 116 insertions(+), 122 deletions(-) diff --git a/ReactCommon/fabric/components/root/RootShadowNode.cpp b/ReactCommon/fabric/components/root/RootShadowNode.cpp index 599b41138d5..d6ad7d11388 100644 --- a/ReactCommon/fabric/components/root/RootShadowNode.cpp +++ b/ReactCommon/fabric/components/root/RootShadowNode.cpp @@ -41,7 +41,6 @@ RootShadowNode::Unshared RootShadowNode::clone( auto newRootShadowNode = std::make_shared( *this, ShadowNodeFragment{ - /* .tag = */ ShadowNodeFragment::tagPlaceholder(), /* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(), /* .props = */ props, }); @@ -75,7 +74,6 @@ RootShadowNode::Unshared RootShadowNode::clone( children[childIndex] = childNode; childNode = parentNode.clone({ - ShadowNodeFragment::tagPlaceholder(), ShadowNodeFragment::surfaceIdPlaceholder(), ShadowNodeFragment::propsPlaceholder(), ShadowNodeFragment::eventEmitterPlaceholder(), diff --git a/ReactCommon/fabric/core/componentdescriptor/ComponentDescriptor.h b/ReactCommon/fabric/core/componentdescriptor/ComponentDescriptor.h index e6271d689c6..06f54d25691 100644 --- a/ReactCommon/fabric/core/componentdescriptor/ComponentDescriptor.h +++ b/ReactCommon/fabric/core/componentdescriptor/ComponentDescriptor.h @@ -78,7 +78,8 @@ class ComponentDescriptor { * Creates a new `ShadowNode` of a particular component type. */ virtual SharedShadowNode createShadowNode( - const ShadowNodeFragment &fragment) const = 0; + const ShadowNodeFragment &fragment, + ShadowNodeFamilyFragment const &familyFragment) const = 0; /* * Clones a `ShadowNode` with optionally new `props` and/or `children`. diff --git a/ReactCommon/fabric/core/componentdescriptor/ConcreteComponentDescriptor.h b/ReactCommon/fabric/core/componentdescriptor/ConcreteComponentDescriptor.h index fbb84022bbf..9f17b37ab08 100644 --- a/ReactCommon/fabric/core/componentdescriptor/ConcreteComponentDescriptor.h +++ b/ReactCommon/fabric/core/componentdescriptor/ConcreteComponentDescriptor.h @@ -66,15 +66,13 @@ class ConcreteComponentDescriptor : public ComponentDescriptor { } SharedShadowNode createShadowNode( - const ShadowNodeFragment &fragment) const override { + const ShadowNodeFragment &fragment, + ShadowNodeFamilyFragment const &familyFragment) const override { assert(std::dynamic_pointer_cast(fragment.props)); assert(std::dynamic_pointer_cast( fragment.eventEmitter)); - auto family = std::make_shared( - ShadowNodeFamilyFragment{ - fragment.tag, fragment.surfaceId, fragment.eventEmitter}, - *this); + auto family = std::make_shared(familyFragment, *this); auto shadowNode = std::make_shared(fragment, family, getTraits()); diff --git a/ReactCommon/fabric/core/shadownode/ShadowNode.cpp b/ReactCommon/fabric/core/shadownode/ShadowNode.cpp index c8688d49c4a..f11db8fe1a4 100644 --- a/ReactCommon/fabric/core/shadownode/ShadowNode.cpp +++ b/ReactCommon/fabric/core/shadownode/ShadowNode.cpp @@ -74,8 +74,7 @@ ShadowNode::ShadowNode( : sourceShadowNode.getMostRecentState()), family_(sourceShadowNode.family_), traits_(sourceShadowNode.traits_) { - // `tag`, `surfaceId`, and `eventEmitter` cannot be changed with cloning. - assert(fragment.tag == ShadowNodeFragment::tagPlaceholder()); + // `surfaceId`, and `eventEmitter` cannot be changed with cloning. assert(fragment.surfaceId == ShadowNodeFragment::surfaceIdPlaceholder()); assert( fragment.eventEmitter == ShadowNodeFragment::eventEmitterPlaceholder()); diff --git a/ReactCommon/fabric/core/shadownode/ShadowNodeFragment.cpp b/ReactCommon/fabric/core/shadownode/ShadowNodeFragment.cpp index 18a3b8acb02..e5cd126a817 100644 --- a/ReactCommon/fabric/core/shadownode/ShadowNodeFragment.cpp +++ b/ReactCommon/fabric/core/shadownode/ShadowNodeFragment.cpp @@ -10,10 +10,6 @@ namespace facebook { namespace react { -Tag const ShadowNodeFragment::tagPlaceholder() { - return 0; -} - SurfaceId const ShadowNodeFragment::surfaceIdPlaceholder() { return 0; } @@ -47,8 +43,7 @@ State::Shared const &ShadowNodeFragment::statePlaceholder() { using Value = ShadowNodeFragment::Value; Value::Value(ShadowNodeFragment const &fragment) - : tag_(fragment.tag), - surfaceId_(fragment.surfaceId), + : surfaceId_(fragment.surfaceId), props_(fragment.props), eventEmitter_(fragment.eventEmitter), children_(fragment.children), @@ -57,7 +52,7 @@ Value::Value(ShadowNodeFragment const &fragment) Value::operator ShadowNodeFragment() const { return ShadowNodeFragment{ - tag_, surfaceId_, props_, eventEmitter_, children_, localData_, state_}; + surfaceId_, props_, eventEmitter_, children_, localData_, state_}; } } // namespace react diff --git a/ReactCommon/fabric/core/shadownode/ShadowNodeFragment.h b/ReactCommon/fabric/core/shadownode/ShadowNodeFragment.h index c828372e783..13a50276622 100644 --- a/ReactCommon/fabric/core/shadownode/ShadowNodeFragment.h +++ b/ReactCommon/fabric/core/shadownode/ShadowNodeFragment.h @@ -27,7 +27,6 @@ namespace react { * fragment content to store or pass the data asynchronously. */ struct ShadowNodeFragment { - Tag const tag = tagPlaceholder(); SurfaceId const surfaceId = surfaceIdPlaceholder(); Props::Shared const &props = propsPlaceholder(); EventEmitter::Shared const &eventEmitter = eventEmitterPlaceholder(); @@ -40,7 +39,6 @@ struct ShadowNodeFragment { * Use as default arguments as an indication that the field does not need to * be changed. */ - static Tag const tagPlaceholder(); static SurfaceId const surfaceIdPlaceholder(); static Props::Shared const &propsPlaceholder(); static EventEmitter::Shared const &eventEmitterPlaceholder(); @@ -66,7 +64,6 @@ struct ShadowNodeFragment { explicit operator ShadowNodeFragment() const; private: - Tag const tag_; SurfaceId const surfaceId_; Props::Shared const props_; EventEmitter::Shared const eventEmitter_; diff --git a/ReactCommon/fabric/core/tests/ComponentDescriptorTest.cpp b/ReactCommon/fabric/core/tests/ComponentDescriptorTest.cpp index 27ea66e19e1..7accaf3cdbb 100644 --- a/ReactCommon/fabric/core/tests/ComponentDescriptorTest.cpp +++ b/ReactCommon/fabric/core/tests/ComponentDescriptorTest.cpp @@ -22,12 +22,18 @@ TEST(ComponentDescriptorTest, createShadowNode) { const auto &raw = RawProps(folly::dynamic::object("nativeID", "abc")); SharedProps props = descriptor->cloneProps(nullptr, raw); - SharedShadowNode node = descriptor->createShadowNode(ShadowNodeFragment{ - /* .tag = */ 9, - /* .surfaceId = */ 1, - /* .props = */ props, - /* .eventEmitter = */ descriptor->createEventEmitter(0, 9), - }); + + SharedShadowNode node = descriptor->createShadowNode( + ShadowNodeFragment{ + /* .surfaceId = */ 1, + /* .props = */ props, + /* .eventEmitter = */ descriptor->createEventEmitter(0, 9), + }, + ShadowNodeFamilyFragment{ + /* .tag = */ 9, + /* .surfaceId = */ 1, + /* .eventEmitter = */ descriptor->createEventEmitter(0, 9), + }); ASSERT_EQ(node->getComponentHandle(), TestShadowNode::Handle()); ASSERT_STREQ(node->getComponentName(), TestShadowNode::Name()); @@ -44,12 +50,17 @@ TEST(ComponentDescriptorTest, cloneShadowNode) { const auto &raw = RawProps(folly::dynamic::object("nativeID", "abc")); SharedProps props = descriptor->cloneProps(nullptr, raw); - SharedShadowNode node = descriptor->createShadowNode(ShadowNodeFragment{ - /* .tag = */ 9, - /* .surfaceId = */ 1, - /* .props = */ props, - /* .eventEmitter = */ descriptor->createEventEmitter(0, 9), - }); + SharedShadowNode node = descriptor->createShadowNode( + ShadowNodeFragment{ + /* .surfaceId = */ 1, + /* .props = */ props, + /* .eventEmitter = */ descriptor->createEventEmitter(0, 9), + }, + ShadowNodeFamilyFragment{ + /* .tag = */ 9, + /* .surfaceId = */ 1, + /* .eventEmitter = */ descriptor->createEventEmitter(0, 9), + }); SharedShadowNode cloned = descriptor->cloneShadowNode(*node, {}); ASSERT_STREQ(cloned->getComponentName(), "Test"); @@ -65,24 +76,40 @@ TEST(ComponentDescriptorTest, appendChild) { const auto &raw = RawProps(folly::dynamic::object("nativeID", "abc")); SharedProps props = descriptor->cloneProps(nullptr, raw); - SharedShadowNode node1 = descriptor->createShadowNode(ShadowNodeFragment{ - /* .tag = */ 1, - /* .surfaceId = */ 1, - /* .props = */ props, - /* .eventEmitter = */ descriptor->createEventEmitter(0, 1), - }); - SharedShadowNode node2 = descriptor->createShadowNode(ShadowNodeFragment{ - /* .tag = */ 2, - /* .surfaceId = */ 1, - /* .props = */ props, - /* .eventEmitter = */ descriptor->createEventEmitter(0, 2), - }); - SharedShadowNode node3 = descriptor->createShadowNode(ShadowNodeFragment{ - /* .tag = */ 3, - /* .surfaceId = */ 1, - /* .props = */ props, - /* .eventEmitter = */ descriptor->createEventEmitter(0, 3), - }); + + SharedShadowNode node1 = descriptor->createShadowNode( + ShadowNodeFragment{ + /* .surfaceId = */ 1, + /* .props = */ props, + /* .eventEmitter = */ descriptor->createEventEmitter(0, 1), + }, + ShadowNodeFamilyFragment{ + /* .tag = */ 1, + /* .surfaceId = */ 1, + /* .eventEmitter = */ descriptor->createEventEmitter(0, 9), + }); + SharedShadowNode node2 = descriptor->createShadowNode( + ShadowNodeFragment{ + /* .surfaceId = */ 1, + /* .props = */ props, + /* .eventEmitter = */ descriptor->createEventEmitter(0, 2), + }, + ShadowNodeFamilyFragment{ + /* .tag = */ 2, + /* .surfaceId = */ 1, + /* .eventEmitter = */ descriptor->createEventEmitter(0, 9), + }); + SharedShadowNode node3 = descriptor->createShadowNode( + ShadowNodeFragment{ + /* .surfaceId = */ 1, + /* .props = */ props, + /* .eventEmitter = */ descriptor->createEventEmitter(0, 3), + }, + ShadowNodeFamilyFragment{ + /* .tag = */ 3, + /* .surfaceId = */ 1, + /* .eventEmitter = */ descriptor->createEventEmitter(0, 9), + }); descriptor->appendChild(node1, node2); descriptor->appendChild(node1, node3); diff --git a/ReactCommon/fabric/core/tests/ShadowNodeTest.cpp b/ReactCommon/fabric/core/tests/ShadowNodeTest.cpp index 0aea63955a0..e3604077b36 100644 --- a/ReactCommon/fabric/core/tests/ShadowNodeTest.cpp +++ b/ReactCommon/fabric/core/tests/ShadowNodeTest.cpp @@ -27,7 +27,6 @@ TEST(ShadowNodeTest, handleShadowNodeCreation) { componentDescriptor); auto node = std::make_shared( ShadowNodeFragment{ - /* .tag = */ 9, /* .surfaceId = */ 1, /* .props = */ std::make_shared(), /* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(), @@ -60,7 +59,6 @@ TEST(ShadowNodeTest, handleShadowNodeSimpleCloning) { componentDescriptor); auto node = std::make_shared( ShadowNodeFragment{ - /* .tag = */ 9, /* .surfaceId = */ 1, /* .props = */ std::make_shared(), /* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(), @@ -89,7 +87,6 @@ TEST(ShadowNodeTest, handleShadowNodeMutation) { auto props = std::make_shared(); auto node1 = std::make_shared( ShadowNodeFragment{ - /* .tag = */ 1, /* .surfaceId = */ 1, /* .props = */ std::make_shared(), /* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(), @@ -106,7 +103,6 @@ TEST(ShadowNodeTest, handleShadowNodeMutation) { componentDescriptor); auto node2 = std::make_shared( ShadowNodeFragment{ - /* .tag = */ 2, /* .surfaceId = */ 1, /* .props = */ std::make_shared(), /* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(), @@ -123,7 +119,6 @@ TEST(ShadowNodeTest, handleShadowNodeMutation) { componentDescriptor); auto node3 = std::make_shared( ShadowNodeFragment{ - /* .tag = */ 3, /* .surfaceId = */ 1, /* .props = */ std::make_shared(), /* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(), @@ -173,7 +168,6 @@ TEST(ShadowNodeTest, handleCloneFunction) { auto firstNode = std::make_shared( ShadowNodeFragment{ - /* .tag = */ 9, /* .surfaceId = */ 1, /* .props = */ std::make_shared(), /* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(), @@ -218,7 +212,6 @@ TEST(ShadowNodeTest, handleLocalData) { auto props = std::make_shared(); auto firstNode = std::make_shared( ShadowNodeFragment{ - /* .tag = */ 9, /* .surfaceId = */ 1, /* .props = */ props, /* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(), @@ -228,7 +221,6 @@ TEST(ShadowNodeTest, handleLocalData) { ShadowNodeTraits{}); auto secondNode = std::make_shared( ShadowNodeFragment{ - /* .tag = */ 9, /* .surfaceId = */ 1, /* .props = */ props, /* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(), @@ -238,7 +230,6 @@ TEST(ShadowNodeTest, handleLocalData) { ShadowNodeTraits{}); auto thirdNode = std::make_shared( ShadowNodeFragment{ - /* .tag = */ 9, /* .surfaceId = */ 1, /* .props = */ props, /* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(), @@ -289,7 +280,6 @@ TEST(ShadowNodeTest, handleBacktracking) { componentDescriptor); auto nodeAA = std::make_shared( ShadowNodeFragment{ - /* .tag = */ ShadowNodeFragment::tagPlaceholder(), /* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(), /* .props = */ props, /* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(), @@ -307,7 +297,6 @@ TEST(ShadowNodeTest, handleBacktracking) { componentDescriptor); auto nodeABA = std::make_shared( ShadowNodeFragment{ - /* .tag = */ ShadowNodeFragment::tagPlaceholder(), /* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(), /* .props = */ props, /* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(), @@ -325,7 +314,6 @@ TEST(ShadowNodeTest, handleBacktracking) { componentDescriptor); auto nodeABB = std::make_shared( ShadowNodeFragment{ - /* .tag = */ ShadowNodeFragment::tagPlaceholder(), /* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(), /* .props = */ props, /* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(), @@ -343,7 +331,6 @@ TEST(ShadowNodeTest, handleBacktracking) { componentDescriptor); auto nodeABC = std::make_shared( ShadowNodeFragment{ - /* .tag = */ ShadowNodeFragment::tagPlaceholder(), /* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(), /* .props = */ props, /* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(), @@ -364,7 +351,6 @@ TEST(ShadowNodeTest, handleBacktracking) { componentDescriptor); auto nodeAB = std::make_shared( ShadowNodeFragment{ - /* .tag = */ ShadowNodeFragment::tagPlaceholder(), /* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(), /* .props = */ props, /* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(), @@ -382,7 +368,6 @@ TEST(ShadowNodeTest, handleBacktracking) { componentDescriptor); auto nodeAC = std::make_shared( ShadowNodeFragment{ - /* .tag = */ ShadowNodeFragment::tagPlaceholder(), /* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(), /* .props = */ props, /* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(), @@ -403,7 +388,6 @@ TEST(ShadowNodeTest, handleBacktracking) { componentDescriptor); auto nodeA = std::make_shared( ShadowNodeFragment{ - /* .tag = */ ShadowNodeFragment::tagPlaceholder(), /* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(), /* .props = */ props, /* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(), @@ -421,7 +405,6 @@ TEST(ShadowNodeTest, handleBacktracking) { componentDescriptor); auto nodeZ = std::make_shared( ShadowNodeFragment{ - /* .tag = */ ShadowNodeFragment::tagPlaceholder(), /* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(), /* .props = */ props, /* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(), diff --git a/ReactCommon/fabric/mounting/ShadowTree.cpp b/ReactCommon/fabric/mounting/ShadowTree.cpp index 72bb0313b50..7a60486a9e0 100644 --- a/ReactCommon/fabric/mounting/ShadowTree.cpp +++ b/ReactCommon/fabric/mounting/ShadowTree.cpp @@ -103,12 +103,13 @@ ShadowTree::ShadowTree( *RootShadowNode::defaultSharedProps(), layoutConstraints, layoutContext); rootShadowNode_ = std::static_pointer_cast( - rootComponentDescriptor.createShadowNode(ShadowNodeFragment{ - /* .tag = */ surfaceId, - /* .surfaceId = */ surfaceId, - /* .props = */ props, - /* .eventEmitter = */ noopEventEmitter, - })); + rootComponentDescriptor.createShadowNode( + ShadowNodeFragment{ + /* .surfaceId = */ surfaceId, + /* .props = */ props, + /* .eventEmitter = */ noopEventEmitter, + }, + {surfaceId, surfaceId, noopEventEmitter})); mountingCoordinator_ = std::make_shared( ShadowTreeRevision{rootShadowNode_, 0, {}}); @@ -210,7 +211,6 @@ void ShadowTree::commitEmptyTree() const { return std::make_shared( *oldRootShadowNode, ShadowNodeFragment{ - /* .tag = */ ShadowNodeFragment::tagPlaceholder(), /* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(), /* .props = */ ShadowNodeFragment::propsPlaceholder(), /* .eventEmitter = */ diff --git a/ReactCommon/fabric/mounting/stubs/stubs.cpp b/ReactCommon/fabric/mounting/stubs/stubs.cpp index 06c738281b2..4036016c0c4 100644 --- a/ReactCommon/fabric/mounting/stubs/stubs.cpp +++ b/ReactCommon/fabric/mounting/stubs/stubs.cpp @@ -50,8 +50,7 @@ StubViewTree stubViewTreeFromShadowNode(ShadowNode const &rootShadowNode) { sliceChildShadowNodeViewPairs(rootShadowNode)); auto emptyRootShadowNode = rootShadowNode.clone( - ShadowNodeFragment{ShadowNodeFragment::tagPlaceholder(), - ShadowNodeFragment::surfaceIdPlaceholder(), + ShadowNodeFragment{ShadowNodeFragment::surfaceIdPlaceholder(), ShadowNodeFragment::propsPlaceholder(), ShadowNodeFragment::eventEmitterPlaceholder(), ShadowNode::emptySharedShadowNodeSharedList()}); diff --git a/ReactCommon/fabric/uimanager/ComponentDescriptorRegistry.cpp b/ReactCommon/fabric/uimanager/ComponentDescriptorRegistry.cpp index 6df7aace5d8..d38a2fa4207 100644 --- a/ReactCommon/fabric/uimanager/ComponentDescriptorRegistry.cpp +++ b/ReactCommon/fabric/uimanager/ComponentDescriptorRegistry.cpp @@ -171,17 +171,18 @@ SharedShadowNode ComponentDescriptorRegistry::createNode( auto const props = componentDescriptor.cloneProps(nullptr, RawProps(propsDynamic)); auto const state = componentDescriptor.createInitialState( - ShadowNodeFragment{tag, surfaceId, props, eventEmitter}); + ShadowNodeFragment{surfaceId, props, eventEmitter}); - return componentDescriptor.createShadowNode({ - /* .tag = */ tag, - /* .surfaceId = */ surfaceId, - /* .props = */ props, - /* .eventEmitter = */ eventEmitter, - /* .children = */ ShadowNodeFragment::childrenPlaceholder(), - /* .localData = */ ShadowNodeFragment::localDataPlaceholder(), - /* .state = */ state, - }); + return componentDescriptor.createShadowNode( + { + /* .surfaceId = */ surfaceId, + /* .props = */ props, + /* .eventEmitter = */ eventEmitter, + /* .children = */ ShadowNodeFragment::childrenPlaceholder(), + /* .localData = */ ShadowNodeFragment::localDataPlaceholder(), + /* .state = */ state, + }, + {tag, surfaceId, eventEmitter}); } void ComponentDescriptorRegistry::setFallbackComponentDescriptor( diff --git a/ReactCommon/fabric/uimanager/Scheduler.cpp b/ReactCommon/fabric/uimanager/Scheduler.cpp index 0e5ec959f62..f9f46da6c2a 100644 --- a/ReactCommon/fabric/uimanager/Scheduler.cpp +++ b/ReactCommon/fabric/uimanager/Scheduler.cpp @@ -174,22 +174,21 @@ void Scheduler::renderTemplateToSurface( uiManager_->getShadowTreeRegistry().visit( surfaceId, [=](const ShadowTree &shadowTree) { - return shadowTree.tryCommit([&](RootShadowNode::Shared const - &oldRootShadowNode) { - return std::make_shared( - *oldRootShadowNode, - ShadowNodeFragment{ - /* .tag = */ ShadowNodeFragment::tagPlaceholder(), - /* .surfaceId = */ - ShadowNodeFragment::surfaceIdPlaceholder(), - /* .props = */ ShadowNodeFragment::propsPlaceholder(), - /* .eventEmitter = */ - ShadowNodeFragment::eventEmitterPlaceholder(), - /* .children = */ - std::make_shared( - SharedShadowNodeList{tree}), - }); - }); + return shadowTree.tryCommit( + [&](RootShadowNode::Shared const &oldRootShadowNode) { + return std::make_shared( + *oldRootShadowNode, + ShadowNodeFragment{ + /* .surfaceId = */ + ShadowNodeFragment::surfaceIdPlaceholder(), + /* .props = */ ShadowNodeFragment::propsPlaceholder(), + /* .eventEmitter = */ + ShadowNodeFragment::eventEmitterPlaceholder(), + /* .children = */ + std::make_shared( + SharedShadowNodeList{tree}), + }); + }); }); } catch (const std::exception &e) { LOG(ERROR) << " >>>> EXCEPTION <<< rendering uiTemplate in " diff --git a/ReactCommon/fabric/uimanager/UIManager.cpp b/ReactCommon/fabric/uimanager/UIManager.cpp index 37327e5126e..c142392d516 100644 --- a/ReactCommon/fabric/uimanager/UIManager.cpp +++ b/ReactCommon/fabric/uimanager/UIManager.cpp @@ -36,23 +36,24 @@ SharedShadowNode UIManager::createNode( componentDescriptor.createEventEmitter(std::move(eventTarget), tag); auto const props = componentDescriptor.cloneProps(nullptr, rawProps); auto const state = componentDescriptor.createInitialState( - ShadowNodeFragment{tag, surfaceId, props, eventEmitter}); + ShadowNodeFragment{surfaceId, props, eventEmitter}); - auto shadowNode = componentDescriptor.createShadowNode({ - /* .tag = */ tag, - /* .surfaceId = */ surfaceId, - /* .props = */ - fallbackDescriptor != nullptr && - fallbackDescriptor->getComponentHandle() == - componentDescriptor.getComponentHandle() - ? componentDescriptor.cloneProps( - props, RawProps(folly::dynamic::object("name", name))) - : props, - /* .eventEmitter = */ eventEmitter, - /* .children = */ ShadowNodeFragment::childrenPlaceholder(), - /* .localData = */ ShadowNodeFragment::localDataPlaceholder(), - /* .state = */ state, - }); + auto shadowNode = componentDescriptor.createShadowNode( + ShadowNodeFragment{ + /* .surfaceId = */ surfaceId, + /* .props = */ + fallbackDescriptor != nullptr && + fallbackDescriptor->getComponentHandle() == + componentDescriptor.getComponentHandle() + ? componentDescriptor.cloneProps( + props, RawProps(folly::dynamic::object("name", name))) + : props, + /* .eventEmitter = */ eventEmitter, + /* .children = */ ShadowNodeFragment::childrenPlaceholder(), + /* .localData = */ ShadowNodeFragment::localDataPlaceholder(), + /* .state = */ state, + }, + ShadowNodeFamilyFragment{tag, surfaceId, eventEmitter}); // state->commit(x) associates a ShadowNode with the State object. // state->commit(x) must be called before calling updateState; updateState @@ -84,7 +85,6 @@ SharedShadowNode UIManager::cloneNode( auto clonedShadowNode = componentDescriptor.cloneShadowNode( *shadowNode, { - /* .tag = */ ShadowNodeFragment::tagPlaceholder(), /* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(), /* .props = */ rawProps ? componentDescriptor.cloneProps( @@ -116,7 +116,6 @@ void UIManager::completeSurface( return std::make_shared( *oldRootShadowNode, ShadowNodeFragment{ - /* .tag = */ ShadowNodeFragment::tagPlaceholder(), /* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(), /* .props = */ ShadowNodeFragment::propsPlaceholder(), /* .eventEmitter = */ @@ -157,7 +156,6 @@ void UIManager::setNativeProps( return oldRootShadowNode->clone( shadowNode, [&](ShadowNode const &oldShadowNode) { return oldShadowNode.clone({ - /* .tag = */ ShadowNodeFragment::tagPlaceholder(), /* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(), /* .props = */ props, @@ -211,7 +209,6 @@ void UIManager::updateState( return oldRootShadowNode->clone( shadowNode, [&](ShadowNode const &oldShadowNode) { return oldShadowNode.clone({ - /* .tag = */ ShadowNodeFragment::tagPlaceholder(), /* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(), /* .props = */ ShadowNodeFragment::propsPlaceholder(),