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 @@ -7,6 +7,7 @@

#include "ViewTransitionModule.h"

#include <glog/logging.h>
#include <react/renderer/components/root/RootShadowNode.h>
#include <react/renderer/core/LayoutableShadowNode.h>
#include <react/renderer/core/RawProps.h>
Expand Down Expand Up @@ -93,7 +94,20 @@ void ViewTransitionModule::applyViewTransitionName(

if (auto it = oldPseudoElementNodesRepository_.find(name);
it != oldPseudoElementNodesRepository_.end()) {
oldPseudoElementNodes_[name] = it->second.node;
// Find the pseudo element created from this specific source tag
auto& pseudoElementsBySourceTag = it->second;
auto innerIt = pseudoElementsBySourceTag.find(tag);
if (innerIt != pseudoElementsBySourceTag.end()) {
oldPseudoElementNodes_[name] = innerIt->second.node;
} else if (!pseudoElementsBySourceTag.empty()) {
// Fallback to first available entry for this name
oldPseudoElementNodes_[name] =
pseudoElementsBySourceTag.begin()->second.node;
}
} else {
LOG(WARNING)
<< "applyViewTransitionName: old pseudo element shadow node doesn't exist for name "
<< name;
}

} else {
Expand Down Expand Up @@ -158,7 +172,7 @@ void ViewTransitionModule::createViewTransitionInstance(
if (!forNextTransition) {
oldPseudoElementNodes_[name] = pseudoElementNode;
}
oldPseudoElementNodesRepository_[name] = InactivePseudoElement{
oldPseudoElementNodesRepository_[name][view.tag] = InactivePseudoElement{
.node = pseudoElementNode, .sourceTag = view.tag};
}
}
Expand Down Expand Up @@ -222,7 +236,12 @@ std::optional<MountingTransaction> ViewTransitionModule::pullTransaction(
auto tag = mutation.oldChildShadowView.tag;
for (auto it = oldPseudoElementNodesRepository_.begin();
it != oldPseudoElementNodesRepository_.end();) {
if (it->second.sourceTag == tag) {
auto& pseudoElementsBySourceTag = it->second;
if (auto innerIt = pseudoElementsBySourceTag.find(tag);
innerIt != pseudoElementsBySourceTag.end()) {
pseudoElementsBySourceTag.erase(innerIt);
}
if (pseudoElementsBySourceTag.empty()) {
it = oldPseudoElementNodesRepository_.erase(it);
} else {
++it;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ class ViewTransitionModule : public UIManagerViewTransitionDelegate,
// pseudo-element nodes created for entering nodes, to be copied into
// oldPseudoElementNodes_ during the next applyViewTransitionName call.
// Mutable because pullTransaction (const) needs to erase unmounted entries.
mutable std::unordered_map<std::string, InactivePseudoElement> oldPseudoElementNodesRepository_{};
mutable std::unordered_map<std::string, std::unordered_map<Tag /* sourceTag */, InactivePseudoElement>>
oldPseudoElementNodesRepository_{};

LayoutMetrics captureLayoutMetricsFromRoot(const ShadowNode &shadowNode);

Expand Down
Loading