Fabric: Removing `Scheduler::rootComponentDescriptor_`
Summary: This diff simplifies `ShadowTree` constructor by removing `rootComponentDescriptor` argument. It was previously stored and supplied by `Scheduler`; now `ShadowTree` class allocates one instance of it for all instances of `ShadowTree`. The `RootComponentDescriptor` instance of it is only needed to clone a `RootShadowNode` instance; it cannot issue events, state updates, or anything like that because it does not have React counterpart. Changelog: [Internal] Fabric-specific internal change. Reviewed By: JoshuaGross, sammy-SC Differential Revision: D26048466 fbshipit-source-id: ec02b1b4bcc917efe17cef58112fa870b341c85f
This commit is contained in:
Родитель
47cd7edf14
Коммит
9117840f1c
|
@ -222,22 +222,26 @@ ShadowTree::ShadowTree(
|
|||
SurfaceId surfaceId,
|
||||
LayoutConstraints const &layoutConstraints,
|
||||
LayoutContext const &layoutContext,
|
||||
RootComponentDescriptor const &rootComponentDescriptor,
|
||||
ShadowTreeDelegate const &delegate,
|
||||
std::weak_ptr<MountingOverrideDelegate const> mountingOverrideDelegate)
|
||||
: surfaceId_(surfaceId), delegate_(delegate) {
|
||||
const auto noopEventEmitter = std::make_shared<const ViewEventEmitter>(
|
||||
nullptr, -1, std::shared_ptr<const EventDispatcher>());
|
||||
|
||||
static auto globalRootComponentDescriptor =
|
||||
std::make_unique<RootComponentDescriptor const>(
|
||||
ComponentDescriptorParameters{
|
||||
EventDispatcher::Shared{}, nullptr, nullptr});
|
||||
|
||||
const auto props = std::make_shared<const RootProps>(
|
||||
*RootShadowNode::defaultSharedProps(), layoutConstraints, layoutContext);
|
||||
|
||||
auto const fragment =
|
||||
ShadowNodeFamilyFragment{surfaceId, surfaceId, noopEventEmitter};
|
||||
auto family = rootComponentDescriptor.createFamily(fragment, nullptr);
|
||||
auto family = globalRootComponentDescriptor->createFamily(fragment, nullptr);
|
||||
|
||||
auto rootShadowNode = std::static_pointer_cast<const RootShadowNode>(
|
||||
rootComponentDescriptor.createShadowNode(
|
||||
globalRootComponentDescriptor->createShadowNode(
|
||||
ShadowNodeFragment{
|
||||
/* .props = */ props,
|
||||
},
|
||||
|
|
|
@ -67,7 +67,6 @@ class ShadowTree final {
|
|||
SurfaceId surfaceId,
|
||||
LayoutConstraints const &layoutConstraints,
|
||||
LayoutContext const &layoutContext,
|
||||
RootComponentDescriptor const &rootComponentDescriptor,
|
||||
ShadowTreeDelegate const &delegate,
|
||||
std::weak_ptr<MountingOverrideDelegate const> mountingOverrideDelegate);
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include <gtest/gtest.h>
|
||||
|
||||
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
|
||||
#include <react/renderer/components/root/RootComponentDescriptor.h>
|
||||
#include <react/renderer/components/view/ViewComponentDescriptor.h>
|
||||
#include <react/renderer/element/ComponentBuilder.h>
|
||||
#include <react/renderer/element/Element.h>
|
||||
|
@ -95,14 +94,10 @@ TEST(StateReconciliationTest, testStateReconciliation) {
|
|||
auto &family = shadowNodeAB->getFamily();
|
||||
auto state1 = shadowNodeAB->getState();
|
||||
auto shadowTreeDelegate = DummyShadowTreeDelegate{};
|
||||
auto eventDispatcher = EventDispatcher::Shared{};
|
||||
auto rootComponentDescriptor =
|
||||
ComponentDescriptorParameters{eventDispatcher, nullptr, nullptr};
|
||||
ShadowTree shadowTree{
|
||||
SurfaceId{11},
|
||||
LayoutConstraints{},
|
||||
LayoutContext{},
|
||||
rootComponentDescriptor,
|
||||
shadowTreeDelegate,
|
||||
{}};
|
||||
|
||||
|
|
|
@ -76,9 +76,6 @@ Scheduler::Scheduler(
|
|||
componentDescriptorRegistry_ = schedulerToolbox.componentRegistryFactory(
|
||||
eventDispatcher, schedulerToolbox.contextContainer);
|
||||
|
||||
rootComponentDescriptor_ = std::make_unique<const RootComponentDescriptor>(
|
||||
ComponentDescriptorParameters{eventDispatcher, nullptr, nullptr});
|
||||
|
||||
uiManager->setBackgroundExecutor(schedulerToolbox.backgroundExecutor);
|
||||
uiManager->setDelegate(this);
|
||||
uiManager->setComponentDescriptorRegistry(componentDescriptorRegistry_);
|
||||
|
@ -188,7 +185,6 @@ void Scheduler::startSurface(
|
|||
surfaceId,
|
||||
layoutConstraints,
|
||||
layoutContext,
|
||||
*rootComponentDescriptor_,
|
||||
*uiManager_,
|
||||
mountingOverrideDelegate);
|
||||
|
||||
|
|
|
@ -123,7 +123,6 @@ class Scheduler final : public UIManagerDelegate {
|
|||
private:
|
||||
SchedulerDelegate *delegate_;
|
||||
SharedComponentDescriptorRegistry componentDescriptorRegistry_;
|
||||
std::unique_ptr<const RootComponentDescriptor> rootComponentDescriptor_;
|
||||
RuntimeExecutor runtimeExecutor_;
|
||||
std::shared_ptr<UIManager> uiManager_;
|
||||
std::shared_ptr<const ReactNativeConfig> reactNativeConfig_;
|
||||
|
|
Загрузка…
Ссылка в новой задаче