mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fabric: Improved signature of calculateMutationInstructions
Summary: Apparently, `calculateMutationInstructions` must also produce mutation instructions for root node as well. To make it possible we have to change the signature of the function and weak some restrictions in TreeMutationInstruction. Reviewed By: fkgozali Differential Revision: D7958248 fbshipit-source-id: 4109a6bce3a77f7eb89157201fd0e80f98487dbd
This commit is contained in:
committed by
Facebook Github Bot
parent
10c5368c37
commit
57d69772b7
@@ -5,7 +5,7 @@
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
void calculateMutationInstructions(
|
||||
static void calculateMutationInstructions(
|
||||
TreeMutationInstructionList &instructions,
|
||||
SharedShadowNode parentNode,
|
||||
SharedShadowNodeSharedList oldChildNodes,
|
||||
@@ -154,5 +154,33 @@ void calculateMutationInstructions(
|
||||
instructions.insert(instructions.end(), downwardInstructions.begin(), downwardInstructions.end());
|
||||
}
|
||||
|
||||
|
||||
void calculateMutationInstructions(
|
||||
TreeMutationInstructionList &instructions,
|
||||
SharedShadowNode oldRootShadowNode,
|
||||
SharedShadowNode newRootShadowNode
|
||||
) {
|
||||
// Root shadow nodes must have same tag.
|
||||
assert(oldRootShadowNode->getTag() == newRootShadowNode->getTag());
|
||||
|
||||
if (*oldRootShadowNode != *newRootShadowNode) {
|
||||
instructions.push_back(
|
||||
TreeMutationInstruction::Replace(
|
||||
nullptr,
|
||||
oldRootShadowNode,
|
||||
newRootShadowNode,
|
||||
-1
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
calculateMutationInstructions(
|
||||
instructions,
|
||||
oldRootShadowNode,
|
||||
oldRootShadowNode->getChildren(),
|
||||
newRootShadowNode->getChildren()
|
||||
);
|
||||
}
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
|
||||
@@ -15,9 +15,8 @@ namespace react {
|
||||
*/
|
||||
void calculateMutationInstructions(
|
||||
TreeMutationInstructionList &instructions,
|
||||
SharedShadowNode parentNode,
|
||||
SharedShadowNodeSharedList oldChildNodes,
|
||||
SharedShadowNodeSharedList newChildNodes
|
||||
SharedShadowNode oldNode,
|
||||
SharedShadowNode newNode
|
||||
);
|
||||
|
||||
} // namespace react
|
||||
|
||||
@@ -69,8 +69,7 @@ void ShadowTree::complete(UnsharedRootShadowNode newRootShadowNode) {
|
||||
calculateMutationInstructions(
|
||||
instructions,
|
||||
oldRootShadowNode,
|
||||
oldRootShadowNode->ShadowNode::getChildren(),
|
||||
newRootShadowNode->ShadowNode::getChildren()
|
||||
newRootShadowNode
|
||||
);
|
||||
|
||||
if (commit(newRootShadowNode)) {
|
||||
|
||||
@@ -82,10 +82,8 @@ const TreeMutationInstruction TreeMutationInstruction::Replace(
|
||||
SharedShadowNode newChildNode,
|
||||
int index
|
||||
) {
|
||||
assert(parentNode);
|
||||
assert(oldChildNode);
|
||||
assert(newChildNode);
|
||||
assert(index != -1);
|
||||
|
||||
return TreeMutationInstruction(
|
||||
Replacement,
|
||||
|
||||
Reference in New Issue
Block a user