Skip to content

Commit 175f91a

Browse files
javachefacebook-github-bot
authored andcommitted
Remove unused ViewShadowNodeProps subclass
Summary: ViewShadowNodeProps was a thin subclass of ViewProps that only forwarded its constructor. After the feature flag propagation logic was removed, the subclass serves no purpose. Changelog: [Internal] Differential Revision: D110095190
1 parent b364490 commit 175f91a

23 files changed

Lines changed: 73 additions & 127 deletions

packages/react-native/ReactCommon/react/renderer/components/view/ViewShadowNode.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ namespace facebook::react {
1414
// NOLINTNEXTLINE(facebook-hte-CArray,modernize-avoid-c-arrays)
1515
const char ViewComponentName[] = "View";
1616

17-
ViewShadowNodeProps::ViewShadowNodeProps(
18-
const PropsParserContext& context,
19-
const ViewShadowNodeProps& sourceProps,
20-
const RawProps& rawProps)
21-
: ViewProps(context, sourceProps, rawProps) {};
22-
2317
ViewShadowNode::ViewShadowNode(
2418
const ShadowNodeFragment& fragment,
2519
const ShadowNodeFamily::Shared& family,

packages/react-native/ReactCommon/react/renderer/components/view/ViewShadowNode.h

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,12 @@ namespace facebook::react {
1515
// NOLINTNEXTLINE(modernize-avoid-c-arrays)
1616
extern const char ViewComponentName[];
1717

18-
/**
19-
* Implementation of the ViewProps that propagates feature flag.
20-
*/
21-
class ViewShadowNodeProps final : public ViewProps {
22-
public:
23-
ViewShadowNodeProps() = default;
24-
ViewShadowNodeProps(
25-
const PropsParserContext &context,
26-
const ViewShadowNodeProps &sourceProps,
27-
const RawProps &rawProps);
28-
};
18+
using ViewShadowNodeProps = ViewProps;
2919

3020
/*
3121
* `ShadowNode` for <View> component.
3222
*/
33-
class ViewShadowNode final : public ConcreteViewShadowNode<ViewComponentName, ViewShadowNodeProps, ViewEventEmitter> {
23+
class ViewShadowNode final : public ConcreteViewShadowNode<ViewComponentName, ViewProps, ViewEventEmitter> {
3424
public:
3525
ViewShadowNode(const ShadowNodeFragment &fragment, const ShadowNodeFamily::Shared &family, ShadowNodeTraits traits);
3626

packages/react-native/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,8 +1017,7 @@ void YogaLayoutableShadowNode::swapLeftAndRightInYogaStyleProps() {
10171017
void YogaLayoutableShadowNode::swapLeftAndRightInViewProps() {
10181018
if (auto viewShadowNode = dynamic_cast<ViewShadowNode*>(this)) {
10191019
// TODO: Do not mutate props directly.
1020-
auto& props =
1021-
const_cast<ViewShadowNodeProps&>(viewShadowNode->getConcreteProps());
1020+
auto& props = const_cast<ViewProps&>(viewShadowNode->getConcreteProps());
10221021

10231022
// Swap border node values, borderRadii, borderColors and borderStyles.
10241023
if (props.borderRadii.topLeft.has_value()) {

packages/react-native/ReactCommon/react/renderer/components/view/tests/LayoutTest.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class LayoutTest : public ::testing::Test {
8686
.reference(viewShadowNodeA_)
8787
.tag(2)
8888
.props([] {
89-
auto sharedProps = std::make_shared<ViewShadowNodeProps>();
89+
auto sharedProps = std::make_shared<ViewProps>();
9090
auto &props = *sharedProps;
9191
auto &yogaStyle = props.yogaStyle;
9292
yogaStyle.setPositionType(yoga::PositionType::Absolute);
@@ -99,7 +99,7 @@ class LayoutTest : public ::testing::Test {
9999
.reference(viewShadowNodeAB_)
100100
.tag(3)
101101
.props([=] {
102-
auto sharedProps = std::make_shared<ViewShadowNodeProps>();
102+
auto sharedProps = std::make_shared<ViewProps>();
103103
auto &props = *sharedProps;
104104
auto &yogaStyle = props.yogaStyle;
105105
yogaStyle.setPositionType(yoga::PositionType::Absolute);
@@ -127,7 +127,7 @@ class LayoutTest : public ::testing::Test {
127127
.reference(viewShadowNodeABC_)
128128
.tag(4)
129129
.props([=] {
130-
auto sharedProps = std::make_shared<ViewShadowNodeProps>();
130+
auto sharedProps = std::make_shared<ViewProps>();
131131
auto &props = *sharedProps;
132132
auto &yogaStyle = props.yogaStyle;
133133

@@ -147,7 +147,7 @@ class LayoutTest : public ::testing::Test {
147147
.reference(viewShadowNodeABCD_)
148148
.tag(5)
149149
.props([] {
150-
auto sharedProps = std::make_shared<ViewShadowNodeProps>();
150+
auto sharedProps = std::make_shared<ViewProps>();
151151
auto &props = *sharedProps;
152152
auto &yogaStyle = props.yogaStyle;
153153
yogaStyle.setPositionType(yoga::PositionType::Absolute);
@@ -162,7 +162,7 @@ class LayoutTest : public ::testing::Test {
162162
.reference(viewShadowNodeABE_)
163163
.tag(6)
164164
.props([] {
165-
auto sharedProps = std::make_shared<ViewShadowNodeProps>();
165+
auto sharedProps = std::make_shared<ViewProps>();
166166
auto &props = *sharedProps;
167167
auto &yogaStyle = props.yogaStyle;
168168
yogaStyle.setPositionType(yoga::PositionType::Absolute);

packages/react-native/ReactCommon/react/renderer/components/view/tests/ViewTest.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class YogaDirtyFlagTest : public ::testing::Test {
5151
/*
5252
* Some non-default props.
5353
*/
54-
auto mutableViewProps = std::make_shared<ViewShadowNodeProps>();
54+
auto mutableViewProps = std::make_shared<ViewProps>();
5555
auto &props = *mutableViewProps;
5656
props.nativeId = "native Id";
5757
props.opacity = 0.5;
@@ -113,7 +113,7 @@ TEST_F(YogaDirtyFlagTest, changingNonLayoutSubPropsMustNotDirtyYogaNode) {
113113
*/
114114
auto newRootShadowNode = rootShadowNode_->cloneTree(
115115
innerShadowNode_->getFamily(), [](const ShadowNode& oldShadowNode) {
116-
auto viewProps = std::make_shared<ViewShadowNodeProps>();
116+
auto viewProps = std::make_shared<ViewProps>();
117117
auto& props = *viewProps;
118118

119119
props.nativeId = "some new native Id";
@@ -136,7 +136,7 @@ TEST_F(YogaDirtyFlagTest, changingLayoutSubPropsMustDirtyYogaNode) {
136136
*/
137137
auto newRootShadowNode = rootShadowNode_->cloneTree(
138138
innerShadowNode_->getFamily(), [](const ShadowNode& oldShadowNode) {
139-
auto viewProps = std::make_shared<ViewShadowNodeProps>();
139+
auto viewProps = std::make_shared<ViewProps>();
140140
auto& props = *viewProps;
141141

142142
props.yogaStyle.setAlignContent(yoga::Align::Baseline);
@@ -243,7 +243,7 @@ TEST_F(YogaDirtyFlagTest, clonedPropsPreserveAspectRatio) {
243243
auto newRootShadowNode = rootShadowNode_->cloneTree(
244244
innerShadowNode_->getFamily(), [&](const ShadowNode& oldShadowNode) {
245245
// First clone: set aspectRatio to 1.5
246-
auto viewProps = std::make_shared<ViewShadowNodeProps>();
246+
auto viewProps = std::make_shared<ViewProps>();
247247
viewProps->yogaStyle.setAspectRatio(yoga::FloatOptional(1.5f));
248248
auto nodeWithAspectRatio =
249249
oldShadowNode.clone(ShadowNodeFragment{.props = viewProps});
@@ -255,8 +255,7 @@ TEST_F(YogaDirtyFlagTest, clonedPropsPreserveAspectRatio) {
255255
auto clonedProps = componentDescriptor.cloneProps(
256256
parserContext, nodeWithAspectRatio->getProps(), RawProps());
257257

258-
auto& clonedViewProps =
259-
static_cast<const ViewShadowNodeProps&>(*clonedProps);
258+
auto& clonedViewProps = static_cast<const ViewProps&>(*clonedProps);
260259
EXPECT_TRUE(clonedViewProps.yogaStyle.aspectRatio().isDefined());
261260
EXPECT_EQ(clonedViewProps.yogaStyle.aspectRatio().unwrap(), 1.5f);
262261

@@ -303,7 +302,7 @@ class YogaCloneTest : public ::testing::Test {
303302
.reference(parentShadowNode_)
304303
.tag(2)
305304
.props([] {
306-
auto sharedProps = std::make_shared<ViewShadowNodeProps>();
305+
auto sharedProps = std::make_shared<ViewProps>();
307306
auto &props = *sharedProps;
308307
auto &yogaStyle = props.yogaStyle;
309308
yogaStyle.setFlexDirection(yoga::FlexDirection::Row);
@@ -320,7 +319,7 @@ class YogaCloneTest : public ::testing::Test {
320319
.reference(childAShadowNode_)
321320
.tag(3)
322321
.props([] {
323-
auto sharedProps = std::make_shared<ViewShadowNodeProps>();
322+
auto sharedProps = std::make_shared<ViewProps>();
324323
sharedProps->yogaStyle.setDimension(
325324
yoga::Dimension::Width,
326325
yoga::StyleSizeLength::points(100));
@@ -333,7 +332,7 @@ class YogaCloneTest : public ::testing::Test {
333332
.reference(childBShadowNode_)
334333
.tag(4)
335334
.props([] {
336-
auto sharedProps = std::make_shared<ViewShadowNodeProps>();
335+
auto sharedProps = std::make_shared<ViewProps>();
337336
sharedProps->yogaStyle.setDimension(
338337
yoga::Dimension::Width,
339338
yoga::StyleSizeLength::points(100));
@@ -346,7 +345,7 @@ class YogaCloneTest : public ::testing::Test {
346345
.reference(childCShadowNode_)
347346
.tag(5)
348347
.props([] {
349-
auto sharedProps = std::make_shared<ViewShadowNodeProps>();
348+
auto sharedProps = std::make_shared<ViewProps>();
350349
sharedProps->yogaStyle.setDimension(
351350
yoga::Dimension::Width,
352351
yoga::StyleSizeLength::points(100));

packages/react-native/ReactCommon/react/renderer/core/tests/FindNodeAtPointTest.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ TEST(FindNodeAtPointTest, viewIsScaled) {
126126
Element<ViewShadowNode>()
127127
.tag(3)
128128
.props([] {
129-
auto sharedProps = std::make_shared<ViewShadowNodeProps>();
129+
auto sharedProps = std::make_shared<ViewProps>();
130130
sharedProps->transform = Transform::Scale(0.5, 0.5, 0);
131131
return sharedProps;
132132
})
@@ -199,7 +199,7 @@ TEST(FindNodeAtPointTest, overlappingViewsWithZIndex) {
199199
Element<ViewShadowNode>()
200200
.tag(2)
201201
.props([] {
202-
auto sharedProps = std::make_shared<ViewShadowNodeProps>();
202+
auto sharedProps = std::make_shared<ViewProps>();
203203
sharedProps->zIndex = 1;
204204
auto &yogaStyle = sharedProps->yogaStyle;
205205
yogaStyle.setPositionType(yoga::PositionType::Absolute);
@@ -235,7 +235,7 @@ TEST(FindNodeAtPointTest, overlappingViewsWithParentPointerEventsBoxOnly) {
235235
Element<ViewShadowNode>()
236236
.tag(1)
237237
.props([] {
238-
auto sharedProps = std::make_shared<ViewShadowNodeProps>();
238+
auto sharedProps = std::make_shared<ViewProps>();
239239
sharedProps->pointerEvents = PointerEventsMode::BoxOnly;
240240
return sharedProps;
241241
})
@@ -277,7 +277,7 @@ TEST(FindNodeAtPointTest, overlappingViewsWithParentPointerEventsBoxNone) {
277277
Element<ViewShadowNode>()
278278
.tag(1)
279279
.props([] {
280-
auto sharedProps = std::make_shared<ViewShadowNodeProps>();
280+
auto sharedProps = std::make_shared<ViewProps>();
281281
sharedProps->pointerEvents = PointerEventsMode::BoxNone;
282282
return sharedProps;
283283
})
@@ -290,7 +290,7 @@ TEST(FindNodeAtPointTest, overlappingViewsWithParentPointerEventsBoxNone) {
290290
Element<ViewShadowNode>()
291291
.tag(2)
292292
.props([] {
293-
auto sharedProps = std::make_shared<ViewShadowNodeProps>();
293+
auto sharedProps = std::make_shared<ViewProps>();
294294
sharedProps->zIndex = 1;
295295
auto &yogaStyle = sharedProps->yogaStyle;
296296
yogaStyle.setPositionType(yoga::PositionType::Absolute);
@@ -326,7 +326,7 @@ TEST(FindNodeAtPointTest, overlappingViewsWithParentPointerEventsNone) {
326326
Element<ViewShadowNode>()
327327
.tag(1)
328328
.props([] {
329-
auto sharedProps = std::make_shared<ViewShadowNodeProps>();
329+
auto sharedProps = std::make_shared<ViewProps>();
330330
sharedProps->pointerEvents = PointerEventsMode::None;
331331
return sharedProps;
332332
})
@@ -339,7 +339,7 @@ TEST(FindNodeAtPointTest, overlappingViewsWithParentPointerEventsNone) {
339339
Element<ViewShadowNode>()
340340
.tag(2)
341341
.props([] {
342-
auto sharedProps = std::make_shared<ViewShadowNodeProps>();
342+
auto sharedProps = std::make_shared<ViewProps>();
343343
sharedProps->zIndex = 1;
344344
auto &yogaStyle = sharedProps->yogaStyle;
345345
yogaStyle.setPositionType(yoga::PositionType::Absolute);

0 commit comments

Comments
 (0)