Skip to content

Commit c49aa90

Browse files
javachemeta-codesync[bot]
authored andcommitted
Remove setViewZIndex and associated state from BaseViewManager (#56717)
Summary: Pull Request resolved: #56717 This is a follow-up to D91121582 which deprecated ReactZIndexedViewGroup and removed custom draw order logic from ReactViewGroup. That diff kept `setZIndex()` in BaseViewManager and BaseViewManagerDelegate for backward compatibility, to be removed in a follow-up. This diff completes that cleanup by removing: - The `setZIndex` method from `BaseViewManager` (which called `ViewGroupManager.setViewZIndex` and triggered `updateDrawingOrder()` on the parent) - The `Z_INDEX` case from `BaseViewManagerDelegate` - The `zIndexHash` WeakHashMap, `setViewZIndex`, and `getViewZIndex` static methods from `ViewGroupManager`'s companion object - The `ViewGroupDrawingOrderHelper` class, which was dead code (marked `LegacyArchitecture`, no longer imported anywhere) and depended on the removed `getViewZIndex` Z-index is now fully managed at the C++ Fabric layer, and these Android-side mechanisms are no longer needed. Changelog: [Android][Removed] Removed `ViewGroupManager.setViewZIndex`/`getViewZIndex` and `ViewGroupDrawingOrderHelper` — z-index is now fully managed by the Fabric C++ layer Reviewed By: sammy-SC Differential Revision: D104101783 fbshipit-source-id: 7c69afc307cef9ebe3a939cf559050372f093c97
1 parent 91702e5 commit c49aa90

6 files changed

Lines changed: 2 additions & 206 deletions

File tree

packages/react-native/ReactAndroid/api/ReactAndroid.api

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4090,11 +4090,6 @@ public final class com/facebook/react/uimanager/ReactStylesDiffMap {
40904090
public fun toString ()Ljava/lang/String;
40914091
}
40924092

4093-
public abstract interface class com/facebook/react/uimanager/ReactZIndexedViewGroup {
4094-
public abstract fun getZIndexMappedChildIndex (I)I
4095-
public abstract fun updateDrawingOrder ()V
4096-
}
4097-
40984093
public abstract interface class com/facebook/react/uimanager/RootView {
40994094
public abstract fun handleException (Ljava/lang/Throwable;)V
41004095
public abstract fun onChildEndedNativeGesture (Landroid/view/View;Landroid/view/MotionEvent;)V
@@ -4400,17 +4395,7 @@ public final class com/facebook/react/uimanager/ViewDefaults {
44004395
public static final field NUMBER_OF_LINES I
44014396
}
44024397

4403-
public final class com/facebook/react/uimanager/ViewGroupDrawingOrderHelper {
4404-
public fun <init> (Landroid/view/ViewGroup;)V
4405-
public final fun getChildDrawingOrder (II)I
4406-
public final fun handleAddView (Landroid/view/View;)V
4407-
public final fun handleRemoveView (Landroid/view/View;)V
4408-
public final fun shouldEnableCustomDrawingOrder ()Z
4409-
public final fun update ()V
4410-
}
4411-
44124398
public abstract class com/facebook/react/uimanager/ViewGroupManager : com/facebook/react/uimanager/BaseViewManager, com/facebook/react/uimanager/IViewGroupManager {
4413-
public static final field Companion Lcom/facebook/react/uimanager/ViewGroupManager$Companion;
44144399
public fun <init> ()V
44154400
public fun <init> (Lcom/facebook/react/bridge/ReactApplicationContext;)V
44164401
public synthetic fun <init> (Lcom/facebook/react/bridge/ReactApplicationContext;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
@@ -4424,21 +4409,14 @@ public abstract class com/facebook/react/uimanager/ViewGroupManager : com/facebo
44244409
public synthetic fun getChildCount (Landroid/view/View;)I
44254410
public fun getChildCount (Landroid/view/ViewGroup;)I
44264411
public fun getShadowNodeClass ()Ljava/lang/Class;
4427-
public static final fun getViewZIndex (Landroid/view/View;)Ljava/lang/Integer;
44284412
public fun needsCustomLayoutForChildren ()Z
44294413
public fun removeView (Landroid/view/ViewGroup;Landroid/view/View;)V
44304414
public synthetic fun removeViewAt (Landroid/view/View;I)V
44314415
public fun removeViewAt (Landroid/view/ViewGroup;I)V
4432-
public static final fun setViewZIndex (Landroid/view/View;I)V
44334416
public synthetic fun updateExtraData (Landroid/view/View;Ljava/lang/Object;)V
44344417
public fun updateExtraData (Landroid/view/ViewGroup;Ljava/lang/Object;)V
44354418
}
44364419

4437-
public final class com/facebook/react/uimanager/ViewGroupManager$Companion {
4438-
public final fun getViewZIndex (Landroid/view/View;)Ljava/lang/Integer;
4439-
public final fun setViewZIndex (Landroid/view/View;I)V
4440-
}
4441-
44424420
public abstract class com/facebook/react/uimanager/ViewManager : com/facebook/react/bridge/BaseJavaModule {
44434421
public fun <init> ()V
44444422
public fun <init> (Lcom/facebook/react/bridge/ReactApplicationContext;)V
@@ -6445,7 +6423,7 @@ public final class com/facebook/react/views/view/ReactDrawableHelper {
64456423
public static final fun createDrawableFromJSDescription (Landroid/content/Context;Lcom/facebook/react/bridge/ReadableMap;)Landroid/graphics/drawable/Drawable;
64466424
}
64476425

6448-
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 {
6426+
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 {
64496427
public fun <init> (Landroid/content/Context;)V
64506428
public fun addChildrenForAccessibility (Ljava/util/ArrayList;)V
64516429
public final fun cleanUpAxOrderListener ()V
@@ -6465,7 +6443,6 @@ public class com/facebook/react/views/view/ReactViewGroup : android/view/ViewGro
64656443
public fun getOverflowInset ()Landroid/graphics/Rect;
64666444
public fun getPointerEvents ()Lcom/facebook/react/uimanager/PointerEvents;
64676445
public fun getRemoveClippedSubviews ()Z
6468-
public fun getZIndexMappedChildIndex (I)I
64696446
public fun hasOverlappingRendering ()Z
64706447
protected fun onAttachedToWindow ()V
64716448
public fun onHoverEvent (Landroid/view/MotionEvent;)Z
@@ -6498,7 +6475,6 @@ public class com/facebook/react/views/view/ReactViewGroup : android/view/ViewGro
64986475
public final fun setTranslucentBackgroundDrawable (Landroid/graphics/drawable/Drawable;)V
64996476
public fun updateClippingRect ()V
65006477
public fun updateClippingRect (Ljava/util/Set;)V
6501-
public fun updateDrawingOrder ()V
65026478
}
65036479

65046480
public class com/facebook/react/views/view/ReactViewManager : com/facebook/react/views/view/ReactClippingViewManager {

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import android.view.View;
1515
import android.view.View.OnFocusChangeListener;
1616
import android.view.ViewGroup;
17-
import android.view.ViewParent;
1817
import android.view.accessibility.AccessibilityEvent;
1918
import androidx.annotation.ColorInt;
2019
import androidx.annotation.NonNull;
@@ -285,12 +284,7 @@ public void setShadowColor(@NonNull T view, int shadowColor) {
285284

286285
@ReactProp(name = ViewProps.Z_INDEX)
287286
public void setZIndex(@NonNull T view, float zIndex) {
288-
int integerZIndex = Math.round(zIndex);
289-
ViewGroupManager.setViewZIndex(view, integerZIndex);
290-
ViewParent parent = view.getParent();
291-
if (parent instanceof ReactZIndexedViewGroup) {
292-
((ReactZIndexedViewGroup) parent).updateDrawingOrder();
293-
}
287+
// No-op: Z-order is managed at the C++ layer in Fabric
294288
}
295289

296290
@ReactProp(name = ViewProps.RENDER_TO_HARDWARE_TEXTURE)

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactZIndexedViewGroup.kt

Lines changed: 0 additions & 35 deletions
This file was deleted.

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewGroupDrawingOrderHelper.kt

Lines changed: 0 additions & 113 deletions
This file was deleted.

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewGroupManager.kt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import android.view.View
1111
import android.view.ViewGroup
1212
import com.facebook.react.bridge.ReactApplicationContext
1313
import com.facebook.react.bridge.UiThreadUtil
14-
import java.util.WeakHashMap
1514

1615
@Suppress("DEPRECATION")
1716
public abstract class ViewGroupManager<T : ViewGroup>
@@ -76,13 +75,4 @@ constructor(reactContext: ReactApplicationContext? = null) :
7675
* that case, onLayout for this View type must *not* call layout on its children.
7776
*/
7877
public override fun needsCustomLayoutForChildren(): Boolean = false
79-
80-
public companion object {
81-
private val zIndexHash: WeakHashMap<View, Int> = WeakHashMap()
82-
83-
@JvmStatic
84-
public fun setViewZIndex(view: View, zIndex: Int): Unit = zIndexHash.set(view, zIndex)
85-
86-
@JvmStatic public fun getViewZIndex(view: View?): Int? = zIndexHash[view]
87-
}
8878
}

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.kt

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ import com.facebook.react.uimanager.ReactClippingViewGroup
5858
import com.facebook.react.uimanager.ReactClippingViewGroupHelper.calculateClippingRect
5959
import com.facebook.react.uimanager.ReactOverflowViewWithInset
6060
import com.facebook.react.uimanager.ReactPointerEventsView
61-
import com.facebook.react.uimanager.ReactZIndexedViewGroup
6261
import com.facebook.react.uimanager.style.BorderRadiusProp
6362
import com.facebook.react.uimanager.style.BorderStyle
6463
import com.facebook.react.uimanager.style.LogicalEdge
@@ -81,7 +80,6 @@ public open class ReactViewGroup public constructor(context: Context?) :
8180
ReactClippingViewGroup,
8281
ReactPointerEventsView,
8382
ReactHitSlopView,
84-
ReactZIndexedViewGroup,
8583
ReactOverflowViewWithInset {
8684

8785
public override val overflowInset: Rect = Rect()
@@ -622,20 +620,6 @@ public open class ReactViewGroup public constructor(context: Context?) :
622620
}
623621
}
624622

625-
/**
626-
* No-op implementation for backward compatibility. Z-order is now managed at the C++ layer in
627-
* Fabric.
628-
*/
629-
override fun getZIndexMappedChildIndex(index: Int): Int = index
630-
631-
/**
632-
* No-op implementation for backward compatibility. Z-order is now managed at the C++ layer in
633-
* Fabric.
634-
*/
635-
override fun updateDrawingOrder() {
636-
// No-op: Z-order is managed at the C++ layer
637-
}
638-
639623
override fun dispatchSetPressed(pressed: Boolean) {
640624
// Prevents the ViewGroup from dispatching the pressed state
641625
// to it's children.

0 commit comments

Comments
 (0)