Skip to content

Commit a88c0ed

Browse files
rubennortefacebook-github-bot
authored andcommitted
Remove references to ShadowNodeFamilyFragment when not used to create new instances of ShadowNodeFamily (#37772)
Summary: Pull Request resolved: #37772 Changelog: [internal] `ShadowNodeFragment` is used in multiple places as a general definition for the fragment, but it lacks information that's going to be constructed in the fragment itself in the future (like `eventEmitter` in D46149084). This migrates some of the usages of this fragment to the `ShadowNodeFamily` directly (as they already have access to it). Reviewed By: javache, sammy-SC Differential Revision: D46190382 fbshipit-source-id: 3a879861106594d66a2580410d4d83523c288314
1 parent 9bd5591 commit a88c0ed

File tree

9 files changed

+27
-97
lines changed

9 files changed

+27
-97
lines changed

packages/react-native/ReactCommon/react/renderer/components/image/ImageShadowNode.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <react/renderer/components/image/ImageProps.h>
1212
#include <react/renderer/components/image/ImageState.h>
1313
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
14+
#include <react/renderer/core/ShadowNodeFamily.h>
1415
#include <react/renderer/imagemanager/ImageManager.h>
1516
#include <react/renderer/imagemanager/primitives.h>
1617

@@ -42,7 +43,7 @@ class ImageShadowNode final : public ConcreteViewShadowNode<
4243

4344
static ImageState initialStateData(
4445
Props::Shared const &props,
45-
ShadowNodeFamilyFragment const &familyFragment,
46+
ShadowNodeFamily::Shared const & /*family*/,
4647
ComponentDescriptor const &componentDescriptor) {
4748
auto imageSource = ImageSource{ImageSource::Type::Invalid};
4849
return {imageSource, {imageSource, nullptr}, 0};

packages/react-native/ReactCommon/react/renderer/components/scrollview/ScrollViewShadowNode.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void ScrollViewShadowNode::updateScrollContentOffsetIfNeeded() {
5050

5151
ScrollViewState ScrollViewShadowNode::initialStateData(
5252
Props::Shared const &props,
53-
const ShadowNodeFamilyFragment & /*familyFragment*/,
53+
const ShadowNodeFamily::Shared & /*family*/,
5454
const ComponentDescriptor & /*componentDescriptor*/) {
5555
return {static_cast<ScrollViewProps const &>(*props).contentOffset, {}, 0};
5656
}

packages/react-native/ReactCommon/react/renderer/components/scrollview/ScrollViewShadowNode.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <react/renderer/components/scrollview/ScrollViewState.h>
1313
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
1414
#include <react/renderer/core/LayoutContext.h>
15+
#include <react/renderer/core/ShadowNodeFamily.h>
1516

1617
namespace facebook::react {
1718

@@ -30,7 +31,7 @@ class ScrollViewShadowNode final : public ConcreteViewShadowNode<
3031

3132
static ScrollViewState initialStateData(
3233
Props::Shared const &props,
33-
ShadowNodeFamilyFragment const &familyFragment,
34+
ShadowNodeFamily::Shared const &family,
3435
ComponentDescriptor const &componentDescriptor);
3536

3637
#pragma mark - LayoutableShadowNode

packages/react-native/ReactCommon/react/renderer/core/ConcreteComponentDescriptor.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,7 @@ class ConcreteComponentDescriptor : public ComponentDescriptor {
160160

161161
return std::make_shared<ConcreteState>(
162162
std::make_shared<ConcreteStateData const>(
163-
ConcreteShadowNode::initialStateData(
164-
props, ShadowNodeFamilyFragment::build(*family), *this)),
163+
ConcreteShadowNode::initialStateData(props, family, *this)),
165164
family);
166165
}
167166

packages/react-native/ReactCommon/react/renderer/core/ConcreteShadowNode.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <react/renderer/core/PropsParserContext.h>
1414
#include <react/renderer/core/RawProps.h>
1515
#include <react/renderer/core/ShadowNode.h>
16+
#include <react/renderer/core/ShadowNodeFamily.h>
1617
#include <react/renderer/core/StateData.h>
1718

1819
namespace facebook::react {
@@ -87,8 +88,8 @@ class ConcreteShadowNode : public BaseShadowNodeT {
8788

8889
static ConcreteStateData initialStateData(
8990
Props::Shared const & /*props*/,
90-
ShadowNodeFamilyFragment const &familyFragment,
91-
ComponentDescriptor const &componentDescriptor) {
91+
ShadowNodeFamily::Shared const & /*family*/,
92+
ComponentDescriptor const & /*componentDescriptor*/) {
9293
return {};
9394
}
9495

packages/react-native/ReactCommon/react/renderer/core/ShadowNodeFamily.h

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,31 @@
1414

1515
#include <react/renderer/core/EventEmitter.h>
1616
#include <react/renderer/core/ReactPrimitives.h>
17-
#include <react/renderer/core/ShadowNodeFamilyFragment.h>
1817

1918
namespace facebook::react {
2019

2120
class ComponentDescriptor;
2221
class ShadowNode;
2322
class State;
2423

24+
/*
25+
* This is a collection of fields serving as a specification to create new
26+
* `ShadowNodeFamily` instances.
27+
*
28+
* Do not use this class as a general purpose container to share information
29+
* about a `ShadowNodeFamily`. Pelase define specific purpose containers in
30+
* those cases.
31+
*
32+
* Note: All of the fields are `const &` references (essentially just raw
33+
* pointers) which means that the Fragment does not copy/store them nor
34+
* retain ownership of them.
35+
*/
36+
struct ShadowNodeFamilyFragment {
37+
Tag const tag;
38+
SurfaceId const surfaceId;
39+
EventEmitter::Shared const &eventEmitter;
40+
};
41+
2542
/*
2643
* Represents all things that shadow nodes from the same family have in common.
2744
* To be used inside `ShadowNode` class *only*.
@@ -96,7 +113,6 @@ class ShadowNodeFamily final {
96113

97114
private:
98115
friend ShadowNode;
99-
friend ShadowNodeFamilyFragment;
100116
friend State;
101117

102118
/*

packages/react-native/ReactCommon/react/renderer/core/ShadowNodeFamilyFragment.cpp

Lines changed: 0 additions & 34 deletions
This file was deleted.

packages/react-native/ReactCommon/react/renderer/core/ShadowNodeFamilyFragment.h

Lines changed: 0 additions & 53 deletions
This file was deleted.

packages/react-native/ReactCommon/react/renderer/element/ComponentBuilder.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <react/renderer/componentregistry/ComponentDescriptorRegistry.h>
1313
#include <react/renderer/core/ComponentDescriptor.h>
1414
#include <react/renderer/core/ShadowNode.h>
15-
#include <react/renderer/core/ShadowNodeFamilyFragment.h>
1615
#include <react/renderer/core/ShadowNodeFragment.h>
1716

1817
#include <react/renderer/element/Element.h>

0 commit comments

Comments
 (0)