Fabric: Introducting `ShadowNode.sourceNode`, the node used in copy-constructor
Summary: We will need this later in the diffing alogrithm. Reviewed By: fkgozali Differential Revision: D7330337 fbshipit-source-id: 3da44a62e4d5f30deed28b18a5779544153244f3
This commit is contained in:
parent
39383d1189
commit
b808bfdce2
|
@ -41,7 +41,8 @@ ShadowNode::ShadowNode(
|
|||
tag_(shadowNode->tag_),
|
||||
instanceHandle_(shadowNode->instanceHandle_),
|
||||
props_(props ? props : shadowNode->props_),
|
||||
children_(children ? children : shadowNode->children_) {}
|
||||
children_(children ? children : shadowNode->children_),
|
||||
sourceNode_(shadowNode) {}
|
||||
|
||||
#pragma mark - Getters
|
||||
|
||||
|
@ -57,7 +58,9 @@ Tag ShadowNode::getTag() const {
|
|||
return tag_;
|
||||
}
|
||||
|
||||
#pragma mark - Mutating Methods
|
||||
SharedShadowNode ShadowNode::getSourceNode() const {
|
||||
return sourceNode_;
|
||||
}
|
||||
|
||||
void ShadowNode::sealRecursive() const {
|
||||
if (getSealed()) {
|
||||
|
@ -73,6 +76,8 @@ void ShadowNode::sealRecursive() const {
|
|||
}
|
||||
}
|
||||
|
||||
#pragma mark - Mutating Methods
|
||||
|
||||
void ShadowNode::appendChild(const SharedShadowNode &child) {
|
||||
ensureUnsealed();
|
||||
|
||||
|
@ -95,6 +100,11 @@ void ShadowNode::replaceChild(const SharedShadowNode &oldChild, const SharedShad
|
|||
children_ = std::make_shared<const SharedShadowNodeList>(nonConstChildrenCopy);
|
||||
}
|
||||
|
||||
void ShadowNode::clearSourceNode() {
|
||||
ensureUnsealed();
|
||||
sourceNode_ = nullptr;
|
||||
}
|
||||
|
||||
#pragma mark - DebugStringConvertible
|
||||
|
||||
std::string ShadowNode::getDebugName() const {
|
||||
|
@ -127,6 +137,13 @@ SharedDebugStringConvertibleList ShadowNode::getDebugProps() const {
|
|||
list.push_back(std::make_shared<DebugStringConvertibleItem>("handle", std::to_string((size_t)instanceHandle_)));
|
||||
}
|
||||
|
||||
if (sourceNode_) {
|
||||
list.push_back(std::make_shared<DebugStringConvertibleItem>(
|
||||
"source",
|
||||
sourceNode_->getDebugDescription({.maximumDepth = 1, .format = false})
|
||||
));
|
||||
}
|
||||
|
||||
SharedDebugStringConvertibleList propsList = props_->getDebugProps();
|
||||
std::move(propsList.begin(), propsList.end(), std::back_inserter(list));
|
||||
return list;
|
||||
|
|
|
@ -55,13 +55,14 @@ public:
|
|||
SharedShadowNodeSharedList getChildren() const;
|
||||
SharedProps getProps() const;
|
||||
Tag getTag() const;
|
||||
SharedShadowNode getSourceNode() const;
|
||||
void sealRecursive() const;
|
||||
|
||||
#pragma mark - Mutating Methods
|
||||
|
||||
void sealRecursive() const;
|
||||
|
||||
void appendChild(const SharedShadowNode &child);
|
||||
void replaceChild(const SharedShadowNode &oldChild, const SharedShadowNode &newChild);
|
||||
void clearSourceNode();
|
||||
|
||||
#pragma mark - DebugStringConvertible
|
||||
|
||||
|
@ -76,6 +77,7 @@ protected:
|
|||
InstanceHandle instanceHandle_;
|
||||
SharedProps props_;
|
||||
SharedShadowNodeSharedList children_;
|
||||
SharedShadowNode sourceNode_;
|
||||
};
|
||||
|
||||
} // namespace react
|
||||
|
|
Loading…
Reference in New Issue