From a4c03ca3343e2c9fafbcea1b2d49b17a5ff81925 Mon Sep 17 00:00:00 2001 From: Adam Gleitman Date: Mon, 25 Mar 2024 14:51:54 -0700 Subject: [PATCH] Move transform updating logic on Mac to RCTView --- packages/react-native/React/Views/RCTView.m | 8 ++++++++ packages/react-native/React/Views/UIView+React.h | 8 ++++++++ packages/react-native/React/Views/UIView+React.m | 13 ++++++++----- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/packages/react-native/React/Views/RCTView.m b/packages/react-native/React/Views/RCTView.m index 194581105da4eb..f4d794cdd339ac 100644 --- a/packages/react-native/React/Views/RCTView.m +++ b/packages/react-native/React/Views/RCTView.m @@ -1318,6 +1318,14 @@ - (void)displayLayer:(CALayer *)layer [self updateClippingForLayer:layer]; } +#if TARGET_OS_OSX // [macOS +- (void)updateInternalReactTransform:(CATransform3D)transform +{ + [self setTransform3D:transform]; + [self setNeedsDisplay]; +} +#endif // macOS] + static BOOL RCTLayerHasShadow(CALayer *layer) { return layer.shadowOpacity * CGColorGetAlpha(layer.shadowColor) > 0; diff --git a/packages/react-native/React/Views/UIView+React.h b/packages/react-native/React/Views/UIView+React.h index e053884d6d0724..0a60fd7d07ecd2 100644 --- a/packages/react-native/React/Views/UIView+React.h +++ b/packages/react-native/React/Views/UIView+React.h @@ -83,6 +83,14 @@ typedef struct { */ - (void)reactSetFrame:(CGRect)frame; + +#if TARGET_OS_OSX // [macOS +/** + * Used by react-native-macos to propagate transform changes internally. + */ +- (void)updateInternalReactTransform:(CATransform3D)transform; +#endif // macOS] + /** * This method finds and returns the containing view controller for the view. */ diff --git a/packages/react-native/React/Views/UIView+React.m b/packages/react-native/React/Views/UIView+React.m index 8c12723a5eedcf..a4d168ce67ea35 100644 --- a/packages/react-native/React/Views/UIView+React.m +++ b/packages/react-native/React/Views/UIView+React.m @@ -12,7 +12,6 @@ #import "RCTAssert.h" #import "RCTLog.h" #import "RCTShadowView.h" -#import "RCTView.h" // [macOS] @implementation RCTPlatformView (React) // [macOS] @@ -312,13 +311,17 @@ static void updateTransform(RCTPlatformView *view) // [macOS] // Enable edge antialiasing in rotation, skew, or perspective transforms view.layer.allowsEdgeAntialiasing = transform.m12 != 0.0f || transform.m21 != 0.0f || transform.m34 != 0.0f; #else // [macOS - if ([view isKindOfClass:[RCTView class]]) { - [(RCTView *)view setTransform3D:transform]; - [view setNeedsDisplay:YES]; - } + [view updateInternalReactTransform:transform]; #endif // macOS] } +#if TARGET_OS_OSX // [macOS +- (void)updateInternalReactTransform:(CATransform3D)transform +{ + // Do nothing, this will get overridden by RCTView +} +#endif // macOS] + - (UIViewController *)reactViewController { id responder = [self nextResponder];