Skip to content

Commit 2ac2f14

Browse files
rubennortefacebook-github-bot
authored andcommitted
Remove references to ShadowNodeFamilyFragment when not used to create new instances of ShadowNodeFamily
Summary: 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 a new class that works as an interface to access information from shadow node family. Reviewed By: sammy-SC Differential Revision: D46190382 fbshipit-source-id: 1fef0992ad15191fa7819d4356db447f158f0b63
1 parent f45f605 commit 2ac2f14

File tree

10 files changed

+72
-7
lines changed

10 files changed

+72
-7
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/ShadowNodeFamilyInfo.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+
ShadowNodeFamilyInfo 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 ShadowNodeFamilyInfo & /*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/ShadowNodeFamilyInfo.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+
ShadowNodeFamilyInfo const &family,
3435
ComponentDescriptor const &componentDescriptor);
3536

3637
#pragma mark - LayoutableShadowNode

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <react/renderer/core/Props.h>
1919
#include <react/renderer/core/PropsParserContext.h>
2020
#include <react/renderer/core/ShadowNode.h>
21+
#include <react/renderer/core/ShadowNodeFamilyInfo.h>
2122
#include <react/renderer/core/ShadowNodeFragment.h>
2223
#include <react/renderer/core/State.h>
2324
#include <react/renderer/graphics/Float.h>
@@ -161,7 +162,7 @@ class ConcreteComponentDescriptor : public ComponentDescriptor {
161162
return std::make_shared<ConcreteState>(
162163
std::make_shared<ConcreteStateData const>(
163164
ConcreteShadowNode::initialStateData(
164-
props, ShadowNodeFamilyFragment::build(*family), *this)),
165+
props, ShadowNodeFamilyInfo::build(*family), *this)),
165166
family);
166167
}
167168

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/ShadowNodeFamilyInfo.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+
ShadowNodeFamilyInfo const & /*family*/,
92+
ComponentDescriptor const & /*componentDescriptor*/) {
9293
return {};
9394
}
9495

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <react/renderer/core/EventEmitter.h>
1616
#include <react/renderer/core/ReactPrimitives.h>
1717
#include <react/renderer/core/ShadowNodeFamilyFragment.h>
18+
#include <react/renderer/core/ShadowNodeFamilyInfo.h>
1819

1920
namespace facebook::react {
2021

@@ -97,6 +98,7 @@ class ShadowNodeFamily final {
9798
private:
9899
friend ShadowNode;
99100
friend ShadowNodeFamilyFragment;
101+
friend ShadowNodeFamilyInfo;
100102
friend State;
101103

102104
/*

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ namespace facebook::react {
1515
class ShadowNodeFamily;
1616

1717
/*
18+
* This is a collection of fields serving as a specification to create new
19+
* `ShadowNodeFamily` instances.
20+
*
21+
* Do not use this class as a general purpose container to share information
22+
* about a `ShadowNodeFamily`. Pelase define specific purpose containers in
23+
* those cases.
24+
*
1825
* Note: All of the fields are `const &` references (essentially just raw
1926
* pointers) which means that the Fragment does not copy/store them nor
2027
* retain ownership of them.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
#include "ShadowNodeFamilyInfo.h"
9+
10+
#include <react/renderer/core/ShadowNodeFamily.h>
11+
12+
namespace facebook::react {
13+
14+
ShadowNodeFamilyInfo ShadowNodeFamilyInfo::build(
15+
ShadowNodeFamily const &family) {
16+
return {
17+
family.tag_,
18+
family.surfaceId_,
19+
family.eventEmitter_,
20+
};
21+
}
22+
23+
} // namespace facebook::react
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
#pragma once
9+
10+
#include <react/renderer/core/EventEmitter.h>
11+
#include <react/renderer/core/ReactPrimitives.h>
12+
13+
namespace facebook::react {
14+
15+
class ShadowNodeFamily;
16+
17+
/*
18+
* This is a public interface to interact with `ShadowNodeFamily`, without
19+
* providing access to the original family
20+
*/
21+
class ShadowNodeFamilyInfo final {
22+
public:
23+
static ShadowNodeFamilyInfo build(ShadowNodeFamily const &family);
24+
25+
Tag const tag;
26+
SurfaceId const surfaceId;
27+
EventEmitter::Shared const eventEmitter;
28+
};
29+
30+
} // namespace facebook::react

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)