From 676676c95428ca92007160bf420eccc62ba41ea4 Mon Sep 17 00:00:00 2001 From: Phillip Pan Date: Wed, 16 Aug 2023 13:34:54 -0700 Subject: [PATCH] kill RCTFabricSurfaceHostingProxyRootView (#38864) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/38864 ## Changelog: [iOS][Breaking] - Deleting RCTFabricSurfaceHostingProxyRootView We currently have 3 different container view classes in new architecture: `RCTFabricSurfaceHostingProxyRootView`, `RCTSurfaceHostingProxyRootView`, and `RCTSurfaceHostingView`. it's a little complicated for the current use case, so there's an opportunity to simplify. in this PR, i get rid of `RCTFabricSurfaceHostingProxyRootView` by relying on the composable behavior of surface and host views instead of existing internal reflection logic that depends on inheritance. these are cleaned up in D48140101 and D48140317. i checked GH search and no one is really using this in a fundamental way. bypass-github-export-checks Reviewed By: cipolleschi Differential Revision: D48139820 fbshipit-source-id: 068b994a8b068a4107397f1862356b8fa1da961f --- .../Libraries/AppDelegate/RCTAppDelegate.mm | 1 - .../Libraries/AppDelegate/RCTAppSetupUtils.mm | 10 +++++---- .../RCTSurfaceHostingProxyRootView.h | 2 ++ .../RCTSurfaceHostingProxyRootView.mm | 9 ++++++++ .../RCTFabricSurfaceHostingProxyRootView.h | 15 ------------- .../RCTFabricSurfaceHostingProxyRootView.mm | 21 ------------------- 6 files changed, 17 insertions(+), 41 deletions(-) delete mode 100644 packages/react-native/React/Fabric/Surface/RCTFabricSurfaceHostingProxyRootView.h delete mode 100644 packages/react-native/React/Fabric/Surface/RCTFabricSurfaceHostingProxyRootView.mm diff --git a/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm b/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm index eeb4a8022f0..12f59473293 100644 --- a/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm +++ b/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm @@ -17,7 +17,6 @@ #import #import #import -#import #import #import #import diff --git a/packages/react-native/Libraries/AppDelegate/RCTAppSetupUtils.mm b/packages/react-native/Libraries/AppDelegate/RCTAppSetupUtils.mm index f5c51079420..5b90e3618bd 100644 --- a/packages/react-native/Libraries/AppDelegate/RCTAppSetupUtils.mm +++ b/packages/react-native/Libraries/AppDelegate/RCTAppSetupUtils.mm @@ -20,7 +20,8 @@ #import // Fabric -#import +#import +#import #import #import #endif @@ -68,9 +69,10 @@ RCTAppSetupDefaultRootView(RCTBridge *bridge, NSString *moduleName, NSDictionary { #if RCT_NEW_ARCH_ENABLED if (fabricEnabled) { - return [[RCTFabricSurfaceHostingProxyRootView alloc] initWithBridge:bridge - moduleName:moduleName - initialProperties:initialProperties]; + id surface = [[RCTFabricSurface alloc] initWithBridge:bridge + moduleName:moduleName + initialProperties:initialProperties]; + return [[RCTSurfaceHostingProxyRootView alloc] initWithSurface:surface]; } #endif return [[RCTRootView alloc] initWithBridge:bridge moduleName:moduleName initialProperties:initialProperties]; diff --git a/packages/react-native/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.h b/packages/react-native/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.h index bb5a574e2ee..f36af0ee7b3 100644 --- a/packages/react-native/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.h +++ b/packages/react-native/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.h @@ -58,6 +58,8 @@ NS_ASSUME_NONNULL_BEGIN sizeMeasureMode:(RCTSurfaceSizeMeasureMode)sizeMeasureMode moduleRegistry:(RCTModuleRegistry *)moduleRegistry; +- (instancetype)initWithSurface:(id)surface; + - (void)cancelTouches; @end diff --git a/packages/react-native/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.mm b/packages/react-native/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.mm index 91ead4e7492..a7c67cffcc6 100644 --- a/packages/react-native/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.mm +++ b/packages/react-native/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.mm @@ -104,6 +104,15 @@ static RCTRootViewSizeFlexibility convertToRootViewSizeFlexibility(RCTSurfaceSiz return self; } +- (instancetype)initWithSurface:(id)surface +{ + if (self = [super initWithSurface:surface + sizeMeasureMode:RCTSurfaceSizeMeasureModeWidthExact | RCTSurfaceSizeMeasureModeHeightExact]) { + [surface start]; + } + return self; +} + - (BOOL)hasBridge { return _bridge != nil; diff --git a/packages/react-native/React/Fabric/Surface/RCTFabricSurfaceHostingProxyRootView.h b/packages/react-native/React/Fabric/Surface/RCTFabricSurfaceHostingProxyRootView.h deleted file mode 100644 index c50144a8ee4..00000000000 --- a/packages/react-native/React/Fabric/Surface/RCTFabricSurfaceHostingProxyRootView.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#import - -/** - * Fabric-compatible RCTSurfaceHostingProxyRootView implementation. - */ -@interface RCTFabricSurfaceHostingProxyRootView : RCTSurfaceHostingProxyRootView - -@end diff --git a/packages/react-native/React/Fabric/Surface/RCTFabricSurfaceHostingProxyRootView.mm b/packages/react-native/React/Fabric/Surface/RCTFabricSurfaceHostingProxyRootView.mm deleted file mode 100644 index 5c399d8a33f..00000000000 --- a/packages/react-native/React/Fabric/Surface/RCTFabricSurfaceHostingProxyRootView.mm +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#import "RCTFabricSurfaceHostingProxyRootView.h" - -#import "RCTFabricSurface.h" - -@implementation RCTFabricSurfaceHostingProxyRootView - -+ (id)createSurfaceWithBridge:(RCTBridge *)bridge - moduleName:(NSString *)moduleName - initialProperties:(NSDictionary *)initialProperties -{ - return [[RCTFabricSurface alloc] initWithBridge:bridge moduleName:moduleName initialProperties:initialProperties]; -} - -@end