Skip to content

Commit

Permalink
Fabric: Sharing a pointer to ShadowTreeRegister with UIManager
Browse files Browse the repository at this point in the history
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
  • Loading branch information
shergin authored and facebook-github-bot committed Nov 22, 2018
1 parent b4fa1fa commit f8be867
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions ReactCommon/fabric/uimanager/Scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Scheduler::Scheduler(const SharedContextContainer &contextContainer)
eventDispatcher, contextContainer);

uiManagerRef.setDelegate(this);
uiManagerRef.setShadowTreeRegistry(&shadowTreeRegistry_);
uiManagerRef.setComponentDescriptorRegistry(componentDescriptorRegistry_);

runtimeExecutor_([=](jsi::Runtime &runtime) {
Expand Down
4 changes: 4 additions & 0 deletions ReactCommon/fabric/uimanager/UIManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ void UIManager::completeSurface(
}
}

void UIManager::setShadowTreeRegistry(ShadowTreeRegistry *shadowTreeRegistry) {
shadowTreeRegistry_ = shadowTreeRegistry;
}

void UIManager::setComponentDescriptorRegistry(
const SharedComponentDescriptorRegistry &componentDescriptorRegistry) {
componentDescriptorRegistry_ = componentDescriptorRegistry;
Expand Down
4 changes: 4 additions & 0 deletions ReactCommon/fabric/uimanager/UIManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@

#include <react/core/ShadowNode.h>
#include <react/uimanager/ComponentDescriptorRegistry.h>
#include <react/uimanager/ShadowTreeRegistry.h>
#include <react/uimanager/UIManagerDelegate.h>

namespace facebook {
namespace react {

class UIManager {
public:
void setShadowTreeRegistry(ShadowTreeRegistry *shadowTreeRegistry);

void setComponentDescriptorRegistry(
const SharedComponentDescriptorRegistry &componentDescriptorRegistry);

Expand Down Expand Up @@ -49,6 +52,7 @@ class UIManager {
SurfaceId surfaceId,
const SharedShadowNodeUnsharedList &rootChildren) const;

ShadowTreeRegistry *shadowTreeRegistry_;
SharedComponentDescriptorRegistry componentDescriptorRegistry_;
UIManagerDelegate *delegate_;
};
Expand Down
1 change: 1 addition & 0 deletions ReactCommon/fabric/uimanager/UIManagerBinding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ void UIManagerBinding::dispatchEvent(
}

void UIManagerBinding::invalidate() const {
uiManager_->setShadowTreeRegistry(nullptr);
uiManager_->setDelegate(nullptr);
}

Expand Down

0 comments on commit f8be867

Please sign in to comment.