mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Rename Binding to FabricUIManagerBinding (#46705)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/46705 We have multiple classes in React Native Android acting as a binding layer (between C++ and Java, between C++ and JS). Make it more obvious this Binding is for (Android) FabricUIManager and flatten the (now) unused Binding interface. Changelog: [Android][Removed] BindingImpl is no longer part of the public interface Reviewed By: cortinico Differential Revision: D63536329 fbshipit-source-id: 329d184c1889fbe804995211cdd339b50a7c9234
This commit is contained in:
committed by
Facebook GitHub Bot
parent
8dd616410d
commit
18faf68b48
@@ -2578,39 +2578,6 @@ public abstract interface class com/facebook/react/devsupport/interfaces/StackFr
|
||||
public abstract fun toJSON ()Lorg/json/JSONObject;
|
||||
}
|
||||
|
||||
public abstract interface class com/facebook/react/fabric/Binding {
|
||||
public abstract fun drainPreallocateViewsQueue ()V
|
||||
public abstract fun driveCxxAnimations ()V
|
||||
public abstract fun getInspectorDataForInstance (Lcom/facebook/react/fabric/events/EventEmitterWrapper;)Lcom/facebook/react/bridge/ReadableNativeMap;
|
||||
public abstract fun register (Lcom/facebook/react/bridge/RuntimeExecutor;Lcom/facebook/react/bridge/RuntimeScheduler;Lcom/facebook/react/fabric/FabricUIManager;Lcom/facebook/react/fabric/events/EventBeatManager;Lcom/facebook/react/fabric/ComponentFactory;Lcom/facebook/react/fabric/ReactNativeConfig;)V
|
||||
public abstract fun reportMount (I)V
|
||||
public abstract fun setConstraints (IFFFFFFZZ)V
|
||||
public abstract fun setPixelDensity (F)V
|
||||
public abstract fun startSurface (ILjava/lang/String;Lcom/facebook/react/bridge/NativeMap;)V
|
||||
public abstract fun startSurfaceWithConstraints (ILjava/lang/String;Lcom/facebook/react/bridge/NativeMap;FFFFFFZZ)V
|
||||
public abstract fun startSurfaceWithSurfaceHandler (ILcom/facebook/react/fabric/SurfaceHandlerBinding;Z)V
|
||||
public abstract fun stopSurface (I)V
|
||||
public abstract fun stopSurfaceWithSurfaceHandler (Lcom/facebook/react/fabric/SurfaceHandlerBinding;)V
|
||||
public abstract fun unregister ()V
|
||||
}
|
||||
|
||||
public final class com/facebook/react/fabric/BindingImpl : com/facebook/react/fabric/Binding {
|
||||
public fun <init> ()V
|
||||
public fun drainPreallocateViewsQueue ()V
|
||||
public fun driveCxxAnimations ()V
|
||||
public fun getInspectorDataForInstance (Lcom/facebook/react/fabric/events/EventEmitterWrapper;)Lcom/facebook/react/bridge/ReadableNativeMap;
|
||||
public fun register (Lcom/facebook/react/bridge/RuntimeExecutor;Lcom/facebook/react/bridge/RuntimeScheduler;Lcom/facebook/react/fabric/FabricUIManager;Lcom/facebook/react/fabric/events/EventBeatManager;Lcom/facebook/react/fabric/ComponentFactory;Lcom/facebook/react/fabric/ReactNativeConfig;)V
|
||||
public fun reportMount (I)V
|
||||
public fun setConstraints (IFFFFFFZZ)V
|
||||
public fun setPixelDensity (F)V
|
||||
public fun startSurface (ILjava/lang/String;Lcom/facebook/react/bridge/NativeMap;)V
|
||||
public fun startSurfaceWithConstraints (ILjava/lang/String;Lcom/facebook/react/bridge/NativeMap;FFFFFFZZ)V
|
||||
public fun startSurfaceWithSurfaceHandler (ILcom/facebook/react/fabric/SurfaceHandlerBinding;Z)V
|
||||
public fun stopSurface (I)V
|
||||
public fun stopSurfaceWithSurfaceHandler (Lcom/facebook/react/fabric/SurfaceHandlerBinding;)V
|
||||
public fun unregister ()V
|
||||
}
|
||||
|
||||
public final class com/facebook/react/fabric/ComponentFactory {
|
||||
public fun <init> ()V
|
||||
}
|
||||
@@ -2715,7 +2682,7 @@ public class com/facebook/react/fabric/FabricUIManager : com/facebook/react/brid
|
||||
public fun resolveView (I)Landroid/view/View;
|
||||
public fun sendAccessibilityEvent (II)V
|
||||
public fun sendAccessibilityEventFromJS (IILjava/lang/String;)V
|
||||
public fun setBinding (Lcom/facebook/react/fabric/Binding;)V
|
||||
public fun setBinding (Lcom/facebook/react/fabric/FabricUIManagerBinding;)V
|
||||
public fun setJSResponder (IIIZ)V
|
||||
public fun startSurface (Landroid/view/View;Ljava/lang/String;Lcom/facebook/react/bridge/WritableMap;II)I
|
||||
public fun startSurface (Lcom/facebook/react/interfaces/fabric/SurfaceHandler;Landroid/content/Context;Landroid/view/View;)V
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.fabric
|
||||
|
||||
import com.facebook.react.bridge.NativeMap
|
||||
import com.facebook.react.bridge.ReadableNativeMap
|
||||
import com.facebook.react.bridge.RuntimeExecutor
|
||||
import com.facebook.react.bridge.RuntimeScheduler
|
||||
import com.facebook.react.fabric.events.EventBeatManager
|
||||
import com.facebook.react.fabric.events.EventEmitterWrapper
|
||||
|
||||
public interface Binding {
|
||||
public fun startSurface(surfaceId: Int, moduleName: String, initialProps: NativeMap)
|
||||
|
||||
public fun startSurfaceWithConstraints(
|
||||
surfaceId: Int,
|
||||
moduleName: String,
|
||||
initialProps: NativeMap,
|
||||
minWidth: Float,
|
||||
maxWidth: Float,
|
||||
minHeight: Float,
|
||||
maxHeight: Float,
|
||||
offsetX: Float,
|
||||
offsetY: Float,
|
||||
isRTL: Boolean,
|
||||
doLeftAndRightSwapInRTL: Boolean
|
||||
)
|
||||
|
||||
public fun startSurfaceWithSurfaceHandler(
|
||||
surfaceId: Int,
|
||||
surfaceHandler: SurfaceHandlerBinding,
|
||||
isMountable: Boolean
|
||||
)
|
||||
|
||||
public fun stopSurface(surfaceId: Int)
|
||||
|
||||
public fun stopSurfaceWithSurfaceHandler(surfaceHandler: SurfaceHandlerBinding)
|
||||
|
||||
public fun setPixelDensity(pointScaleFactor: Float)
|
||||
|
||||
public fun setConstraints(
|
||||
surfaceId: Int,
|
||||
minWidth: Float,
|
||||
maxWidth: Float,
|
||||
minHeight: Float,
|
||||
maxHeight: Float,
|
||||
offsetX: Float,
|
||||
offsetY: Float,
|
||||
isRTL: Boolean,
|
||||
doLeftAndRightSwapInRTL: Boolean
|
||||
)
|
||||
|
||||
public fun driveCxxAnimations()
|
||||
|
||||
public fun drainPreallocateViewsQueue()
|
||||
|
||||
public fun reportMount(surfaceId: Int)
|
||||
|
||||
public fun getInspectorDataForInstance(
|
||||
eventEmitterWrapper: EventEmitterWrapper?
|
||||
): ReadableNativeMap?
|
||||
|
||||
public fun register(
|
||||
runtimeExecutor: RuntimeExecutor,
|
||||
runtimeScheduler: RuntimeScheduler,
|
||||
fabricUIManager: FabricUIManager,
|
||||
eventBeatManager: EventBeatManager,
|
||||
componentFactory: ComponentFactory,
|
||||
reactNativeConfig: ReactNativeConfig
|
||||
)
|
||||
|
||||
public fun unregister()
|
||||
}
|
||||
+3
-3
@@ -158,7 +158,7 @@ public class FabricUIManager
|
||||
FabricSoLoader.staticInit();
|
||||
}
|
||||
|
||||
@Nullable private Binding mBinding;
|
||||
@Nullable private FabricUIManagerBinding mBinding;
|
||||
@NonNull private final ReactApplicationContext mReactApplicationContext;
|
||||
@NonNull private final MountingManager mMountingManager;
|
||||
@NonNull private final EventDispatcher mEventDispatcher;
|
||||
@@ -872,7 +872,7 @@ public class FabricUIManager
|
||||
}
|
||||
}
|
||||
|
||||
public void setBinding(Binding binding) {
|
||||
public void setBinding(FabricUIManagerBinding binding) {
|
||||
mBinding = binding;
|
||||
}
|
||||
|
||||
@@ -1271,7 +1271,7 @@ public class FabricUIManager
|
||||
public void run() {
|
||||
mMountNotificationScheduled = false;
|
||||
|
||||
final @Nullable Binding binding = mBinding;
|
||||
final @Nullable FabricUIManagerBinding binding = mBinding;
|
||||
if (binding == null || mDestroyed) {
|
||||
mMountedSurfaceIds.clear();
|
||||
return;
|
||||
|
||||
+20
-18
@@ -8,7 +8,7 @@
|
||||
package com.facebook.react.fabric
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import com.facebook.jni.HybridData
|
||||
import com.facebook.jni.HybridClassBase
|
||||
import com.facebook.proguard.annotations.DoNotStrip
|
||||
import com.facebook.react.bridge.NativeMap
|
||||
import com.facebook.react.bridge.ReadableNativeMap
|
||||
@@ -21,8 +21,12 @@ import com.facebook.react.uimanager.PixelUtil.getDisplayMetricDensity
|
||||
|
||||
@DoNotStrip
|
||||
@SuppressLint("MissingNativeLoadLibrary")
|
||||
public class BindingImpl : Binding {
|
||||
@DoNotStrip @Suppress("NoHungarianNotation") private val mHybridData: HybridData = initHybrid()
|
||||
internal class FabricUIManagerBinding : HybridClassBase() {
|
||||
init {
|
||||
initHybrid()
|
||||
}
|
||||
|
||||
private external fun initHybrid()
|
||||
|
||||
private external fun installFabricUIManager(
|
||||
runtimeExecutor: RuntimeExecutor,
|
||||
@@ -33,9 +37,9 @@ public class BindingImpl : Binding {
|
||||
reactNativeConfig: Any
|
||||
)
|
||||
|
||||
external override fun startSurface(surfaceId: Int, moduleName: String, initialProps: NativeMap)
|
||||
public external fun startSurface(surfaceId: Int, moduleName: String, initialProps: NativeMap)
|
||||
|
||||
external override fun startSurfaceWithConstraints(
|
||||
public external fun startSurfaceWithConstraints(
|
||||
surfaceId: Int,
|
||||
moduleName: String,
|
||||
initialProps: NativeMap,
|
||||
@@ -49,19 +53,19 @@ public class BindingImpl : Binding {
|
||||
doLeftAndRightSwapInRTL: Boolean
|
||||
)
|
||||
|
||||
external override fun startSurfaceWithSurfaceHandler(
|
||||
public external fun startSurfaceWithSurfaceHandler(
|
||||
surfaceId: Int,
|
||||
surfaceHandler: SurfaceHandlerBinding,
|
||||
isMountable: Boolean
|
||||
)
|
||||
|
||||
external override fun stopSurface(surfaceId: Int)
|
||||
public external fun stopSurface(surfaceId: Int)
|
||||
|
||||
external override fun stopSurfaceWithSurfaceHandler(surfaceHandler: SurfaceHandlerBinding)
|
||||
public external fun stopSurfaceWithSurfaceHandler(surfaceHandler: SurfaceHandlerBinding)
|
||||
|
||||
external override fun setPixelDensity(pointScaleFactor: Float)
|
||||
public external fun setPixelDensity(pointScaleFactor: Float)
|
||||
|
||||
external override fun setConstraints(
|
||||
public external fun setConstraints(
|
||||
surfaceId: Int,
|
||||
minWidth: Float,
|
||||
maxWidth: Float,
|
||||
@@ -73,17 +77,17 @@ public class BindingImpl : Binding {
|
||||
doLeftAndRightSwapInRTL: Boolean
|
||||
)
|
||||
|
||||
external override fun driveCxxAnimations()
|
||||
public external fun driveCxxAnimations()
|
||||
|
||||
external override fun drainPreallocateViewsQueue()
|
||||
public external fun drainPreallocateViewsQueue()
|
||||
|
||||
external override fun reportMount(surfaceId: Int)
|
||||
public external fun reportMount(surfaceId: Int)
|
||||
|
||||
external override fun getInspectorDataForInstance(
|
||||
public external fun getInspectorDataForInstance(
|
||||
eventEmitterWrapper: EventEmitterWrapper?
|
||||
): ReadableNativeMap?
|
||||
|
||||
override fun register(
|
||||
public fun register(
|
||||
runtimeExecutor: RuntimeExecutor,
|
||||
runtimeScheduler: RuntimeScheduler,
|
||||
fabricUIManager: FabricUIManager,
|
||||
@@ -104,7 +108,7 @@ public class BindingImpl : Binding {
|
||||
|
||||
private external fun uninstallFabricUIManager()
|
||||
|
||||
override fun unregister() {
|
||||
public fun unregister() {
|
||||
uninstallFabricUIManager()
|
||||
}
|
||||
|
||||
@@ -113,7 +117,5 @@ public class BindingImpl : Binding {
|
||||
FabricSoLoader.staticInit()
|
||||
MapBufferSoLoader.staticInit()
|
||||
}
|
||||
|
||||
@JvmStatic private external fun initHybrid(): HybridData
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -47,7 +47,7 @@ public class FabricUIManagerProviderImpl implements UIManagerProvider {
|
||||
|
||||
Systrace.beginSection(
|
||||
Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "FabricUIManagerProviderImpl.registerBinding");
|
||||
final Binding binding = new BindingImpl();
|
||||
final FabricUIManagerBinding binding = new FabricUIManagerBinding();
|
||||
|
||||
CatalystInstance catalystInstance = reactApplicationContext.getCatalystInstance();
|
||||
|
||||
|
||||
+2
-3
@@ -40,10 +40,9 @@ import com.facebook.react.bridge.queue.ReactQueueConfigurationImpl;
|
||||
import com.facebook.react.bridge.queue.ReactQueueConfigurationSpec;
|
||||
import com.facebook.react.devsupport.StackTraceHelper;
|
||||
import com.facebook.react.devsupport.interfaces.DevSupportManager;
|
||||
import com.facebook.react.fabric.Binding;
|
||||
import com.facebook.react.fabric.BindingImpl;
|
||||
import com.facebook.react.fabric.ComponentFactory;
|
||||
import com.facebook.react.fabric.FabricUIManager;
|
||||
import com.facebook.react.fabric.FabricUIManagerBinding;
|
||||
import com.facebook.react.fabric.events.EventBeatManager;
|
||||
import com.facebook.react.interfaces.exceptionmanager.ReactJsExceptionHandler;
|
||||
import com.facebook.react.internal.AndroidChoreographerProvider;
|
||||
@@ -272,7 +271,7 @@ final class ReactInstance {
|
||||
// Misc initialization that needs to be done before Fabric init
|
||||
DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(mBridgelessReactContext);
|
||||
|
||||
Binding binding = new BindingImpl();
|
||||
FabricUIManagerBinding binding = new FabricUIManagerBinding();
|
||||
binding.register(
|
||||
getBufferedRuntimeExecutor(),
|
||||
getRuntimeScheduler(),
|
||||
|
||||
+55
-48
@@ -5,7 +5,7 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include "Binding.h"
|
||||
#include "FabricUIManagerBinding.h"
|
||||
|
||||
#include "AsyncEventBeat.h"
|
||||
#include "ComponentFactory.h"
|
||||
@@ -34,13 +34,12 @@
|
||||
|
||||
namespace facebook::react {
|
||||
|
||||
jni::local_ref<Binding::jhybriddata> Binding::initHybrid(
|
||||
jni::alias_ref<jclass>) {
|
||||
return makeCxxInstance();
|
||||
void FabricUIManagerBinding::initHybrid(jni::alias_ref<jhybridobject> jobj) {
|
||||
setCxxInstance(jobj);
|
||||
}
|
||||
|
||||
// Thread-safe getter
|
||||
std::shared_ptr<Scheduler> Binding::getScheduler() {
|
||||
std::shared_ptr<Scheduler> FabricUIManagerBinding::getScheduler() {
|
||||
std::shared_lock lock(installMutex_);
|
||||
// Need to return a copy of the shared_ptr to make sure this is safe if called
|
||||
// concurrently with uninstallFabricUIManager
|
||||
@@ -48,7 +47,7 @@ std::shared_ptr<Scheduler> Binding::getScheduler() {
|
||||
}
|
||||
|
||||
jni::local_ref<ReadableNativeMap::jhybridobject>
|
||||
Binding::getInspectorDataForInstance(
|
||||
FabricUIManagerBinding::getInspectorDataForInstance(
|
||||
jni::alias_ref<EventEmitterWrapper::javaobject> eventEmitterWrapper) {
|
||||
auto scheduler = getScheduler();
|
||||
if (!scheduler) {
|
||||
@@ -81,18 +80,18 @@ static bool getFeatureFlagValue(const char* name) {
|
||||
static const auto reactFeatureFlagsClass =
|
||||
jni::findClassStatic(kReactFeatureFlagsJavaDescriptor);
|
||||
const auto field = reactFeatureFlagsClass->getStaticField<jboolean>(name);
|
||||
return reactFeatureFlagsClass->getStaticFieldValue(field);
|
||||
return reactFeatureFlagsClass->getStaticFieldValue(field) != 0;
|
||||
}
|
||||
|
||||
void Binding::setPixelDensity(float pointScaleFactor) {
|
||||
void FabricUIManagerBinding::setPixelDensity(float pointScaleFactor) {
|
||||
pointScaleFactor_ = pointScaleFactor;
|
||||
}
|
||||
|
||||
void Binding::driveCxxAnimations() {
|
||||
void FabricUIManagerBinding::driveCxxAnimations() {
|
||||
getScheduler()->animationTick();
|
||||
}
|
||||
|
||||
void Binding::drainPreallocateViewsQueue() {
|
||||
void FabricUIManagerBinding::drainPreallocateViewsQueue() {
|
||||
auto mountingManager = getMountingManager("drainPreallocateViewsQueue");
|
||||
if (!mountingManager) {
|
||||
return;
|
||||
@@ -100,7 +99,7 @@ void Binding::drainPreallocateViewsQueue() {
|
||||
mountingManager->drainPreallocateViewsQueue();
|
||||
}
|
||||
|
||||
void Binding::reportMount(SurfaceId surfaceId) {
|
||||
void FabricUIManagerBinding::reportMount(SurfaceId surfaceId) {
|
||||
if (ReactNativeFeatureFlags::
|
||||
fixMountingCoordinatorReportedPendingTransactionsOnAndroid()) {
|
||||
// This is a fix for `MountingCoordinator::hasPendingTransactions` on
|
||||
@@ -141,7 +140,7 @@ void Binding::reportMount(SurfaceId surfaceId) {
|
||||
#pragma mark - Surface management
|
||||
|
||||
// Used by bridgeless
|
||||
void Binding::startSurfaceWithSurfaceHandler(
|
||||
void FabricUIManagerBinding::startSurfaceWithSurfaceHandler(
|
||||
jint surfaceId,
|
||||
jni::alias_ref<SurfaceHandlerBinding::jhybridobject> surfaceHandlerBinding,
|
||||
jboolean isMountable) {
|
||||
@@ -185,7 +184,7 @@ void Binding::startSurfaceWithSurfaceHandler(
|
||||
}
|
||||
|
||||
// Used by non-bridgeless+Fabric
|
||||
void Binding::startSurface(
|
||||
void FabricUIManagerBinding::startSurface(
|
||||
jint surfaceId,
|
||||
jni::alias_ref<jstring> moduleName,
|
||||
NativeMap* initialProps) {
|
||||
@@ -232,7 +231,7 @@ void Binding::startSurface(
|
||||
}
|
||||
|
||||
// Used by non-bridgeless+Fabric
|
||||
void Binding::startSurfaceWithConstraints(
|
||||
void FabricUIManagerBinding::startSurfaceWithConstraints(
|
||||
jint surfaceId,
|
||||
jni::alias_ref<jstring> moduleName,
|
||||
NativeMap* initialProps,
|
||||
@@ -267,12 +266,12 @@ void Binding::startSurfaceWithConstraints(
|
||||
context.viewportOffset =
|
||||
Point{offsetX / pointScaleFactor_, offsetY / pointScaleFactor_};
|
||||
context.pointScaleFactor = {pointScaleFactor_};
|
||||
context.swapLeftAndRightInRTL = doLeftAndRightSwapInRTL;
|
||||
context.swapLeftAndRightInRTL = doLeftAndRightSwapInRTL != 0;
|
||||
LayoutConstraints constraints = {};
|
||||
constraints.minimumSize = minimumSize;
|
||||
constraints.maximumSize = maximumSize;
|
||||
constraints.layoutDirection =
|
||||
isRTL ? LayoutDirection::RightToLeft : LayoutDirection::LeftToRight;
|
||||
isRTL != 0 ? LayoutDirection::RightToLeft : LayoutDirection::LeftToRight;
|
||||
|
||||
auto surfaceHandler = SurfaceHandler{moduleName->toStdString(), surfaceId};
|
||||
surfaceHandler.setContextContainer(scheduler->getContextContainer());
|
||||
@@ -303,7 +302,7 @@ void Binding::startSurfaceWithConstraints(
|
||||
}
|
||||
|
||||
// Used by non-bridgeless+Fabric
|
||||
void Binding::stopSurface(jint surfaceId) {
|
||||
void FabricUIManagerBinding::stopSurface(jint surfaceId) {
|
||||
SystraceSection s("FabricUIManagerBinding::stopSurface");
|
||||
if (enableFabricLogs_) {
|
||||
LOG(WARNING) << "Binding::stopSurface() was called (address: " << this
|
||||
@@ -342,7 +341,7 @@ void Binding::stopSurface(jint surfaceId) {
|
||||
}
|
||||
|
||||
// Used by bridgeless
|
||||
void Binding::stopSurfaceWithSurfaceHandler(
|
||||
void FabricUIManagerBinding::stopSurfaceWithSurfaceHandler(
|
||||
jni::alias_ref<SurfaceHandlerBinding::jhybridobject>
|
||||
surfaceHandlerBinding) {
|
||||
SystraceSection s("FabricUIManagerBinding::stopSurfaceWithSurfaceHandler");
|
||||
@@ -375,7 +374,7 @@ void Binding::stopSurfaceWithSurfaceHandler(
|
||||
mountingManager->onSurfaceStop(surfaceHandler.getSurfaceId());
|
||||
}
|
||||
|
||||
void Binding::setConstraints(
|
||||
void FabricUIManagerBinding::setConstraints(
|
||||
jint surfaceId,
|
||||
jfloat minWidth,
|
||||
jfloat maxWidth,
|
||||
@@ -402,7 +401,7 @@ void Binding::setConstraints(
|
||||
context.viewportOffset =
|
||||
Point{offsetX / pointScaleFactor_, offsetY / pointScaleFactor_};
|
||||
context.pointScaleFactor = {pointScaleFactor_};
|
||||
context.swapLeftAndRightInRTL = doLeftAndRightSwapInRTL;
|
||||
context.swapLeftAndRightInRTL = doLeftAndRightSwapInRTL != 0;
|
||||
LayoutConstraints constraints = {};
|
||||
constraints.minimumSize = minimumSize;
|
||||
constraints.maximumSize = maximumSize;
|
||||
@@ -426,7 +425,7 @@ void Binding::setConstraints(
|
||||
|
||||
#pragma mark - Install/uninstall java binding
|
||||
|
||||
void Binding::installFabricUIManager(
|
||||
void FabricUIManagerBinding::installFabricUIManager(
|
||||
jni::alias_ref<JRuntimeExecutor::javaobject> runtimeExecutorHolder,
|
||||
jni::alias_ref<JRuntimeScheduler::javaobject> runtimeSchedulerHolder,
|
||||
jni::alias_ref<JFabricUIManager::javaobject> javaUIManager,
|
||||
@@ -506,7 +505,7 @@ void Binding::installFabricUIManager(
|
||||
std::make_shared<Scheduler>(toolbox, animationDriver_.get(), this);
|
||||
}
|
||||
|
||||
void Binding::uninstallFabricUIManager() {
|
||||
void FabricUIManagerBinding::uninstallFabricUIManager() {
|
||||
if (enableFabricLogs_) {
|
||||
LOG(WARNING) << "Binding::uninstallFabricUIManager() was called (address: "
|
||||
<< this << ").";
|
||||
@@ -519,8 +518,8 @@ void Binding::uninstallFabricUIManager() {
|
||||
reactNativeConfig_ = nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<FabricMountingManager> Binding::getMountingManager(
|
||||
const char* locationHint) {
|
||||
std::shared_ptr<FabricMountingManager>
|
||||
FabricUIManagerBinding::getMountingManager(const char* locationHint) {
|
||||
std::shared_lock lock(installMutex_);
|
||||
if (!mountingManager_) {
|
||||
LOG(ERROR) << "FabricMountingManager::" << locationHint
|
||||
@@ -531,7 +530,7 @@ std::shared_ptr<FabricMountingManager> Binding::getMountingManager(
|
||||
return mountingManager_;
|
||||
}
|
||||
|
||||
void Binding::schedulerDidFinishTransaction(
|
||||
void FabricUIManagerBinding::schedulerDidFinishTransaction(
|
||||
const MountingCoordinator::Shared& 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),
|
||||
@@ -560,8 +559,8 @@ void Binding::schedulerDidFinishTransaction(
|
||||
}
|
||||
}
|
||||
|
||||
void Binding::schedulerShouldRenderTransactions(
|
||||
const MountingCoordinator::Shared& mountingCoordinator) {
|
||||
void FabricUIManagerBinding::schedulerShouldRenderTransactions(
|
||||
const MountingCoordinator::Shared& /* mountingCoordinator */) {
|
||||
auto mountingManager =
|
||||
getMountingManager("schedulerShouldRenderTransactions");
|
||||
if (!mountingManager) {
|
||||
@@ -592,7 +591,7 @@ void Binding::schedulerShouldRenderTransactions(
|
||||
}
|
||||
}
|
||||
|
||||
void Binding::schedulerDidRequestPreliminaryViewAllocation(
|
||||
void FabricUIManagerBinding::schedulerDidRequestPreliminaryViewAllocation(
|
||||
const ShadowNode& shadowNode) {
|
||||
auto mountingManager = getMountingManager("preallocateView");
|
||||
if (!mountingManager) {
|
||||
@@ -614,7 +613,7 @@ void Binding::schedulerDidRequestPreliminaryViewAllocation(
|
||||
}
|
||||
}
|
||||
|
||||
void Binding::schedulerDidDispatchCommand(
|
||||
void FabricUIManagerBinding::schedulerDidDispatchCommand(
|
||||
const ShadowView& shadowView,
|
||||
const std::string& commandName,
|
||||
const folly::dynamic& args) {
|
||||
@@ -625,7 +624,7 @@ void Binding::schedulerDidDispatchCommand(
|
||||
mountingManager->dispatchCommand(shadowView, commandName, args);
|
||||
}
|
||||
|
||||
void Binding::schedulerDidSendAccessibilityEvent(
|
||||
void FabricUIManagerBinding::schedulerDidSendAccessibilityEvent(
|
||||
const ShadowView& shadowView,
|
||||
const std::string& eventType) {
|
||||
auto mountingManager =
|
||||
@@ -636,7 +635,7 @@ void Binding::schedulerDidSendAccessibilityEvent(
|
||||
mountingManager->sendAccessibilityEvent(shadowView, eventType);
|
||||
}
|
||||
|
||||
void Binding::schedulerDidSetIsJSResponder(
|
||||
void FabricUIManagerBinding::schedulerDidSetIsJSResponder(
|
||||
const ShadowView& shadowView,
|
||||
bool isJSResponder,
|
||||
bool blockNativeResponder) {
|
||||
@@ -648,7 +647,7 @@ void Binding::schedulerDidSetIsJSResponder(
|
||||
shadowView, isJSResponder, blockNativeResponder);
|
||||
}
|
||||
|
||||
void Binding::onAnimationStarted() {
|
||||
void FabricUIManagerBinding::onAnimationStarted() {
|
||||
auto mountingManager = getMountingManager("onAnimationStarted");
|
||||
if (!mountingManager) {
|
||||
return;
|
||||
@@ -656,7 +655,7 @@ void Binding::onAnimationStarted() {
|
||||
mountingManager->onAnimationStarted();
|
||||
}
|
||||
|
||||
void Binding::onAllAnimationsComplete() {
|
||||
void FabricUIManagerBinding::onAllAnimationsComplete() {
|
||||
auto mountingManager = getMountingManager("onAnimationComplete");
|
||||
if (!mountingManager) {
|
||||
return;
|
||||
@@ -664,31 +663,39 @@ void Binding::onAllAnimationsComplete() {
|
||||
mountingManager->onAllAnimationsComplete();
|
||||
}
|
||||
|
||||
void Binding::registerNatives() {
|
||||
void FabricUIManagerBinding::registerNatives() {
|
||||
registerHybrid({
|
||||
makeNativeMethod("initHybrid", Binding::initHybrid),
|
||||
makeNativeMethod("initHybrid", FabricUIManagerBinding::initHybrid),
|
||||
makeNativeMethod(
|
||||
"installFabricUIManager", Binding::installFabricUIManager),
|
||||
makeNativeMethod("startSurface", Binding::startSurface),
|
||||
"installFabricUIManager",
|
||||
FabricUIManagerBinding::installFabricUIManager),
|
||||
makeNativeMethod("startSurface", FabricUIManagerBinding::startSurface),
|
||||
makeNativeMethod(
|
||||
"getInspectorDataForInstance", Binding::getInspectorDataForInstance),
|
||||
"getInspectorDataForInstance",
|
||||
FabricUIManagerBinding::getInspectorDataForInstance),
|
||||
makeNativeMethod(
|
||||
"startSurfaceWithConstraints", Binding::startSurfaceWithConstraints),
|
||||
makeNativeMethod("stopSurface", Binding::stopSurface),
|
||||
makeNativeMethod("setConstraints", Binding::setConstraints),
|
||||
makeNativeMethod("setPixelDensity", Binding::setPixelDensity),
|
||||
makeNativeMethod("driveCxxAnimations", Binding::driveCxxAnimations),
|
||||
"startSurfaceWithConstraints",
|
||||
FabricUIManagerBinding::startSurfaceWithConstraints),
|
||||
makeNativeMethod("stopSurface", FabricUIManagerBinding::stopSurface),
|
||||
makeNativeMethod(
|
||||
"drainPreallocateViewsQueue", Binding::drainPreallocateViewsQueue),
|
||||
makeNativeMethod("reportMount", Binding::reportMount),
|
||||
"setConstraints", FabricUIManagerBinding::setConstraints),
|
||||
makeNativeMethod(
|
||||
"uninstallFabricUIManager", Binding::uninstallFabricUIManager),
|
||||
"setPixelDensity", FabricUIManagerBinding::setPixelDensity),
|
||||
makeNativeMethod(
|
||||
"driveCxxAnimations", FabricUIManagerBinding::driveCxxAnimations),
|
||||
makeNativeMethod(
|
||||
"drainPreallocateViewsQueue",
|
||||
FabricUIManagerBinding::drainPreallocateViewsQueue),
|
||||
makeNativeMethod("reportMount", FabricUIManagerBinding::reportMount),
|
||||
makeNativeMethod(
|
||||
"uninstallFabricUIManager",
|
||||
FabricUIManagerBinding::uninstallFabricUIManager),
|
||||
makeNativeMethod(
|
||||
"startSurfaceWithSurfaceHandler",
|
||||
Binding::startSurfaceWithSurfaceHandler),
|
||||
FabricUIManagerBinding::startSurfaceWithSurfaceHandler),
|
||||
makeNativeMethod(
|
||||
"stopSurfaceWithSurfaceHandler",
|
||||
Binding::stopSurfaceWithSurfaceHandler),
|
||||
FabricUIManagerBinding::stopSurfaceWithSurfaceHandler),
|
||||
});
|
||||
}
|
||||
|
||||
+5
-11
@@ -35,16 +35,12 @@ class LayoutAnimationDriver;
|
||||
class ReactNativeConfig;
|
||||
class Scheduler;
|
||||
|
||||
struct JBinding : public jni::JavaClass<JBinding> {
|
||||
constexpr static auto kJavaDescriptor = "Lcom/facebook/react/fabric/Binding;";
|
||||
};
|
||||
|
||||
class Binding : public jni::HybridClass<Binding, JBinding>,
|
||||
public SchedulerDelegate,
|
||||
public LayoutAnimationStatusDelegate {
|
||||
class FabricUIManagerBinding : public jni::HybridClass<FabricUIManagerBinding>,
|
||||
public SchedulerDelegate,
|
||||
public LayoutAnimationStatusDelegate {
|
||||
public:
|
||||
constexpr static const char* const kJavaDescriptor =
|
||||
"Lcom/facebook/react/fabric/BindingImpl;";
|
||||
"Lcom/facebook/react/fabric/FabricUIManagerBinding;";
|
||||
|
||||
static void registerNatives();
|
||||
|
||||
@@ -65,7 +61,7 @@ class Binding : public jni::HybridClass<Binding, JBinding>,
|
||||
jni::local_ref<ReadableNativeMap::jhybridobject> getInspectorDataForInstance(
|
||||
jni::alias_ref<EventEmitterWrapper::javaobject> eventEmitterWrapper);
|
||||
|
||||
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jclass>);
|
||||
static void initHybrid(jni::alias_ref<jhybridobject> jobj);
|
||||
|
||||
void installFabricUIManager(
|
||||
jni::alias_ref<JRuntimeExecutor::javaobject> runtimeExecutorHolder,
|
||||
@@ -151,8 +147,6 @@ class Binding : public jni::HybridClass<Binding, JBinding>,
|
||||
|
||||
std::shared_ptr<LayoutAnimationDriver> animationDriver_;
|
||||
|
||||
BackgroundExecutor backgroundExecutor_;
|
||||
|
||||
// Roots not created through ReactSurface (non-bridgeless) will store their
|
||||
// SurfaceHandler here, for other roots we keep a weak reference to the Java
|
||||
// owner
|
||||
@@ -7,15 +7,14 @@
|
||||
|
||||
#include "JFabricUIManager.h"
|
||||
|
||||
#include "Binding.h"
|
||||
#include "FabricUIManagerBinding.h"
|
||||
|
||||
namespace facebook::react {
|
||||
|
||||
Binding* JFabricUIManager::getBinding() {
|
||||
FabricUIManagerBinding* JFabricUIManager::getBinding() {
|
||||
static const auto bindingField =
|
||||
javaClassStatic()->getField<JBinding::javaobject>("mBinding");
|
||||
|
||||
return jni::static_ref_cast<Binding::javaobject>(getFieldValue(bindingField))
|
||||
->cthis();
|
||||
javaClassStatic()->getField<FabricUIManagerBinding::javaobject>(
|
||||
"mBinding");
|
||||
return getFieldValue(bindingField)->cthis();
|
||||
}
|
||||
} // namespace facebook::react
|
||||
|
||||
@@ -11,14 +11,14 @@
|
||||
|
||||
namespace facebook::react {
|
||||
|
||||
class Binding;
|
||||
class FabricUIManagerBinding;
|
||||
|
||||
class JFabricUIManager : public jni::JavaClass<JFabricUIManager> {
|
||||
public:
|
||||
static constexpr auto kJavaDescriptor =
|
||||
"Lcom/facebook/react/fabric/FabricUIManager;";
|
||||
|
||||
Binding* getBinding();
|
||||
FabricUIManagerBinding* getBinding();
|
||||
};
|
||||
|
||||
} // namespace facebook::react
|
||||
|
||||
@@ -7,19 +7,19 @@
|
||||
|
||||
#include <fbjni/fbjni.h>
|
||||
|
||||
#include "Binding.h"
|
||||
#include "ComponentFactory.h"
|
||||
#include "EventBeatManager.h"
|
||||
#include "EventEmitterWrapper.h"
|
||||
#include "FabricUIManagerBinding.h"
|
||||
#include "JEmptyReactNativeConfig.h"
|
||||
#include "StateWrapperImpl.h"
|
||||
#include "SurfaceHandlerBinding.h"
|
||||
|
||||
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
|
||||
return facebook::jni::initialize(vm, [] {
|
||||
facebook::react::Binding::registerNatives();
|
||||
facebook::react::EventBeatManager::registerNatives();
|
||||
facebook::react::EventEmitterWrapper::registerNatives();
|
||||
facebook::react::FabricUIManagerBinding::registerNatives();
|
||||
facebook::react::StateWrapperImpl::registerNatives();
|
||||
facebook::react::ComponentFactory::registerNatives();
|
||||
facebook::react::SurfaceHandlerBinding::registerNatives();
|
||||
|
||||
Reference in New Issue
Block a user