mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add getSurfaceProps helper method to SurfaceManager (#48487)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/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
This commit is contained in:
committed by
Facebook GitHub Bot
parent
44525aaf8b
commit
65c6a0a941
@@ -89,6 +89,22 @@ std::unordered_set<SurfaceId> SurfaceManager::getRunningSurfaces()
|
||||
return surfaceIds;
|
||||
}
|
||||
|
||||
std::optional<SurfaceManager::SurfaceProps> SurfaceManager::getSurfaceProps(
|
||||
SurfaceId surfaceId) const noexcept {
|
||||
std::optional<SurfaceManager::SurfaceProps> surfaceProps;
|
||||
|
||||
visit(surfaceId, [&](const SurfaceHandler& surfaceHandler) {
|
||||
surfaceProps = SurfaceManager::SurfaceProps{
|
||||
surfaceId,
|
||||
surfaceHandler.getModuleName(),
|
||||
surfaceHandler.getProps(),
|
||||
surfaceHandler.getLayoutConstraints(),
|
||||
surfaceHandler.getLayoutContext()};
|
||||
});
|
||||
|
||||
return surfaceProps;
|
||||
}
|
||||
|
||||
Size SurfaceManager::measureSurface(
|
||||
SurfaceId surfaceId,
|
||||
const LayoutConstraints& layoutConstraints,
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
#include <shared_mutex>
|
||||
#include <unordered_map>
|
||||
|
||||
@@ -29,6 +30,15 @@ class SurfaceManager final {
|
||||
explicit SurfaceManager(const Scheduler& scheduler) noexcept;
|
||||
~SurfaceManager() noexcept;
|
||||
|
||||
/* SurfaceProps contain information about running surfaces */
|
||||
struct SurfaceProps {
|
||||
SurfaceId surfaceId;
|
||||
std::string moduleName;
|
||||
folly::dynamic props;
|
||||
LayoutConstraints layoutConstraints;
|
||||
LayoutContext layoutContext;
|
||||
};
|
||||
|
||||
#pragma mark - Surface Management
|
||||
|
||||
void startSurface(
|
||||
@@ -46,6 +56,9 @@ class SurfaceManager final {
|
||||
|
||||
std::unordered_set<SurfaceId> getRunningSurfaces() const noexcept;
|
||||
|
||||
std::optional<SurfaceManager::SurfaceProps> getSurfaceProps(
|
||||
SurfaceId surfaceId) const noexcept;
|
||||
|
||||
Size measureSurface(
|
||||
SurfaceId surfaceId,
|
||||
const LayoutConstraints& layoutConstraints,
|
||||
|
||||
Reference in New Issue
Block a user