// Copyright 2004-present Facebook. All Rights Reserved. #include "UIManager.h" #include #include namespace facebook { namespace react { SharedShadowNode UIManager::createNode( Tag tag, const ComponentName &name, SurfaceId surfaceId, const RawProps &rawProps, SharedEventTarget eventTarget) const { auto &componentDescriptor = componentDescriptorRegistry_->at(name); auto shadowNode = componentDescriptor.createShadowNode( {.tag = tag, .rootTag = surfaceId, .eventEmitter = componentDescriptor.createEventEmitter(std::move(eventTarget), tag), .props = componentDescriptor.cloneProps(nullptr, rawProps)}); if (delegate_) { delegate_->uiManagerDidCreateShadowNode(shadowNode); } return std::const_pointer_cast(shadowNode); } SharedShadowNode UIManager::cloneNode( const SharedShadowNode &shadowNode, const SharedShadowNodeSharedList &children, const folly::Optional &rawProps) const { auto &componentDescriptor = componentDescriptorRegistry_->at(shadowNode->getComponentHandle()); auto clonedShadowNode = componentDescriptor.cloneShadowNode( *shadowNode, { .props = rawProps.has_value() ? componentDescriptor.cloneProps( shadowNode->getProps(), rawProps.value()) : ShadowNodeFragment::nullSharedProps(), .children = children, }); return std::const_pointer_cast(clonedShadowNode); } void UIManager::appendChild( const SharedShadowNode &parentShadowNode, const SharedShadowNode &childShadowNode) const { auto &componentDescriptor = componentDescriptorRegistry_->at(parentShadowNode->getComponentHandle()); componentDescriptor.appendChild(parentShadowNode, childShadowNode); } void UIManager::completeSurface( SurfaceId surfaceId, const SharedShadowNodeUnsharedList &rootChildren) const { SystraceSection s("FabricUIManager::completeSurface"); if (delegate_) { delegate_->uiManagerDidFinishTransaction(surfaceId, rootChildren); } } void UIManager::setComponentDescriptorRegistry( const SharedComponentDescriptorRegistry &componentDescriptorRegistry) { componentDescriptorRegistry_ = componentDescriptorRegistry; } void UIManager::setDelegate(UIManagerDelegate *delegate) { delegate_ = delegate; } UIManagerDelegate *UIManager::getDelegate() { return delegate_; } } // namespace react } // namespace facebook