Fabric: Introducing ShadowNode::shallowSourceNode()

Summary:
The method replaces the current source node with its source node.
It's useful when we have to clone some node but don't want to change a source node pointer.

Reviewed By: fkgozali

Differential Revision: D7503384

fbshipit-source-id: 81ec64079c7e99cb9abdda2af10d85281a94e1b1
This commit is contained in:
Valentin Shergin
2018-04-10 12:46:04 -07:00
committed by Facebook Github Bot
parent 5463fc260b
commit db7f98b789
2 changed files with 12 additions and 0 deletions

View File

@@ -108,6 +108,10 @@ void ShadowNode::clearSourceNode() {
sourceNode_.reset();
}
void ShadowNode::shallowSourceNode() {
sourceNode_ = sourceNode_.lock()->getSourceNode();
}
#pragma mark - Equality
bool ShadowNode::operator==(const ShadowNode& rhs) const {

View File

@@ -67,6 +67,14 @@ public:
void replaceChild(const SharedShadowNode &oldChild, const SharedShadowNode &newChild);
void clearSourceNode();
/*
* Replaces the current source node with its source node.
* This method might be used for illuminating side-effects caused by the last
* cloning operation which are not desirable from the diffing algorithm
* perspective.
*/
void shallowSourceNode();
#pragma mark - Equality
/*