Package cursor images correctly on Mac OS X so that all CSS cursor values work. b=349618 r=smorgan sr=bsmedberg

This commit is contained in:
joshmoz@gmail.com 2007-04-03 13:19:36 -07:00
parent f9204d14df
commit 8949ad1c8e
2 changed files with 31 additions and 1 deletions

View File

@ -170,6 +170,7 @@ ifneq ($(ABS_topsrcdir),$(MOZ_BUILD_ROOT))
export::
ln -fs $(srcdir)/cursors
endif
$(INSTALL) $(srcdir)/cursors $(DIST)/bin/res
$(RESOURCE): $(RES_SRC)
/Developer/Tools/Rez -i /Developer/Headers/FlatCarbon -useDF $< -o $@

View File

@ -37,6 +37,10 @@
#include "nsMacCursor.h"
#include "nsDebug.h"
#include "nsDirectoryServiceDefs.h"
#include "nsCOMPtr.h"
#include "nsIFile.h"
#include "nsString.h"
/*! @category nsMacCursor (PrivateMethods)
@abstract Private methods internal to the nsMacCursor class.
@ -345,7 +349,32 @@
- (id) initWithImageNamed: (NSString *) aCursorImage hotSpot: (NSPoint) aPoint
{
return [self initWithCursor: [[NSCursor alloc] initWithImage: [NSImage imageNamed: aCursorImage] hotSpot: aPoint]];
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;
}
- (void) setFrame: (int) aFrameIndex