Make Mac OS X cursor code 64-bit ready. Remove all Carbon API dependencies. b=464315 r=mstange sr=roc
authorJosh Aas <joshmoz@gmail.com>
Sat, 17 Jan 2009 14:23:43 -0500
changeset 23877 77cadc513819bef912ffddc392460a69e302997e
parent 23876 bcb61d06a3d47ad10dca6cc0cc1b73bd143ffb37
child 23878 fea1965d16bcf89a4aafb64f824181dc3a6eb04d
push id4769
push userjosh@mozilla.com
push dateSat, 17 Jan 2009 19:22:27 +0000
treeherdermozilla-central@77cadc513819 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange, roc
bugs464315
milestone1.9.2a1pre
Make Mac OS X cursor code 64-bit ready. Remove all Carbon API dependencies. b=464315 r=mstange sr=roc
widget/src/cocoa/Makefile.in
widget/src/cocoa/nsCursorManager.mm
widget/src/cocoa/nsMacCursor.h
widget/src/cocoa/nsMacCursor.mm
widget/src/cocoa/nsMacWidget.r
--- a/widget/src/cocoa/Makefile.in
+++ b/widget/src/cocoa/Makefile.in
@@ -140,36 +140,26 @@ NIB_DEST = $(DIST)/bin/res/MainMenu.nib
 libs:: $(addprefix $(NIB_DEST)/,$(NIB_FILES))
 
 $(NIB_DEST):
 	$(NSINSTALL) -D $@
 
 $(NIB_DEST)/%: $(srcdir)/resources/MainMenu.nib/% $(NIB_DEST)
 	$(INSTALL) $< $(NIB_DEST)
 
-RESOURCE = libwidget.rsrc
-
 # for objdir builds, symlink the cursors dir
 ABS_topsrcdir   := $(shell cd $(topsrcdir); pwd)
 ifneq ($(ABS_topsrcdir),$(MOZ_BUILD_ROOT))
 export::
 	ln -fs $(srcdir)/cursors
 endif
 
 export::
 	$(INSTALL) $(srcdir)/cursors $(DIST)/bin/res
 
-$(RESOURCE): nsMacWidget.r
-	/Developer/Tools/Rez -i /Developer/Headers/FlatCarbon -useDF $< -o $@
-
-GARBAGE += $(RESOURCE)
-
-libs:: $(RESOURCE)
-	$(INSTALL) $(IFLAGS1) $^ $(DIST)/bin
-
 LOCAL_INCLUDES	= \
 	$(TK_CFLAGS) \
 	-I$(srcdir)/../xpwidgets \
 	$(NULL)
 
 LDFLAGS	+= \
 	-framework QuickTime \
 	-framework IOKit \
--- a/widget/src/cocoa/nsCursorManager.mm
+++ b/widget/src/cocoa/nsCursorManager.mm
@@ -35,16 +35,17 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsCursorManager.h"
 #include "nsObjCExceptions.h"
 #include <math.h>
 
 static nsCursorManager *gInstance;
+static NSArray* sSpinCursorFrames = nil;
 
 /*! @category nsCursorManager(PrivateMethods)
     Private methods for the cursor manager class.
 */
 @interface nsCursorManager(PrivateMethods)
 /*! @method     getCursor:
     @abstract   Get a reference to the native Mac representation of a cursor.
     @discussion Gets a reference to the Mac native implementation of a cursor.
@@ -69,77 +70,87 @@ static nsCursorManager *gInstance;
 
 + (nsCursorManager *) sharedInstance
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
   if (!gInstance) {
     gInstance = [[nsCursorManager alloc] init];
   }
+
+  if (!sSpinCursorFrames) {
+    NSCursor* cursor1 = [nsMacCursor cocoaCursorWithImageNamed:@"spin1" hotSpot:NSMakePoint(1.0, 1.0)];
+    NSCursor* cursor2 = [nsMacCursor cocoaCursorWithImageNamed:@"spin2" hotSpot:NSMakePoint(1.0, 1.0)];
+    NSCursor* cursor3 = [nsMacCursor cocoaCursorWithImageNamed:@"spin3" hotSpot:NSMakePoint(1.0, 1.0)];
+    NSCursor* cursor4 = [nsMacCursor cocoaCursorWithImageNamed:@"spin4" hotSpot:NSMakePoint(1.0, 1.0)];
+    sSpinCursorFrames = [[NSArray alloc] initWithObjects:cursor1, cursor2, cursor3, cursor4, nil];
+  }
   return gInstance;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
 }
 
 + (void) dispose
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
   [gInstance release];
   gInstance = nil;
 
+  [sSpinCursorFrames release];
+  sSpinCursorFrames = nil;
+
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 + (nsMacCursor *) createCursor: (enum nsCursor) aCursor 
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
   switch(aCursor)
   {
     case eCursor_standard:
       return [nsMacCursor cursorWithCursor: [NSCursor arrowCursor]];
     case eCursor_wait:
-      return [nsMacCursor cursorWithThemeCursor: kThemeWatchCursor];
+    case eCursor_spinning:
+      return [nsMacCursor cursorWithFrames: sSpinCursorFrames];
     case eCursor_select:
       return [nsMacCursor cursorWithCursor: [NSCursor IBeamCursor]];
     case eCursor_hyperlink:
       return [nsMacCursor cursorWithCursor: [NSCursor pointingHandCursor]];
     case eCursor_crosshair:
       return [nsMacCursor cursorWithCursor: [NSCursor crosshairCursor]];
     case eCursor_move:
       return [nsMacCursor cursorWithCursor: [NSCursor openHandCursor]];
     case eCursor_help:
       return [nsMacCursor cursorWithImageNamed: @"help" hotSpot: NSMakePoint(1,1)];
     case eCursor_copy:
-      return [nsMacCursor cursorWithThemeCursor: kThemeCopyArrowCursor];
+      return [nsMacCursor cursorWithCursor: [NSCursor arrowCursor]]; //XXX needs real implementation
     case eCursor_alias:
-      return [nsMacCursor cursorWithThemeCursor: kThemeAliasArrowCursor];
+      return [nsMacCursor cursorWithCursor: [NSCursor arrowCursor]]; //XXX needs real implementation
     case eCursor_context_menu:
-      return [nsMacCursor cursorWithThemeCursor: kThemeContextualMenuArrowCursor];
+      return [nsMacCursor cursorWithCursor: [NSCursor arrowCursor]]; //XXX needs real implementation
 
     case eCursor_cell:
-      return [nsMacCursor cursorWithThemeCursor: kThemePlusCursor];
+      return [nsMacCursor cursorWithCursor: [NSCursor crosshairCursor]];
     case eCursor_grab:
       return [nsMacCursor cursorWithCursor: [NSCursor openHandCursor]];
     case eCursor_grabbing:
       return [nsMacCursor cursorWithCursor: [NSCursor closedHandCursor]];
-    case eCursor_spinning:
-      return [nsMacCursor cursorWithResources: 200 lastFrame: 203]; // better than kThemeSpinningCursor
     case eCursor_zoom_in:
       return [nsMacCursor cursorWithImageNamed: @"zoomIn" hotSpot: NSMakePoint(6,6)];
     case eCursor_zoom_out:
       return [nsMacCursor cursorWithImageNamed: @"zoomOut" hotSpot: NSMakePoint(6,6)];
     case eCursor_vertical_text:
       return [nsMacCursor cursorWithImageNamed: @"vtIBeam" hotSpot: NSMakePoint(7,8)];
     case eCursor_all_scroll:
       return [nsMacCursor cursorWithCursor: [NSCursor openHandCursor]];;
     case eCursor_not_allowed:
     case eCursor_no_drop:
-      return [nsMacCursor cursorWithThemeCursor: kThemeNotAllowedCursor];
+      return [nsMacCursor cursorWithCursor: [NSCursor arrowCursor]]; //XXX needs real implementation
 
     // Resize Cursors:
     //North
     case eCursor_n_resize:
         return [nsMacCursor cursorWithCursor: [NSCursor resizeUpCursor]];
     //North East
     case eCursor_ne_resize:
         return [nsMacCursor cursorWithImageNamed: @"sizeNE" hotSpot: NSMakePoint(8,7)];
--- a/widget/src/cocoa/nsMacCursor.h
+++ b/widget/src/cocoa/nsMacCursor.h
@@ -32,40 +32,31 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef nsMacCursor_h_
 #define nsMacCursor_h_
 
 #import <Cocoa/Cocoa.h>
-#import <Carbon/Carbon.h>
 
 /*! @class      nsMacCursor
     @abstract   Represents a native Mac cursor.
     @discussion <code>nsMacCursor</code> provides a simple API for creating and working with native Macintosh cursors.
                 Cursors can be created used without needing to be aware of the way different cursors are implemented,
                 in particular the details of managing an animated cursor are hidden.
 */
 @interface nsMacCursor : NSObject
 {
   @private
   NSTimer *mTimer;
   @protected
   int mFrameCounter;    
 }
 
-/*! @method     cursorWithThemeCursor:
-    @abstract   Create a cursor by specifying a Carbon Apperance Manager <code>ThemeCursor</code> constant.
-    @discussion Creates a cursor representing the given Appearance Manager built in cursor.
-    @param      aCursor the <code>ThemeCursor</code> to use
-    @result     an autoreleased instance of <code>nsMacCursor</code> representing the given <code>ThemeCursor</code>
- */
-+ (nsMacCursor *) cursorWithThemeCursor: (ThemeCursor) aCursor;
-
 /*! @method     cursorWithCursor:
     @abstract   Create a cursor by specifying a Cocoa <code>NSCursor</code>.
     @discussion Creates a cursor representing the given Cocoa built-in cursor.
     @param      aCursor the <code>NSCursor</code> to use
     @result     an autoreleased instance of <code>nsMacCursor</code> representing the given <code>NSCursor</code>
  */
 + (nsMacCursor *) cursorWithCursor: (NSCursor *) aCursor;
 
@@ -86,28 +77,24 @@
     @discussion Creates a cursor that will animate by cycling through the given frames. Each element of the array
                 must be an instance of <code>NSCursor</code>
     @param      aCursorFrames an array of <code>NSCursor</code>, representing the frames of an animated cursor, in the
                 order they should be played.
     @result     an autoreleased instance of <code>nsMacCursor</code> that will animate the given cursor frames
  */
 + (nsMacCursor *) cursorWithFrames: (NSArray *) aCursorFrames;
 
-/*! @method     cursorWithResources:lastFrame:
-    @abstract   Create an animated cursor by specifying a range of <code>CURS</code> resources to load and animate.
-    @discussion Creates a cursor that will animate by cycling through the given range of cursor resource ids. Each
-                resource in the range must be the next frame in the animation.
-                <p>To create a static cursor, simply pass the same resource id for both parameters.</p>
-                <p>The frames are loaded from the compiled version of the resource file nsMacWidget.r.</p>
-    @param      aFirstFrame the resource id for the first frame of the animation. Must be 128 or greated
-    @param      aLastFrame the resource id for the last frame of the animation. Must be 128 or greater, and greater than
-                or equal to <code>aFirstFrame</code>
-    @result     an autoreleased instance of <code>nsMacCursor</code> that will animate the given cursor resources
+/*! @method     cocoaCursorWithImageNamed:hotSpot:
+ @abstract   Create a Cocoa NSCursor object with a Gecko image resource name and a hotspot point.
+ @discussion Create a Cocoa NSCursor object with a Gecko image resource name and a hotspot point.
+ @param      imageName the name of the gecko image resource, "tiff" extension is assumed, do not append.
+ @param      aPoint the point within the cursor to use as the hotspot
+ @result     an autoreleased instance of <code>nsMacCursor</code> that will animate the given cursor frames
  */
-+ (nsMacCursor *) cursorWithResources: (int) aFirstFrame lastFrame: (int) aLastFrame;
++ (NSCursor *) cocoaCursorWithImageNamed: (NSString *) imageName hotSpot: (NSPoint) aPoint;
 
 /*! @method     set
     @abstract   Set the cursor.
     @discussion Makes this cursor the current cursor. If the cursor is animated, the animation is started.
  */
 - (void) set;
 
 /*! @method     unset
--- a/widget/src/cocoa/nsMacCursor.mm
+++ b/widget/src/cocoa/nsMacCursor.mm
@@ -75,56 +75,35 @@
     @discussion Invalidates and releases any <code>NSTimer</code> instance associated with this cursor.
  */
 - (void) destroyTimer;
 /*! @method     destroyTimer
     @abstract   Destroy any timer instance associated with this cursor.
     @discussion Invalidates and releases any <code>NSTimer</code> instance associated with this cursor.
 */
 
-/*! @method     spinCursor:
+/*! @method     advanceAnimatedCursor:
     @abstract   Method called by animation timer to perform animation.
     @discussion Called by an animated cursor's associated timer to advance the animation to the next frame.
                 Determines which frame should occur next and sets the cursor to that frame.
     @param      aTimer the timer causing the animation
 */
-- (void) spinCursor: (NSTimer *) aTimer;
+- (void) advanceAnimatedCursor: (NSTimer *) aTimer;
 
 /*! @method     setFrame:
     @abstract   Sets the current cursor, using an index to determine which frame in the animation to display.
     @discussion Sets the current cursor. The frame index determines which frame is shown if the cursor is animated.
                 Frames and numbered from <code>0</code> to <code>-[nsMacCursor numFrames] - 1</code>. A static cursor
                 has a single frame, numbered 0.
     @param      aFrameIndex the index indicating which frame from the animation to display
 */
 - (void) setFrame: (int) aFrameIndex;
 
 @end
 
-/*! @class      nsThemeCursor
-    @abstract   Implementation of <code>nsMacCursor</code> that uses Carbon Appearance Manager cursors.
-    @discussion Displays a static or animated <code>ThemeCursor</code> using Carbon Appearance Manager functions.
-                Understands how many frames exist in each of the built-in <code>ThemeCursor</code>s.
-*/
-@interface nsThemeCursor : nsMacCursor
-{
-  @private
-  ThemeCursor mCursor;
-}
-
-/*! @method     initWithThemeCursor:
-    @abstract   Create a cursor by specifying a Carbon Apperance Manager <code>ThemeCursor</code> constant.
-    @discussion Creates a cursor representing the given Appearance Manager built in cursor.
-    @param      aCursor the <code>ThemeCursor</code> to use
-    @result     an instance of <code>nsThemeCursor</code> representing the given <code>ThemeCursor</code>
-*/
-- (id) initWithThemeCursor: (ThemeCursor) aCursor;
-
-@end
-
 /*! @class      nsCocoaCursor
     @abstract   Implementation of <code>nsMacCursor</code> that uses Cocoa <code>NSCursor</code> instances.
     @discussion Displays a static or animated cursor, using Cocoa <code>NSCursor</code> instances. These can be either
                 built-in <code>NSCursor</code> instances, or custom <code>NSCursor</code>s created from images.
                 When more than one <code>NSCursor</code> is provided, the cursor will use these as animation frames.
 */
 @interface nsCocoaCursor : nsMacCursor
 {
@@ -159,64 +138,18 @@
     @param      aCursor the name of the image to use for the cursor
     @param      aPoint the point within the cursor to use as the hotspot
     @result     an instance of <code>nsCocoaCursor</code> that uses the given image and hotspot
 */
 - (id) initWithImageNamed: (NSString *) aCursorImage hotSpot: (NSPoint) aPoint;
 
 @end
 
-/*! @class      nsResourceCursor
-    @abstract   Implementation of <code>nsMacCursor</code> that uses Carbon <code>CURS</code> resources.
-    @discussion Displays a static or animated cursor, using Carbon <code>CURS</code> resources.
-                <p>Animated cursors are produced by cycling through a range of cursor resource ids.</p>
-                <p>The frames are loaded from the compiled version of the resource file nsMacWidget.r.</p>
- */
-@interface nsResourceCursor : nsMacCursor
-{
-  @private
-  int mFirstFrame;
-  int mLastFrame;
-}
-
-/*! @method     initWithResources:lastFrame:
-    @abstract   Create an animated cursor by specifying a range of <code>CURS</code> resources to load and animate.
-    @discussion Creates a cursor that will animate by cycling through the given range of cursor resource ids. Each
-                resource in the range must be the next frame in the animation.
-                <p>To create a static cursor, simply pass the same resource id for both parameters.</p>
-                <p>The frames are loaded from the compiled version of the resource file nsMacWidget.r.</p>
-    @param      aFirstFrame the resource id for the first frame of the animation. Must be 128 or greated
-    @param      aLastFrame the resource id for the last frame of the animation. Must be 128 or greater, and greater than
-                or equal to <code>aFirstFrame</code>
-    @result     an instance of <code>nsResourceCursor</code> that will animate the given cursor resources
-*/
-- (id) initWithFirstFrame: (int) aFirstFrame lastFrame: (int) aLastFrame;
-
-@end
-
 @implementation nsMacCursor
 
-+ (nsMacCursor *) cursorWithThemeCursor: (ThemeCursor) aCursor
-{
-  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
-
-  return [[[nsThemeCursor alloc] initWithThemeCursor: aCursor] autorelease];
-
-  NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
-}
-
-+ (nsMacCursor *) cursorWithResources: (int) aFirstFrame lastFrame: (int) aLastFrame
-{
-  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
-
-  return [[[nsResourceCursor alloc] initWithFirstFrame: aFirstFrame lastFrame: aLastFrame] autorelease];
-
-  NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
-}
-
 + (nsMacCursor *) cursorWithCursor: (NSCursor *) aCursor
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
   return [[[nsCocoaCursor alloc] initWithCursor: aCursor] autorelease];
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
 }
@@ -234,16 +167,54 @@
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
   return [[[nsCocoaCursor alloc] initWithFrames: aCursorFrames] autorelease];
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
 }
 
++ (NSCursor *) cocoaCursorWithImageNamed: (NSString *) imageName hotSpot: (NSPoint) aPoint
+{
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
+
+  nsCOMPtr<nsIFile> resDir;
+  nsCAutoString resPath;
+  NSString* pathToImage;
+  NSImage* cursorImage;
+
+  nsresult rv = NS_GetSpecialDirectory(NS_GRE_DIR, getter_AddRefs(resDir));
+  if (NS_FAILED(rv))
+    goto INIT_FAILURE;
+  resDir->AppendNative(NS_LITERAL_CSTRING("res"));
+  resDir->AppendNative(NS_LITERAL_CSTRING("cursors"));
+
+  rv = resDir->GetNativePath(resPath);
+  if (NS_FAILED(rv))
+    goto INIT_FAILURE;
+
+  pathToImage = [NSString stringWithUTF8String:(const char*)resPath.get()];
+  if (!pathToImage)
+    goto INIT_FAILURE;
+  pathToImage = [pathToImage stringByAppendingPathComponent:imageName];
+  pathToImage = [pathToImage stringByAppendingPathExtension:@"tiff"];
+
+  cursorImage = [[[NSImage alloc] initWithContentsOfFile:pathToImage] autorelease];
+  if (!cursorImage)
+    goto INIT_FAILURE;
+  return [[[NSCursor alloc] initWithImage: cursorImage hotSpot: aPoint] autorelease];
+
+INIT_FAILURE:
+  NS_WARNING("Problem getting path to cursor image file!");
+  [self release];
+  return nil;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
+}
+
 - (void) set
 {
   if ([self isAnimated]) {
     [self createTimer];
   }
   //if the cursor isn't animated or the timer creation fails for any reason...
   if (!mTimer) {
     [self setFrame: 0];
@@ -271,20 +242,20 @@
   mFrameCounter = (mFrameCounter + 1) % [self numFrames];
   return mFrameCounter;
 }
 
 - (void) createTimer
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
-  if (mTimer == nil) {
+  if (!mTimer) {
     mTimer = [[NSTimer scheduledTimerWithTimeInterval: 0.25
                                                target: self
-                                             selector: @selector(spinCursor:)
+                                             selector: @selector(advanceAnimatedCursor:)
                                              userInfo: nil
                                               repeats: YES] retain];
   }
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 - (void) destroyTimer
@@ -295,17 +266,17 @@
       [mTimer invalidate];
       [mTimer release];
       mTimer = nil;
   }
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
-- (void) spinCursor: (NSTimer *) aTimer
+- (void) advanceAnimatedCursor: (NSTimer *) aTimer
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
   if ([aTimer isValid]) {
     [self setFrame: [self getNextCursorFrame]];
   }
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
@@ -323,65 +294,16 @@
   [self destroyTimer];
   [super dealloc];
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 @end
 
-@implementation nsThemeCursor
-
-- (id) initWithThemeCursor: (ThemeCursor) aCursor
-{
-  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
-
-  self = [super init];
-  //Appearance Manager cursors all fall into the range 0..127. Custom application CURS resources begin at id 128.
-  NS_ASSERTION(mCursor >= 0 && mCursor < 128, "Theme cursors must be in the range 0 <= num < 128");
-  mCursor = aCursor;    
-  return self;
-
-  NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
-}
-
-- (void) setFrame: (int) aFrameIndex
-{
-  NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
-
-  if ([self isAnimated]) {
-    //if the cursor is animated try to draw the appropriate frame
-    OSStatus err = ::SetAnimatedThemeCursor(mCursor, aFrameIndex);
-    if (err != noErr) {
-      //in the event of any kind of problem, just try to show the first frame
-      ::SetThemeCursor(mCursor);
-    }
-  }
-  else {
-    ::SetThemeCursor(mCursor);
-  }
-
-  NS_OBJC_END_TRY_ABORT_BLOCK;
-}
-
-- (int) numFrames
-{
-  //These don't appear to be documented. Trial and Error...
-  switch (mCursor)
-  {
-    case kThemeWatchCursor:
-    case kThemeSpinningCursor:            
-      return 8;
-    default:
-      return 1;
-  }
-}
-
-@end
-
 @implementation nsCocoaCursor
 
 - (id) initWithFrames: (NSArray *) aCursorFrames
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
   self = [super init];
   NSEnumerator *it = [aCursorFrames objectEnumerator];
@@ -405,42 +327,17 @@
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
 }
 
 - (id) initWithImageNamed: (NSString *) aCursorImage hotSpot: (NSPoint) aPoint
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
-  nsCOMPtr<nsIFile> resDir;
-  nsCAutoString resPath;
-  NSString* pathToImage;
-  NSImage* cursorImage;
-
-  nsresult rv = NS_GetSpecialDirectory(NS_GRE_DIR, getter_AddRefs(resDir));
-  if (NS_FAILED(rv)) goto INIT_FAILURE;
-  resDir->AppendNative(NS_LITERAL_CSTRING("res"));
-  resDir->AppendNative(NS_LITERAL_CSTRING("cursors"));
-
-  rv = resDir->GetNativePath(resPath);
-  if (NS_FAILED(rv)) goto INIT_FAILURE;
-
-  pathToImage = [NSString stringWithUTF8String:(const char*)resPath.get()];
-  if (!pathToImage) goto INIT_FAILURE;
-  pathToImage = [pathToImage stringByAppendingPathComponent:aCursorImage];
-  pathToImage = [pathToImage stringByAppendingPathExtension:@"tiff"];
-
-  cursorImage = [[[NSImage alloc] initWithContentsOfFile:pathToImage] autorelease];
-  if (!cursorImage) goto INIT_FAILURE;
-  return [self initWithCursor: [[NSCursor alloc] initWithImage: cursorImage hotSpot: aPoint]];
-
-INIT_FAILURE:
-  NS_WARNING("Problem getting path to cursor image file!");
-  [self release];
-  return nil;
+  return [self initWithCursor: [nsMacCursor cocoaCursorWithImageNamed: aCursorImage hotSpot: aPoint]];
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
 }
 
 - (void) setFrame: (int) aFrameIndex
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
@@ -473,98 +370,8 @@ INIT_FAILURE:
 
   [mFrames release];
   [super dealloc];
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 @end
-
-@implementation nsResourceCursor
-
-static short sRefNum = kResFileNotOpened;
-static short sSaveResFile = 0;
-
-// this could be simplified if it was rewritten using Cocoa
-+(void)openLocalResourceFile
-{
-  NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
-
-  if (sRefNum == kResFileNotOpened) {
-    CFBundleRef appBundle = ::CFBundleGetMainBundle();
-    if (appBundle) {
-      CFURLRef executable = ::CFBundleCopyExecutableURL(appBundle);
-      if (executable) {
-        CFURLRef binDir = ::CFURLCreateCopyDeletingLastPathComponent(kCFAllocatorDefault, executable);
-        if (binDir) {
-          CFURLRef resourceFile = ::CFURLCreateCopyAppendingPathComponent(kCFAllocatorDefault, binDir,
-                                                                          CFSTR("libwidget.rsrc"), PR_FALSE);
-          if (resourceFile) {
-            FSRef resourceRef;
-            if (::CFURLGetFSRef(resourceFile, &resourceRef))
-              ::FSOpenResourceFile(&resourceRef, 0, NULL, fsRdPerm, &sRefNum);
-            ::CFRelease(resourceFile);
-          }
-          ::CFRelease(binDir);
-        }
-        ::CFRelease(executable);
-      }
-    }
-  }
-
-  if (sRefNum == kResFileNotOpened)
-    return;
-  
-  sSaveResFile = ::CurResFile();
-  ::UseResFile(sRefNum);
-
-  NS_OBJC_END_TRY_ABORT_BLOCK;
-}
-
-+(void)closeLocalResourceFile
-{
-  NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
-
-  if (sRefNum == kResFileNotOpened)
-    return;
-
-  ::UseResFile(sSaveResFile);
-
-  NS_OBJC_END_TRY_ABORT_BLOCK;
-}
-
--(id) initWithFirstFrame: (int) aFirstFrame lastFrame: (int) aLastFrame
-{
-  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
-
-  if ((self = [super init])) {
-    //Appearance Manager cursors all fall into the range 0..127. Custom application CURS resources begin at id 128.
-    NS_ASSERTION(aFirstFrame >= 128 && aLastFrame >= 128 && aLastFrame >= aFirstFrame, "Nonsensical frame indicies");
-    mFirstFrame = aFirstFrame;
-    mLastFrame = aLastFrame;
-  }
-  return self;
-
-  NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
-}
-
-- (void) setFrame: (int) aFrameIndex
-{
-  NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
-
-  [nsResourceCursor openLocalResourceFile];
-  CursHandle cursHandle = ::GetCursor(mFirstFrame + aFrameIndex);
-  NS_ASSERTION(cursHandle, "Can't load cursor, is the resource file installed correctly?");
-  if (cursHandle) {
-    ::SetCursor(*cursHandle);
-  }
-  [nsResourceCursor closeLocalResourceFile];
-
-  NS_OBJC_END_TRY_ABORT_BLOCK;
-}
-
-- (int) numFrames
-{
-  return (mLastFrame - mFirstFrame) + 1;
-}
-
-@end
deleted file mode 100644
--- a/widget/src/cocoa/nsMacWidget.r
+++ /dev/null
@@ -1,222 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include <Types.r>
-
-resource 'CURS' (128, locked, preload) {
-	$"0000 4000 6000 7000 7800 7C00 7E00 7F00"
-	$"7F8E 7C1B 6C03 4606 060C 0300 030C",
-	$"C000 E000 F000 F800 FC00 FE00 FF00 FF80"
-	$"FFCE FFDB FE03 EF06 CF0C 8780 078C 0380",
-	{1, 1}
-};
-
-resource 'CURS' (129, locked, preload) {
-	$"0F00 30C0 4020 4620 8610 9F90 9F90 8610"
-	$"4620 4020 30F0 0F38 001C 000E 0007 0002",
-	$"0F00 3FC0 7FE0 7FE0 FFF0 FFF0 FFF0 FFF0"
-	$"7FE0 7FE0 3FF0 0F38 001C 000E 0007 0002",
-	{6, 6}
-};
-
-resource 'CURS' (130, locked, preload) {
-	$"0F00 30C0 4020 4020 8010 9F90 9F90 8010"
-	$"4020 4020 30F0 0F38 001C 000E 0007 0002",
-	$"0F00 3FC0 7FE0 7FE0 FFF0 FFF0 FFF0 FFF0"
-	$"7FE0 7FE0 3FF0 0F38 001C 000E 0007 0002",
-	{6, 6}
-};
-
-resource 'CURS' (131, locked, preload) {
-	$"0000 4000 6000 7000 7800 7C00 7E00 7F00"
-	$"7F80 7000 6600 4900 1480 1280 0900 06",
-	$"C000 E000 F000 F800 FC00 FE00 FF00 FF80"
-	$"FFC0 FF80 FF00 FF80 FFC0 3FC0 1F80 0F",
-	{0, 0}
-};
-
-resource 'CURS' (132, locked, preload) {
-	$"0000 0660 0660 0660 0660 2664 6666 FE7F"
-	$"FE7F 6666 2664 0660 0660 0660 0660",
-	$"0FF0 0FF0 0FF0 0FF0 2FF4 6FF6 FFFF FFFF"
-	$"FFFF FFFF 6FF6 2FF4 0FF0 0FF0 0FF0 0FF0",
-	{7, 7}
-};
-
-resource 'CURS' (133, locked, preload) {
-	$"0180 03C0 07E0 0180 0180 7FFE 7FFE 0000"
-	$"0000 7FFE 7FFE 0180 0180 07E0 03C0 0180",
-	$"03C0 07E0 0FF0 03C0 FFFF FFFF FFFF FFFF"
-	$"FFFF FFFF FFFF FFFF 03C0 0FF0 07E0 03C0",
-	{7, 7}
-};
-
-resource 'CURS' (134, locked, preload) {
-	$"0000 0000 0000 0000 8001 8001 4102 3FFC"
-	$"4102 8001 8001",
-	$"0000 0000 0000 0000 8001 8001 4102 3FFC"
-	$"4102 8001 8001",
-	{7, 7}
-};
-
-resource 'CURS' (135, locked, preload) {
-	$"0000 0180 03C0 07E0 0180 0180 0180 7FFE"
-	$"7FFE",
-	$"0180 03C0 07E0 0FF0 0FF0 03C0 FFFF FFFF"
-	$"FFFF FFFF",
-	{7, 7}
-};
-
-resource 'CURS' (136, locked, preload) {
-	$"0000 0000 0000 0000 0000 0000 0000 7FFE"
-	$"7FFE 0180 0180 0180 07E0 03C0 0180",
-	$"0000 0000 0000 0000 0000 0000 FFFF FFFF"
-	$"FFFF FFFF 03C0 0FF0 0FF0 07E0 03C0 0180",
-	{7, 7}
-};
-
-resource 'CURS' (137, locked, preload) {
-	$"0000 0000 0000 1E18 1C38 1E70 17E0 03C0"
-	$"0380 0700 0E00 1C00 18",
-	$"0000 0000 3F80 3F18 3E38 3E70 3FE0 33C0"
-	$"2380 0700 0E00 1C00 18",
-	{7, 7}
-};
-
-resource 'CURS' (138, locked, preload) {
-	$"0000 0000 0000 0018 0038 0070 00E0 01C0"
-	$"03C0 07E8 0E78 1C38 1878",
-	$"0000 0000 0000 0018 0038 0070 00E0 01C4"
-	$"03CC 07FC 0E7C 1C7C 18FC 01FC",
-	{8, 8}
-};
-
-resource 'CURS' (139, locked, preload) {
-	$"0000 0000 0000 1878 1C38 0E78 07E8 03C0"
-	$"01C0 00E0 0070 0038 0018",
-	$"0000 0000 01FC 18FC 1C7C 0E7C 07FC 03CC"
-	$"01C4 00E0 0070 0038 0018",
-	{7, 8}
-};
-
-resource 'CURS' (140, locked, preload) {
-	$"0000 0000 0000 1800 1C00 0E00 0700 0380"
-	$"03C0 17E0 1E70 1C38 1E18",
-	$"0000 0000 0000 1800 1C00 0E00 0700 2380"
-	$"33C0 3FE0 3E70 3E38 3F18 3F80",
-	{8, 6}
-};
-
-resource 'CURS' (141, locked, preload) {
-	$"0000 0180 03C0 07E0 0180 0180 0180 7FFE"
-	$"7FFE 0180 0180 0180 07E0 03C0 0180",
-	$"0180 03C0 07E0 0FF0 0FF0 03C0 FFFF FFFF"
-	$"FFFF FFFF 03C0 0FF0 0FF0 07E0 03C0 0180",
-	{7, 7}
-};
-
-resource 'CURS' (142, locked, preload) {
-	$"0000 0000 0000 1878 1C38 0E78 07E8 03C0"
-	$"03C0 17E0 1E70 1C38 1E18",
-	$"0000 0000 387C 3CFC 3E7C 1FFC 0FFC 07E8"
-	$"17E0 3FF0 3FF8 3E7C 3F3C 3E1C",
-	{7, 7}
-};
-
-resource 'CURS' (143, locked, preload) {
-	$"0000 0000 0000 1E18 1C38 1E70 17E0 03C0"
-	$"03C0 07E8 0E78 1C38 1878",
-	$"0000 0000 3E1C 3F3C 3E7C 3FF8 3FF0 17E0"
-	$"07E8 0FFC 1FFC 3E7C 3CFC 387C",
-	{7, 7}
-};
-
-resource 'CURS' (200, locked, preload) {
-    $"0000 4000 6000 7000 7800 7C00 7E00 7F00"
-    $"7FB8 7C74 6CF2 46FE 069E 035C 0338 0000",
-    $"C000 E000 F000 F800 FC00 FE00 FF00 FFB8"
-    $"FFFC FFFE FFFF EFFF CFFF 87FE 07FC 03B8",
-    {1,1}
-};
-
-resource 'CURS' (201, locked, preload) {
-    $"0000 4000 6000 7000 7800 7C00 7E00 7F00"
-    $"7FB8 7C7C 6CBA 4692 06BA 037C 0338 0000",
-    $"C000 E000 F000 F800 FC00 FE00 FF00 FFB8"
-    $"FFFC FFFE FFFF EFFF CFFF 87FE 07FC 03B8",
-    {1,1}
-};
-
-resource 'CURS' (202, locked, preload) {
-    $"0000 4000 6000 7000 7800 7C00 7E00 7F00"
-    $"7FB8 7C5C 6C9E 46FE 06F2 0374 0338 0000",
-    $"C000 E000 F000 F800 FC00 FE00 FF00 FFB8"
-    $"FFFC FFFE FFFF EFFF CFFF 87FE 07FC 03B8",
-    {1,1}
-};
-
-resource 'CURS' (203, locked, preload) {
-    $"0000 4000 6000 7000 7800 7C00 7E00 7F00"
-    $"7FB8 7C44 6CEE 46FE 06EE 0344 0338 0000",
-    $"C000 E000 F000 F800 FC00 FE00 FF00 FFB8"
-    $"FFFC FFFE FFFF EFFF CFFF 87FE 07FC 03B8",
-    {1,1}
-};
-
-data 'TMPL' (129, "ldes") {
-	$"0756 6572 7369 6F6E 4457 5244 0452 6F77"            /* .VersionDWRD.Row */
-	$"7344 5752 4407 436F 6C75 6D6E 7344 5752"            /* sDWRD.ColumnsDWR */
-	$"440B 4365 6C6C 2048 6569 6768 7444 5752"            /* D.Cell HeightDWR */
-	$"440A 4365 6C6C 2057 6964 7468 4457 5244"            /* DĀCell WidthDWRD */
-	$"0B56 6572 7420 5363 726F 6C6C 424F 4F4C"            /* .Vert ScrollBOOL */
-	$"0C48 6F72 697A 2053 6372 6F6C 6C42 4F4F"            /* .Horiz ScrollBOO */
-	$"4C07 4C44 4546 2049 4444 5752 4408 4861"            /* L.LDEF IDDWRD.Ha */
-	$"7320 4772 6F77 424F 4F4C"                           /* s GrowBOOL */
-};
-
-resource 'ldes' (128, purgeable) {
-	versionZero {
-		0,
-		1,
-		0,
-		0,
-		hasVertScroll,
-		noHorizScroll,
-		0,
-		noGrowSpace
-	}
-};