Skip to content

Commit

Permalink
Move transform updating logic on Mac to RCTView
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Gleitman committed Mar 25, 2024
1 parent c90b0e1 commit a4c03ca
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
8 changes: 8 additions & 0 deletions packages/react-native/React/Views/RCTView.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions packages/react-native/React/Views/UIView+React.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
13 changes: 8 additions & 5 deletions packages/react-native/React/Views/UIView+React.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#import "RCTAssert.h"
#import "RCTLog.h"
#import "RCTShadowView.h"
#import "RCTView.h" // [macOS]

@implementation RCTPlatformView (React) // [macOS]

Expand Down Expand Up @@ -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];
Expand Down

0 comments on commit a4c03ca

Please sign in to comment.