Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Saadnajmi committed Feb 27, 2024
1 parent 46cbec4 commit 76b0732
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 209 deletions.
72 changes: 0 additions & 72 deletions packages/react-native/Libraries/Text/RCTTextAttributes.mm
Original file line number Diff line number Diff line change
Expand Up @@ -15,78 +15,6 @@
NSString *const RCTTextAttributesIsHighlightedAttributeName = @"RCTTextAttributesIsHighlightedAttributeName";
NSString *const RCTTextAttributesTagAttributeName = @"RCTTextAttributesTagAttributeName";

#if TARGET_OS_OSX // [macOS
// Duplicate this function here as RCTTextAttributes doesn't depend on RCTView
static NSCursor *NSCursorFromRCTCursor(RCTCursor cursor)
{
NSCursor *platformCursor;

switch (cursor) {
case RCTCursorAlias:
platformCursor = [NSCursor dragLinkCursor];
break;
case RCTCursorAuto:
platformCursor = [NSCursor arrowCursor];
break;
case RCTCursorColumnResize:
platformCursor = [NSCursor resizeLeftRightCursor];
break;
case RCTCursorContextualMenu:
platformCursor = [NSCursor contextualMenuCursor];
break;
case RCTCursorCopy:
platformCursor = [NSCursor dragCopyCursor];
break;
case RCTCursorCrosshair:
platformCursor = [NSCursor crosshairCursor];
break;
case RCTCursorDefault:
platformCursor = [NSCursor arrowCursor];
break;
case RCTCursorDisappearingItem:
platformCursor = [NSCursor disappearingItemCursor];
break;
case RCTCursorEastResize:
platformCursor = [NSCursor resizeRightCursor];
break;
case RCTCursorGrab:
platformCursor = [NSCursor openHandCursor];
break;
case RCTCursorGrabbing:
platformCursor = [NSCursor closedHandCursor];
break;
case RCTCursorNorthResize:
platformCursor = [NSCursor resizeUpCursor];
break;
case RCTCursorNoDrop:
platformCursor = [NSCursor operationNotAllowedCursor];
break;
case RCTCursorNotAllowed:
platformCursor = [NSCursor operationNotAllowedCursor];
break;
case RCTCursorPointer:
platformCursor = [NSCursor pointingHandCursor];
break;
case RCTCursorRowResize:
platformCursor = [NSCursor resizeUpDownCursor];
break;
case RCTCursorSouthResize:
platformCursor = [NSCursor resizeDownCursor];
break;
case RCTCursorText:
platformCursor = [NSCursor IBeamCursor];
break;
case RCTCursorVerticalText:
platformCursor = [NSCursor IBeamCursorForVerticalLayout];
break;
case RCTCursorWestResize:
platformCursor = [NSCursor resizeLeftCursor];
break;
}
return platformCursor;
}
#endif // macOS]

@implementation RCTTextAttributes

// [macOS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -603,71 +603,48 @@ static RCTBorderStyle RCTBorderStyleFromBorderStyle(BorderStyle borderStyle)
#if TARGET_OS_OSX // [macOS
static NSCursor *NSCursorFromCursor(Cursor cursor)
{
NSCursor *platformCursor;

switch (cursor) {
case Cursor::Alias:
platformCursor = [NSCursor dragLinkCursor];
break;
return [NSCursor dragLinkCursor];
case Cursor::Auto:
platformCursor = [NSCursor arrowCursor];
break;
return [NSCursor arrowCursor];
case Cursor::ColumnResize:
platformCursor = [NSCursor resizeLeftRightCursor];
break;
return [NSCursor resizeLeftRightCursor];
case Cursor::ContextualMenu:
platformCursor = [NSCursor contextualMenuCursor];
break;
return [NSCursor contextualMenuCursor];
case Cursor::Copy:
platformCursor = [NSCursor dragCopyCursor];
break;
return [NSCursor dragCopyCursor];
case Cursor::Crosshair:
platformCursor = [NSCursor crosshairCursor];
break;
return [NSCursor crosshairCursor];
case Cursor::Default:
platformCursor = [NSCursor arrowCursor];
break;
return [NSCursor arrowCursor];
case Cursor::DisappearingItem:
platformCursor = [NSCursor disappearingItemCursor];
break;
return [NSCursor disappearingItemCursor];
case Cursor::EastResize:
platformCursor = [NSCursor resizeRightCursor];
break;
return [NSCursor resizeRightCursor];
case Cursor::Grab:
platformCursor = [NSCursor openHandCursor];
break;
return [NSCursor openHandCursor];
case Cursor::Grabbing:
platformCursor = [NSCursor closedHandCursor];
break;
return [NSCursor closedHandCursor];
case Cursor::NorthResize:
platformCursor = [NSCursor resizeUpCursor];
break;
return [NSCursor resizeUpCursor];
case Cursor::NoDrop:
platformCursor = [NSCursor operationNotAllowedCursor];
break;
return [NSCursor operationNotAllowedCursor];
case Cursor::NotAllowed:
platformCursor = [NSCursor operationNotAllowedCursor];
break;
return [NSCursor operationNotAllowedCursor];
case Cursor::Pointer:
platformCursor = [NSCursor pointingHandCursor];
break;
return [NSCursor pointingHandCursor];
case Cursor::RowResize:
platformCursor = [NSCursor resizeUpDownCursor];
break;
return [NSCursor resizeUpDownCursor];
case Cursor::SouthResize:
platformCursor = [NSCursor resizeDownCursor];
break;
return [NSCursor resizeDownCursor];
case Cursor::Text:
platformCursor = [NSCursor IBeamCursor];
break;
return [NSCursor IBeamCursor];
case Cursor::VerticalText:
platformCursor = [NSCursor IBeamCursorForVerticalLayout];
break;
return [NSCursor IBeamCursorForVerticalLayout];
case Cursor::WestResize:
platformCursor = [NSCursor resizeLeftCursor];
break;
return [NSCursor resizeLeftCursor];
}
return platformCursor;
}
#endif // macOS]

Expand Down
49 changes: 49 additions & 0 deletions packages/react-native/React/Views/RCTCursor.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,52 @@ typedef NS_ENUM(NSInteger, RCTCursor) {
RCTCursorVerticalText,
RCTCursorWestResize,
};

#if TARGET_OS_OSX // [macOS
inline static NSCursor *NSCursorFromRCTCursor(RCTCursor cursor)
{
switch (cursor) {
case RCTCursorAlias:
return [NSCursor dragLinkCursor];
case RCTCursorAuto:
return [NSCursor arrowCursor];
case RCTCursorColumnResize:
return [NSCursor resizeLeftRightCursor];
case RCTCursorContextualMenu:
return [NSCursor contextualMenuCursor];
case RCTCursorCopy:
return [NSCursor dragCopyCursor];
case RCTCursorCrosshair:
return [NSCursor crosshairCursor];
case RCTCursorDefault:
return [NSCursor arrowCursor];
case RCTCursorDisappearingItem:
return [NSCursor disappearingItemCursor];
case RCTCursorEastResize:
return [NSCursor resizeRightCursor];
case RCTCursorGrab:
return [NSCursor openHandCursor];
case RCTCursorGrabbing:
return [NSCursor closedHandCursor];
case RCTCursorNorthResize:
return [NSCursor resizeUpCursor];
case RCTCursorNoDrop:
return [NSCursor operationNotAllowedCursor];
case RCTCursorNotAllowed:
return [NSCursor operationNotAllowedCursor];
case RCTCursorPointer:
return [NSCursor pointingHandCursor];
case RCTCursorRowResize:
return [NSCursor resizeUpDownCursor];
case RCTCursorSouthResize:
return [NSCursor resizeDownCursor];
case RCTCursorText:
return [NSCursor IBeamCursor];
case RCTCursorVerticalText:
return [NSCursor IBeamCursorForVerticalLayout];
case RCTCursorWestResize:
return [NSCursor resizeLeftCursor];
}
}
#endif // macOS]

71 changes: 0 additions & 71 deletions packages/react-native/React/Views/RCTView.m
Original file line number Diff line number Diff line change
Expand Up @@ -1379,77 +1379,6 @@ static void RCTUpdateHoverStyleForView(RCTView *view)
}
#endif // visionOS]

#if TARGET_OS_OSX // [macOS
static NSCursor *NSCursorFromRCTCursor(RCTCursor cursor)
{
NSCursor *platformCursor;

switch (cursor) {
case RCTCursorAlias:
platformCursor = [NSCursor dragLinkCursor];
break;
case RCTCursorAuto:
platformCursor = [NSCursor arrowCursor];
break;
case RCTCursorColumnResize:
platformCursor = [NSCursor resizeLeftRightCursor];
break;
case RCTCursorContextualMenu:
platformCursor = [NSCursor contextualMenuCursor];
break;
case RCTCursorCopy:
platformCursor = [NSCursor dragCopyCursor];
break;
case RCTCursorCrosshair:
platformCursor = [NSCursor crosshairCursor];
break;
case RCTCursorDefault:
platformCursor = [NSCursor arrowCursor];
break;
case RCTCursorDisappearingItem:
platformCursor = [NSCursor disappearingItemCursor];
break;
case RCTCursorEastResize:
platformCursor = [NSCursor resizeRightCursor];
break;
case RCTCursorGrab:
platformCursor = [NSCursor openHandCursor];
break;
case RCTCursorGrabbing:
platformCursor = [NSCursor closedHandCursor];
break;
case RCTCursorNorthResize:
platformCursor = [NSCursor resizeUpCursor];
break;
case RCTCursorNoDrop:
platformCursor = [NSCursor operationNotAllowedCursor];
break;
case RCTCursorNotAllowed:
platformCursor = [NSCursor operationNotAllowedCursor];
break;
case RCTCursorPointer:
platformCursor = [NSCursor pointingHandCursor];
break;
case RCTCursorRowResize:
platformCursor = [NSCursor resizeUpDownCursor];
break;
case RCTCursorSouthResize:
platformCursor = [NSCursor resizeDownCursor];
break;
case RCTCursorText:
platformCursor = [NSCursor IBeamCursor];
break;
case RCTCursorVerticalText:
platformCursor = [NSCursor IBeamCursorForVerticalLayout];
break;
case RCTCursorWestResize:
platformCursor = [NSCursor resizeLeftCursor];
break;
}
return platformCursor;
}
#endif // macOS]

- (void)updateClippingForLayer:(CALayer *)layer
{
CALayer *mask = nil;
Expand Down
Loading

0 comments on commit 76b0732

Please sign in to comment.