From f8be867cd81bac32f8cff8a52a534a7a77d2263e Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Wed, 21 Nov 2018 17:10:31 -0800 Subject: [PATCH] Fabric: Sharing a pointer to ShadowTreeRegister with UIManager Summary: The diff adds a pointer to ShadowTreeRegistry to UIManager which enables the possibility of implementing ShadowTree mutating and inspecting methods like `setNativeProps` and `getRelativeLayoutMetrics`. Reviewed By: mdvacca Differential Revision: D13036549 fbshipit-source-id: 5ed1252d84c8dd895fe0e6e8cc71afbaa9dab4b7 --- ReactCommon/fabric/uimanager/Scheduler.cpp | 1 + ReactCommon/fabric/uimanager/UIManager.cpp | 4 ++++ ReactCommon/fabric/uimanager/UIManager.h | 4 ++++ ReactCommon/fabric/uimanager/UIManagerBinding.cpp | 1 + 4 files changed, 10 insertions(+) diff --git a/ReactCommon/fabric/uimanager/Scheduler.cpp b/ReactCommon/fabric/uimanager/Scheduler.cpp index a06fffccaa70e4..478f52def840fc 100644 --- a/ReactCommon/fabric/uimanager/Scheduler.cpp +++ b/ReactCommon/fabric/uimanager/Scheduler.cpp @@ -49,6 +49,7 @@ Scheduler::Scheduler(const SharedContextContainer &contextContainer) eventDispatcher, contextContainer); uiManagerRef.setDelegate(this); + uiManagerRef.setShadowTreeRegistry(&shadowTreeRegistry_); uiManagerRef.setComponentDescriptorRegistry(componentDescriptorRegistry_); runtimeExecutor_([=](jsi::Runtime &runtime) { diff --git a/ReactCommon/fabric/uimanager/UIManager.cpp b/ReactCommon/fabric/uimanager/UIManager.cpp index 881362cb283e6b..d56649f069f57e 100644 --- a/ReactCommon/fabric/uimanager/UIManager.cpp +++ b/ReactCommon/fabric/uimanager/UIManager.cpp @@ -67,6 +67,10 @@ void UIManager::completeSurface( } } +void UIManager::setShadowTreeRegistry(ShadowTreeRegistry *shadowTreeRegistry) { + shadowTreeRegistry_ = shadowTreeRegistry; +} + void UIManager::setComponentDescriptorRegistry( const SharedComponentDescriptorRegistry &componentDescriptorRegistry) { componentDescriptorRegistry_ = componentDescriptorRegistry; diff --git a/ReactCommon/fabric/uimanager/UIManager.h b/ReactCommon/fabric/uimanager/UIManager.h index f7431c9ad3df40..b16cff07d10644 100644 --- a/ReactCommon/fabric/uimanager/UIManager.h +++ b/ReactCommon/fabric/uimanager/UIManager.h @@ -8,6 +8,7 @@ #include #include +#include #include namespace facebook { @@ -15,6 +16,8 @@ namespace react { class UIManager { public: + void setShadowTreeRegistry(ShadowTreeRegistry *shadowTreeRegistry); + void setComponentDescriptorRegistry( const SharedComponentDescriptorRegistry &componentDescriptorRegistry); @@ -49,6 +52,7 @@ class UIManager { SurfaceId surfaceId, const SharedShadowNodeUnsharedList &rootChildren) const; + ShadowTreeRegistry *shadowTreeRegistry_; SharedComponentDescriptorRegistry componentDescriptorRegistry_; UIManagerDelegate *delegate_; }; diff --git a/ReactCommon/fabric/uimanager/UIManagerBinding.cpp b/ReactCommon/fabric/uimanager/UIManagerBinding.cpp index 05341d3d7c9456..6c460e973391e4 100644 --- a/ReactCommon/fabric/uimanager/UIManagerBinding.cpp +++ b/ReactCommon/fabric/uimanager/UIManagerBinding.cpp @@ -90,6 +90,7 @@ void UIManagerBinding::dispatchEvent( } void UIManagerBinding::invalidate() const { + uiManager_->setShadowTreeRegistry(nullptr); uiManager_->setDelegate(nullptr); }