File tree Expand file tree Collapse file tree
packages/react-native/ReactCommon/react/renderer Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -463,6 +463,9 @@ CommitStatus ShadowTree::tryCommit(
463463 }
464464 }
465465
466+ delegate_.shadowTreeDidCommit (
467+ *this , newRevision.rootShadowNode , affectedLayoutableNodes);
468+
466469 emitLayoutEvents (affectedLayoutableNodes);
467470
468471 if (isReactBranch) {
Original file line number Diff line number Diff line change 1111
1212namespace facebook ::react {
1313
14+ class LayoutableShadowNode ;
1415class ShadowTree ;
1516struct ShadowTreeCommitOptions ;
1617
@@ -49,6 +50,16 @@ class ShadowTreeDelegate {
4950 */
5051 virtual void shadowTreeDidPromoteReactRevision (const ShadowTree &shadowTree) const = 0;
5152
53+ /*
54+ * Called right after a Shadow Tree commits a new tree, reporting the nodes
55+ * whose layout changed in this commit.
56+ */
57+ virtual void shadowTreeDidCommit (
58+ const ShadowTree& shadowTree,
59+ const RootShadowNode::Shared& rootShadowNode,
60+ const std::vector<const LayoutableShadowNode*>& affectedLayoutableNodes)
61+ const noexcept {}
62+
5263 virtual ~ShadowTreeDelegate () noexcept = default ;
5364};
5465
Original file line number Diff line number Diff line change @@ -670,6 +670,21 @@ void UIManager::shadowTreeDidPromoteReactRevision(
670670 }
671671}
672672
673+ void UIManager::shadowTreeDidCommit (
674+ const ShadowTree& shadowTree,
675+ const RootShadowNode::Shared& rootShadowNode,
676+ const std::vector<const LayoutableShadowNode*>& affectedLayoutableNodes)
677+ const noexcept {
678+ TraceSection s (" UIManager::shadowTreeDidCommit" );
679+
680+ std::shared_lock lock (commitHookMutex_);
681+
682+ for (auto * commitHook : commitHooks_) {
683+ commitHook->shadowTreeDidCommit (
684+ shadowTree, rootShadowNode, affectedLayoutableNodes);
685+ }
686+ }
687+
673688void UIManager::reportMount (SurfaceId surfaceId) const {
674689 TraceSection s (" UIManager::reportMount" );
675690
Original file line number Diff line number Diff line change @@ -146,6 +146,12 @@ class UIManager final : public ShadowTreeDelegate {
146146
147147 void shadowTreeDidPromoteReactRevision (const ShadowTree &shadowTree) const override ;
148148
149+ void shadowTreeDidCommit (
150+ const ShadowTree& shadowTree,
151+ const RootShadowNode::Shared& rootShadowNode,
152+ const std::vector<const LayoutableShadowNode*>& affectedLayoutableNodes)
153+ const noexcept override ;
154+
149155 std::shared_ptr<ShadowNode> createNode (
150156 Tag tag,
151157 const std::string &componentName,
Original file line number Diff line number Diff line change 1111
1212namespace facebook ::react {
1313
14+ class LayoutableShadowNode ;
1415class ShadowTree ;
1516struct ShadowTreeCommitOptions ;
1617class UIManager ;
@@ -54,6 +55,16 @@ class UIManagerCommitHook {
5455 return newRootShadowNode;
5556 }
5657
58+ /*
59+ * Called right after a `ShadowTree` commits a new tree.
60+ * The semantic of the method corresponds to a method of the same name
61+ * from `ShadowTreeDelegate`.
62+ */
63+ virtual void shadowTreeDidCommit (
64+ const ShadowTree& /* shadowTree*/ ,
65+ const RootShadowNode::Shared& /* rootShadowNode*/ ,
66+ const std::vector<const LayoutableShadowNode*>& /* affectedLayoutableNodes*/ ) noexcept {}
67+
5768 virtual ~UIManagerCommitHook () noexcept = default ;
5869};
5970
You can’t perform that action at this time.
0 commit comments