Fabric: Remove tag from ShadowNodeFragment
Summary: As part of the plan is splitting `ShadowNodeFragment` into two parts. `ShadowNodeFamilyFragment` is already in place. This diff removes use of `ShadowNodeFragment::tag` and goes over all call sites to change it to `ShadowNodeFamilyFragment::tag`. Changelog: [Internal] Reviewed By: shergin Differential Revision: D19115781 fbshipit-source-id: 6ab3464a063c220d0924bf5a69b75449ca178650
This commit is contained in:
Родитель
90874d974f
Коммит
f9c5bf8bee
|
@ -41,7 +41,6 @@ RootShadowNode::Unshared RootShadowNode::clone(
|
|||
auto newRootShadowNode = std::make_shared<RootShadowNode>(
|
||||
*this,
|
||||
ShadowNodeFragment{
|
||||
/* .tag = */ ShadowNodeFragment::tagPlaceholder(),
|
||||
/* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(),
|
||||
/* .props = */ props,
|
||||
});
|
||||
|
@ -75,7 +74,6 @@ RootShadowNode::Unshared RootShadowNode::clone(
|
|||
children[childIndex] = childNode;
|
||||
|
||||
childNode = parentNode.clone({
|
||||
ShadowNodeFragment::tagPlaceholder(),
|
||||
ShadowNodeFragment::surfaceIdPlaceholder(),
|
||||
ShadowNodeFragment::propsPlaceholder(),
|
||||
ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
|
|
|
@ -78,7 +78,8 @@ class ComponentDescriptor {
|
|||
* Creates a new `ShadowNode` of a particular component type.
|
||||
*/
|
||||
virtual SharedShadowNode createShadowNode(
|
||||
const ShadowNodeFragment &fragment) const = 0;
|
||||
const ShadowNodeFragment &fragment,
|
||||
ShadowNodeFamilyFragment const &familyFragment) const = 0;
|
||||
|
||||
/*
|
||||
* Clones a `ShadowNode` with optionally new `props` and/or `children`.
|
||||
|
|
|
@ -66,15 +66,13 @@ class ConcreteComponentDescriptor : public ComponentDescriptor {
|
|||
}
|
||||
|
||||
SharedShadowNode createShadowNode(
|
||||
const ShadowNodeFragment &fragment) const override {
|
||||
const ShadowNodeFragment &fragment,
|
||||
ShadowNodeFamilyFragment const &familyFragment) const override {
|
||||
assert(std::dynamic_pointer_cast<const ConcreteProps>(fragment.props));
|
||||
assert(std::dynamic_pointer_cast<const ConcreteEventEmitter>(
|
||||
fragment.eventEmitter));
|
||||
|
||||
auto family = std::make_shared<ShadowNodeFamily const>(
|
||||
ShadowNodeFamilyFragment{
|
||||
fragment.tag, fragment.surfaceId, fragment.eventEmitter},
|
||||
*this);
|
||||
auto family = std::make_shared<ShadowNodeFamily>(familyFragment, *this);
|
||||
|
||||
auto shadowNode =
|
||||
std::make_shared<ShadowNodeT>(fragment, family, getTraits());
|
||||
|
|
|
@ -74,8 +74,7 @@ ShadowNode::ShadowNode(
|
|||
: sourceShadowNode.getMostRecentState()),
|
||||
family_(sourceShadowNode.family_),
|
||||
traits_(sourceShadowNode.traits_) {
|
||||
// `tag`, `surfaceId`, and `eventEmitter` cannot be changed with cloning.
|
||||
assert(fragment.tag == ShadowNodeFragment::tagPlaceholder());
|
||||
// `surfaceId`, and `eventEmitter` cannot be changed with cloning.
|
||||
assert(fragment.surfaceId == ShadowNodeFragment::surfaceIdPlaceholder());
|
||||
assert(
|
||||
fragment.eventEmitter == ShadowNodeFragment::eventEmitterPlaceholder());
|
||||
|
|
|
@ -10,10 +10,6 @@
|
|||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
Tag const ShadowNodeFragment::tagPlaceholder() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
SurfaceId const ShadowNodeFragment::surfaceIdPlaceholder() {
|
||||
return 0;
|
||||
}
|
||||
|
@ -47,8 +43,7 @@ State::Shared const &ShadowNodeFragment::statePlaceholder() {
|
|||
using Value = ShadowNodeFragment::Value;
|
||||
|
||||
Value::Value(ShadowNodeFragment const &fragment)
|
||||
: tag_(fragment.tag),
|
||||
surfaceId_(fragment.surfaceId),
|
||||
: surfaceId_(fragment.surfaceId),
|
||||
props_(fragment.props),
|
||||
eventEmitter_(fragment.eventEmitter),
|
||||
children_(fragment.children),
|
||||
|
@ -57,7 +52,7 @@ Value::Value(ShadowNodeFragment const &fragment)
|
|||
|
||||
Value::operator ShadowNodeFragment() const {
|
||||
return ShadowNodeFragment{
|
||||
tag_, surfaceId_, props_, eventEmitter_, children_, localData_, state_};
|
||||
surfaceId_, props_, eventEmitter_, children_, localData_, state_};
|
||||
}
|
||||
|
||||
} // namespace react
|
||||
|
|
|
@ -27,7 +27,6 @@ namespace react {
|
|||
* fragment content to store or pass the data asynchronously.
|
||||
*/
|
||||
struct ShadowNodeFragment {
|
||||
Tag const tag = tagPlaceholder();
|
||||
SurfaceId const surfaceId = surfaceIdPlaceholder();
|
||||
Props::Shared const &props = propsPlaceholder();
|
||||
EventEmitter::Shared const &eventEmitter = eventEmitterPlaceholder();
|
||||
|
@ -40,7 +39,6 @@ struct ShadowNodeFragment {
|
|||
* Use as default arguments as an indication that the field does not need to
|
||||
* be changed.
|
||||
*/
|
||||
static Tag const tagPlaceholder();
|
||||
static SurfaceId const surfaceIdPlaceholder();
|
||||
static Props::Shared const &propsPlaceholder();
|
||||
static EventEmitter::Shared const &eventEmitterPlaceholder();
|
||||
|
@ -66,7 +64,6 @@ struct ShadowNodeFragment {
|
|||
explicit operator ShadowNodeFragment() const;
|
||||
|
||||
private:
|
||||
Tag const tag_;
|
||||
SurfaceId const surfaceId_;
|
||||
Props::Shared const props_;
|
||||
EventEmitter::Shared const eventEmitter_;
|
||||
|
|
|
@ -22,12 +22,18 @@ TEST(ComponentDescriptorTest, createShadowNode) {
|
|||
|
||||
const auto &raw = RawProps(folly::dynamic::object("nativeID", "abc"));
|
||||
SharedProps props = descriptor->cloneProps(nullptr, raw);
|
||||
SharedShadowNode node = descriptor->createShadowNode(ShadowNodeFragment{
|
||||
/* .tag = */ 9,
|
||||
/* .surfaceId = */ 1,
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ descriptor->createEventEmitter(0, 9),
|
||||
});
|
||||
|
||||
SharedShadowNode node = descriptor->createShadowNode(
|
||||
ShadowNodeFragment{
|
||||
/* .surfaceId = */ 1,
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ descriptor->createEventEmitter(0, 9),
|
||||
},
|
||||
ShadowNodeFamilyFragment{
|
||||
/* .tag = */ 9,
|
||||
/* .surfaceId = */ 1,
|
||||
/* .eventEmitter = */ descriptor->createEventEmitter(0, 9),
|
||||
});
|
||||
|
||||
ASSERT_EQ(node->getComponentHandle(), TestShadowNode::Handle());
|
||||
ASSERT_STREQ(node->getComponentName(), TestShadowNode::Name());
|
||||
|
@ -44,12 +50,17 @@ TEST(ComponentDescriptorTest, cloneShadowNode) {
|
|||
|
||||
const auto &raw = RawProps(folly::dynamic::object("nativeID", "abc"));
|
||||
SharedProps props = descriptor->cloneProps(nullptr, raw);
|
||||
SharedShadowNode node = descriptor->createShadowNode(ShadowNodeFragment{
|
||||
/* .tag = */ 9,
|
||||
/* .surfaceId = */ 1,
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ descriptor->createEventEmitter(0, 9),
|
||||
});
|
||||
SharedShadowNode node = descriptor->createShadowNode(
|
||||
ShadowNodeFragment{
|
||||
/* .surfaceId = */ 1,
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ descriptor->createEventEmitter(0, 9),
|
||||
},
|
||||
ShadowNodeFamilyFragment{
|
||||
/* .tag = */ 9,
|
||||
/* .surfaceId = */ 1,
|
||||
/* .eventEmitter = */ descriptor->createEventEmitter(0, 9),
|
||||
});
|
||||
SharedShadowNode cloned = descriptor->cloneShadowNode(*node, {});
|
||||
|
||||
ASSERT_STREQ(cloned->getComponentName(), "Test");
|
||||
|
@ -65,24 +76,40 @@ TEST(ComponentDescriptorTest, appendChild) {
|
|||
|
||||
const auto &raw = RawProps(folly::dynamic::object("nativeID", "abc"));
|
||||
SharedProps props = descriptor->cloneProps(nullptr, raw);
|
||||
SharedShadowNode node1 = descriptor->createShadowNode(ShadowNodeFragment{
|
||||
/* .tag = */ 1,
|
||||
/* .surfaceId = */ 1,
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ descriptor->createEventEmitter(0, 1),
|
||||
});
|
||||
SharedShadowNode node2 = descriptor->createShadowNode(ShadowNodeFragment{
|
||||
/* .tag = */ 2,
|
||||
/* .surfaceId = */ 1,
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ descriptor->createEventEmitter(0, 2),
|
||||
});
|
||||
SharedShadowNode node3 = descriptor->createShadowNode(ShadowNodeFragment{
|
||||
/* .tag = */ 3,
|
||||
/* .surfaceId = */ 1,
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ descriptor->createEventEmitter(0, 3),
|
||||
});
|
||||
|
||||
SharedShadowNode node1 = descriptor->createShadowNode(
|
||||
ShadowNodeFragment{
|
||||
/* .surfaceId = */ 1,
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ descriptor->createEventEmitter(0, 1),
|
||||
},
|
||||
ShadowNodeFamilyFragment{
|
||||
/* .tag = */ 1,
|
||||
/* .surfaceId = */ 1,
|
||||
/* .eventEmitter = */ descriptor->createEventEmitter(0, 9),
|
||||
});
|
||||
SharedShadowNode node2 = descriptor->createShadowNode(
|
||||
ShadowNodeFragment{
|
||||
/* .surfaceId = */ 1,
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ descriptor->createEventEmitter(0, 2),
|
||||
},
|
||||
ShadowNodeFamilyFragment{
|
||||
/* .tag = */ 2,
|
||||
/* .surfaceId = */ 1,
|
||||
/* .eventEmitter = */ descriptor->createEventEmitter(0, 9),
|
||||
});
|
||||
SharedShadowNode node3 = descriptor->createShadowNode(
|
||||
ShadowNodeFragment{
|
||||
/* .surfaceId = */ 1,
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ descriptor->createEventEmitter(0, 3),
|
||||
},
|
||||
ShadowNodeFamilyFragment{
|
||||
/* .tag = */ 3,
|
||||
/* .surfaceId = */ 1,
|
||||
/* .eventEmitter = */ descriptor->createEventEmitter(0, 9),
|
||||
});
|
||||
|
||||
descriptor->appendChild(node1, node2);
|
||||
descriptor->appendChild(node1, node3);
|
||||
|
|
|
@ -27,7 +27,6 @@ TEST(ShadowNodeTest, handleShadowNodeCreation) {
|
|||
componentDescriptor);
|
||||
auto node = std::make_shared<TestShadowNode>(
|
||||
ShadowNodeFragment{
|
||||
/* .tag = */ 9,
|
||||
/* .surfaceId = */ 1,
|
||||
/* .props = */ std::make_shared<const TestProps>(),
|
||||
/* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
|
@ -60,7 +59,6 @@ TEST(ShadowNodeTest, handleShadowNodeSimpleCloning) {
|
|||
componentDescriptor);
|
||||
auto node = std::make_shared<TestShadowNode>(
|
||||
ShadowNodeFragment{
|
||||
/* .tag = */ 9,
|
||||
/* .surfaceId = */ 1,
|
||||
/* .props = */ std::make_shared<const TestProps>(),
|
||||
/* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
|
@ -89,7 +87,6 @@ TEST(ShadowNodeTest, handleShadowNodeMutation) {
|
|||
auto props = std::make_shared<const TestProps>();
|
||||
auto node1 = std::make_shared<TestShadowNode>(
|
||||
ShadowNodeFragment{
|
||||
/* .tag = */ 1,
|
||||
/* .surfaceId = */ 1,
|
||||
/* .props = */ std::make_shared<const TestProps>(),
|
||||
/* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
|
@ -106,7 +103,6 @@ TEST(ShadowNodeTest, handleShadowNodeMutation) {
|
|||
componentDescriptor);
|
||||
auto node2 = std::make_shared<TestShadowNode>(
|
||||
ShadowNodeFragment{
|
||||
/* .tag = */ 2,
|
||||
/* .surfaceId = */ 1,
|
||||
/* .props = */ std::make_shared<const TestProps>(),
|
||||
/* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
|
@ -123,7 +119,6 @@ TEST(ShadowNodeTest, handleShadowNodeMutation) {
|
|||
componentDescriptor);
|
||||
auto node3 = std::make_shared<TestShadowNode>(
|
||||
ShadowNodeFragment{
|
||||
/* .tag = */ 3,
|
||||
/* .surfaceId = */ 1,
|
||||
/* .props = */ std::make_shared<const TestProps>(),
|
||||
/* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
|
@ -173,7 +168,6 @@ TEST(ShadowNodeTest, handleCloneFunction) {
|
|||
|
||||
auto firstNode = std::make_shared<TestShadowNode>(
|
||||
ShadowNodeFragment{
|
||||
/* .tag = */ 9,
|
||||
/* .surfaceId = */ 1,
|
||||
/* .props = */ std::make_shared<const TestProps>(),
|
||||
/* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
|
@ -218,7 +212,6 @@ TEST(ShadowNodeTest, handleLocalData) {
|
|||
auto props = std::make_shared<const TestProps>();
|
||||
auto firstNode = std::make_shared<TestShadowNode>(
|
||||
ShadowNodeFragment{
|
||||
/* .tag = */ 9,
|
||||
/* .surfaceId = */ 1,
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
|
@ -228,7 +221,6 @@ TEST(ShadowNodeTest, handleLocalData) {
|
|||
ShadowNodeTraits{});
|
||||
auto secondNode = std::make_shared<TestShadowNode>(
|
||||
ShadowNodeFragment{
|
||||
/* .tag = */ 9,
|
||||
/* .surfaceId = */ 1,
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
|
@ -238,7 +230,6 @@ TEST(ShadowNodeTest, handleLocalData) {
|
|||
ShadowNodeTraits{});
|
||||
auto thirdNode = std::make_shared<TestShadowNode>(
|
||||
ShadowNodeFragment{
|
||||
/* .tag = */ 9,
|
||||
/* .surfaceId = */ 1,
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
|
@ -289,7 +280,6 @@ TEST(ShadowNodeTest, handleBacktracking) {
|
|||
componentDescriptor);
|
||||
auto nodeAA = std::make_shared<TestShadowNode>(
|
||||
ShadowNodeFragment{
|
||||
/* .tag = */ ShadowNodeFragment::tagPlaceholder(),
|
||||
/* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(),
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
|
@ -307,7 +297,6 @@ TEST(ShadowNodeTest, handleBacktracking) {
|
|||
componentDescriptor);
|
||||
auto nodeABA = std::make_shared<TestShadowNode>(
|
||||
ShadowNodeFragment{
|
||||
/* .tag = */ ShadowNodeFragment::tagPlaceholder(),
|
||||
/* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(),
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
|
@ -325,7 +314,6 @@ TEST(ShadowNodeTest, handleBacktracking) {
|
|||
componentDescriptor);
|
||||
auto nodeABB = std::make_shared<TestShadowNode>(
|
||||
ShadowNodeFragment{
|
||||
/* .tag = */ ShadowNodeFragment::tagPlaceholder(),
|
||||
/* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(),
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
|
@ -343,7 +331,6 @@ TEST(ShadowNodeTest, handleBacktracking) {
|
|||
componentDescriptor);
|
||||
auto nodeABC = std::make_shared<TestShadowNode>(
|
||||
ShadowNodeFragment{
|
||||
/* .tag = */ ShadowNodeFragment::tagPlaceholder(),
|
||||
/* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(),
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
|
@ -364,7 +351,6 @@ TEST(ShadowNodeTest, handleBacktracking) {
|
|||
componentDescriptor);
|
||||
auto nodeAB = std::make_shared<TestShadowNode>(
|
||||
ShadowNodeFragment{
|
||||
/* .tag = */ ShadowNodeFragment::tagPlaceholder(),
|
||||
/* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(),
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
|
@ -382,7 +368,6 @@ TEST(ShadowNodeTest, handleBacktracking) {
|
|||
componentDescriptor);
|
||||
auto nodeAC = std::make_shared<TestShadowNode>(
|
||||
ShadowNodeFragment{
|
||||
/* .tag = */ ShadowNodeFragment::tagPlaceholder(),
|
||||
/* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(),
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
|
@ -403,7 +388,6 @@ TEST(ShadowNodeTest, handleBacktracking) {
|
|||
componentDescriptor);
|
||||
auto nodeA = std::make_shared<TestShadowNode>(
|
||||
ShadowNodeFragment{
|
||||
/* .tag = */ ShadowNodeFragment::tagPlaceholder(),
|
||||
/* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(),
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
|
@ -421,7 +405,6 @@ TEST(ShadowNodeTest, handleBacktracking) {
|
|||
componentDescriptor);
|
||||
auto nodeZ = std::make_shared<TestShadowNode>(
|
||||
ShadowNodeFragment{
|
||||
/* .tag = */ ShadowNodeFragment::tagPlaceholder(),
|
||||
/* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(),
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
|
|
|
@ -103,12 +103,13 @@ ShadowTree::ShadowTree(
|
|||
*RootShadowNode::defaultSharedProps(), layoutConstraints, layoutContext);
|
||||
|
||||
rootShadowNode_ = std::static_pointer_cast<const RootShadowNode>(
|
||||
rootComponentDescriptor.createShadowNode(ShadowNodeFragment{
|
||||
/* .tag = */ surfaceId,
|
||||
/* .surfaceId = */ surfaceId,
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ noopEventEmitter,
|
||||
}));
|
||||
rootComponentDescriptor.createShadowNode(
|
||||
ShadowNodeFragment{
|
||||
/* .surfaceId = */ surfaceId,
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ noopEventEmitter,
|
||||
},
|
||||
{surfaceId, surfaceId, noopEventEmitter}));
|
||||
|
||||
mountingCoordinator_ = std::make_shared<MountingCoordinator const>(
|
||||
ShadowTreeRevision{rootShadowNode_, 0, {}});
|
||||
|
@ -210,7 +211,6 @@ void ShadowTree::commitEmptyTree() const {
|
|||
return std::make_shared<RootShadowNode>(
|
||||
*oldRootShadowNode,
|
||||
ShadowNodeFragment{
|
||||
/* .tag = */ ShadowNodeFragment::tagPlaceholder(),
|
||||
/* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(),
|
||||
/* .props = */ ShadowNodeFragment::propsPlaceholder(),
|
||||
/* .eventEmitter = */
|
||||
|
|
|
@ -50,8 +50,7 @@ StubViewTree stubViewTreeFromShadowNode(ShadowNode const &rootShadowNode) {
|
|||
sliceChildShadowNodeViewPairs(rootShadowNode));
|
||||
|
||||
auto emptyRootShadowNode = rootShadowNode.clone(
|
||||
ShadowNodeFragment{ShadowNodeFragment::tagPlaceholder(),
|
||||
ShadowNodeFragment::surfaceIdPlaceholder(),
|
||||
ShadowNodeFragment{ShadowNodeFragment::surfaceIdPlaceholder(),
|
||||
ShadowNodeFragment::propsPlaceholder(),
|
||||
ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
ShadowNode::emptySharedShadowNodeSharedList()});
|
||||
|
|
|
@ -171,17 +171,18 @@ SharedShadowNode ComponentDescriptorRegistry::createNode(
|
|||
auto const props =
|
||||
componentDescriptor.cloneProps(nullptr, RawProps(propsDynamic));
|
||||
auto const state = componentDescriptor.createInitialState(
|
||||
ShadowNodeFragment{tag, surfaceId, props, eventEmitter});
|
||||
ShadowNodeFragment{surfaceId, props, eventEmitter});
|
||||
|
||||
return componentDescriptor.createShadowNode({
|
||||
/* .tag = */ tag,
|
||||
/* .surfaceId = */ surfaceId,
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ eventEmitter,
|
||||
/* .children = */ ShadowNodeFragment::childrenPlaceholder(),
|
||||
/* .localData = */ ShadowNodeFragment::localDataPlaceholder(),
|
||||
/* .state = */ state,
|
||||
});
|
||||
return componentDescriptor.createShadowNode(
|
||||
{
|
||||
/* .surfaceId = */ surfaceId,
|
||||
/* .props = */ props,
|
||||
/* .eventEmitter = */ eventEmitter,
|
||||
/* .children = */ ShadowNodeFragment::childrenPlaceholder(),
|
||||
/* .localData = */ ShadowNodeFragment::localDataPlaceholder(),
|
||||
/* .state = */ state,
|
||||
},
|
||||
{tag, surfaceId, eventEmitter});
|
||||
}
|
||||
|
||||
void ComponentDescriptorRegistry::setFallbackComponentDescriptor(
|
||||
|
|
|
@ -174,22 +174,21 @@ void Scheduler::renderTemplateToSurface(
|
|||
|
||||
uiManager_->getShadowTreeRegistry().visit(
|
||||
surfaceId, [=](const ShadowTree &shadowTree) {
|
||||
return shadowTree.tryCommit([&](RootShadowNode::Shared const
|
||||
&oldRootShadowNode) {
|
||||
return std::make_shared<RootShadowNode>(
|
||||
*oldRootShadowNode,
|
||||
ShadowNodeFragment{
|
||||
/* .tag = */ ShadowNodeFragment::tagPlaceholder(),
|
||||
/* .surfaceId = */
|
||||
ShadowNodeFragment::surfaceIdPlaceholder(),
|
||||
/* .props = */ ShadowNodeFragment::propsPlaceholder(),
|
||||
/* .eventEmitter = */
|
||||
ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
/* .children = */
|
||||
std::make_shared<SharedShadowNodeList>(
|
||||
SharedShadowNodeList{tree}),
|
||||
});
|
||||
});
|
||||
return shadowTree.tryCommit(
|
||||
[&](RootShadowNode::Shared const &oldRootShadowNode) {
|
||||
return std::make_shared<RootShadowNode>(
|
||||
*oldRootShadowNode,
|
||||
ShadowNodeFragment{
|
||||
/* .surfaceId = */
|
||||
ShadowNodeFragment::surfaceIdPlaceholder(),
|
||||
/* .props = */ ShadowNodeFragment::propsPlaceholder(),
|
||||
/* .eventEmitter = */
|
||||
ShadowNodeFragment::eventEmitterPlaceholder(),
|
||||
/* .children = */
|
||||
std::make_shared<SharedShadowNodeList>(
|
||||
SharedShadowNodeList{tree}),
|
||||
});
|
||||
});
|
||||
});
|
||||
} catch (const std::exception &e) {
|
||||
LOG(ERROR) << " >>>> EXCEPTION <<< rendering uiTemplate in "
|
||||
|
|
|
@ -36,23 +36,24 @@ SharedShadowNode UIManager::createNode(
|
|||
componentDescriptor.createEventEmitter(std::move(eventTarget), tag);
|
||||
auto const props = componentDescriptor.cloneProps(nullptr, rawProps);
|
||||
auto const state = componentDescriptor.createInitialState(
|
||||
ShadowNodeFragment{tag, surfaceId, props, eventEmitter});
|
||||
ShadowNodeFragment{surfaceId, props, eventEmitter});
|
||||
|
||||
auto shadowNode = componentDescriptor.createShadowNode({
|
||||
/* .tag = */ tag,
|
||||
/* .surfaceId = */ surfaceId,
|
||||
/* .props = */
|
||||
fallbackDescriptor != nullptr &&
|
||||
fallbackDescriptor->getComponentHandle() ==
|
||||
componentDescriptor.getComponentHandle()
|
||||
? componentDescriptor.cloneProps(
|
||||
props, RawProps(folly::dynamic::object("name", name)))
|
||||
: props,
|
||||
/* .eventEmitter = */ eventEmitter,
|
||||
/* .children = */ ShadowNodeFragment::childrenPlaceholder(),
|
||||
/* .localData = */ ShadowNodeFragment::localDataPlaceholder(),
|
||||
/* .state = */ state,
|
||||
});
|
||||
auto shadowNode = componentDescriptor.createShadowNode(
|
||||
ShadowNodeFragment{
|
||||
/* .surfaceId = */ surfaceId,
|
||||
/* .props = */
|
||||
fallbackDescriptor != nullptr &&
|
||||
fallbackDescriptor->getComponentHandle() ==
|
||||
componentDescriptor.getComponentHandle()
|
||||
? componentDescriptor.cloneProps(
|
||||
props, RawProps(folly::dynamic::object("name", name)))
|
||||
: props,
|
||||
/* .eventEmitter = */ eventEmitter,
|
||||
/* .children = */ ShadowNodeFragment::childrenPlaceholder(),
|
||||
/* .localData = */ ShadowNodeFragment::localDataPlaceholder(),
|
||||
/* .state = */ state,
|
||||
},
|
||||
ShadowNodeFamilyFragment{tag, surfaceId, eventEmitter});
|
||||
|
||||
// state->commit(x) associates a ShadowNode with the State object.
|
||||
// state->commit(x) must be called before calling updateState; updateState
|
||||
|
@ -84,7 +85,6 @@ SharedShadowNode UIManager::cloneNode(
|
|||
auto clonedShadowNode = componentDescriptor.cloneShadowNode(
|
||||
*shadowNode,
|
||||
{
|
||||
/* .tag = */ ShadowNodeFragment::tagPlaceholder(),
|
||||
/* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(),
|
||||
/* .props = */
|
||||
rawProps ? componentDescriptor.cloneProps(
|
||||
|
@ -116,7 +116,6 @@ void UIManager::completeSurface(
|
|||
return std::make_shared<RootShadowNode>(
|
||||
*oldRootShadowNode,
|
||||
ShadowNodeFragment{
|
||||
/* .tag = */ ShadowNodeFragment::tagPlaceholder(),
|
||||
/* .surfaceId = */ ShadowNodeFragment::surfaceIdPlaceholder(),
|
||||
/* .props = */ ShadowNodeFragment::propsPlaceholder(),
|
||||
/* .eventEmitter = */
|
||||
|
@ -157,7 +156,6 @@ void UIManager::setNativeProps(
|
|||
return oldRootShadowNode->clone(
|
||||
shadowNode, [&](ShadowNode const &oldShadowNode) {
|
||||
return oldShadowNode.clone({
|
||||
/* .tag = */ ShadowNodeFragment::tagPlaceholder(),
|
||||
/* .surfaceId = */
|
||||
ShadowNodeFragment::surfaceIdPlaceholder(),
|
||||
/* .props = */ props,
|
||||
|
@ -211,7 +209,6 @@ void UIManager::updateState(
|
|||
return oldRootShadowNode->clone(
|
||||
shadowNode, [&](ShadowNode const &oldShadowNode) {
|
||||
return oldShadowNode.clone({
|
||||
/* .tag = */ ShadowNodeFragment::tagPlaceholder(),
|
||||
/* .surfaceId = */
|
||||
ShadowNodeFragment::surfaceIdPlaceholder(),
|
||||
/* .props = */ ShadowNodeFragment::propsPlaceholder(),
|
||||
|
|
Загрузка…
Ссылка в новой задаче