From 23fccd3209ffd4ec8767cdea18f89ecc4da7f27d Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Fri, 31 Oct 2025 17:55:05 -0700 Subject: [PATCH] fix(RCTUIKit): remove clipsToBounds overrides --- packages/react-native/React/Base/RCTUIKit.h | 11 --------- .../react-native/React/Base/macOS/RCTUIKit.m | 24 ------------------- packages/react-native/React/Views/RCTView.m | 4 ++-- 3 files changed, 2 insertions(+), 37 deletions(-) diff --git a/packages/react-native/React/Base/RCTUIKit.h b/packages/react-native/React/Base/RCTUIKit.h index 9df93b735199c8..d01c4029f8b371 100644 --- a/packages/react-native/React/Base/RCTUIKit.h +++ b/packages/react-native/React/Base/RCTUIKit.h @@ -65,11 +65,6 @@ UIKIT_STATIC_INLINE RCTPlatformView *RCTUIViewHitTestWithEvent(RCTPlatformView * return [view hitTest:point withEvent:event]; } -UIKIT_STATIC_INLINE BOOL RCTUIViewSetClipsToBounds(RCTPlatformView *view) -{ - return view.clipsToBounds; -} - UIKIT_STATIC_INLINE void RCTUIViewSetContentModeRedraw(UIView *view) { view.contentMode = UIViewContentModeRedraw; @@ -398,8 +393,6 @@ void UIBezierPathAppendPath(UIBezierPath *path, UIBezierPath *appendPath); - (void)setNeedsDisplay; -// FUTURE: When Xcode 14 is no longer supported (CI is building with Xcode 15), we can remove this override since it's now declared on NSView -@property BOOL clipsToBounds; @property (nonatomic, copy) NSColor *backgroundColor; @property (nonatomic) CGAffineTransform transform; @@ -462,8 +455,6 @@ NS_INLINE RCTPlatformView *RCTUIViewHitTestWithEvent(RCTPlatformView *view, CGPo return [view hitTest:pointInSuperview]; } -BOOL RCTUIViewSetClipsToBounds(RCTPlatformView *view); - NS_INLINE void RCTUIViewSetContentModeRedraw(RCTPlatformView *view) { view.layerContentsRedrawPolicy = NSViewLayerContentsRedrawDuringViewResize; @@ -604,8 +595,6 @@ typedef UIImageView RCTUIImageView; #else @interface RCTUIImageView : NSImageView NS_ASSUME_NONNULL_BEGIN -// FUTURE: When Xcode 14 is no longer supported (CI is building with Xcode 15), we can remove this override since it's now declared on NSView -@property (assign) BOOL clipsToBounds; @property (nonatomic, strong) RCTUIColor *tintColor; @property (nonatomic, assign) UIViewContentMode contentMode; NS_ASSUME_NONNULL_END diff --git a/packages/react-native/React/Base/macOS/RCTUIKit.m b/packages/react-native/React/Base/macOS/RCTUIKit.m index 08e6c95545ac6d..5ab447832ed5a9 100644 --- a/packages/react-native/React/Base/macOS/RCTUIKit.m +++ b/packages/react-native/React/Base/macOS/RCTUIKit.m @@ -526,20 +526,6 @@ - (void)setAlwaysBounceVertical:(BOOL)alwaysBounceVertical @end -BOOL RCTUIViewSetClipsToBounds(RCTPlatformView *view) -{ - // NSViews are always clipped to bounds - BOOL clipsToBounds = YES; - - // But see if UIView overrides that behavior - if ([view respondsToSelector:@selector(clipsToBounds)]) - { - clipsToBounds = [(id)view clipsToBounds]; - } - - return clipsToBounds; -} - @implementation RCTClipView - (instancetype)initWithFrame:(NSRect)frameRect @@ -743,16 +729,6 @@ - (instancetype)initWithFrame:(CGRect)frame return self; } -- (BOOL)clipsToBounds -{ - return [[self layer] masksToBounds]; -} - -- (void)setClipsToBounds:(BOOL)clipsToBounds -{ - [[self layer] setMasksToBounds:clipsToBounds]; -} - - (void)setContentMode:(UIViewContentMode)contentMode { _contentMode = contentMode; diff --git a/packages/react-native/React/Views/RCTView.m b/packages/react-native/React/Views/RCTView.m index 35e04098424874..7c30545a68e799 100644 --- a/packages/react-native/React/Views/RCTView.m +++ b/packages/react-native/React/Views/RCTView.m @@ -55,7 +55,7 @@ - (void)react_updateClippedSubviewsWithClipRect:(CGRect)clipRect relativeToView: // we do support clipsToBounds, so if that's enabled // we'll update the clipping - if (RCTUIViewSetClipsToBounds(self) && self.subviews.count > 0) { // [macOS] + if (self.clipsToBounds && self.subviews.count > 0) { clipRect = [clipView convertRect:clipRect toView:self]; clipRect = CGRectIntersection(clipRect, self.bounds); clipView = self; @@ -77,7 +77,7 @@ - (RCTPlatformView *)react_findClipView // [macOS] CGRect clipRect = self.bounds; // We will only look for a clipping view up the view hierarchy until we hit the root view. while (testView) { - if (RCTUIViewSetClipsToBounds(testView)) { // [macOS] + if (testView.clipsToBounds) { if (clipView) { CGRect testRect = [clipView convertRect:clipRect toView:testView]; if (!CGRectContainsRect(testView.bounds, testRect)) {