Skip to content

Commit 65c6a0a

Browse files
Add getSurfaceProps helper method to SurfaceManager (facebook#48487)
Summary: Pull Request resolved: facebook#48487 [Changelog] [Internal] - Add getSurfaceProps helper method to SurfaceManager When reload a reactHost we need to know which surface properties have been applied when starting the surface. This adds a utility function for that. Reviewed By: rshest Differential Revision: D67822459 fbshipit-source-id: 6d1f182514ed6e7ae8e31d3e1ca052c93bac2843
1 parent 44525aa commit 65c6a0a

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

packages/react-native/ReactCommon/react/renderer/scheduler/SurfaceManager.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,22 @@ std::unordered_set<SurfaceId> SurfaceManager::getRunningSurfaces()
8989
return surfaceIds;
9090
}
9191

92+
std::optional<SurfaceManager::SurfaceProps> SurfaceManager::getSurfaceProps(
93+
SurfaceId surfaceId) const noexcept {
94+
std::optional<SurfaceManager::SurfaceProps> surfaceProps;
95+
96+
visit(surfaceId, [&](const SurfaceHandler& surfaceHandler) {
97+
surfaceProps = SurfaceManager::SurfaceProps{
98+
surfaceId,
99+
surfaceHandler.getModuleName(),
100+
surfaceHandler.getProps(),
101+
surfaceHandler.getLayoutConstraints(),
102+
surfaceHandler.getLayoutContext()};
103+
});
104+
105+
return surfaceProps;
106+
}
107+
92108
Size SurfaceManager::measureSurface(
93109
SurfaceId surfaceId,
94110
const LayoutConstraints& layoutConstraints,

packages/react-native/ReactCommon/react/renderer/scheduler/SurfaceManager.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#pragma once
99

1010
#include <mutex>
11+
#include <optional>
1112
#include <shared_mutex>
1213
#include <unordered_map>
1314

@@ -29,6 +30,15 @@ class SurfaceManager final {
2930
explicit SurfaceManager(const Scheduler& scheduler) noexcept;
3031
~SurfaceManager() noexcept;
3132

33+
/* SurfaceProps contain information about running surfaces */
34+
struct SurfaceProps {
35+
SurfaceId surfaceId;
36+
std::string moduleName;
37+
folly::dynamic props;
38+
LayoutConstraints layoutConstraints;
39+
LayoutContext layoutContext;
40+
};
41+
3242
#pragma mark - Surface Management
3343

3444
void startSurface(
@@ -46,6 +56,9 @@ class SurfaceManager final {
4656

4757
std::unordered_set<SurfaceId> getRunningSurfaces() const noexcept;
4858

59+
std::optional<SurfaceManager::SurfaceProps> getSurfaceProps(
60+
SurfaceId surfaceId) const noexcept;
61+
4962
Size measureSurface(
5063
SurfaceId surfaceId,
5164
const LayoutConstraints& layoutConstraints,

0 commit comments

Comments
 (0)