Skip to content

Commit 352d73b

Browse files
mdvaccameta-codesync[bot]
authored andcommitted
Add NativeViewHierarchyOptimizer parameter to ReactShadowNode methods (facebook#55661)
Summary: Pull Request resolved: facebook#55661 Add a `NativeViewHierarchyOptimizer` parameter to `onBeforeLayout()` and `dispatchUpdates()` methods in `ReactShadowNode` and `ReactShadowNodeImpl`. This introduces a deprecated stub class `NativeViewHierarchyOptimizer.kt` annotated with `LegacyArchitecture` to support downstream callers that still reference this type, while signaling that it is part of the legacy architecture and will be removed in the future. Callers in `UIImplementation` pass `null` for now since the optimizer is not actively used in this code path. Changelog: [Android][Deprecated] - Deprecate NativeViewHierarchyOptimizer as part of Legacy Architecture cleanup Reviewed By: NickGerleman Differential Revision: D93935604 fbshipit-source-id: 0d96d30f0089a5a896a80f6da7e6d53b5f4e8675
1 parent 3918dd1 commit 352d73b

5 files changed

Lines changed: 38 additions & 10 deletions

File tree

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3539,6 +3539,10 @@ public class com/facebook/react/uimanager/NativeViewHierarchyManager {
35393539
public fun updateViewExtraData (ILjava/lang/Object;)V
35403540
}
35413541

3542+
public final class com/facebook/react/uimanager/NativeViewHierarchyOptimizer {
3543+
public fun <init> ()V
3544+
}
3545+
35423546
public final class com/facebook/react/uimanager/OnLayoutEvent : com/facebook/react/uimanager/events/Event {
35433547
public static final field Companion Lcom/facebook/react/uimanager/OnLayoutEvent$Companion;
35443548
public fun getEventName ()Ljava/lang/String;
@@ -3839,7 +3843,7 @@ public abstract interface class com/facebook/react/uimanager/ReactShadowNode {
38393843
public abstract fun calculateLayout (FF)V
38403844
public abstract fun calculateLayoutOnChildren ()Ljava/lang/Iterable;
38413845
public abstract fun dirty ()V
3842-
public abstract fun dispatchUpdates (FFLcom/facebook/react/uimanager/UIViewOperationQueue;)V
3846+
public abstract fun dispatchUpdates (FFLcom/facebook/react/uimanager/UIViewOperationQueue;Lcom/facebook/react/uimanager/NativeViewHierarchyOptimizer;)V
38433847
public abstract fun dispatchUpdatesWillChangeLayout (FF)Z
38443848
public abstract fun dispose ()V
38453849
public abstract fun getChildAt (I)Lcom/facebook/react/uimanager/ReactShadowNode;
@@ -3888,7 +3892,7 @@ public abstract interface class com/facebook/react/uimanager/ReactShadowNode {
38883892
public abstract fun markUpdateSeen ()V
38893893
public abstract fun markUpdated ()V
38903894
public abstract fun onAfterUpdateTransaction ()V
3891-
public abstract fun onBeforeLayout ()V
3895+
public abstract fun onBeforeLayout (Lcom/facebook/react/uimanager/NativeViewHierarchyOptimizer;)V
38923896
public abstract fun onCollectExtraUpdates (Lcom/facebook/react/uimanager/UIViewOperationQueue;)V
38933897
public abstract fun removeAllNativeChildren ()V
38943898
public abstract fun removeAndDisposeAllChildren ()V
@@ -3965,7 +3969,7 @@ public class com/facebook/react/uimanager/ReactShadowNodeImpl : com/facebook/rea
39653969
public fun calculateLayout (FF)V
39663970
public fun calculateLayoutOnChildren ()Ljava/lang/Iterable;
39673971
public fun dirty ()V
3968-
public fun dispatchUpdates (FFLcom/facebook/react/uimanager/UIViewOperationQueue;)V
3972+
public fun dispatchUpdates (FFLcom/facebook/react/uimanager/UIViewOperationQueue;Lcom/facebook/react/uimanager/NativeViewHierarchyOptimizer;)V
39693973
public fun dispatchUpdatesWillChangeLayout (FF)Z
39703974
public fun dispose ()V
39713975
public synthetic fun getChildAt (I)Lcom/facebook/react/uimanager/ReactShadowNode;
@@ -4022,7 +4026,7 @@ public class com/facebook/react/uimanager/ReactShadowNodeImpl : com/facebook/rea
40224026
public final fun markUpdateSeen ()V
40234027
public fun markUpdated ()V
40244028
public fun onAfterUpdateTransaction ()V
4025-
public fun onBeforeLayout ()V
4029+
public fun onBeforeLayout (Lcom/facebook/react/uimanager/NativeViewHierarchyOptimizer;)V
40264030
public fun onCollectExtraUpdates (Lcom/facebook/react/uimanager/UIViewOperationQueue;)V
40274031
public final fun removeAllNativeChildren ()V
40284032
public fun removeAndDisposeAllChildren ()V
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
package com.facebook.react.uimanager
9+
10+
import com.facebook.react.common.annotations.internal.LegacyArchitecture
11+
import com.facebook.react.common.annotations.internal.LegacyArchitectureLogLevel
12+
13+
@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.ERROR)
14+
@Deprecated(
15+
message = "This class is part of Legacy Architecture and will be removed in a future release",
16+
level = DeprecationLevel.ERROR,
17+
)
18+
public class NativeViewHierarchyOptimizer() {}

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public interface ReactShadowNode<T extends ReactShadowNode> {
111111
* layout. Will be only called for nodes that are marked as updated with {@link #markUpdated()} or
112112
* require layouting (marked with {@link #dirty()}).
113113
*/
114-
void onBeforeLayout();
114+
void onBeforeLayout(NativeViewHierarchyOptimizer nativeViewHierarchyOptimizer);
115115

116116
void updateProperties(ReactStylesDiffMap props);
117117

@@ -129,7 +129,10 @@ public interface ReactShadowNode<T extends ReactShadowNode> {
129129
/* package */ boolean dispatchUpdatesWillChangeLayout(float absoluteX, float absoluteY);
130130

131131
/* package */ void dispatchUpdates(
132-
float absoluteX, float absoluteY, UIViewOperationQueue uiViewOperationQueue);
132+
float absoluteX,
133+
float absoluteY,
134+
UIViewOperationQueue uiViewOperationQueue,
135+
NativeViewHierarchyOptimizer nativeViewHierarchyOptimizer);
133136

134137
int getReactTag();
135138

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ private void updateNativeChildrenCountInParent(int delta) {
318318
* require layouting (marked with {@link #dirty()}).
319319
*/
320320
@Override
321-
public void onBeforeLayout() {}
321+
public void onBeforeLayout(NativeViewHierarchyOptimizer nativeViewHierarchyOptimizer) {}
322322

323323
@Override
324324
public final void updateProperties(ReactStylesDiffMap props) {
@@ -367,7 +367,10 @@ public boolean dispatchUpdatesWillChangeLayout(float absoluteX, float absoluteY)
367367

368368
@Override
369369
public void dispatchUpdates(
370-
float absoluteX, float absoluteY, UIViewOperationQueue uiViewOperationQueue) {
370+
float absoluteX,
371+
float absoluteY,
372+
UIViewOperationQueue uiViewOperationQueue,
373+
@Nullable NativeViewHierarchyOptimizer nativeViewHierarchyOptimizer) {
371374
if (mNodeUpdated) {
372375
onCollectExtraUpdates(uiViewOperationQueue);
373376
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ private void notifyOnBeforeLayoutRecursive(ReactShadowNode cssNode) {
849849
for (int i = 0; i < cssNode.getChildCount(); i++) {
850850
notifyOnBeforeLayoutRecursive(cssNode.getChildAt(i));
851851
}
852-
cssNode.onBeforeLayout();
852+
cssNode.onBeforeLayout(null);
853853
}
854854

855855
protected void calculateRootLayout(ReactShadowNode cssRoot) {
@@ -897,7 +897,7 @@ protected void applyUpdatesRecursive(
897897
}
898898
}
899899

900-
cssNode.dispatchUpdates(absoluteX, absoluteY, mOperationsQueue);
900+
cssNode.dispatchUpdates(absoluteX, absoluteY, mOperationsQueue, null);
901901

902902
cssNode.markUpdateSeen();
903903
}

0 commit comments

Comments
 (0)