Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 5 additions & 32 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -2702,8 +2702,8 @@ public class com/facebook/react/fabric/mounting/SurfaceMountingManager {
public fun <init> (ILcom/facebook/react/touch/JSResponderHandler;Lcom/facebook/react/uimanager/ViewManagerRegistry;Lcom/facebook/react/uimanager/RootViewManager;Lcom/facebook/react/fabric/mounting/MountingManager$MountItemExecutor;Lcom/facebook/react/uimanager/ThemedReactContext;)V
public fun addViewAt (III)V
public fun attachRootView (Landroid/view/View;Lcom/facebook/react/uimanager/ThemedReactContext;)V
public fun createView (Ljava/lang/String;ILjava/lang/Object;Lcom/facebook/react/uimanager/StateWrapper;Lcom/facebook/react/fabric/events/EventEmitterWrapper;Z)V
public fun createViewUnsafe (Ljava/lang/String;ILjava/lang/Object;Lcom/facebook/react/uimanager/StateWrapper;Lcom/facebook/react/fabric/events/EventEmitterWrapper;Z)V
public fun createView (Ljava/lang/String;ILcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/uimanager/StateWrapper;Lcom/facebook/react/fabric/events/EventEmitterWrapper;Z)V
public fun createViewUnsafe (Ljava/lang/String;ILcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/uimanager/StateWrapper;Lcom/facebook/react/fabric/events/EventEmitterWrapper;Z)V
public fun deleteView (I)V
public fun enqueuePendingEvent (ILjava/lang/String;ZLcom/facebook/react/bridge/WritableMap;I)V
public fun getContext ()Lcom/facebook/react/uimanager/ThemedReactContext;
Expand All @@ -2713,7 +2713,7 @@ public class com/facebook/react/fabric/mounting/SurfaceMountingManager {
public fun getViewExists (I)Z
public fun isRootViewAttached ()Z
public fun isStopped ()Z
public fun preallocateView (Ljava/lang/String;ILjava/lang/Object;Lcom/facebook/react/uimanager/StateWrapper;Lcom/facebook/react/fabric/events/EventEmitterWrapper;Z)V
public fun preallocateView (Ljava/lang/String;ILcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/uimanager/StateWrapper;Lcom/facebook/react/fabric/events/EventEmitterWrapper;Z)V
public fun printSurfaceState ()V
public fun receiveCommand (IILcom/facebook/react/bridge/ReadableArray;)V
public fun receiveCommand (ILjava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V
Expand All @@ -2727,7 +2727,7 @@ public class com/facebook/react/fabric/mounting/SurfaceMountingManager {
public fun updateLayout (IIIIIII)V
public fun updateOverflowInset (IIIII)V
public fun updatePadding (IIIII)V
public fun updateProps (ILjava/lang/Object;)V
public fun updateProps (ILcom/facebook/react/bridge/ReadableMap;)V
public fun updateState (ILcom/facebook/react/uimanager/StateWrapper;)V
}

Expand All @@ -2751,7 +2751,7 @@ public class com/facebook/react/fabric/mounting/mountitems/MountItemFactory {
public static fun createDispatchCommandMountItem (IIILcom/facebook/react/bridge/ReadableArray;)Lcom/facebook/react/fabric/mounting/mountitems/DispatchCommandMountItem;
public static fun createDispatchCommandMountItem (IILjava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)Lcom/facebook/react/fabric/mounting/mountitems/DispatchCommandMountItem;
public static fun createIntBufferBatchMountItem (I[I[Ljava/lang/Object;I)Lcom/facebook/react/fabric/mounting/mountitems/MountItem;
public static fun createPreAllocateViewMountItem (IILjava/lang/String;Ljava/lang/Object;Lcom/facebook/react/uimanager/StateWrapper;Lcom/facebook/react/fabric/events/EventEmitterWrapper;Z)Lcom/facebook/react/fabric/mounting/mountitems/MountItem;
public static fun createPreAllocateViewMountItem (IILjava/lang/String;Lcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/uimanager/StateWrapper;Lcom/facebook/react/fabric/events/EventEmitterWrapper;Z)Lcom/facebook/react/fabric/mounting/mountitems/MountItem;
public static fun createSendAccessibilityEventMountItem (III)Lcom/facebook/react/fabric/mounting/mountitems/MountItem;
}

Expand Down Expand Up @@ -7673,33 +7673,6 @@ public class com/facebook/react/views/view/ReactViewManager$$PropsSetter : com/f
public fun setProperty (Lcom/facebook/react/views/view/ReactViewManager;Lcom/facebook/react/views/view/ReactViewGroup;Ljava/lang/String;Ljava/lang/Object;)V
}

public abstract interface class com/facebook/react/views/view/ReactViewManagerWrapper {
public abstract fun createView (ILcom/facebook/react/uimanager/ThemedReactContext;Ljava/lang/Object;Lcom/facebook/react/uimanager/StateWrapper;Lcom/facebook/react/touch/JSResponderHandler;)Landroid/view/View;
public abstract fun getName ()Ljava/lang/String;
public abstract fun getViewGroupManager ()Lcom/facebook/react/uimanager/IViewGroupManager;
public abstract fun onDropViewInstance (Landroid/view/View;)V
public abstract fun receiveCommand (Landroid/view/View;ILcom/facebook/react/bridge/ReadableArray;)V
public abstract fun receiveCommand (Landroid/view/View;Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V
public abstract fun setPadding (Landroid/view/View;IIII)V
public abstract fun updateExtraData (Landroid/view/View;Ljava/lang/Object;)V
public abstract fun updateProperties (Landroid/view/View;Ljava/lang/Object;)V
public abstract fun updateState (Landroid/view/View;Ljava/lang/Object;Lcom/facebook/react/uimanager/StateWrapper;)Ljava/lang/Object;
}

public final class com/facebook/react/views/view/ReactViewManagerWrapper$DefaultViewManager : com/facebook/react/views/view/ReactViewManagerWrapper {
public fun <init> (Lcom/facebook/react/uimanager/ViewManager;)V
public fun createView (ILcom/facebook/react/uimanager/ThemedReactContext;Ljava/lang/Object;Lcom/facebook/react/uimanager/StateWrapper;Lcom/facebook/react/touch/JSResponderHandler;)Landroid/view/View;
public fun getName ()Ljava/lang/String;
public fun getViewGroupManager ()Lcom/facebook/react/uimanager/IViewGroupManager;
public fun onDropViewInstance (Landroid/view/View;)V
public fun receiveCommand (Landroid/view/View;ILcom/facebook/react/bridge/ReadableArray;)V
public fun receiveCommand (Landroid/view/View;Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V
public fun setPadding (Landroid/view/View;IIII)V
public fun updateExtraData (Landroid/view/View;Ljava/lang/Object;)V
public fun updateProperties (Landroid/view/View;Ljava/lang/Object;)V
public fun updateState (Landroid/view/View;Ljava/lang/Object;Lcom/facebook/react/uimanager/StateWrapper;)Ljava/lang/Object;
}

public class com/facebook/react/views/view/ViewGroupClickEvent : com/facebook/react/uimanager/events/Event {
public fun <init> (I)V
public fun <init> (II)V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ private void preallocateView(
rootTag,
reactTag,
componentName,
props,
(ReadableMap) props,
(StateWrapper) stateWrapper,
(EventEmitterWrapper) eventEmitterWrapper,
isLayoutable));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import com.facebook.react.uimanager.ViewManagerRegistry;
import com.facebook.react.uimanager.events.EventCategoryDef;
import com.facebook.react.views.view.ReactViewGroup;
import com.facebook.react.views.view.ReactViewManagerWrapper;
import java.util.ArrayDeque;
import java.util.HashSet;
import java.util.LinkedList;
Expand Down Expand Up @@ -189,13 +188,7 @@ private void addRootView(@NonNull final View rootView) {
return;
}

mTagToViewState.put(
mSurfaceId,
new ViewState(
mSurfaceId,
rootView,
new ReactViewManagerWrapper.DefaultViewManager((ViewManager) mRootViewManager),
true));
mTagToViewState.put(mSurfaceId, new ViewState(mSurfaceId, rootView, mRootViewManager, true));

Runnable runnable =
() -> {
Expand Down Expand Up @@ -796,7 +789,7 @@ public void run() {
public void createView(
@NonNull String componentName,
int reactTag,
@Nullable Object props,
@Nullable ReadableMap props,
@Nullable StateWrapper stateWrapper,
@Nullable EventEmitterWrapper eventEmitterWrapper,
boolean isLayoutable) {
Expand Down Expand Up @@ -834,24 +827,18 @@ public void createView(
public void createViewUnsafe(
@NonNull String componentName,
int reactTag,
@Nullable Object props,
@Nullable ReadableMap props,
@Nullable StateWrapper stateWrapper,
@Nullable EventEmitterWrapper eventEmitterWrapper,
boolean isLayoutable) {
View view = null;
ReactViewManagerWrapper viewManager = null;
ViewManager viewManager = null;

Object propMap;
if (props instanceof ReadableMap) {
propMap = new ReactStylesDiffMap((ReadableMap) props);
} else {
propMap = props;
}
ReactStylesDiffMap propMap = new ReactStylesDiffMap(props);

if (isLayoutable) {
viewManager =
new ReactViewManagerWrapper.DefaultViewManager(mViewManagerRegistry.get(componentName));
// View Managers are responsible for dealing with initial state and props.
viewManager = mViewManagerRegistry.get(componentName);
// View Managers are responsible for dealing with inital state and props.
view =
viewManager.createView(
reactTag, mThemedReactContext, propMap, stateWrapper, mJSResponderHandler);
Expand All @@ -865,14 +852,13 @@ public void createViewUnsafe(
mTagToViewState.put(reactTag, viewState);
}

public void updateProps(int reactTag, Object props) {
public void updateProps(int reactTag, ReadableMap props) {
if (isStopped()) {
return;
}

ViewState viewState = getViewState(reactTag);
viewState.mCurrentProps =
props instanceof ReadableMap ? new ReactStylesDiffMap((ReadableMap) props) : props;
viewState.mCurrentProps = new ReactStylesDiffMap(props);
View view = viewState.mView;

if (view == null) {
Expand Down Expand Up @@ -992,7 +978,7 @@ public void updateLayout(
ViewState parentViewState = getViewState(parentTag);
IViewGroupManager<?> parentViewManager = null;
if (parentViewState.mViewManager != null) {
parentViewManager = parentViewState.mViewManager.getViewGroupManager();
parentViewManager = (IViewGroupManager) parentViewState.mViewManager;
}
if (parentViewManager == null || !parentViewManager.needsCustomLayoutForChildren()) {
viewToUpdate.layout(x, y, x + width, y + height);
Expand Down Expand Up @@ -1023,7 +1009,7 @@ public void updatePadding(int reactTag, int left, int top, int right, int bottom
throw new IllegalStateException("Unable to find View for tag: " + reactTag);
}

ReactViewManagerWrapper viewManager = viewState.mViewManager;
ViewManager viewManager = viewState.mViewManager;
if (viewManager == null) {
throw new IllegalStateException("Unable to find ViewManager for view: " + viewState);
}
Expand Down Expand Up @@ -1073,7 +1059,7 @@ public void updateState(final int reactTag, @Nullable StateWrapper stateWrapper)
StateWrapper prevStateWrapper = viewState.mStateWrapper;
viewState.mStateWrapper = stateWrapper;

ReactViewManagerWrapper viewManager = viewState.mViewManager;
ViewManager viewManager = viewState.mViewManager;

if (viewManager == null) {
throw new IllegalStateException("Unable to find ViewManager for tag: " + reactTag);
Expand Down Expand Up @@ -1173,7 +1159,7 @@ private void onViewStateDeleted(ViewState viewState) {
}

// For non-root views we notify viewmanager with {@link ViewManager#onDropInstance}
ReactViewManagerWrapper viewManager = viewState.mViewManager;
ViewManager viewManager = viewState.mViewManager;
if (!viewState.mIsRoot && viewManager != null) {
viewManager.onDropViewInstance(viewState.mView);
}
Expand Down Expand Up @@ -1208,7 +1194,7 @@ public void deleteView(int reactTag) {
public void preallocateView(
@NonNull String componentName,
int reactTag,
@Nullable Object props,
@Nullable ReadableMap props,
@Nullable StateWrapper stateWrapper,
@Nullable EventEmitterWrapper eventEmitterWrapper,
boolean isLayoutable) {
Expand Down Expand Up @@ -1268,7 +1254,7 @@ public View getView(int reactTag) {
if (viewState.mViewManager == null) {
throw new IllegalStateException("Unable to find ViewManager for view: " + viewState);
}
return (IViewGroupManager<ViewGroup>) viewState.mViewManager.getViewGroupManager();
return (IViewGroupManager<ViewGroup>) viewState.mViewManager;
}

public void printSurfaceState() {
Expand Down Expand Up @@ -1335,8 +1321,8 @@ private static class ViewState {
@Nullable final View mView;
final int mReactTag;
final boolean mIsRoot;
@Nullable final ReactViewManagerWrapper mViewManager;
@Nullable public Object mCurrentProps = null;
@Nullable final ViewManager mViewManager;
@Nullable public ReactStylesDiffMap mCurrentProps = null;
@Nullable public ReadableMap mCurrentLocalData = null;
@Nullable public StateWrapper mStateWrapper = null;
@Nullable public EventEmitterWrapper mEventEmitter = null;
Expand All @@ -1345,16 +1331,12 @@ private static class ViewState {
@Nullable
public Queue<PendingViewEvent> mPendingEventQueue = null;

private ViewState(
int reactTag, @Nullable View view, @Nullable ReactViewManagerWrapper viewManager) {
private ViewState(int reactTag, @Nullable View view, @Nullable ViewManager viewManager) {
this(reactTag, view, viewManager, false);
}

private ViewState(
int reactTag,
@Nullable View view,
@Nullable ReactViewManagerWrapper viewManager,
boolean isRoot) {
int reactTag, @Nullable View view, @Nullable ViewManager viewManager, boolean isRoot) {
mReactTag = reactTag;
mView = view;
mIsRoot = isRoot;
Expand Down Expand Up @@ -1450,8 +1432,9 @@ public void doFrameGuarded(long frameTimeNanos) {
ViewState thisViewState = getNullableViewState(reactTag);
if (thisViewState != null) {
View thisView = thisViewState.mView;
if (thisView instanceof ViewGroup) {
IViewGroupManager viewManager = getViewGroupManager(thisViewState);
ViewManager thisViewManager = thisViewState.mViewManager;
if (thisViewManager instanceof IViewGroupManager) {
IViewGroupManager viewManager = (IViewGroupManager) thisViewManager;

// Children are managed by React Native if both of the following are true:
// 1) There are 1 or more children of this View, which must be a ViewGroup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.react.bridge.ReactMarker;
import com.facebook.react.bridge.ReactMarkerConstants;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.fabric.events.EventEmitterWrapper;
import com.facebook.react.fabric.mounting.MountingManager;
import com.facebook.react.fabric.mounting.SurfaceMountingManager;
Expand Down Expand Up @@ -89,14 +90,6 @@ private void endMarkers() {
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
}

private static StateWrapper castToState(Object obj) {
return obj != null ? (StateWrapper) obj : null;
}

private static EventEmitterWrapper castToEventEmitter(Object obj) {
return obj != null ? (EventEmitterWrapper) obj : null;
}

@Override
public void execute(@NonNull MountingManager mountingManager) {
SurfaceMountingManager surfaceMountingManager = mountingManager.getSurfaceManager(mSurfaceId);
Expand Down Expand Up @@ -128,9 +121,9 @@ public void execute(@NonNull MountingManager mountingManager) {
surfaceMountingManager.createView(
componentName,
mIntBuffer[i++],
mObjBuffer[j++],
castToState(mObjBuffer[j++]),
castToEventEmitter(mObjBuffer[j++]),
(ReadableMap) mObjBuffer[j++],
(StateWrapper) mObjBuffer[j++],
(EventEmitterWrapper) mObjBuffer[j++],
mIntBuffer[i++] == 1);
} else if (type == INSTRUCTION_DELETE) {
surfaceMountingManager.deleteView(mIntBuffer[i++]);
Expand All @@ -144,9 +137,9 @@ public void execute(@NonNull MountingManager mountingManager) {
surfaceMountingManager.removeDeleteTreeAt(
mIntBuffer[i++], mIntBuffer[i++], mIntBuffer[i++]);
} else if (type == INSTRUCTION_UPDATE_PROPS) {
surfaceMountingManager.updateProps(mIntBuffer[i++], mObjBuffer[j++]);
surfaceMountingManager.updateProps(mIntBuffer[i++], (ReadableMap) mObjBuffer[j++]);
} else if (type == INSTRUCTION_UPDATE_STATE) {
surfaceMountingManager.updateState(mIntBuffer[i++], castToState(mObjBuffer[j++]));
surfaceMountingManager.updateState(mIntBuffer[i++], (StateWrapper) mObjBuffer[j++]);
} else if (type == INSTRUCTION_UPDATE_LAYOUT) {
int reactTag = mIntBuffer[i++];
int parentTag = mIntBuffer[i++];
Expand Down Expand Up @@ -177,7 +170,7 @@ public void execute(@NonNull MountingManager mountingManager) {
overflowInsetBottom);
} else if (type == INSTRUCTION_UPDATE_EVENT_EMITTER) {
surfaceMountingManager.updateEventEmitter(
mIntBuffer[i++], castToEventEmitter(mObjBuffer[j++]));
mIntBuffer[i++], (EventEmitterWrapper) mObjBuffer[j++]);
} else {
throw new IllegalArgumentException(
"Invalid type argument to IntBufferBatchMountItem: " + type + " at index: " + i);
Expand Down Expand Up @@ -239,7 +232,7 @@ public String toString() {
: "<hidden>";
s.append(String.format("UPDATE PROPS [%d]: %s\n", mIntBuffer[i++], propsString));
} else if (type == INSTRUCTION_UPDATE_STATE) {
StateWrapper state = castToState(mObjBuffer[j++]);
StateWrapper state = (StateWrapper) mObjBuffer[j++];
String stateString =
IS_DEVELOPMENT_ENVIRONMENT
? (state != null ? state.toString() : "<null>")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import androidx.annotation.Nullable;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.fabric.events.EventEmitterWrapper;
import com.facebook.react.uimanager.StateWrapper;

Expand Down Expand Up @@ -41,7 +42,7 @@ public static MountItem createPreAllocateViewMountItem(
int surfaceId,
int reactTag,
@NonNull String component,
@Nullable Object props,
@Nullable ReadableMap props,
@Nullable StateWrapper stateWrapper,
@Nullable EventEmitterWrapper eventEmitterWrapper,
boolean isLayoutable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import androidx.annotation.Nullable;
import com.facebook.common.logging.FLog;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.fabric.events.EventEmitterWrapper;
import com.facebook.react.fabric.mounting.MountingManager;
import com.facebook.react.fabric.mounting.SurfaceMountingManager;
Expand All @@ -27,7 +28,7 @@ final class PreAllocateViewMountItem implements MountItem {
private final @NonNull String mComponent;
private final int mSurfaceId;
private final int mReactTag;
private final @Nullable Object mProps;
private final @Nullable ReadableMap mProps;
private final @Nullable StateWrapper mStateWrapper;
private final @Nullable EventEmitterWrapper mEventEmitterWrapper;
private final boolean mIsLayoutable;
Expand All @@ -36,7 +37,7 @@ final class PreAllocateViewMountItem implements MountItem {
int surfaceId,
int reactTag,
@NonNull String component,
@Nullable Object props,
@Nullable ReadableMap props,
@Nullable StateWrapper stateWrapper,
@Nullable EventEmitterWrapper eventEmitterWrapper,
boolean isLayoutable) {
Expand Down
Loading