Skip to content

Commit

Permalink
delete MountingCoordinator::Shared typealias
Browse files Browse the repository at this point in the history
Summary:
changelog: [internal]

delete typealias `MountingCoordinator::Shared` and use `std::shared_ptr<const MountingCoordinator>` directly.

Reviewed By: christophpurrer

Differential Revision: D64917023
  • Loading branch information
sammy-SC authored and facebook-github-bot committed Oct 25, 2024
1 parent eddc0a1 commit 20d45d2
Show file tree
Hide file tree
Showing 22 changed files with 37 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ NS_ASSUME_NONNULL_BEGIN
* Schedule a mounting transaction to be performed on the main thread.
* Can be called from any thread.
*/
- (void)scheduleTransaction:(facebook::react::MountingCoordinator::Shared)mountingCoordinator;
- (void)scheduleTransaction:(std::shared_ptr<const facebook::react::MountingCoordinator>)mountingCoordinator;

/**
* Dispatch a command to be performed on the main thread.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ - (void)detachSurfaceFromView:(UIView *)view surfaceId:(SurfaceId)surfaceId
componentViewDescriptor:rootViewDescriptor];
}

- (void)scheduleTransaction:(MountingCoordinator::Shared)mountingCoordinator
- (void)scheduleTransaction:(std::shared_ptr<const MountingCoordinator>)mountingCoordinator
{
if (RCTIsMainQueue()) {
// Already on the proper thread, so:
Expand Down
5 changes: 3 additions & 2 deletions packages/react-native/React/Fabric/RCTScheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ NS_ASSUME_NONNULL_BEGIN
*/
@protocol RCTSchedulerDelegate

- (void)schedulerDidFinishTransaction:(facebook::react::MountingCoordinator::Shared)mountingCoordinator;
- (void)schedulerDidFinishTransaction:(std::shared_ptr<const facebook::react::MountingCoordinator>)mountingCoordinator;

- (void)schedulerShouldRenderTransactions:(facebook::react::MountingCoordinator::Shared)mountingCoordinator;
- (void)schedulerShouldRenderTransactions:
(std::shared_ptr<const facebook::react::MountingCoordinator>)mountingCoordinator;

- (void)schedulerDidDispatchCommand:(const facebook::react::ShadowView &)shadowView
commandName:(const std::string &)commandName
Expand Down
4 changes: 2 additions & 2 deletions packages/react-native/React/Fabric/RCTScheduler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
public:
SchedulerDelegateProxy(void *scheduler) : scheduler_(scheduler) {}

void schedulerDidFinishTransaction(const MountingCoordinator::Shared &mountingCoordinator) override
void schedulerDidFinishTransaction(const std::shared_ptr<const MountingCoordinator> &mountingCoordinator) override
{
RCTScheduler *scheduler = (__bridge RCTScheduler *)scheduler_;
[scheduler.delegate schedulerDidFinishTransaction:mountingCoordinator];
}

void schedulerShouldRenderTransactions(const MountingCoordinator::Shared &mountingCoordinator) override
void schedulerShouldRenderTransactions(const std::shared_ptr<const MountingCoordinator> &mountingCoordinator) override
{
RCTScheduler *scheduler = (__bridge RCTScheduler *)scheduler_;
[scheduler.delegate schedulerShouldRenderTransactions:mountingCoordinator];
Expand Down
4 changes: 2 additions & 2 deletions packages/react-native/React/Fabric/RCTSurfacePresenter.mm
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,12 @@ - (void)_applicationWillTerminate

#pragma mark - RCTSchedulerDelegate

- (void)schedulerDidFinishTransaction:(MountingCoordinator::Shared)mountingCoordinator
- (void)schedulerDidFinishTransaction:(std::shared_ptr<const MountingCoordinator>)mountingCoordinator
{
// no-op, we will flush the transaction from schedulerShouldRenderTransactions
}

- (void)schedulerShouldRenderTransactions:(MountingCoordinator::Shared)mountingCoordinator
- (void)schedulerShouldRenderTransactions:(std::shared_ptr<const MountingCoordinator>)mountingCoordinator
{
[_mountingManager scheduleTransaction:mountingCoordinator];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ FabricUIManagerBinding::getMountingManager(const char* locationHint) {
}

void FabricUIManagerBinding::schedulerDidFinishTransaction(
const MountingCoordinator::Shared& mountingCoordinator) {
const std::shared_ptr<const MountingCoordinator>& mountingCoordinator) {
// We shouldn't be pulling the transaction here (which triggers diffing of
// the trees to determine the mutations to run on the host platform),
// but we have to due to current limitations in the Android implementation.
Expand Down Expand Up @@ -564,7 +564,8 @@ void FabricUIManagerBinding::schedulerDidFinishTransaction(
}

void FabricUIManagerBinding::schedulerShouldRenderTransactions(
const MountingCoordinator::Shared& /* mountingCoordinator */) {
const std::shared_ptr<
const MountingCoordinator>& /* mountingCoordinator */) {
auto mountingManager =
getMountingManager("schedulerShouldRenderTransactions");
if (!mountingManager) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,12 @@ class FabricUIManagerBinding : public jni::HybridClass<FabricUIManagerBinding>,
jni::alias_ref<SurfaceHandlerBinding::jhybridobject> surfaceHandler);

void schedulerDidFinishTransaction(
const MountingCoordinator::Shared& mountingCoordinator) override;
const std::shared_ptr<const MountingCoordinator>& mountingCoordinator)
override;

void schedulerShouldRenderTransactions(
const MountingCoordinator::Shared& mountingCoordinator) override;
const std::shared_ptr<const MountingCoordinator>& mountingCoordinator)
override;

void schedulerDidRequestPreliminaryViewAllocation(
const ShadowNode& shadowNode) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ namespace facebook::react {
*/
class MountingCoordinator final {
public:
using Shared = std::shared_ptr<const MountingCoordinator>;

/*
* The constructor is meant to be used only inside `ShadowTree`, and it's
* `public` only to enable using with `std::make_shared<>`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ CommitMode ShadowTree::getCommitMode() const {
return commitMode_;
}

MountingCoordinator::Shared ShadowTree::getMountingCoordinator() const {
std::shared_ptr<const MountingCoordinator> ShadowTree::getMountingCoordinator()
const {
return mountingCoordinator_;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class ShadowTree final {
*/
void notifyDelegatesOfUpdates() const;

MountingCoordinator::Shared getMountingCoordinator() const;
std::shared_ptr<const MountingCoordinator> getMountingCoordinator() const;

private:
constexpr static ShadowTreeRevision::Number INITIAL_REVISION{0};
Expand All @@ -148,7 +148,7 @@ class ShadowTree final {
mutable ShadowTreeRevision currentRevision_; // Protected by `commitMutex_`.
mutable ShadowTreeRevision::Number
lastRevisionNumberWithNewState_; // Protected by `commitMutex_`.
MountingCoordinator::Shared mountingCoordinator_;
std::shared_ptr<const MountingCoordinator> mountingCoordinator_;
};

} // namespace facebook::react
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ShadowTreeDelegate {
* Called right after Shadow Tree commit a new state of the tree.
*/
virtual void shadowTreeDidFinishTransaction(
MountingCoordinator::Shared mountingCoordinator,
std::shared_ptr<const MountingCoordinator> mountingCoordinator,
bool mountSynchronously) const = 0;

virtual ~ShadowTreeDelegate() noexcept = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class DummyShadowTreeDelegate : public ShadowTreeDelegate {
};

void shadowTreeDidFinishTransaction(
MountingCoordinator::Shared mountingCoordinator,
std::shared_ptr<const MountingCoordinator> mountingCoordinator,
bool mountSynchronously) const override {};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void IntersectionObserverManager::observe(
// (like on the Web) and we'd send the initial notification there, but as
// we don't have it we have to run this check once and manually dispatch.
auto& shadowTreeRegistry = uiManager.getShadowTreeRegistry();
MountingCoordinator::Shared mountingCoordinator = nullptr;
std::shared_ptr<const MountingCoordinator> mountingCoordinator = nullptr;
RootShadowNode::Shared rootShadowNode = nullptr;
shadowTreeRegistry.visit(surfaceId, [&](const ShadowTree& shadowTree) {
mountingCoordinator = shadowTree.getMountingCoordinator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ void Scheduler::animationTick() const {
#pragma mark - UIManagerDelegate

void Scheduler::uiManagerDidFinishTransaction(
MountingCoordinator::Shared mountingCoordinator,
std::shared_ptr<const MountingCoordinator> mountingCoordinator,
bool mountSynchronously) {
SystraceSection s("Scheduler::uiManagerDidFinishTransaction");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class Scheduler final : public UIManagerDelegate {
#pragma mark - UIManagerDelegate

void uiManagerDidFinishTransaction(
MountingCoordinator::Shared mountingCoordinator,
std::shared_ptr<const MountingCoordinator> mountingCoordinator,
bool mountSynchronously) override;
void uiManagerDidCreateShadowNode(const ShadowNode& shadowNode) override;
void uiManagerDidDispatchCommand(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ class SchedulerDelegate {
* to construct a new one.
*/
virtual void schedulerDidFinishTransaction(
const MountingCoordinator::Shared& mountingCoordinator) = 0;
const std::shared_ptr<const MountingCoordinator>&
mountingCoordinator) = 0;

/*
* Called when the runtime scheduler decides that one-or-more previously
Expand All @@ -37,7 +38,8 @@ class SchedulerDelegate {
* correctly apply changes, due to changes in Props representation.
*/
virtual void schedulerShouldRenderTransactions(
const MountingCoordinator::Shared& mountingCoordinator) = 0;
const std::shared_ptr<const MountingCoordinator>&
mountingCoordinator) = 0;

/*
* Called right after a new ShadowNode was created.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ Size SurfaceManager::measureSurface(
return size;
}

MountingCoordinator::Shared SurfaceManager::findMountingCoordinator(
SurfaceId surfaceId) const noexcept {
auto mountingCoordinator = MountingCoordinator::Shared{};
std::shared_ptr<const MountingCoordinator>
SurfaceManager::findMountingCoordinator(SurfaceId surfaceId) const noexcept {
auto mountingCoordinator = std::shared_ptr<const MountingCoordinator>{};

visit(surfaceId, [&](const SurfaceHandler& surfaceHandler) {
mountingCoordinator = surfaceHandler.getMountingCoordinator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class SurfaceManager final {
const LayoutConstraints& layoutConstraints,
const LayoutContext& layoutContext) const noexcept;

MountingCoordinator::Shared findMountingCoordinator(
std::shared_ptr<const MountingCoordinator> findMountingCoordinator(
SurfaceId surfaceId) const noexcept;

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ RootShadowNode::Unshared UIManager::shadowTreeWillCommit(
}

void UIManager::shadowTreeDidFinishTransaction(
MountingCoordinator::Shared mountingCoordinator,
std::shared_ptr<const MountingCoordinator> mountingCoordinator,
bool mountSynchronously) const {
SystraceSection s("UIManager::shadowTreeDidFinishTransaction");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class UIManager final : public ShadowTreeDelegate {
#pragma mark - ShadowTreeDelegate

void shadowTreeDidFinishTransaction(
MountingCoordinator::Shared mountingCoordinator,
std::shared_ptr<const MountingCoordinator> mountingCoordinator,
bool mountSynchronously) const override;

RootShadowNode::Unshared shadowTreeWillCommit(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class UIManagerDelegate {
* For this moment the tree is already laid out and sealed.
*/
virtual void uiManagerDidFinishTransaction(
MountingCoordinator::Shared mountingCoordinator,
std::shared_ptr<const MountingCoordinator> mountingCoordinator,
bool mountSynchronously) = 0;

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class FakeShadowTreeDelegate : public ShadowTreeDelegate {
};

void shadowTreeDidFinishTransaction(
MountingCoordinator::Shared mountingCoordinator,
std::shared_ptr<const MountingCoordinator> mountingCoordinator,
bool mountSynchronously) const override {};
};

Expand Down

0 comments on commit 20d45d2

Please sign in to comment.