From 035e0403bba7afbfa8365c3e063070a1ec6a6615 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Mon, 29 Apr 2019 21:17:38 -0700 Subject: [PATCH] Fabric: `ShadowNodeFragment::rootTag` was renamed to `surfaceId` Summary: Trivial. We are replacing rootTag with surfaceId according to the plan describing here: https://fb.workplace.com/groups/rn.fabric/permalink/1374002366064519/ Reviewed By: JoshuaGross, mdvacca Differential Revision: D15039134 fbshipit-source-id: ec8c3044f9f3f23939488bc01c66e9b653e651dd --- .../fabric/components/root/RootShadowNode.cpp | 2 +- .../fabric/core/shadownode/ShadowNode.cpp | 4 +-- .../core/shadownode/ShadowNodeFragment.h | 2 +- .../core/tests/ComponentDescriptorTest.cpp | 10 +++--- .../fabric/core/tests/ShadowNodeTest.cpp | 34 +++++++++---------- ReactCommon/fabric/mounting/ShadowTree.cpp | 4 +-- .../uimanager/ComponentDescriptorRegistry.cpp | 4 +-- .../uimanager/ComponentDescriptorRegistry.h | 2 +- ReactCommon/fabric/uimanager/Scheduler.cpp | 7 ++-- ReactCommon/fabric/uimanager/UIManager.cpp | 8 ++--- 10 files changed, 39 insertions(+), 38 deletions(-) diff --git a/ReactCommon/fabric/components/root/RootShadowNode.cpp b/ReactCommon/fabric/components/root/RootShadowNode.cpp index 70058412586..0c2340ada09 100644 --- a/ReactCommon/fabric/components/root/RootShadowNode.cpp +++ b/ReactCommon/fabric/components/root/RootShadowNode.cpp @@ -37,7 +37,7 @@ UnsharedRootShadowNode RootShadowNode::clone( *this, ShadowNodeFragment{ /* .tag = */ ShadowNodeFragment::tagPlaceholder(), - /* .rootTag = */ ShadowNodeFragment::surfaceIdPlaceholder(), + /* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(), /* .props = */ props, }); return newRootShadowNode; diff --git a/ReactCommon/fabric/core/shadownode/ShadowNode.cpp b/ReactCommon/fabric/core/shadownode/ShadowNode.cpp index 5b104a6d231..239282df391 100644 --- a/ReactCommon/fabric/core/shadownode/ShadowNode.cpp +++ b/ReactCommon/fabric/core/shadownode/ShadowNode.cpp @@ -42,7 +42,7 @@ ShadowNode::ShadowNode( state_(fragment.state), family_(std::make_shared( fragment.tag, - fragment.rootTag, + fragment.surfaceId, fragment.eventEmitter, componentDescriptor)), childrenAreShared_(true), @@ -72,7 +72,7 @@ ShadowNode::ShadowNode( revision_(sourceShadowNode.revision_ + 1) { // `tag`, `surfaceId`, and `eventEmitter` cannot be changed with cloning. assert(fragment.tag == ShadowNodeFragment::tagPlaceholder()); - assert(fragment.rootTag == ShadowNodeFragment::surfaceIdPlaceholder()); + assert(fragment.surfaceId == ShadowNodeFragment::surfaceIdPlaceholder()); assert( fragment.eventEmitter == ShadowNodeFragment::eventEmitterPlaceholder()); diff --git a/ReactCommon/fabric/core/shadownode/ShadowNodeFragment.h b/ReactCommon/fabric/core/shadownode/ShadowNodeFragment.h index 754e0553189..a091c8e043f 100644 --- a/ReactCommon/fabric/core/shadownode/ShadowNodeFragment.h +++ b/ReactCommon/fabric/core/shadownode/ShadowNodeFragment.h @@ -26,7 +26,7 @@ namespace react { */ struct ShadowNodeFragment { Tag const tag = tagPlaceholder(); - SurfaceId const rootTag = surfaceIdPlaceholder(); + SurfaceId const surfaceId = surfaceIdPlaceholder(); Props::Shared const &props = propsPlaceholder(); EventEmitter::Shared const &eventEmitter = eventEmitterPlaceholder(); ShadowNode::SharedListOfShared const &children = childrenPlaceholder(); diff --git a/ReactCommon/fabric/core/tests/ComponentDescriptorTest.cpp b/ReactCommon/fabric/core/tests/ComponentDescriptorTest.cpp index 405dde03592..3fb5575144d 100644 --- a/ReactCommon/fabric/core/tests/ComponentDescriptorTest.cpp +++ b/ReactCommon/fabric/core/tests/ComponentDescriptorTest.cpp @@ -24,7 +24,7 @@ TEST(ComponentDescriptorTest, createShadowNode) { SharedProps props = descriptor->cloneProps(nullptr, raw); SharedShadowNode node = descriptor->createShadowNode(ShadowNodeFragment{ /* .tag = */ 9, - /* .rootTag = */ 1, + /* .surfaceId = */ 1, /* .props = */ props, /* .eventEmitter = */ descriptor->createEventEmitter(0, 9), }); @@ -46,7 +46,7 @@ TEST(ComponentDescriptorTest, cloneShadowNode) { SharedProps props = descriptor->cloneProps(nullptr, raw); SharedShadowNode node = descriptor->createShadowNode(ShadowNodeFragment{ /* .tag = */ 9, - /* .rootTag = */ 1, + /* .surfaceId = */ 1, /* .props = */ props, /* .eventEmitter = */ descriptor->createEventEmitter(0, 9), }); @@ -66,19 +66,19 @@ TEST(ComponentDescriptorTest, appendChild) { SharedProps props = descriptor->cloneProps(nullptr, raw); SharedShadowNode node1 = descriptor->createShadowNode(ShadowNodeFragment{ /* .tag = */ 1, - /* .rootTag = */ 1, + /* .surfaceId = */ 1, /* .props = */ props, /* .eventEmitter = */ descriptor->createEventEmitter(0, 1), }); SharedShadowNode node2 = descriptor->createShadowNode(ShadowNodeFragment{ /* .tag = */ 2, - /* .rootTag = */ 1, + /* .surfaceId = */ 1, /* .props = */ props, /* .eventEmitter = */ descriptor->createEventEmitter(0, 2), }); SharedShadowNode node3 = descriptor->createShadowNode(ShadowNodeFragment{ /* .tag = */ 3, - /* .rootTag = */ 1, + /* .surfaceId = */ 1, /* .props = */ props, /* .eventEmitter = */ descriptor->createEventEmitter(0, 3), }); diff --git a/ReactCommon/fabric/core/tests/ShadowNodeTest.cpp b/ReactCommon/fabric/core/tests/ShadowNodeTest.cpp index b1658f4c75d..0b38648a2e7 100644 --- a/ReactCommon/fabric/core/tests/ShadowNodeTest.cpp +++ b/ReactCommon/fabric/core/tests/ShadowNodeTest.cpp @@ -31,7 +31,7 @@ TEST(ShadowNodeTest, handleShadowNodeCreation) { auto node = std::make_shared( ShadowNodeFragment{ /* .tag = */ 9, - /* .rootTag = */ 1, + /* .surfaceId = */ 1, /* .props = */ std::make_shared(), /* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(), /* .children = */ ShadowNode::emptySharedShadowNodeSharedList(), @@ -57,7 +57,7 @@ TEST(ShadowNodeTest, handleShadowNodeSimpleCloning) { auto node = std::make_shared( ShadowNodeFragment{ /* .tag = */ 9, - /* .rootTag = */ 1, + /* .surfaceId = */ 1, /* .props = */ std::make_shared(), /* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(), /* .children = */ ShadowNode::emptySharedShadowNodeSharedList(), @@ -77,7 +77,7 @@ TEST(ShadowNodeTest, handleShadowNodeMutation) { auto node1 = std::make_shared( ShadowNodeFragment{ /* .tag = */ 1, - /* .rootTag = */ 1, + /* .surfaceId = */ 1, /* .props = */ std::make_shared(), /* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(), /* .children = */ ShadowNode::emptySharedShadowNodeSharedList(), @@ -86,7 +86,7 @@ TEST(ShadowNodeTest, handleShadowNodeMutation) { auto node2 = std::make_shared( ShadowNodeFragment{ /* .tag = */ 2, - /* .rootTag = */ 1, + /* .surfaceId = */ 1, /* .props = */ std::make_shared(), /* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(), /* .children = */ ShadowNode::emptySharedShadowNodeSharedList(), @@ -95,7 +95,7 @@ TEST(ShadowNodeTest, handleShadowNodeMutation) { auto node3 = std::make_shared( ShadowNodeFragment{ /* .tag = */ 3, - /* .rootTag = */ 1, + /* .surfaceId = */ 1, /* .props = */ std::make_shared(), /* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(), /* .children = */ ShadowNode::emptySharedShadowNodeSharedList(), @@ -136,7 +136,7 @@ TEST(ShadowNodeTest, handleCloneFunction) { auto firstNode = std::make_shared( ShadowNodeFragment{ /* .tag = */ 9, - /* .rootTag = */ 1, + /* .surfaceId = */ 1, /* .props = */ std::make_shared(), /* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(), /* .children = */ ShadowNode::emptySharedShadowNodeSharedList(), @@ -172,7 +172,7 @@ TEST(ShadowNodeTest, handleLocalData) { auto firstNode = std::make_shared( ShadowNodeFragment{ /* .tag = */ 9, - /* .rootTag = */ 1, + /* .surfaceId = */ 1, /* .props = */ props, /* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(), /* .children = */ ShadowNode::emptySharedShadowNodeSharedList(), @@ -181,7 +181,7 @@ TEST(ShadowNodeTest, handleLocalData) { auto secondNode = std::make_shared( ShadowNodeFragment{ /* .tag = */ 9, - /* .rootTag = */ 1, + /* .surfaceId = */ 1, /* .props = */ props, /* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(), /* .children = */ ShadowNode::emptySharedShadowNodeSharedList(), @@ -190,7 +190,7 @@ TEST(ShadowNodeTest, handleLocalData) { auto thirdNode = std::make_shared( ShadowNodeFragment{ /* .tag = */ 9, - /* .rootTag = */ 1, + /* .surfaceId = */ 1, /* .props = */ props, /* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(), /* .children = */ ShadowNode::emptySharedShadowNodeSharedList(), @@ -232,7 +232,7 @@ TEST(ShadowNodeTest, handleBacktracking) { auto nodeAA = std::make_shared( ShadowNodeFragment{ /* .tag = */ ShadowNodeFragment::tagPlaceholder(), - /* .rootTag = */ ShadowNodeFragment::surfaceIdPlaceholder(), + /* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(), /* .props = */ props, /* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(), /* .children = */ ShadowNode::emptySharedShadowNodeSharedList(), @@ -242,7 +242,7 @@ TEST(ShadowNodeTest, handleBacktracking) { auto nodeABA = std::make_shared( ShadowNodeFragment{ /* .tag = */ ShadowNodeFragment::tagPlaceholder(), - /* .rootTag = */ ShadowNodeFragment::surfaceIdPlaceholder(), + /* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(), /* .props = */ props, /* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(), /* .children = */ ShadowNode::emptySharedShadowNodeSharedList(), @@ -251,7 +251,7 @@ TEST(ShadowNodeTest, handleBacktracking) { auto nodeABB = std::make_shared( ShadowNodeFragment{ /* .tag = */ ShadowNodeFragment::tagPlaceholder(), - /* .rootTag = */ ShadowNodeFragment::surfaceIdPlaceholder(), + /* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(), /* .props = */ props, /* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(), /* .children = */ ShadowNode::emptySharedShadowNodeSharedList(), @@ -260,7 +260,7 @@ TEST(ShadowNodeTest, handleBacktracking) { auto nodeABC = std::make_shared( ShadowNodeFragment{ /* .tag = */ ShadowNodeFragment::tagPlaceholder(), - /* .rootTag = */ ShadowNodeFragment::surfaceIdPlaceholder(), + /* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(), /* .props = */ props, /* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(), /* .children = */ ShadowNode::emptySharedShadowNodeSharedList(), @@ -272,7 +272,7 @@ TEST(ShadowNodeTest, handleBacktracking) { auto nodeAB = std::make_shared( ShadowNodeFragment{ /* .tag = */ ShadowNodeFragment::tagPlaceholder(), - /* .rootTag = */ ShadowNodeFragment::surfaceIdPlaceholder(), + /* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(), /* .props = */ props, /* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(), /* .children = */ nodeABChildren, @@ -282,7 +282,7 @@ TEST(ShadowNodeTest, handleBacktracking) { auto nodeAC = std::make_shared( ShadowNodeFragment{ /* .tag = */ ShadowNodeFragment::tagPlaceholder(), - /* .rootTag = */ ShadowNodeFragment::surfaceIdPlaceholder(), + /* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(), /* .props = */ props, /* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(), /* .children = */ ShadowNode::emptySharedShadowNodeSharedList(), @@ -294,7 +294,7 @@ TEST(ShadowNodeTest, handleBacktracking) { auto nodeA = std::make_shared( ShadowNodeFragment{ /* .tag = */ ShadowNodeFragment::tagPlaceholder(), - /* .rootTag = */ ShadowNodeFragment::surfaceIdPlaceholder(), + /* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(), /* .props = */ props, /* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(), /* .children = */ nodeAChildren, @@ -304,7 +304,7 @@ TEST(ShadowNodeTest, handleBacktracking) { auto nodeZ = std::make_shared( ShadowNodeFragment{ /* .tag = */ ShadowNodeFragment::tagPlaceholder(), - /* .rootTag = */ ShadowNodeFragment::surfaceIdPlaceholder(), + /* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(), /* .props = */ props, /* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(), /* .children = */ ShadowNode::emptySharedShadowNodeSharedList(), diff --git a/ReactCommon/fabric/mounting/ShadowTree.cpp b/ReactCommon/fabric/mounting/ShadowTree.cpp index c2ec749e821..4cf7f5b60c2 100644 --- a/ReactCommon/fabric/mounting/ShadowTree.cpp +++ b/ReactCommon/fabric/mounting/ShadowTree.cpp @@ -94,7 +94,7 @@ ShadowTree::ShadowTree( rootShadowNode_ = std::static_pointer_cast( rootComponentDescriptor.createShadowNode(ShadowNodeFragment{ /* .tag = */ surfaceId, - /* .rootTag = */ surfaceId, + /* .surfaceId = */ surfaceId, /* .props = */ props, /* .eventEmitter = */ noopEventEmitter, })); @@ -111,7 +111,7 @@ ShadowTree::~ShadowTree() { *oldRootShadowNode, ShadowNodeFragment{ /* .tag = */ ShadowNodeFragment::tagPlaceholder(), - /* .rootTag = */ ShadowNodeFragment::surfaceIdPlaceholder(), + /* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(), /* .props = */ ShadowNodeFragment::propsPlaceholder(), /* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(), diff --git a/ReactCommon/fabric/uimanager/ComponentDescriptorRegistry.cpp b/ReactCommon/fabric/uimanager/ComponentDescriptorRegistry.cpp index c55ae59560c..a90c17d87e1 100644 --- a/ReactCommon/fabric/uimanager/ComponentDescriptorRegistry.cpp +++ b/ReactCommon/fabric/uimanager/ComponentDescriptorRegistry.cpp @@ -142,14 +142,14 @@ ComponentDescriptor const &ComponentDescriptorRegistry::at( SharedShadowNode ComponentDescriptorRegistry::createNode( Tag tag, ComponentName const &viewName, - Tag rootTag, + SurfaceId surfaceId, folly::dynamic const &props, SharedEventTarget const &eventTarget) const { auto unifiedComponentName = componentNameByReactViewName(viewName); auto const &componentDescriptor = this->at(unifiedComponentName); return componentDescriptor.createShadowNode({ /* .tag = */ tag, - /* .rootTag = */ rootTag, + /* .surfaceId = */ surfaceId, /* .props = */ componentDescriptor.cloneProps(nullptr, RawProps(props)), /* .eventEmitter = */ componentDescriptor.createEventEmitter(std::move(eventTarget), tag), diff --git a/ReactCommon/fabric/uimanager/ComponentDescriptorRegistry.h b/ReactCommon/fabric/uimanager/ComponentDescriptorRegistry.h index b7ebaa276bc..0f3254b1037 100644 --- a/ReactCommon/fabric/uimanager/ComponentDescriptorRegistry.h +++ b/ReactCommon/fabric/uimanager/ComponentDescriptorRegistry.h @@ -51,7 +51,7 @@ class ComponentDescriptorRegistry { SharedShadowNode createNode( Tag tag, ComponentName const &viewName, - Tag rootTag, + SurfaceId surfaceId, folly::dynamic const &props, SharedEventTarget const &eventTarget) const; diff --git a/ReactCommon/fabric/uimanager/Scheduler.cpp b/ReactCommon/fabric/uimanager/Scheduler.cpp index c6639333769..e22ead6b4fe 100644 --- a/ReactCommon/fabric/uimanager/Scheduler.cpp +++ b/ReactCommon/fabric/uimanager/Scheduler.cpp @@ -131,7 +131,8 @@ void Scheduler::renderTemplateToSurface( *oldRootShadowNode, ShadowNodeFragment{ /* .tag = */ ShadowNodeFragment::tagPlaceholder(), - /* .rootTag = */ ShadowNodeFragment::surfaceIdPlaceholder(), + /* .surfaceId = */ + ShadowNodeFragment::surfaceIdPlaceholder(), /* .props = */ ShadowNodeFragment::propsPlaceholder(), /* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(), @@ -161,7 +162,7 @@ void Scheduler::stopSurface(SurfaceId surfaceId) const { *oldRootShadowNode, ShadowNodeFragment{ /* .tag = */ ShadowNodeFragment::tagPlaceholder(), - /* .rootTag = */ + /* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(), /* .props = */ ShadowNodeFragment::propsPlaceholder(), /* .eventEmitter = */ @@ -265,7 +266,7 @@ void Scheduler::uiManagerDidFinishTransaction( *oldRootShadowNode, ShadowNodeFragment{ /* .tag = */ ShadowNodeFragment::tagPlaceholder(), - /* .rootTag = */ ShadowNodeFragment::surfaceIdPlaceholder(), + /* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(), /* .props = */ ShadowNodeFragment::propsPlaceholder(), /* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(), diff --git a/ReactCommon/fabric/uimanager/UIManager.cpp b/ReactCommon/fabric/uimanager/UIManager.cpp index 3b98978cd86..7bdb4f33869 100644 --- a/ReactCommon/fabric/uimanager/UIManager.cpp +++ b/ReactCommon/fabric/uimanager/UIManager.cpp @@ -26,7 +26,7 @@ SharedShadowNode UIManager::createNode( auto shadowNode = componentDescriptor.createShadowNode({ /* .tag = */ tag, - /* .rootTag = */ surfaceId, + /* .surfaceId = */ surfaceId, /* .props = */ fallbackDescriptor != nullptr && fallbackDescriptor->getComponentHandle() == @@ -59,7 +59,7 @@ SharedShadowNode UIManager::cloneNode( *shadowNode, { /* .tag = */ ShadowNodeFragment::tagPlaceholder(), - /* .rootTag = */ ShadowNodeFragment::surfaceIdPlaceholder(), + /* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(), /* .props = */ rawProps ? componentDescriptor.cloneProps( shadowNode->getProps(), *rawProps) @@ -102,7 +102,7 @@ void UIManager::setNativeProps( auto props = componentDescriptor.cloneProps(shadowNode->getProps(), rawProps); auto newShadowNode = shadowNode->clone({ /* .tag = */ ShadowNodeFragment::tagPlaceholder(), - /* .rootTag = */ ShadowNodeFragment::surfaceIdPlaceholder(), + /* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(), /* .props = */ props, }); @@ -158,7 +158,7 @@ void UIManager::updateState( componentDescriptor.createState(shadowNode->getState(), rawStateData); auto newShadowNode = shadowNode->clone({ /* .tag = */ ShadowNodeFragment::tagPlaceholder(), - /* .rootTag = */ ShadowNodeFragment::surfaceIdPlaceholder(), + /* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(), /* .props = */ ShadowNodeFragment::propsPlaceholder(), /* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(), /* .children = */ ShadowNodeFragment::childrenPlaceholder(),