diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index 024da3c221b3..cee6dc815714 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -4090,11 +4090,6 @@ public final class com/facebook/react/uimanager/ReactStylesDiffMap { public fun toString ()Ljava/lang/String; } -public abstract interface class com/facebook/react/uimanager/ReactZIndexedViewGroup { - public abstract fun getZIndexMappedChildIndex (I)I - public abstract fun updateDrawingOrder ()V -} - public abstract interface class com/facebook/react/uimanager/RootView { public abstract fun handleException (Ljava/lang/Throwable;)V public abstract fun onChildEndedNativeGesture (Landroid/view/View;Landroid/view/MotionEvent;)V @@ -4400,17 +4395,7 @@ public final class com/facebook/react/uimanager/ViewDefaults { public static final field NUMBER_OF_LINES I } -public final class com/facebook/react/uimanager/ViewGroupDrawingOrderHelper { - public fun (Landroid/view/ViewGroup;)V - public final fun getChildDrawingOrder (II)I - public final fun handleAddView (Landroid/view/View;)V - public final fun handleRemoveView (Landroid/view/View;)V - public final fun shouldEnableCustomDrawingOrder ()Z - public final fun update ()V -} - public abstract class com/facebook/react/uimanager/ViewGroupManager : com/facebook/react/uimanager/BaseViewManager, com/facebook/react/uimanager/IViewGroupManager { - public static final field Companion Lcom/facebook/react/uimanager/ViewGroupManager$Companion; public fun ()V public fun (Lcom/facebook/react/bridge/ReactApplicationContext;)V public synthetic fun (Lcom/facebook/react/bridge/ReactApplicationContext;ILkotlin/jvm/internal/DefaultConstructorMarker;)V @@ -4424,21 +4409,14 @@ public abstract class com/facebook/react/uimanager/ViewGroupManager : com/facebo public synthetic fun getChildCount (Landroid/view/View;)I public fun getChildCount (Landroid/view/ViewGroup;)I public fun getShadowNodeClass ()Ljava/lang/Class; - public static final fun getViewZIndex (Landroid/view/View;)Ljava/lang/Integer; public fun needsCustomLayoutForChildren ()Z public fun removeView (Landroid/view/ViewGroup;Landroid/view/View;)V public synthetic fun removeViewAt (Landroid/view/View;I)V public fun removeViewAt (Landroid/view/ViewGroup;I)V - public static final fun setViewZIndex (Landroid/view/View;I)V public synthetic fun updateExtraData (Landroid/view/View;Ljava/lang/Object;)V public fun updateExtraData (Landroid/view/ViewGroup;Ljava/lang/Object;)V } -public final class com/facebook/react/uimanager/ViewGroupManager$Companion { - public final fun getViewZIndex (Landroid/view/View;)Ljava/lang/Integer; - public final fun setViewZIndex (Landroid/view/View;I)V -} - public abstract class com/facebook/react/uimanager/ViewManager : com/facebook/react/bridge/BaseJavaModule { public fun ()V public fun (Lcom/facebook/react/bridge/ReactApplicationContext;)V @@ -6445,7 +6423,7 @@ public final class com/facebook/react/views/view/ReactDrawableHelper { public static final fun createDrawableFromJSDescription (Landroid/content/Context;Lcom/facebook/react/bridge/ReadableMap;)Landroid/graphics/drawable/Drawable; } -public class com/facebook/react/views/view/ReactViewGroup : android/view/ViewGroup, com/facebook/react/touch/ReactHitSlopView, com/facebook/react/touch/ReactInterceptingViewGroup, com/facebook/react/uimanager/ReactClippingViewGroup, com/facebook/react/uimanager/ReactOverflowViewWithInset, com/facebook/react/uimanager/ReactPointerEventsView, com/facebook/react/uimanager/ReactZIndexedViewGroup { +public class com/facebook/react/views/view/ReactViewGroup : android/view/ViewGroup, com/facebook/react/touch/ReactHitSlopView, com/facebook/react/touch/ReactInterceptingViewGroup, com/facebook/react/uimanager/ReactClippingViewGroup, com/facebook/react/uimanager/ReactOverflowViewWithInset, com/facebook/react/uimanager/ReactPointerEventsView { public fun (Landroid/content/Context;)V public fun addChildrenForAccessibility (Ljava/util/ArrayList;)V public final fun cleanUpAxOrderListener ()V @@ -6465,7 +6443,6 @@ public class com/facebook/react/views/view/ReactViewGroup : android/view/ViewGro public fun getOverflowInset ()Landroid/graphics/Rect; public fun getPointerEvents ()Lcom/facebook/react/uimanager/PointerEvents; public fun getRemoveClippedSubviews ()Z - public fun getZIndexMappedChildIndex (I)I public fun hasOverlappingRendering ()Z protected fun onAttachedToWindow ()V public fun onHoverEvent (Landroid/view/MotionEvent;)Z @@ -6498,7 +6475,6 @@ public class com/facebook/react/views/view/ReactViewGroup : android/view/ViewGro public final fun setTranslucentBackgroundDrawable (Landroid/graphics/drawable/Drawable;)V public fun updateClippingRect ()V public fun updateClippingRect (Ljava/util/Set;)V - public fun updateDrawingOrder ()V } public class com/facebook/react/views/view/ReactViewManager : com/facebook/react/views/view/ReactClippingViewManager { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java index c837b84adc6d..9e246e9d754d 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java @@ -14,7 +14,6 @@ import android.view.View; import android.view.View.OnFocusChangeListener; import android.view.ViewGroup; -import android.view.ViewParent; import android.view.accessibility.AccessibilityEvent; import androidx.annotation.ColorInt; import androidx.annotation.NonNull; @@ -285,12 +284,7 @@ public void setShadowColor(@NonNull T view, int shadowColor) { @ReactProp(name = ViewProps.Z_INDEX) public void setZIndex(@NonNull T view, float zIndex) { - int integerZIndex = Math.round(zIndex); - ViewGroupManager.setViewZIndex(view, integerZIndex); - ViewParent parent = view.getParent(); - if (parent instanceof ReactZIndexedViewGroup) { - ((ReactZIndexedViewGroup) parent).updateDrawingOrder(); - } + // No-op: Z-order is managed at the C++ layer in Fabric } @ReactProp(name = ViewProps.RENDER_TO_HARDWARE_TEXTURE) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactZIndexedViewGroup.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactZIndexedViewGroup.kt deleted file mode 100644 index 8d3cb0432923..000000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactZIndexedViewGroup.kt +++ /dev/null @@ -1,35 +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.uimanager - -import com.facebook.react.common.annotations.internal.LegacyArchitecture - -/** - * ViewGroup that supports z-index. - * - * This interface is part of the legacy architecture. CustomDrawOrder is no longer used when Fabric - * is enabled, which is now everywhere. Z-order is managed at the C++ layer, and no re-ordering is - * needed in the Android View layer. This interface is kept for backward compatibility but should - * not be used in new code. - */ -@LegacyArchitecture -public interface ReactZIndexedViewGroup { - /** - * Determine the index of a child view at [index] considering z-index. - * - * @param index The child view index - * @return The child view index considering z-index - */ - public fun getZIndexMappedChildIndex(index: Int): Int - - /** - * Redraw the view based on updated child z-index. This should be called after updating one of its - * child z-index. - */ - public fun updateDrawingOrder() -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewGroupDrawingOrderHelper.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewGroupDrawingOrderHelper.kt deleted file mode 100644 index 8b431943af87..000000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewGroupDrawingOrderHelper.kt +++ /dev/null @@ -1,113 +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.uimanager - -import android.view.View -import android.view.ViewGroup -import com.facebook.common.logging.FLog -import com.facebook.react.common.ReactConstants -import com.facebook.react.common.annotations.internal.LegacyArchitecture - -/** Helper to handle implementing ViewGroups with custom drawing order based on z-index. */ -@LegacyArchitecture -public class ViewGroupDrawingOrderHelper(private val viewGroup: ViewGroup) { - private var numberOfChildrenWithZIndex = 0 - private var drawingOrderIndices: IntArray? = null - - /** - * This should be called every time a view is added to the ViewGroup in [ViewGroup.addView]. - * - * @param view The view that is being added - */ - public fun handleAddView(view: View) { - if (ViewGroupManager.getViewZIndex(view) != null) { - numberOfChildrenWithZIndex++ - } - - drawingOrderIndices = null - } - - /** - * This should be called every time a view is removed from the ViewGroup in [ViewGroup.removeView] - * and [ViewGroup.removeViewAt]. - * - * @param view The view that is being removed. - */ - public fun handleRemoveView(view: View?) { - if (ViewGroupManager.getViewZIndex(view) != null) { - numberOfChildrenWithZIndex-- - } - - drawingOrderIndices = null - } - - /** - * If the ViewGroup should enable drawing order. ViewGroups should call - * [ViewGroup.setChildrenDrawingOrderEnabled] with the value returned from this method when a view - * is added or removed. - */ - public fun shouldEnableCustomDrawingOrder(): Boolean = numberOfChildrenWithZIndex > 0 - - /** - * The index of the child view that should be drawn. This should be used in - * [ViewGroup.getChildDrawingOrder]. - */ - public fun getChildDrawingOrder(childCount: Int, index: Int): Int { - var currentDrawingOrderIndices = this.drawingOrderIndices - if ( - currentDrawingOrderIndices != null && - (index >= currentDrawingOrderIndices.size || - currentDrawingOrderIndices[index] >= childCount) - ) { - FLog.w( - ReactConstants.TAG, - "getChildDrawingOrder index out of bounds! Please check any custom view manipulations you" + - " may have done. childCount = %d, index = %d", - childCount, - index, - ) - update() - } - - if (currentDrawingOrderIndices == null) { - val viewsToSort = ArrayList() - for (i in 0 until childCount) { - viewsToSort.add(viewGroup.getChildAt(i)) - } - - // Sort the views by zIndex - viewsToSort.sortWith { view1, view2 -> - val view1ZIndex = ViewGroupManager.getViewZIndex(view1) ?: 0 - val view2ZIndex = ViewGroupManager.getViewZIndex(view2) ?: 0 - view1ZIndex - view2ZIndex - } - - currentDrawingOrderIndices = IntArray(childCount) - for (i in 0 until childCount) { - val child = viewsToSort[i] - currentDrawingOrderIndices[i] = viewGroup.indexOfChild(child) - } - - this.drawingOrderIndices = currentDrawingOrderIndices - } - - return currentDrawingOrderIndices[index] - } - - /** Recheck all children for z-index changes. */ - public fun update() { - numberOfChildrenWithZIndex = 0 - for (i in 0 until viewGroup.childCount) { - val child = viewGroup.getChildAt(i) - if (ViewGroupManager.getViewZIndex(child) != null) { - numberOfChildrenWithZIndex++ - } - } - drawingOrderIndices = null - } -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewGroupManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewGroupManager.kt index 57cd75935915..ed2e2bb4d0b6 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewGroupManager.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewGroupManager.kt @@ -11,7 +11,6 @@ import android.view.View import android.view.ViewGroup import com.facebook.react.bridge.ReactApplicationContext import com.facebook.react.bridge.UiThreadUtil -import java.util.WeakHashMap @Suppress("DEPRECATION") public abstract class ViewGroupManager @@ -76,13 +75,4 @@ constructor(reactContext: ReactApplicationContext? = null) : * that case, onLayout for this View type must *not* call layout on its children. */ public override fun needsCustomLayoutForChildren(): Boolean = false - - public companion object { - private val zIndexHash: WeakHashMap = WeakHashMap() - - @JvmStatic - public fun setViewZIndex(view: View, zIndex: Int): Unit = zIndexHash.set(view, zIndex) - - @JvmStatic public fun getViewZIndex(view: View?): Int? = zIndexHash[view] - } } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.kt index 0d2f5faba3b2..eb98c3905752 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.kt @@ -58,7 +58,6 @@ import com.facebook.react.uimanager.ReactClippingViewGroup import com.facebook.react.uimanager.ReactClippingViewGroupHelper.calculateClippingRect import com.facebook.react.uimanager.ReactOverflowViewWithInset import com.facebook.react.uimanager.ReactPointerEventsView -import com.facebook.react.uimanager.ReactZIndexedViewGroup import com.facebook.react.uimanager.style.BorderRadiusProp import com.facebook.react.uimanager.style.BorderStyle import com.facebook.react.uimanager.style.LogicalEdge @@ -81,7 +80,6 @@ public open class ReactViewGroup public constructor(context: Context?) : ReactClippingViewGroup, ReactPointerEventsView, ReactHitSlopView, - ReactZIndexedViewGroup, ReactOverflowViewWithInset { public override val overflowInset: Rect = Rect() @@ -622,20 +620,6 @@ public open class ReactViewGroup public constructor(context: Context?) : } } - /** - * No-op implementation for backward compatibility. Z-order is now managed at the C++ layer in - * Fabric. - */ - override fun getZIndexMappedChildIndex(index: Int): Int = index - - /** - * No-op implementation for backward compatibility. Z-order is now managed at the C++ layer in - * Fabric. - */ - override fun updateDrawingOrder() { - // No-op: Z-order is managed at the C++ layer - } - override fun dispatchSetPressed(pressed: Boolean) { // Prevents the ViewGroup from dispatching the pressed state // to it's children.