Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ static void sliceChildShadowNodeViewPairsRecursively(
size_t& startOfStaticIndex,
ViewNodePairScope& scope,
Point layoutOffset,
const ShadowNode& shadowNode) {
const ShadowNode& shadowNode,
Tag unflattenedParentTag) {
for (const auto& sharedChildShadowNode : shadowNode.getChildren()) {
auto& childShadowNode = *sharedChildShadowNode;

Expand Down Expand Up @@ -254,12 +255,16 @@ static void sliceChildShadowNodeViewPairsRecursively(
if (areChildrenFlattened) {
storedOrigin = origin;
}
if (shadowNode.getTraits().check(ShadowNodeTraits::Trait::FormsView)){
unflattenedParentTag = shadowNode.getTag();
}
scope.push_back(
{shadowView,
&childShadowNode,
areChildrenFlattened,
isConcreteView,
storedOrigin});
storedOrigin,
unflattenedParentTag});

if (shadowView.layoutMetrics.positionType == PositionType::Static) {
auto it = pairList.begin();
Expand All @@ -268,14 +273,14 @@ static void sliceChildShadowNodeViewPairsRecursively(
startOfStaticIndex++;
if (areChildrenFlattened) {
sliceChildShadowNodeViewPairsRecursively(
pairList, startOfStaticIndex, scope, origin, childShadowNode);
pairList, startOfStaticIndex, scope, origin, childShadowNode, unflattenedParentTag);
}
} else {
pairList.push_back(&scope.back());
if (areChildrenFlattened) {
size_t pairListSize = pairList.size();
sliceChildShadowNodeViewPairsRecursively(
pairList, pairListSize, scope, origin, childShadowNode);
pairList, pairListSize, scope, origin, childShadowNode, unflattenedParentTag);
}
}
}
Expand All @@ -296,7 +301,7 @@ ShadowViewNodePair::NonOwningList sliceChildShadowNodeViewPairs(

size_t startOfStaticIndex = 0;
sliceChildShadowNodeViewPairsRecursively(
pairList, startOfStaticIndex, scope, layoutOffset, shadowNode);
pairList, startOfStaticIndex, scope, layoutOffset, shadowNode, shadowNode.getTag());

// Sorting pairs based on `orderIndex` if needed.
reorderInPlaceIfNeeded(pairList);
Expand Down Expand Up @@ -558,7 +563,8 @@ static void updateMatchedPair(
ShadowViewMutation::RemoveMutation(
parentShadowView,
oldPair.shadowView,
static_cast<int>(oldPair.mountIndex)));
static_cast<int>(oldPair.mountIndex),
oldPair.unflattenedParentTag));
}
mutationContainer.deleteMutations.push_back(
ShadowViewMutation::DeleteMutation(oldPair.shadowView));
Expand All @@ -571,7 +577,8 @@ static void updateMatchedPair(
ShadowViewMutation::RemoveMutation(
parentShadowView,
newPair.shadowView,
static_cast<int>(oldPair.mountIndex)));
static_cast<int>(oldPair.mountIndex),
newPair.unflattenedParentTag));
}

// Even if node's children are flattened, it might still be a
Expand Down Expand Up @@ -775,13 +782,15 @@ static void calculateShadowViewMutationsFlattener(
ShadowViewMutation::RemoveMutation(
node.shadowView,
treeChildPair.otherTreePair->shadowView,
static_cast<int>(treeChildPair.mountIndex)));
static_cast<int>(treeChildPair.mountIndex),
treeChildPair.otherTreePair->unflattenedParentTag));
} else {
mutationContainer.removeMutations.push_back(
ShadowViewMutation::RemoveMutation(
node.shadowView,
treeChildPair.shadowView,
static_cast<int>(treeChildPair.mountIndex)));
static_cast<int>(treeChildPair.mountIndex),
treeChildPair.unflattenedParentTag));
}
} else {
// treeChildParent represents the "new" version of the node, so
Expand Down Expand Up @@ -1201,6 +1210,7 @@ static void calculateShadowViewMutations(
parentShadowView,
oldChildPair.shadowView,
static_cast<int>(oldChildPair.mountIndex),
oldChildPair.unflattenedParentTag,
isRecursionRedundant ||
ShadowViewMutation::
PlatformSupportsRemoveDeleteTreeInstruction));
Expand Down Expand Up @@ -1399,15 +1409,17 @@ static void calculateShadowViewMutations(
ShadowViewMutation::RemoveMutation(
parentShadowView,
otherTreeView,
static_cast<int>(oldChildPair.mountIndex)));
static_cast<int>(oldChildPair.mountIndex),
oldChildPair.unflattenedParentTag));
continue;
}

mutationContainer.removeMutations.push_back(
ShadowViewMutation::RemoveMutation(
parentShadowView,
oldChildPair.shadowView,
static_cast<int>(oldChildPair.mountIndex)));
static_cast<int>(oldChildPair.mountIndex),
oldChildPair.unflattenedParentTag));

deletionCandidatePairs.insert(
{oldChildPair.shadowView.tag, &oldChildPair});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ struct ShadowViewNodePair final {
*/
bool isConcreteView{true};
Point contextOrigin{0, 0};
Tag unflattenedParentTag{-1};

size_t mountIndex{0};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ ShadowViewMutation ShadowViewMutation::RemoveMutation(
ShadowView parentShadowView,
ShadowView childShadowView,
int index,
Tag unflattenedParentTag,
bool isRedundantOperation) {
return {
/* .type = */ Remove,
Expand All @@ -65,6 +66,7 @@ ShadowViewMutation ShadowViewMutation::RemoveMutation(
/* .newChildShadowView = */ {},
/* .index = */ index,
/* .isRedundantOperation */ isRedundantOperation,
/* .parentTag */ unflattenedParentTag
};
}

Expand Down Expand Up @@ -116,12 +118,14 @@ ShadowViewMutation::ShadowViewMutation(
ShadowView oldChildShadowView,
ShadowView newChildShadowView,
int index,
bool isRedundantOperation)
bool isRedundantOperation,
Tag unflattenedParentTag)
: type(type),
parentShadowView(std::move(parentShadowView)),
oldChildShadowView(std::move(oldChildShadowView)),
newChildShadowView(std::move(newChildShadowView)),
index(index),
unflattenedParentTag(unflattenedParentTag),
isRedundantOperation(isRedundantOperation) {}

#if RN_DEBUG_STRING_CONVERTIBLE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ struct ShadowViewMutation final {
ShadowView parentShadowView,
ShadowView childShadowView,
int index,
Tag unflattenedParentTag = -1,
bool isRedundantOperation = false);

/*
Expand Down Expand Up @@ -96,6 +97,7 @@ struct ShadowViewMutation final {
ShadowView oldChildShadowView = {};
ShadowView newChildShadowView = {};
int index = -1;
Tag unflattenedParentTag = -1;

// RemoveDeleteTree causes many Remove/Delete operations to be redundant.
// However, we must internally produce all of them for any consumers that
Expand All @@ -117,7 +119,8 @@ struct ShadowViewMutation final {
ShadowView oldChildShadowView,
ShadowView newChildShadowView,
int index,
bool isRedundantOperation = false);
bool isRedundantOperation = false,
Tag unflattenedParentTag = -1);
};

using ShadowViewMutationList = std::vector<ShadowViewMutation>;
Expand Down