Skip to content

Commit 51c600c

Browse files
alanleedevgabrieldonadel
authored andcommitted
Back out "Migrate ReactClippingViewGroup to Kotlin" (facebook#49586)
Summary: Pull Request resolved: facebook#49586 Reverting facebook#49413 as it was causing a crash with assertion failure in ReactViewGroup.addViewWithSubviewClippingEnabled() Changelog: [INTERNAL] revert Kotlin conversion due to crash Reviewed By: sbuggay Differential Revision: D69953848 fbshipit-source-id: b438fb928a4849f3dbad6a9d59d0f48449035fd6
1 parent 07a88bd commit 51c600c

File tree

3 files changed

+66
-61
lines changed

3 files changed

+66
-61
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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 android.graphics.Rect;
11+
import android.view.View;
12+
13+
/**
14+
* Interface that should be implemented by {@link View} subclasses that support {@code
15+
* removeClippedSubviews} property. When this property is set for the {@link ViewGroup} subclass
16+
* it's responsible for detaching it's child views that are clipped by the view boundaries. Those
17+
* view boundaries should be determined based on it's parent clipping area and current view's offset
18+
* in parent and doesn't necessarily reflect the view visible area (in a sense of a value that
19+
* {@link View#getGlobalVisibleRect} may return). In order to determine the clipping rect for
20+
* current view helper method {@link ReactClippingViewGroupHelper#calculateClippingRect} can be used
21+
* that takes into account parent view settings.
22+
*/
23+
public interface ReactClippingViewGroup {
24+
25+
/**
26+
* Notify view that clipping area may have changed and it should recalculate the list of children
27+
* that should be attached/detached. This method should be called only when property {@code
28+
* removeClippedSubviews} is set to {@code true} on a view.
29+
*
30+
* <p>CAUTION: Views are responsible for calling {@link #updateClippingRect} on it's children.
31+
* This should happen if child implement {@link ReactClippingViewGroup}, return true from {@link
32+
* #getRemoveClippedSubviews} and clipping rect change of the current view may affect clipping
33+
* rect of this child.
34+
*/
35+
void updateClippingRect();
36+
37+
/**
38+
* Get rectangular bounds to which view is currently clipped to. Called only on views that has set
39+
* {@code removeCLippedSubviews} property value to {@code true}.
40+
*
41+
* @param outClippingRect output clipping rect should be written to this object.
42+
*/
43+
void getClippingRect(Rect outClippingRect);
44+
45+
/**
46+
* Sets property {@code removeClippedSubviews} as a result of property update in JS. Should be
47+
* called only from @{link ViewManager#updateView} method.
48+
*
49+
* <p>Helper method {@link ReactClippingViewGroupHelper#applyRemoveClippedSubviewsProperty} may be
50+
* used by {@link ViewManager} subclass to apply this property based on property update map {@link
51+
* ReactStylesDiffMap}.
52+
*/
53+
void setRemoveClippedSubviews(boolean removeClippedSubviews);
54+
55+
/** Get the current value of {@code removeClippedSubviews} property. */
56+
boolean getRemoveClippedSubviews();
57+
}

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

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

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollContainerLegacyView.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ internal class ReactHorizontalScrollContainerLegacyView(context: Context) :
1919
ReactViewGroup(context) {
2020
private val isRTL: Boolean = I18nUtil.instance.isRTL(context)
2121

22-
override var removeClippedSubviews: Boolean = false
23-
set(value) {
24-
// removeClippedSubviews logic may read metrics before the offsetting we do in onLayout() and
25-
// is such unsafe
26-
if (isRTL) {
27-
field = false
28-
} else {
29-
field = value
30-
}
22+
override fun setRemoveClippedSubviews(removeClippedSubviews: Boolean) {
23+
// removeClippedSubviews logic may read metrics before the offsetting we do in onLayout() and is
24+
// such unsafe
25+
if (isRTL) {
26+
super.setRemoveClippedSubviews(false)
27+
return
3128
}
3229

30+
super.setRemoveClippedSubviews(removeClippedSubviews)
31+
}
32+
3333
override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
3434
if (isRTL) {
3535
// When the layout direction is RTL, we expect Yoga to give us a layout

0 commit comments

Comments
 (0)