Skip to content

Commit 099d5e0

Browse files
authored
chore: remove clipsToBounds overrides (#2748)
## Summary: Back in macOS 13, Apple made a breaking change to NSView (I know, rare) to set the default of `clipsToBounds` from true to false to match iOS. We did some working around of it (See #1864 ). Now that our minimum is above macOS 13, we can remove this property. ## Test Plan: Booting paper and fabric seem fine.
1 parent 2b48430 commit 099d5e0

File tree

3 files changed

+2
-37
lines changed

3 files changed

+2
-37
lines changed

packages/react-native/React/Base/RCTUIKit.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,6 @@ UIKIT_STATIC_INLINE RCTPlatformView *RCTUIViewHitTestWithEvent(RCTPlatformView *
6565
return [view hitTest:point withEvent:event];
6666
}
6767

68-
UIKIT_STATIC_INLINE BOOL RCTUIViewSetClipsToBounds(RCTPlatformView *view)
69-
{
70-
return view.clipsToBounds;
71-
}
72-
7368
UIKIT_STATIC_INLINE void RCTUIViewSetContentModeRedraw(UIView *view)
7469
{
7570
view.contentMode = UIViewContentModeRedraw;
@@ -398,8 +393,6 @@ void UIBezierPathAppendPath(UIBezierPath *path, UIBezierPath *appendPath);
398393

399394
- (void)setNeedsDisplay;
400395

401-
// 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
402-
@property BOOL clipsToBounds;
403396
@property (nonatomic, copy) NSColor *backgroundColor;
404397
@property (nonatomic) CGAffineTransform transform;
405398

@@ -462,8 +455,6 @@ NS_INLINE RCTPlatformView *RCTUIViewHitTestWithEvent(RCTPlatformView *view, CGPo
462455
return [view hitTest:pointInSuperview];
463456
}
464457

465-
BOOL RCTUIViewSetClipsToBounds(RCTPlatformView *view);
466-
467458
NS_INLINE void RCTUIViewSetContentModeRedraw(RCTPlatformView *view)
468459
{
469460
view.layerContentsRedrawPolicy = NSViewLayerContentsRedrawDuringViewResize;
@@ -604,8 +595,6 @@ typedef UIImageView RCTUIImageView;
604595
#else
605596
@interface RCTUIImageView : NSImageView
606597
NS_ASSUME_NONNULL_BEGIN
607-
// 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
608-
@property (assign) BOOL clipsToBounds;
609598
@property (nonatomic, strong) RCTUIColor *tintColor;
610599
@property (nonatomic, assign) UIViewContentMode contentMode;
611600
NS_ASSUME_NONNULL_END

packages/react-native/React/Base/macOS/RCTUIKit.m

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -526,20 +526,6 @@ - (void)setAlwaysBounceVertical:(BOOL)alwaysBounceVertical
526526

527527
@end
528528

529-
BOOL RCTUIViewSetClipsToBounds(RCTPlatformView *view)
530-
{
531-
// NSViews are always clipped to bounds
532-
BOOL clipsToBounds = YES;
533-
534-
// But see if UIView overrides that behavior
535-
if ([view respondsToSelector:@selector(clipsToBounds)])
536-
{
537-
clipsToBounds = [(id)view clipsToBounds];
538-
}
539-
540-
return clipsToBounds;
541-
}
542-
543529
@implementation RCTClipView
544530

545531
- (instancetype)initWithFrame:(NSRect)frameRect
@@ -743,16 +729,6 @@ - (instancetype)initWithFrame:(CGRect)frame
743729
return self;
744730
}
745731

746-
- (BOOL)clipsToBounds
747-
{
748-
return [[self layer] masksToBounds];
749-
}
750-
751-
- (void)setClipsToBounds:(BOOL)clipsToBounds
752-
{
753-
[[self layer] setMasksToBounds:clipsToBounds];
754-
}
755-
756732
- (void)setContentMode:(UIViewContentMode)contentMode
757733
{
758734
_contentMode = contentMode;

packages/react-native/React/Views/RCTView.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ - (void)react_updateClippedSubviewsWithClipRect:(CGRect)clipRect relativeToView:
5555
// we do support clipsToBounds, so if that's enabled
5656
// we'll update the clipping
5757

58-
if (RCTUIViewSetClipsToBounds(self) && self.subviews.count > 0) { // [macOS]
58+
if (self.clipsToBounds && self.subviews.count > 0) {
5959
clipRect = [clipView convertRect:clipRect toView:self];
6060
clipRect = CGRectIntersection(clipRect, self.bounds);
6161
clipView = self;
@@ -77,7 +77,7 @@ - (RCTPlatformView *)react_findClipView // [macOS]
7777
CGRect clipRect = self.bounds;
7878
// We will only look for a clipping view up the view hierarchy until we hit the root view.
7979
while (testView) {
80-
if (RCTUIViewSetClipsToBounds(testView)) { // [macOS]
80+
if (testView.clipsToBounds) {
8181
if (clipView) {
8282
CGRect testRect = [clipView convertRect:clipRect toView:testView];
8383
if (!CGRectContainsRect(testView.bounds, testRect)) {

0 commit comments

Comments
 (0)