From db7f98b78993a28100ca15134c0f8f8138e9efcf Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Tue, 10 Apr 2018 12:46:04 -0700 Subject: [PATCH] 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 --- ReactCommon/fabric/core/shadownode/ShadowNode.cpp | 4 ++++ ReactCommon/fabric/core/shadownode/ShadowNode.h | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/ReactCommon/fabric/core/shadownode/ShadowNode.cpp b/ReactCommon/fabric/core/shadownode/ShadowNode.cpp index f15964b0b..8f54601d0 100644 --- a/ReactCommon/fabric/core/shadownode/ShadowNode.cpp +++ b/ReactCommon/fabric/core/shadownode/ShadowNode.cpp @@ -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 { diff --git a/ReactCommon/fabric/core/shadownode/ShadowNode.h b/ReactCommon/fabric/core/shadownode/ShadowNode.h index f03acb107..cd0264c22 100644 --- a/ReactCommon/fabric/core/shadownode/ShadowNode.h +++ b/ReactCommon/fabric/core/shadownode/ShadowNode.h @@ -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 /*