mirror of
https://github.com/status-im/react-native.git
synced 2025-02-11 08:56:44 +00:00
Fabric: Removed last two plactical usages of ShadowNode::sourceNode_
Summary: @public * In case of `ShadowTree` we just pass original old node as a `commit` method argument; * In case of `ConcreteViewShadowNode` we just don't need that because diffing algorithm does not use that information anymore. Reviewed By: mdvacca Differential Revision: D8753906 fbshipit-source-id: b8555083c7e72e9b3c0f9a8065745946d4cf44c7
This commit is contained in:
parent
fcd72bf34a
commit
e78bf723bf
@ -78,7 +78,7 @@ void ShadowTree::complete(UnsharedRootShadowNode newRootShadowNode) {
|
|||||||
newRootShadowNode
|
newRootShadowNode
|
||||||
);
|
);
|
||||||
|
|
||||||
if (commit(newRootShadowNode)) {
|
if (commit(oldRootShadowNode, newRootShadowNode)) {
|
||||||
emitLayoutEvents(instructions);
|
emitLayoutEvents(instructions);
|
||||||
|
|
||||||
if (delegate_) {
|
if (delegate_) {
|
||||||
@ -87,10 +87,10 @@ void ShadowTree::complete(UnsharedRootShadowNode newRootShadowNode) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShadowTree::commit(const SharedRootShadowNode &newRootShadowNode) {
|
bool ShadowTree::commit(const SharedRootShadowNode &oldRootShadowNode, const SharedRootShadowNode &newRootShadowNode) {
|
||||||
std::lock_guard<std::mutex> lock(commitMutex_);
|
std::lock_guard<std::mutex> lock(commitMutex_);
|
||||||
|
|
||||||
if (newRootShadowNode->getSourceNode() != rootShadowNode_) {
|
if (oldRootShadowNode != rootShadowNode_) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ private:
|
|||||||
|
|
||||||
UnsharedRootShadowNode cloneRootShadowNode(const LayoutConstraints &layoutConstraints, const LayoutContext &layoutContext) const;
|
UnsharedRootShadowNode cloneRootShadowNode(const LayoutConstraints &layoutConstraints, const LayoutContext &layoutContext) const;
|
||||||
void complete(UnsharedRootShadowNode newRootShadowNode);
|
void complete(UnsharedRootShadowNode newRootShadowNode);
|
||||||
bool commit(const SharedRootShadowNode &newRootShadowNode);
|
bool commit(const SharedRootShadowNode &oldRootShadowNode, const SharedRootShadowNode &newRootShadowNode);
|
||||||
void emitLayoutEvents(const TreeMutationInstructionList &instructions);
|
void emitLayoutEvents(const TreeMutationInstructionList &instructions);
|
||||||
|
|
||||||
const Tag rootTag_;
|
const Tag rootTag_;
|
||||||
|
@ -105,21 +105,6 @@ public:
|
|||||||
auto childShadowNode = std::dynamic_pointer_cast<const ShadowNode>(child);
|
auto childShadowNode = std::dynamic_pointer_cast<const ShadowNode>(child);
|
||||||
assert(childShadowNode);
|
assert(childShadowNode);
|
||||||
auto childShadowNodeClone = childShadowNode->clone();
|
auto childShadowNodeClone = childShadowNode->clone();
|
||||||
|
|
||||||
// This is overloading of `SharedLayoutableShadowNode::cloneAndReplaceChild`,
|
|
||||||
// the method is used to clone some node as a preparation for future mutation
|
|
||||||
// caused by relayout.
|
|
||||||
// Because those changes are not requested by UIManager, they add a layer
|
|
||||||
// of node generation (between the committed stage and new proposed stage).
|
|
||||||
// That additional layer confuses the Diffing algorithm which uses
|
|
||||||
// `sourceNode` for referencing the previous (aka committed) stage
|
|
||||||
// of the tree to produce mutation instructions.
|
|
||||||
// In other words, if we don't compensate this change here,
|
|
||||||
// the Diffing algorithm will compare wrong trees
|
|
||||||
// ("new-but-not-laid-out-yet vs. new" instead of "committed vs. new").
|
|
||||||
auto nonConstChildShadowNodeClone = std::const_pointer_cast<ShadowNode>(childShadowNodeClone);
|
|
||||||
nonConstChildShadowNodeClone->shallowSourceNode();
|
|
||||||
|
|
||||||
ShadowNode::replaceChild(childShadowNode, childShadowNodeClone);
|
ShadowNode::replaceChild(childShadowNode, childShadowNodeClone);
|
||||||
return std::dynamic_pointer_cast<const LayoutableShadowNode>(childShadowNodeClone);
|
return std::dynamic_pointer_cast<const LayoutableShadowNode>(childShadowNodeClone);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user