From ce13860281f833de8a3296b7a3dad9caced102e9 Mon Sep 17 00:00:00 2001 From: Andrew Clark Date: Thu, 28 Apr 2022 15:05:41 -0400 Subject: [PATCH] Remove enablePersistentOffscreenHostContainer flag (#24460) This was a Fabric-related experiment that we ended up not shipping. --- .../src/ReactFabricHostConfig.js | 32 ---- .../src/createReactNoop.js | 179 +----------------- .../react-reconciler/src/ReactFiber.new.js | 25 +-- .../react-reconciler/src/ReactFiber.old.js | 25 +-- .../src/ReactFiberBeginWork.new.js | 109 +---------- .../src/ReactFiberBeginWork.old.js | 109 +---------- .../src/ReactFiberCompleteWork.new.js | 72 +------ .../src/ReactFiberCompleteWork.old.js | 72 +------ .../ReactFiberHostConfigWithNoPersistence.js | 2 - .../src/ReactFiberThrow.new.js | 25 --- .../src/ReactFiberThrow.old.js | 25 --- .../src/forks/ReactFiberHostConfig.custom.js | 4 - packages/shared/ReactFeatureFlags.js | 1 - .../ReactFeatureFlags.native-fb-dynamic.js | 18 +- .../forks/ReactFeatureFlags.native-fb.js | 5 +- .../forks/ReactFeatureFlags.native-oss.js | 1 - .../forks/ReactFeatureFlags.test-renderer.js | 1 - .../ReactFeatureFlags.test-renderer.native.js | 1 - .../ReactFeatureFlags.test-renderer.www.js | 1 - .../shared/forks/ReactFeatureFlags.testing.js | 1 - .../forks/ReactFeatureFlags.testing.www.js | 1 - .../forks/ReactFeatureFlags.www-dynamic.js | 1 - .../shared/forks/ReactFeatureFlags.www.js | 2 - scripts/flow/xplat.js | 1 - 24 files changed, 25 insertions(+), 688 deletions(-) diff --git a/packages/react-native-renderer/src/ReactFabricHostConfig.js b/packages/react-native-renderer/src/ReactFabricHostConfig.js index 81295f6e50f6..515c4e0f9665 100644 --- a/packages/react-native-renderer/src/ReactFabricHostConfig.js +++ b/packages/react-native-renderer/src/ReactFabricHostConfig.js @@ -7,7 +7,6 @@ * @flow */ -import type {ReactNodeList, OffscreenMode} from 'shared/ReactTypes'; import type {ElementRef} from 'react'; import type { HostComponent, @@ -545,37 +544,6 @@ export function cloneInstance( }; } -// TODO: These two methods should be replaced with `createOffscreenInstance` and -// `cloneOffscreenInstance`. I did it this way for now because the offscreen -// instance is stored on an extra HostComponent fiber instead of the -// OffscreenComponent fiber, and I didn't want to add an extra check to the -// generic HostComponent path. Instead we should use the OffscreenComponent -// fiber, but currently Fabric expects a 1:1 correspondence between Fabric -// instances and host fibers, so I'm leaving this optimization for later once -// we can confirm this won't break any downstream expectations. -export function getOffscreenContainerType(): string { - return 'RCTView'; -} - -export function getOffscreenContainerProps( - mode: OffscreenMode, - children: ReactNodeList, -): Props { - if (mode === 'hidden') { - return { - children, - style: {display: 'none'}, - }; - } else { - return { - children, - style: { - flex: 1, - }, - }; - } -} - export function cloneHiddenInstance( instance: Instance, type: string, diff --git a/packages/react-noop-renderer/src/createReactNoop.js b/packages/react-noop-renderer/src/createReactNoop.js index 8e4050dcfa33..13a0f49105c2 100644 --- a/packages/react-noop-renderer/src/createReactNoop.js +++ b/packages/react-noop-renderer/src/createReactNoop.js @@ -19,7 +19,7 @@ import type { TransitionTracingCallbacks, } from 'react-reconciler/src/ReactInternalTypes'; import type {UpdateQueue} from 'react-reconciler/src/ReactUpdateQueue'; -import type {ReactNodeList, OffscreenMode} from 'shared/ReactTypes'; +import type {ReactNodeList} from 'shared/ReactTypes'; import type {RootTag} from 'react-reconciler/src/ReactRootTags'; import * as Scheduler from 'scheduler/unstable_mock'; @@ -595,20 +595,6 @@ function createReactNoop(reconciler: Function, useMutation: boolean) { container.children = newChildren; }, - getOffscreenContainerType(): string { - return 'offscreen'; - }, - - getOffscreenContainerProps( - mode: OffscreenMode, - children: ReactNodeList, - ): Props { - return { - hidden: mode === 'hidden', - children, - }; - }, - cloneHiddenInstance( instance: Instance, type: string, @@ -721,9 +707,7 @@ function createReactNoop(reconciler: Function, useMutation: boolean) { function getChildren(root) { if (root) { - return useMutation - ? root.children - : removeOffscreenContainersFromChildren(root.children, false); + return root.children; } else { return null; } @@ -731,169 +715,12 @@ function createReactNoop(reconciler: Function, useMutation: boolean) { function getPendingChildren(root) { if (root) { - return useMutation - ? root.children - : removeOffscreenContainersFromChildren(root.pendingChildren, false); + return root.children; } else { return null; } } - function removeOffscreenContainersFromChildren(children, hideNearestNode) { - // Mutation mode and persistent mode have different outputs for Offscreen - // and Suspense trees. Persistent mode adds an additional host node wrapper, - // whereas mutation mode does not. - // - // This function removes the offscreen host wrappers so that the output is - // consistent. If the offscreen node is hidden, it transfers the hiddenness - // to the child nodes, to mimic how it works in mutation mode. That way our - // tests don't have to fork tree assertions. - // - // So, it takes a tree that looks like this: - // - //