Valentin Shergin 9842e39019 Fabric: folly::dynamic was replaced with RawValue in prop-parsing infra
Summary:
Our long-term plan is to completely illuminate `jsi::Value`-to-`folly::dynamic` serialization step in prop parsing process improving performance and memory pressure. At the same time, we don't want to introduce a hard dependency in application code to JSI because it exposes direct access to VM and prevents parsing some data that come *NOT* from JSVM.
RawValue is an extremely light-weight (hopefully fully optimized-out) abstraction that provides limited JSON-like and C++-idiomatic interface.

The current particular implementation is still using `folly::dynamic` inside, but I have fully JSI-powered one which will replace the current one right after we figure out how to deal with folly::dynamic-specific callsites. Or we can implement RawValue in a hybrid manner if a code-size implication of that will be minimal.

Reviewed By: JoshuaGross, mdvacca

Differential Revision: D13962466

fbshipit-source-id: e848522fd242f21e9e771773f2103f1c1d9d7f21
2019-02-06 16:34:46 -08:00

75 lines
2.0 KiB
C++

// Copyright 2004-present Facebook. All Rights Reserved.
#pragma once
#include <folly/Optional.h>
#include <folly/dynamic.h>
#include <jsi/jsi.h>
#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);
/*
* Sets and gets the UIManager's delegate.
* The delegate is stored as a raw pointer, so the owner must null
* the pointer before being destroyed.
*/
void setDelegate(UIManagerDelegate *delegate);
UIManagerDelegate *getDelegate();
private:
friend class UIManagerBinding;
SharedShadowNode createNode(
Tag tag,
const std::string &name,
SurfaceId surfaceId,
const RawProps &props,
SharedEventTarget eventTarget) const;
SharedShadowNode cloneNode(
const SharedShadowNode &shadowNode,
const SharedShadowNodeSharedList &children = nullptr,
const RawProps *rawProps = nullptr) const;
void appendChild(
const SharedShadowNode &parentShadowNode,
const SharedShadowNode &childShadowNode) const;
void completeSurface(
SurfaceId surfaceId,
const SharedShadowNodeUnsharedList &rootChildren) const;
void setNativeProps(
const SharedShadowNode &shadowNode,
const RawProps &rawProps) const;
/*
* Returns layout metrics of given `shadowNode` relative to
* `ancestorShadowNode` (relative to the root node in case if provided
* `ancestorShadowNode` is nullptr).
*/
LayoutMetrics getRelativeLayoutMetrics(
const ShadowNode &shadowNode,
const ShadowNode *ancestorShadowNode) const;
ShadowTreeRegistry *shadowTreeRegistry_;
SharedComponentDescriptorRegistry componentDescriptorRegistry_;
UIManagerDelegate *delegate_;
};
} // namespace react
} // namespace facebook