Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -6457,6 +6457,8 @@ public class com/facebook/react/views/view/ReactViewGroup : android/view/ViewGro
protected fun drawChild (Landroid/graphics/Canvas;Landroid/view/View;J)Z
public fun endViewTransition (Landroid/view/View;)V
public final fun getAxOrderList ()Ljava/util/List;
public fun getClipBounds ()Landroid/graphics/Rect;
public fun getClipBounds (Landroid/graphics/Rect;)Z
public fun getClippingRect (Landroid/graphics/Rect;)V
public fun getHitSlopRect ()Landroid/graphics/Rect;
public fun getOverflow ()Ljava/lang/String;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<eb70fd41bc36f1a49849e29bea081007>>
* @generated SignedSource<<cd8218c8b8588f3317bf63ce8d608548>>
*/

/**
Expand Down Expand Up @@ -480,6 +480,12 @@ public object ReactNativeFeatureFlags {
@JvmStatic
public fun skipActivityIdentityAssertionOnHostPause(): Boolean = accessor.skipActivityIdentityAssertionOnHostPause()

/**
* Override getClipBounds on Android views to return the padding box when overflow is hidden
*/
@JvmStatic
public fun syncAndroidClipBoundsWithOverflow(): Boolean = accessor.syncAndroidClipBoundsWithOverflow()

/**
* Enables storing js caller stack when creating promise in native module. This is useful in case of Promise rejection and tracing the cause.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<f79ca61a0da053a1661eca4d3a35b081>>
* @generated SignedSource<<4f9f5c1c46217ed6802abd5f786aac19>>
*/

/**
Expand Down Expand Up @@ -95,6 +95,7 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
private var shouldPressibilityUseW3CPointerEventsForHoverCache: Boolean? = null
private var shouldTriggerResponderTransferOnScrollAndroidCache: Boolean? = null
private var skipActivityIdentityAssertionOnHostPauseCache: Boolean? = null
private var syncAndroidClipBoundsWithOverflowCache: Boolean? = null
private var traceTurboModulePromiseRejectionsOnAndroidCache: Boolean? = null
private var updateRuntimeShadowNodeReferencesOnCommitCache: Boolean? = null
private var updateRuntimeShadowNodeReferencesOnCommitThreadCache: Boolean? = null
Expand Down Expand Up @@ -787,6 +788,15 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
return cached
}

override fun syncAndroidClipBoundsWithOverflow(): Boolean {
var cached = syncAndroidClipBoundsWithOverflowCache
if (cached == null) {
cached = ReactNativeFeatureFlagsCxxInterop.syncAndroidClipBoundsWithOverflow()
syncAndroidClipBoundsWithOverflowCache = cached
}
return cached
}

override fun traceTurboModulePromiseRejectionsOnAndroid(): Boolean {
var cached = traceTurboModulePromiseRejectionsOnAndroidCache
if (cached == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<62d1f0fcdf8e3165480da12575d62826>>
* @generated SignedSource<<8916e9f4a938a69ff175c806db9835d4>>
*/

/**
Expand Down Expand Up @@ -178,6 +178,8 @@ public object ReactNativeFeatureFlagsCxxInterop {

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

@DoNotStrip @JvmStatic public external fun syncAndroidClipBoundsWithOverflow(): Boolean

@DoNotStrip @JvmStatic public external fun traceTurboModulePromiseRejectionsOnAndroid(): Boolean

@DoNotStrip @JvmStatic public external fun updateRuntimeShadowNodeReferencesOnCommit(): Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<84ac5b80585f9185c879c81822718d86>>
* @generated SignedSource<<d2b14345bf627e35562530912b3aae1f>>
*/

/**
Expand Down Expand Up @@ -173,6 +173,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi

override fun skipActivityIdentityAssertionOnHostPause(): Boolean = false

override fun syncAndroidClipBoundsWithOverflow(): Boolean = false

override fun traceTurboModulePromiseRejectionsOnAndroid(): Boolean = false

override fun updateRuntimeShadowNodeReferencesOnCommit(): Boolean = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<3574e23fe8f846e408964af26cf0dd4c>>
* @generated SignedSource<<cbe90c2bf8ba9d34804d97c31edfd31a>>
*/

/**
Expand Down Expand Up @@ -99,6 +99,7 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
private var shouldPressibilityUseW3CPointerEventsForHoverCache: Boolean? = null
private var shouldTriggerResponderTransferOnScrollAndroidCache: Boolean? = null
private var skipActivityIdentityAssertionOnHostPauseCache: Boolean? = null
private var syncAndroidClipBoundsWithOverflowCache: Boolean? = null
private var traceTurboModulePromiseRejectionsOnAndroidCache: Boolean? = null
private var updateRuntimeShadowNodeReferencesOnCommitCache: Boolean? = null
private var updateRuntimeShadowNodeReferencesOnCommitThreadCache: Boolean? = null
Expand Down Expand Up @@ -866,6 +867,16 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
return cached
}

override fun syncAndroidClipBoundsWithOverflow(): Boolean {
var cached = syncAndroidClipBoundsWithOverflowCache
if (cached == null) {
cached = currentProvider.syncAndroidClipBoundsWithOverflow()
accessedFeatureFlags.add("syncAndroidClipBoundsWithOverflow")
syncAndroidClipBoundsWithOverflowCache = cached
}
return cached
}

override fun traceTurboModulePromiseRejectionsOnAndroid(): Boolean {
var cached = traceTurboModulePromiseRejectionsOnAndroidCache
if (cached == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<9222fd90d191a91893e2c58770d83259>>
* @generated SignedSource<<536a5156deea17740dd24782bf79feb4>>
*/

/**
Expand Down Expand Up @@ -173,6 +173,8 @@ public interface ReactNativeFeatureFlagsProvider {

@DoNotStrip public fun skipActivityIdentityAssertionOnHostPause(): Boolean

@DoNotStrip public fun syncAndroidClipBoundsWithOverflow(): Boolean

@DoNotStrip public fun traceTurboModulePromiseRejectionsOnAndroid(): Boolean

@DoNotStrip public fun updateRuntimeShadowNodeReferencesOnCommit(): Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,35 @@ public object BackgroundStyleApplicator {
clipToPaddingBoxWithAntiAliasing(view, canvas, null)
}

/**
* Populates [outRect] with the padding box rect of the view.
*
* The padding box is the area within the borders of the view. For views without a
* [CompositeBackgroundDrawable] or without borders, this returns the full view bounds.
*
* This is useful for overriding [View.getClipBounds] to communicate the view's clipping region to
* the Android framework (e.g. for [View.getGlobalVisibleRect] calculations).
*
* @param view The view whose padding box to compute
* @param outRect The rect to populate with the padding box bounds
*/
internal fun getPaddingBoxRect(view: View, outRect: Rect) {
val composite = getCompositeBackgroundDrawable(view)
val computedBorderInsets =
composite?.borderInsets?.resolve(composite.layoutDirection, view.context)
if (computedBorderInsets == null) {
outRect.set(0, 0, view.width, view.height)
return
}

val left = (computedBorderInsets.left.dpToPx()).toInt()
val top = (computedBorderInsets.top.dpToPx()).toInt()
val right = (view.width.toFloat() - computedBorderInsets.right.dpToPx()).toInt()
val bottom = (view.height.toFloat() - computedBorderInsets.bottom.dpToPx()).toInt()

outRect.set(left, top, right, bottom)
}

/**
* Clips the canvas to the padding box of the view.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import com.facebook.react.touch.OnInterceptTouchEventListener
import com.facebook.react.touch.ReactHitSlopView
import com.facebook.react.touch.ReactInterceptingViewGroup
import com.facebook.react.uimanager.BackgroundStyleApplicator.clipToPaddingBox
import com.facebook.react.uimanager.BackgroundStyleApplicator.getPaddingBoxRect
import com.facebook.react.uimanager.BackgroundStyleApplicator.setBackgroundColor
import com.facebook.react.uimanager.BackgroundStyleApplicator.setBorderColor
import com.facebook.react.uimanager.BackgroundStyleApplicator.setBorderRadius
Expand Down Expand Up @@ -820,6 +821,39 @@ public open class ReactViewGroup public constructor(context: Context?) :
invalidate()
}

/**
* Returns the clip bounds for this view based on the overflow property.
*
* When overflow is hidden or scroll, returns the padding box rect (the area inside the borders)
* so that systems querying [View.getClipBounds] can determine the view's clipping region. Returns
* null when overflow is visible (no clipping).
*/
override fun getClipBounds(): Rect? {
if (
ReactNativeFeatureFlags.syncAndroidClipBoundsWithOverflow() &&
_overflow != null &&
_overflow != Overflow.VISIBLE
) {
val rect = Rect()
getPaddingBoxRect(this, rect)
return rect
}
return super.getClipBounds()
}

/** See [getClipBounds]. */
override fun getClipBounds(outRect: Rect): Boolean {
if (
ReactNativeFeatureFlags.syncAndroidClipBoundsWithOverflow() &&
_overflow != null &&
_overflow != Overflow.VISIBLE
) {
getPaddingBoxRect(this, outRect)
return true
}
return super.getClipBounds(outRect)
}

override fun setOverflowInset(left: Int, top: Int, right: Int, bottom: Int) {
if (
needsIsolatedLayer(this) &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<e8cf371a99a72250ea1b0104dc7f8254>>
* @generated SignedSource<<b99eaffc2d11a08a6efe32b2e2732965>>
*/

/**
Expand Down Expand Up @@ -489,6 +489,12 @@ class ReactNativeFeatureFlagsJavaProvider
return method(javaProvider_);
}

bool syncAndroidClipBoundsWithOverflow() override {
static const auto method =
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("syncAndroidClipBoundsWithOverflow");
return method(javaProvider_);
}

bool traceTurboModulePromiseRejectionsOnAndroid() override {
static const auto method =
getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("traceTurboModulePromiseRejectionsOnAndroid");
Expand Down Expand Up @@ -964,6 +970,11 @@ bool JReactNativeFeatureFlagsCxxInterop::skipActivityIdentityAssertionOnHostPaus
return ReactNativeFeatureFlags::skipActivityIdentityAssertionOnHostPause();
}

bool JReactNativeFeatureFlagsCxxInterop::syncAndroidClipBoundsWithOverflow(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::syncAndroidClipBoundsWithOverflow();
}

bool JReactNativeFeatureFlagsCxxInterop::traceTurboModulePromiseRejectionsOnAndroid(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
return ReactNativeFeatureFlags::traceTurboModulePromiseRejectionsOnAndroid();
Expand Down Expand Up @@ -1300,6 +1311,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
makeNativeMethod(
"skipActivityIdentityAssertionOnHostPause",
JReactNativeFeatureFlagsCxxInterop::skipActivityIdentityAssertionOnHostPause),
makeNativeMethod(
"syncAndroidClipBoundsWithOverflow",
JReactNativeFeatureFlagsCxxInterop::syncAndroidClipBoundsWithOverflow),
makeNativeMethod(
"traceTurboModulePromiseRejectionsOnAndroid",
JReactNativeFeatureFlagsCxxInterop::traceTurboModulePromiseRejectionsOnAndroid),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<773741594e911047dac28904e9fc9544>>
* @generated SignedSource<<4be32bad403baeca1a28f19ad181c42c>>
*/

/**
Expand Down Expand Up @@ -255,6 +255,9 @@ class JReactNativeFeatureFlagsCxxInterop
static bool skipActivityIdentityAssertionOnHostPause(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);

static bool syncAndroidClipBoundsWithOverflow(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);

static bool traceTurboModulePromiseRejectionsOnAndroid(
facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<6a15a6444767342acf4da0c0c8aa6208>>
* @generated SignedSource<<b55a79c9f84947fa4c12b04f15cfeefb>>
*/

/**
Expand Down Expand Up @@ -326,6 +326,10 @@ bool ReactNativeFeatureFlags::skipActivityIdentityAssertionOnHostPause() {
return getAccessor().skipActivityIdentityAssertionOnHostPause();
}

bool ReactNativeFeatureFlags::syncAndroidClipBoundsWithOverflow() {
return getAccessor().syncAndroidClipBoundsWithOverflow();
}

bool ReactNativeFeatureFlags::traceTurboModulePromiseRejectionsOnAndroid() {
return getAccessor().traceTurboModulePromiseRejectionsOnAndroid();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<62d1840f9a39eaceaa800542b7351a41>>
* @generated SignedSource<<8e9b09843bf4a0312b254559a975f612>>
*/

/**
Expand Down Expand Up @@ -414,6 +414,11 @@ class ReactNativeFeatureFlags {
*/
RN_EXPORT static bool skipActivityIdentityAssertionOnHostPause();

/**
* Override getClipBounds on Android views to return the padding box when overflow is hidden
*/
RN_EXPORT static bool syncAndroidClipBoundsWithOverflow();

/**
* Enables storing js caller stack when creating promise in native module. This is useful in case of Promise rejection and tracing the cause.
*/
Expand Down
Loading
Loading