Skip to content

Commit fa4d5fb

Browse files
fabriziocuccimeta-codesync[bot]
authored andcommitted
Sync clipToPadding with overflow on Android views
Summary: Changelog: [Internal] This change syncs the `clipToPadding` property with the `overflow` property on Android views to enable input systems to correctly identify which views are clipping their content. When `overflow` is set to `VISIBLE`, `clipToPadding` is set to `false`. For any other overflow value (e.g., `HIDDEN`, `SCROLL`), `clipToPadding` is set to `true`. The change is gated behind the `syncAndroidClipToPaddingWithOverflow` feature flag. Differential Revision: D93248532
1 parent c8d498d commit fa4d5fb

24 files changed

Lines changed: 181 additions & 35 deletions

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<65e8cae8a55213f4b08ec4d896a05c00>>
7+
* @generated SignedSource<<9a521f1f6989bb2735ae87d0a0c2f5fe>>
88
*/
99

1010
/**
@@ -432,6 +432,12 @@ public object ReactNativeFeatureFlags {
432432
@JvmStatic
433433
public fun skipActivityIdentityAssertionOnHostPause(): Boolean = accessor.skipActivityIdentityAssertionOnHostPause()
434434

435+
/**
436+
* Sync clipToPadding on Android views with the overflow property
437+
*/
438+
@JvmStatic
439+
public fun syncAndroidClipToPaddingWithOverflow(): Boolean = accessor.syncAndroidClipToPaddingWithOverflow()
440+
435441
/**
436442
* Enables storing js caller stack when creating promise in native module. This is useful in case of Promise rejection and tracing the cause.
437443
*/

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxAccessor.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<d92407e77cb3be0d57a84b5a9a931f2b>>
7+
* @generated SignedSource<<5a92af0a54f8aae7ba6f36a952c64df4>>
88
*/
99

1010
/**
@@ -87,6 +87,7 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
8787
private var shouldPressibilityUseW3CPointerEventsForHoverCache: Boolean? = null
8888
private var shouldTriggerResponderTransferOnScrollAndroidCache: Boolean? = null
8989
private var skipActivityIdentityAssertionOnHostPauseCache: Boolean? = null
90+
private var syncAndroidClipToPaddingWithOverflowCache: Boolean? = null
9091
private var traceTurboModulePromiseRejectionsOnAndroidCache: Boolean? = null
9192
private var updateRuntimeShadowNodeReferencesOnCommitCache: Boolean? = null
9293
private var updateRuntimeShadowNodeReferencesOnCommitThreadCache: Boolean? = null
@@ -705,6 +706,15 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
705706
return cached
706707
}
707708

709+
override fun syncAndroidClipToPaddingWithOverflow(): Boolean {
710+
var cached = syncAndroidClipToPaddingWithOverflowCache
711+
if (cached == null) {
712+
cached = ReactNativeFeatureFlagsCxxInterop.syncAndroidClipToPaddingWithOverflow()
713+
syncAndroidClipToPaddingWithOverflowCache = cached
714+
}
715+
return cached
716+
}
717+
708718
override fun traceTurboModulePromiseRejectionsOnAndroid(): Boolean {
709719
var cached = traceTurboModulePromiseRejectionsOnAndroidCache
710720
if (cached == null) {

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<b83744bb70330f8c540c448ebc1cad47>>
7+
* @generated SignedSource<<cabb5ba7c0486e777be721f6ff880d05>>
88
*/
99

1010
/**
@@ -162,6 +162,8 @@ public object ReactNativeFeatureFlagsCxxInterop {
162162

163163
@DoNotStrip @JvmStatic public external fun skipActivityIdentityAssertionOnHostPause(): Boolean
164164

165+
@DoNotStrip @JvmStatic public external fun syncAndroidClipToPaddingWithOverflow(): Boolean
166+
165167
@DoNotStrip @JvmStatic public external fun traceTurboModulePromiseRejectionsOnAndroid(): Boolean
166168

167169
@DoNotStrip @JvmStatic public external fun updateRuntimeShadowNodeReferencesOnCommit(): Boolean

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<0139bc7a7b2ae5c9175f44de1ac80105>>
7+
* @generated SignedSource<<c302baa5e3dcdf6655da02cd9850e653>>
88
*/
99

1010
/**
@@ -157,6 +157,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
157157

158158
override fun skipActivityIdentityAssertionOnHostPause(): Boolean = false
159159

160+
override fun syncAndroidClipToPaddingWithOverflow(): Boolean = false
161+
160162
override fun traceTurboModulePromiseRejectionsOnAndroid(): Boolean = false
161163

162164
override fun updateRuntimeShadowNodeReferencesOnCommit(): Boolean = false

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsLocalAccessor.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<d3d6ecfc14d5a0c317d968b65455955a>>
7+
* @generated SignedSource<<07501a0c5936c8fe26a432d57c541d7e>>
88
*/
99

1010
/**
@@ -91,6 +91,7 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
9191
private var shouldPressibilityUseW3CPointerEventsForHoverCache: Boolean? = null
9292
private var shouldTriggerResponderTransferOnScrollAndroidCache: Boolean? = null
9393
private var skipActivityIdentityAssertionOnHostPauseCache: Boolean? = null
94+
private var syncAndroidClipToPaddingWithOverflowCache: Boolean? = null
9495
private var traceTurboModulePromiseRejectionsOnAndroidCache: Boolean? = null
9596
private var updateRuntimeShadowNodeReferencesOnCommitCache: Boolean? = null
9697
private var updateRuntimeShadowNodeReferencesOnCommitThreadCache: Boolean? = null
@@ -776,6 +777,16 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
776777
return cached
777778
}
778779

780+
override fun syncAndroidClipToPaddingWithOverflow(): Boolean {
781+
var cached = syncAndroidClipToPaddingWithOverflowCache
782+
if (cached == null) {
783+
cached = currentProvider.syncAndroidClipToPaddingWithOverflow()
784+
accessedFeatureFlags.add("syncAndroidClipToPaddingWithOverflow")
785+
syncAndroidClipToPaddingWithOverflowCache = cached
786+
}
787+
return cached
788+
}
789+
779790
override fun traceTurboModulePromiseRejectionsOnAndroid(): Boolean {
780791
var cached = traceTurboModulePromiseRejectionsOnAndroidCache
781792
if (cached == null) {

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<f8cbc05fd0bda7b6efa74279b9cadaa7>>
7+
* @generated SignedSource<<34a625414f22a7c36ff9db90e76b1254>>
88
*/
99

1010
/**
@@ -157,6 +157,8 @@ public interface ReactNativeFeatureFlagsProvider {
157157

158158
@DoNotStrip public fun skipActivityIdentityAssertionOnHostPause(): Boolean
159159

160+
@DoNotStrip public fun syncAndroidClipToPaddingWithOverflow(): Boolean
161+
160162
@DoNotStrip public fun traceTurboModulePromiseRejectionsOnAndroid(): Boolean
161163

162164
@DoNotStrip public fun updateRuntimeShadowNodeReferencesOnCommit(): Boolean

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,14 @@ public Rect getOverflowInset() {
460460
return mOverflowInset;
461461
}
462462

463+
@Override
464+
public boolean getClipToPadding() {
465+
if (ReactNativeFeatureFlags.syncAndroidClipToPaddingWithOverflow()) {
466+
return mOverflow != Overflow.VISIBLE;
467+
}
468+
return super.getClipToPadding();
469+
}
470+
463471
@Override
464472
public void onDraw(Canvas canvas) {
465473
if (mOverflow != Overflow.VISIBLE) {

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<78fb92f68ec0a93d0041ed381f76728e>>
7+
* @generated SignedSource<<fefaf14f0291216b635ea0c356e9929c>>
88
*/
99

1010
/**
@@ -787,6 +787,14 @@ public void updateClippingRect(@Nullable Set<Integer> excludedViewsSet) {
787787
}
788788
}
789789

790+
@Override
791+
public boolean getClipToPadding() {
792+
if (ReactNativeFeatureFlags.syncAndroidClipToPaddingWithOverflow()) {
793+
return mOverflow != Overflow.VISIBLE;
794+
}
795+
return super.getClipToPadding();
796+
}
797+
790798
@Override
791799
public void getClippingRect(Rect outClippingRect) {
792800
outClippingRect.set(Assertions.assertNotNull(mClippingRect));

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,14 @@ public void updateClippingRect(@Nullable Set<Integer> excludedViewsSet) {
779779
}
780780
}
781781

782+
@Override
783+
public boolean getClipToPadding() {
784+
if (ReactNativeFeatureFlags.syncAndroidClipToPaddingWithOverflow()) {
785+
return mOverflow != Overflow.VISIBLE;
786+
}
787+
return super.getClipToPadding();
788+
}
789+
782790
@Override
783791
public void getClippingRect(Rect outClippingRect) {
784792
outClippingRect.set(Assertions.assertNotNull(mClippingRect));

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ public open class ReactViewGroup public constructor(context: Context?) :
166166
*/
167167
private fun initView() {
168168
clipChildren = false
169+
if (ReactNativeFeatureFlags.syncAndroidClipToPaddingWithOverflow()) {
170+
clipToPadding = false
171+
}
169172

170173
_removeClippedSubviews = false
171174
inSubviewClippingLoop = false
@@ -819,6 +822,9 @@ public open class ReactViewGroup public constructor(context: Context?) :
819822
} else {
820823
Overflow.fromString(overflow)
821824
}
825+
if (ReactNativeFeatureFlags.syncAndroidClipToPaddingWithOverflow()) {
826+
clipToPadding = _overflow != Overflow.VISIBLE
827+
}
822828
invalidate()
823829
}
824830

0 commit comments

Comments
 (0)