From 9b5ae05e33202ddc0aae4d1e8d60015e8968ca70 Mon Sep 17 00:00:00 2001 From: "seawood%netscape.com" Date: Sat, 27 Oct 2001 07:38:18 +0000 Subject: [PATCH] Landing the rest of the mach-o OSX changes. Bug #75653 r=cls sr=waterson --- Makefile.in | 5 + allmakefiles.sh | 6 + config/rules.mk | 2 +- configure.in | 38 +- gfx/src/mac/Makefile.in | 4 +- gfx/src/mac/nsDeviceContextMac.cpp | 4 +- gfx/src/mac/nsDeviceContextSpecX.cpp | 1 + gfx/src/mac/nsGfxFactoryMac.cpp | 102 ++- gfx/src/mac/nsPrintOptionsX.cpp | 23 +- gfx/src/mac/nsWatchTask.cpp | 9 +- gfx/src/mac/nsWatchTask.h | 4 + js/src/fdlibm/k_standard.c | 2 +- js/src/prmjtime.c | 4 +- layout/base/nsCSSFrameConstructor.cpp | 2 +- .../html/style/src/nsCSSFrameConstructor.cpp | 2 +- lib/mac/MoreFiles/MoreFilesSearch.c | 4 +- modules/libimg/gifcom/gif.cpp | 4 +- modules/libpr0n/decoders/gif/GIF2.cpp | 4 +- .../libpr0n/decoders/gif/nsGIFDecoder2.cpp | 6 +- .../libpr0n/decoders/jpeg/nsJPEGDecoder.cpp | 6 +- modules/libpr0n/decoders/png/nsPNGDecoder.cpp | 10 +- modules/libreg/src/Makefile.in | 4 + modules/libreg/src/VerReg.c | 32 +- modules/libreg/src/nr_bufio.c | 6 +- modules/libreg/src/reg.c | 26 +- modules/libreg/src/vr_stubs.c | 10 +- modules/libreg/src/vr_stubs.h | 2 +- modules/libreg/standalone/Makefile.in | 5 + modules/libreg/xpcom/nsRegistry.cpp | 2 +- modules/plugin/base/public/nsPluginDefs.idl | 10 +- modules/plugin/base/public/nsplugindefs.h | 10 +- modules/plugin/base/src/nsPluginHostImpl.cpp | 2 +- netwerk/protocol/http/src/nsHttpHandler.cpp | 4 +- webshell/src/Makefile.in | 2 +- webshell/tests/viewer/Makefile.in | 4 +- webshell/tests/viewer/nsMacMain.cpp | 625 +++++++++--------- webshell/tests/viewer/nsViewerApp.cpp | 5 + webshell/tests/viewer/nsViewerApp.h | 2 +- widget/src/mac/nsAppShell.cpp | 4 +- widget/src/mac/nsDragService.cpp | 4 + widget/src/mac/nsFilePicker.cpp | 4 + widget/src/mac/nsMacEventHandler.cpp | 2 +- widget/src/mac/nsMacMessagePump.cpp | 8 +- widget/src/mac/nsMacResources.cpp | 10 + widget/src/mac/nsMacWindow.cpp | 13 +- widget/src/mac/nsMenuBar.cpp | 2 + widget/src/mac/nsSound.cpp | 6 +- widget/src/mac/nsToolkit.h | 4 +- widget/src/mac/nsWidgetFactory.cpp | 156 +++++ xpcom/base/nsISupportsUtils.h | 2 +- xpcom/build/Makefile.in | 10 + xpcom/components/nsComponentManager.h | 2 +- xpcom/components/nsNativeComponentLoader.cpp | 6 +- xpcom/components/nsRegistry.cpp | 2 +- xpcom/glue/nsISupportsUtils.h | 2 +- xpcom/io/Makefile.in | 9 + xpcom/io/nsAppFileLocationProvider.cpp | 11 +- xpcom/io/nsDirectoryService.cpp | 111 +++- xpcom/io/nsDirectoryService.h | 4 +- xpcom/io/nsDirectoryServiceDefs.h | 15 +- xpcom/io/nsFileSpec.cpp | 67 +- xpcom/io/nsFileSpec.h | 38 +- xpcom/io/nsFileSpecMac.cpp | 11 +- xpcom/io/nsILocalFileMac.h | 3 + xpcom/io/nsLocalFile.h | 4 +- xpcom/io/nsLocalFileMac.cpp | 22 +- xpcom/io/nsSpecialSystemDirectory.cpp | 86 ++- xpcom/io/nsSpecialSystemDirectory.h | 4 +- xpcom/io/nsStdFileStream.cpp | 2 +- xpcom/reflect/xptcall/src/md/unix/Makefile.in | 2 +- xpcom/tests/FilesTest.cpp | 4 +- xpcom/threads/plevent.c | 4 +- xpfe/appshell/src/nsWebShellWindow.cpp | 4 +- xpfe/bootstrap/Makefile.in | 13 + xpfe/bootstrap/nsAppRunner.cpp | 22 + xpinstall/cleanup/Makefile.in | 4 + xpinstall/src/nsInstall.cpp | 4 +- 77 files changed, 1080 insertions(+), 594 deletions(-) diff --git a/Makefile.in b/Makefile.in index 94fcd2c04e3f..e3e965dce4a8 100644 --- a/Makefile.in +++ b/Makefile.in @@ -51,6 +51,11 @@ endif DIRS += $(NSPRPUB_DIR) +# MacOSX needs to build lib for MoreFiles before xpcom +ifeq ($(OS_ARCH),Darwin) +DIRS += lib/mac/MoreFiles +endif + # intl should not be in here - it's just temporary until # xpconnect's dependency on intl is repaired - see bug 106130 DIRS += dbm modules/libreg js string xpcom intl js/src/xpconnect diff --git a/allmakefiles.sh b/allmakefiles.sh index 7a79701970d7..ac7e1e7bb62c 100755 --- a/allmakefiles.sh +++ b/allmakefiles.sh @@ -786,6 +786,12 @@ extensions/transformiix/source/Makefile extensions/transformiix/Makefile " +if [ "$MACOSX" ]; then + MAKEFILES_macmorefiles=" + lib/mac/MoreFiles/Makefile +" +fi + if [ "$MOZ_MAIL_NEWS" ]; then if [ -f ${srcdir}/mailnews/makefiles ]; then MAKEFILES_mailnews=`cat ${srcdir}/mailnews/makefiles` diff --git a/config/rules.mk b/config/rules.mk index 4760feb2ebda..32a9a3b7a34b 100644 --- a/config/rules.mk +++ b/config/rules.mk @@ -747,7 +747,7 @@ ifneq ($(OS_ARCH),OS2) # that are built using other static libraries. Confused...? # ifdef SHARED_LIBRARY_LIBS -ifneq (,$(filter OSF1 BSD_OS FreeBSD NetBSD OpenBSD SunOS Rhapsody,$(OS_ARCH))) +ifneq (,$(filter OSF1 BSD_OS FreeBSD NetBSD OpenBSD SunOS Darwin,$(OS_ARCH))) CLEANUP1 := | egrep -v '(________64ELEL_|__.SYMDEF)' CLEANUP2 := rm -f ________64ELEL_ __.SYMDEF else diff --git a/configure.in b/configure.in index 993150784238..6d5731144e71 100644 --- a/configure.in +++ b/configure.in @@ -921,23 +921,35 @@ alpha*-*-osf*) fi ;; -*-rhapsody*) - DLL_SUFFIX=".dylib" - DSO_LDOPTS='-compatibility_version 1 -current_version 1' - AC_DEFINE(NO_X11) +*-darwin*) AC_DEFINE(DARWIN) - AC_DEFINE(RHAPSODY) AC_DEFINE(TARGET_CARBON) AC_DEFINE(TARGET_API_MAC_CARBON) ENABLE_TESTS= - MOZ_WIDGET_TOOLKIT='mac' - TK_LIBS='/System/Library/Frameworks/Carbon.framework/Carbon' - CFLAGS="$CFLAGS -traditional-cpp -fno-common -I/System/Library/Frameworks/Carbon.framework/Headers" - CXXFLAGS="$CXXFLAGS -traditional-cpp -fno-common -I/System/Library/Frameworks/Carbon.framework/Headers" - MKSHLIB='$(CXX) $(CXXFLAGS) -arch ppc $(DSO_LDOPTS) -o $@' + _PEDANTIC= + CFLAGS="$CFLAGS -fpascal-strings -traditional-cpp -fno-common" + CXXFLAGS="$CXXFLAGS -fpascal-strings -traditional-cpp -fno-common" + DLL_SUFFIX=".dylib" + DSO_LDOPTS='-compatibility_version 1 -current_version 1' + MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_LDOPTS) -o $@' MKCSHLIB='$(CC) $(CFLAGS) $(DSO_LDOPTS) -o $@' - MKSHLIB_FORCE_ALL='' - MKSHLIB_UNFORCE_ALL='' + case "${target_cpu}" in + powerpc*) + AC_DEFINE(NO_X11) + AC_DEFINE(XP_MACOSX) + AC_DEFINE(TARGET_CARBON) + AC_DEFINE(TARGET_API_MAC_CARBON) + no_x=yes + MACOSX=1 + MOZ_WIDGET_TOOLKIT='mac' + LDFLAGS="$LDFLAGS -framework Carbon" + DSO_LDOPTS="$DSO_LDOPTS -arch ppc -install_name @executable_path/\$@" + TK_LIBS='/System/Library/Frameworks/Carbon.framework/Carbon' + TK_CFLAGS="-I/Developer/Headers/FlatCarbon -F/System/Library/Frameworks" + CFLAGS="$CFLAGS $TK_CFLAGS" + CXXFLAGS="$CXXFLAGS $TK_CFLAGS" + ;; + esac ;; *-sco*) @@ -4018,7 +4030,7 @@ elif test "$OS_TARGET" = "BeOS"; then AC_DEFINE(XP_BEOS) MOZ_MOVEMAIL=1 AC_SUBST(MOZ_MOVEMAIL) -elif test "$OS_TARGET" = "Mac OS"; then +elif test "$OS_TARGET" = "Darwin"; then AC_DEFINE(XP_UNIX) AC_DEFINE(UNIX_EMBED) AC_DEFINE(UNIX_LDAP) diff --git a/gfx/src/mac/Makefile.in b/gfx/src/mac/Makefile.in index ab747d9a89be..65cd880df116 100644 --- a/gfx/src/mac/Makefile.in +++ b/gfx/src/mac/Makefile.in @@ -62,11 +62,13 @@ CPPSRCS = \ nsUnicodeRenderingToolkit.cpp \ nsScreenMac.cpp \ nsScreenManagerMac.cpp \ + nsPrintOptionsX.cpp \ $(NULL) +# $(DIST)/lib/libimg_s.a \ + EXTRA_DSO_LDOPTS = \ $(MKSHLIB_FORCE_ALL) \ - $(DIST)/lib/libimg_s.a \ $(DIST)/lib/libmozutil_s.a \ -lgkgfx \ $(MKSHLIB_UNFORCE_ALL) \ diff --git a/gfx/src/mac/nsDeviceContextMac.cpp b/gfx/src/mac/nsDeviceContextMac.cpp index 7b78147b7bdf..62a729533781 100644 --- a/gfx/src/mac/nsDeviceContextMac.cpp +++ b/gfx/src/mac/nsDeviceContextMac.cpp @@ -954,10 +954,10 @@ PRUint32 nsDeviceContextMac::GetScreenResolution() nsCOMPtr prefs(do_GetService(kPrefCID, &rv)); if (NS_SUCCEEDED(rv) && prefs) { PRInt32 intVal; - if (NS_SUCCEEDED(prefs->GetIntPref("browser.display.screen_resolution", &intVal))) { + if (NS_SUCCEEDED(prefs->GetIntPref("browser.display.screen_resolution", &intVal)) && intVal > 0) { mPixelsPerInch = intVal; } -#if 0 +#ifdef XP_MACOSX else { short hppi, vppi; ::ScreenRes(&hppi, &vppi); diff --git a/gfx/src/mac/nsDeviceContextSpecX.cpp b/gfx/src/mac/nsDeviceContextSpecX.cpp index c2fc543df5f4..7dc17d8c3cfb 100644 --- a/gfx/src/mac/nsDeviceContextSpecX.cpp +++ b/gfx/src/mac/nsDeviceContextSpecX.cpp @@ -38,6 +38,7 @@ * * ***** END LICENSE BLOCK ***** */ +#define PM_USE_SESSION_APIS 0 #include "nsDeviceContextSpecX.h" #include "prmem.h" diff --git a/gfx/src/mac/nsGfxFactoryMac.cpp b/gfx/src/mac/nsGfxFactoryMac.cpp index 206c085ddde9..9e8b549fb290 100644 --- a/gfx/src/mac/nsGfxFactoryMac.cpp +++ b/gfx/src/mac/nsGfxFactoryMac.cpp @@ -20,7 +20,7 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): - * + * Patrick C. Beard * * 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 @@ -59,6 +59,104 @@ #include "nsScreenManagerMac.h" #include "nsBlender.h" #include "nsCOMPtr.h" +#include "nsPrintOptionsMac.h" + +#ifdef XP_MACOSX + +#include "nsIGenericFactory.h" + +// XXX Implement the GFX module using NS_GENERIC_FACTORY_CONSTRUCTOR / NS_IMPL_NSGETMODULE + +NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontMetricsMac) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextMac) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsRenderingContextMac) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsImageMac) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsRegionMac) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsBlender) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsDrawingSurfaceMac) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecX) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrintOptionsX) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecFactoryMac) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontEnumeratorMac) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontList) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerMac) + +static NS_IMETHODIMP +nsScriptableRegionConstructor(nsISupports* aOuter, REFNSIID aIID, void** aResult) +{ + NS_ENSURE_NO_AGGREGATION(aOuter); + NS_ENSURE_ARG_POINTER(aResult); + *aResult = nsnull; + nsCOMPtr region = new nsRegionMac(); + NS_ENSURE_TRUE(region, NS_ERROR_OUT_OF_MEMORY); + nsCOMPtr result(new nsScriptableRegion(region)); + NS_ENSURE_TRUE(result, NS_ERROR_OUT_OF_MEMORY); + return result->QueryInterface(aIID, aResult); +} + +static nsModuleComponentInfo components[] = +{ + { "nsFontMetrics", + NS_FONT_METRICS_CID, + "@mozilla.org/gfx/fontmetrics;1", + nsFontMetricsMacConstructor }, + { "nsDeviceContext", + NS_DEVICE_CONTEXT_CID, + "@mozilla.org/gfx/devicecontext;1", + nsDeviceContextMacConstructor }, + { "nsRenderingContext", + NS_RENDERING_CONTEXT_CID, + "@mozilla.org/gfx/renderingcontext;1", + nsRenderingContextMacConstructor }, + { "nsImage", + NS_IMAGE_CID, + "@mozilla.org/gfx/image;1", + nsImageMacConstructor }, + { "nsRegion", + NS_REGION_CID, + "@mozilla.org/gfx/unscriptable-region;1", + nsRegionMacConstructor }, + { "nsBlender", + NS_BLENDER_CID, + "@mozilla.org/gfx/blender;1", + nsBlenderConstructor }, + { "nsDrawingSurface", + NS_DRAWING_SURFACE_CID, + "@mozilla.org/gfx/drawing-surface;1", + nsDrawingSurfaceMacConstructor }, + { "nsDeviceContextSpec", + NS_DEVICE_CONTEXT_SPEC_CID, + "@mozilla.org/gfx/devicecontextspec;1", + nsDeviceContextSpecXConstructor }, + { "nsDeviceContextSpecFactory", + NS_DEVICE_CONTEXT_SPEC_FACTORY_CID, + "@mozilla.org/gfx/devicecontextspecfactory;1", + nsDeviceContextSpecFactoryMacConstructor }, + { "nsScriptableRegion", + NS_SCRIPTABLE_REGION_CID, + "@mozilla.org/gfx/region;1", + nsScriptableRegionConstructor }, + { "nsPrintOptions", + NS_PRINTOPTIONS_CID, + "@mozilla.org/gfx/printoptions;1", + nsPrintOptionsXConstructor }, + { "nsFontEnumerator", + NS_FONT_ENUMERATOR_CID, + "@mozilla.org/gfx/fontenumerator;1", + nsFontEnumeratorMacConstructor }, + { "nsFontList", + NS_FONTLIST_CID, + "@mozilla.org/gfx/fontlist;1", + nsFontListConstructor }, + { "nsScreenManager", + NS_SCREENMANAGER_CID, + "@mozilla.org/gfx/screenmanager;1", + nsScreenManagerMacConstructor } +}; + +NS_IMPL_NSGETMODULE(nsGfxModule, components) + +#else static NS_DEFINE_IID(kCFontMetrics, NS_FONT_METRICS_CID); static NS_DEFINE_IID(kCFontEnumerator, NS_FONT_ENUMERATOR_CID); @@ -211,3 +309,5 @@ extern "C" NS_GFX nsresult NSGetFactory(nsISupports* servMgr, return factory->QueryInterface(kIFactoryIID, (void**)aFactory); } + +#endif diff --git a/gfx/src/mac/nsPrintOptionsX.cpp b/gfx/src/mac/nsPrintOptionsX.cpp index fc9744c7ab7d..01cbcf64cabd 100644 --- a/gfx/src/mac/nsPrintOptionsX.cpp +++ b/gfx/src/mac/nsPrintOptionsX.cpp @@ -36,6 +36,7 @@ * * ***** END LICENSE BLOCK ***** */ +#define PM_USE_SESSION_APIS 0 #include #include "nsCOMPtr.h" @@ -145,18 +146,20 @@ nsPrintOptionsX::GetNativeData(PRInt16 aDataType, void * *_retval) switch (aDataType) { case kNativeDataPrintRecord: - // we need to clone and pass out - PMPageFormat pageFormat = kPMNoPageFormat; - OSStatus status = ::PMNewPageFormat(&pageFormat); - if (status != noErr) return NS_ERROR_FAILURE; + { + // we need to clone and pass out + PMPageFormat pageFormat = kPMNoPageFormat; + OSStatus status = ::PMNewPageFormat(&pageFormat); + if (status != noErr) return NS_ERROR_FAILURE; - status = ::PMCopyPageFormat(mPageFormat, pageFormat); - if (status != noErr) { - ::PMDisposePageFormat(pageFormat); - return NS_ERROR_FAILURE; + status = ::PMCopyPageFormat(mPageFormat, pageFormat); + if (status != noErr) { + ::PMDisposePageFormat(pageFormat); + return NS_ERROR_FAILURE; + } + + *_retval = pageFormat; } - - *_retval = pageFormat; break; default: diff --git a/gfx/src/mac/nsWatchTask.cpp b/gfx/src/mac/nsWatchTask.cpp index 23ca9375a8d1..305e20ab9c00 100644 --- a/gfx/src/mac/nsWatchTask.cpp +++ b/gfx/src/mac/nsWatchTask.cpp @@ -122,11 +122,11 @@ nsWatchTask :: DoWatchTask ( nsWatchTask* inSelf ) { if ( inSelf->mChecksum == 'mozz' ) { if ( !inSelf->mSuspended ) { - #if TARGET_CARBON +#if TARGET_CARBON PRBool busy = inSelf->mBusy; - #else +#else PRBool busy = inSelf->mBusy && LMGetCrsrBusy(); - #endif +#endif if ( !busy ) { if ( ::TickCount() - inSelf->mTicks > kTicksToShowWatch ) { ::SetCursor ( &(inSelf->mWatchCursor) ); @@ -140,9 +140,10 @@ nsWatchTask :: DoWatchTask ( nsWatchTask* inSelf ) ++inSelf->mAnimation; } +#if !TARGET_CARBON // reset the task to fire again inSelf->mTask.vblCount = kRepeatInterval; - +#endif } // if valid checksum } // DoWatchTask diff --git a/gfx/src/mac/nsWatchTask.h b/gfx/src/mac/nsWatchTask.h index d35eb4f99eff..f14d83e32fe4 100644 --- a/gfx/src/mac/nsWatchTask.h +++ b/gfx/src/mac/nsWatchTask.h @@ -41,7 +41,9 @@ #define WatchTask_h__ +#ifndef XP_MACOSX #include +#endif #include #include "PRTypes.h" #include "nscore.h" @@ -87,7 +89,9 @@ private: // the VBL task static pascal void DoWatchTask(nsWatchTask* theTaskPtr) ; +#if !TARGET_CARBON VBLTask mTask; // this must be first!! +#endif long mChecksum; // 'mozz' to validate we have real data at interrupt time (not needed?) void* mSelf; // so we can get back to |this| from the static routine long mTicks; // last time the event loop was hit diff --git a/js/src/fdlibm/k_standard.c b/js/src/fdlibm/k_standard.c index af5502611aff..f4ef2767a7f0 100644 --- a/js/src/fdlibm/k_standard.c +++ b/js/src/fdlibm/k_standard.c @@ -48,7 +48,7 @@ #include "fdlibm.h" /* XXX ugly hack to get msvc to link without error. */ -#if _LIB_VERSION == _IEEE_ && !defined(RHAPSODY) +#if _LIB_VERSION == _IEEE_ && !defined(DARWIN) int errno; # define EDOM 0 # define ERANGE 0 diff --git a/js/src/prmjtime.c b/js/src/prmjtime.c index cad69a323979..4aae2323ab01 100644 --- a/js/src/prmjtime.c +++ b/js/src/prmjtime.c @@ -357,7 +357,7 @@ PRMJ_DSTOffset(JSInt64 local_time) JSInt64 maxtimet; struct tm tm; PRMJTime prtm; -#if ( defined( USE_AUTOCONF ) && !defined( HAVE_LOCALTIME_R) ) || ( !defined ( USE_AUTOCONF ) && ( defined( XP_PC ) || defined( __FreeBSD__ ) || defined ( HPUX9 ) || defined ( SNI ) || defined ( NETBSD ) || defined ( OPENBSD ) || defined( RHAPSODY ) ) ) +#if ( defined( USE_AUTOCONF ) && !defined( HAVE_LOCALTIME_R) ) || ( !defined ( USE_AUTOCONF ) && ( defined( XP_PC ) || defined( __FreeBSD__ ) || defined ( HPUX9 ) || defined ( SNI ) || defined ( NETBSD ) || defined ( OPENBSD ) || defined( DARWIN ) ) ) struct tm *ptm; #endif @@ -376,7 +376,7 @@ PRMJ_DSTOffset(JSInt64 local_time) } JSLL_L2UI(local,local_time); PRMJ_basetime(local_time,&prtm); -#if ( defined( USE_AUTOCONF ) && !defined( HAVE_LOCALTIME_R) ) || ( !defined ( USE_AUTOCONF ) && ( defined( XP_PC ) || defined( __FreeBSD__ ) || defined ( HPUX9 ) || defined ( SNI ) || defined ( NETBSD ) || defined ( OPENBSD ) || defined( RHAPSODY ) ) ) +#if ( defined( USE_AUTOCONF ) && !defined( HAVE_LOCALTIME_R) ) || ( !defined ( USE_AUTOCONF ) && ( defined( XP_PC ) || defined( __FreeBSD__ ) || defined ( HPUX9 ) || defined ( SNI ) || defined ( NETBSD ) || defined ( OPENBSD ) || defined( DARWIN ) ) ) ptm = localtime(&local); if(!ptm){ return JSLL_ZERO; diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index e9e3bea4da3c..fe1f2a7dca63 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -5215,7 +5215,7 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell, ((nsMenuFrame*) newFrame)->SetFrameConstructor(this); } else if (aTag == nsXULAtoms::menubar) { - #if defined(XP_MAC) || defined(RHAPSODY) // The Mac uses its native menu bar. + #if defined(XP_MAC) || defined(XP_MACOSX) // The Mac uses its native menu bar. aHaltProcessing = PR_TRUE; return NS_OK; #else diff --git a/layout/html/style/src/nsCSSFrameConstructor.cpp b/layout/html/style/src/nsCSSFrameConstructor.cpp index e9e3bea4da3c..fe1f2a7dca63 100644 --- a/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -5215,7 +5215,7 @@ nsCSSFrameConstructor::ConstructXULFrame(nsIPresShell* aPresShell, ((nsMenuFrame*) newFrame)->SetFrameConstructor(this); } else if (aTag == nsXULAtoms::menubar) { - #if defined(XP_MAC) || defined(RHAPSODY) // The Mac uses its native menu bar. + #if defined(XP_MAC) || defined(XP_MACOSX) // The Mac uses its native menu bar. aHaltProcessing = PR_TRUE; return NS_OK; #else diff --git a/lib/mac/MoreFiles/MoreFilesSearch.c b/lib/mac/MoreFiles/MoreFilesSearch.c index 3441c70d6f40..c808d716b7e8 100644 --- a/lib/mac/MoreFiles/MoreFilesSearch.c +++ b/lib/mac/MoreFiles/MoreFilesSearch.c @@ -144,7 +144,7 @@ static void CheckForMatches(CInfoPBPtr cPB, #undef pascal #endif -#if TARGET_RT_MAC_CFM || defined(MACOSX) +#if TARGET_RT_MAC_CFM || defined(XP_MACOSX) static pascal void TimeOutTask(TMTaskPtr tmTaskPtr); @@ -687,7 +687,7 @@ Failed: #undef pascal #endif -#if TARGET_RT_MAC_CFM || defined(MACOSX) +#if TARGET_RT_MAC_CFM || defined(XP_MACOSX) static pascal void TimeOutTask(TMTaskPtr tmTaskPtr) { diff --git a/modules/libimg/gifcom/gif.cpp b/modules/libimg/gifcom/gif.cpp index 9cd79c80dec3..6deaf0e79d10 100644 --- a/modules/libimg/gifcom/gif.cpp +++ b/modules/libimg/gifcom/gif.cpp @@ -1066,7 +1066,7 @@ il_gif_write(il_container *ic, const PRUint8 *buf, int32 len) gs->global_colormap = map; #ifndef M12N /* Fix me. */ -#ifdef XP_MAC +#if defined(XP_MAC) || defined(XP_MACOSX) im->hasUniqueColormap = 1; #endif #endif /* M12N */ @@ -1475,7 +1475,7 @@ il_gif_write(il_container *ic, const PRUint8 *buf, int32 len) } #ifndef M12N /* Fix me */ -#ifdef XP_MAC +#if defined(XP_MAC) || defined(XP_MACOSX) im->hasUniqueColormap = 1; #endif #endif /* M12N */ diff --git a/modules/libpr0n/decoders/gif/GIF2.cpp b/modules/libpr0n/decoders/gif/GIF2.cpp index c3f65104451a..d7ea0435428a 100644 --- a/modules/libpr0n/decoders/gif/GIF2.cpp +++ b/modules/libpr0n/decoders/gif/GIF2.cpp @@ -1035,7 +1035,7 @@ int gif_write(gif_struct *gs, const PRUint8 *buf, PRUint32 len) gs->global_colormap = map; #ifndef M12N /* Fix me. */ -#ifdef XP_MAC +#if defined(XP_MAC) || defined(XP_MACOSX) //im->hasUniqueColormap = 1; // What the hell is this? #endif #endif /* M12N */ @@ -1440,7 +1440,7 @@ int gif_write(gif_struct *gs, const PRUint8 *buf, PRUint32 len) } #ifndef M12N /* Fix me */ -#ifdef XP_MAC +#if defined(XP_MAC) || defined(XP_MACOSX) //im->hasUniqueColormap = 1; // WTF? #endif #endif /* M12N */ diff --git a/modules/libpr0n/decoders/gif/nsGIFDecoder2.cpp b/modules/libpr0n/decoders/gif/nsGIFDecoder2.cpp index 09c0b5311338..1c71a9d956a7 100644 --- a/modules/libpr0n/decoders/gif/nsGIFDecoder2.cpp +++ b/modules/libpr0n/decoders/gif/nsGIFDecoder2.cpp @@ -427,7 +427,7 @@ int HaveDecodedRow( case gfxIFormats::RGB: { while(rowBufIndex != decoder->mGIFStruct->rowend) { -#ifdef XP_MAC +#if defined(XP_MAC) || defined(XP_MACOSX) *rgbRowIndex++ = 0; // Mac is always 32bits per pixel, this is pad #endif *rgbRowIndex++ = cmap[PRUint8(*rowBufIndex)].red; @@ -477,7 +477,7 @@ int HaveDecodedRow( *rgbRowIndex++ = cmap[PRUint8(*rowBufIndex)].green; *rgbRowIndex++ = cmap[PRUint8(*rowBufIndex)].red; #else -#ifdef XP_MAC +#if defined(XP_MAC) || defined(XP_MACOSX) *rgbRowIndex++ = 0; // Mac is always 32bits per pixel, this is pad #endif *rgbRowIndex++ = cmap[PRUint8(*rowBufIndex)].red; @@ -486,7 +486,7 @@ int HaveDecodedRow( #endif decoder->mAlphaLine[x>>3] |= 1<<(7-x&0x7); } else { -#ifdef XP_MAC +#if defined(XP_MAC) || defined(XP_MACOSX) rgbRowIndex+=4; #else rgbRowIndex+=3; diff --git a/modules/libpr0n/decoders/jpeg/nsJPEGDecoder.cpp b/modules/libpr0n/decoders/jpeg/nsJPEGDecoder.cpp index 2a812c6c424f..af863407c116 100644 --- a/modules/libpr0n/decoders/jpeg/nsJPEGDecoder.cpp +++ b/modules/libpr0n/decoders/jpeg/nsJPEGDecoder.cpp @@ -329,7 +329,7 @@ NS_IMETHODIMP nsJPEGDecoder::WriteFrom(nsIInputStream *inStr, PRUint32 count, PR JPOOL_IMAGE, row_stride, 1); -#if defined(XP_PC) || defined(XP_BEOS) || defined(XP_MAC) || defined(MOZ_WIDGET_PHOTON) +#if defined(XP_PC) || defined(XP_BEOS) || defined(XP_MAC) || defined(XP_MACOSX) || defined(MOZ_WIDGET_PHOTON) // allocate buffer to do byte flipping if needed if (mInfo.output_components == 3) { mRGBPadRow = (PRUint8*) PR_MALLOC(row_stride); @@ -496,7 +496,7 @@ nsJPEGDecoder::OutputScanlines(int num_scanlines) /* Convert from grayscale to RGB. */ while (j1 < j1end) { -#ifdef XP_MAC +#if defined(XP_MAC) || defined(XP_MACOSX) j = *j1++; j3[0] = 0; j3[1] = j; @@ -527,7 +527,7 @@ nsJPEGDecoder::OutputScanlines(int num_scanlines) } samples = mRGBPadRow; -#elif defined(XP_MAC) +#elif defined(XP_MAC) || defined(XP_MACOSX) memset(mRGBPadRow, 0, mInfo.output_width * 4); PRUint8 *ptrOutputBuf = mRGBPadRow; diff --git a/modules/libpr0n/decoders/png/nsPNGDecoder.cpp b/modules/libpr0n/decoders/png/nsPNGDecoder.cpp index f806fe57f9b7..1c9ea0c59b1a 100644 --- a/modules/libpr0n/decoders/png/nsPNGDecoder.cpp +++ b/modules/libpr0n/decoders/png/nsPNGDecoder.cpp @@ -191,7 +191,7 @@ info_callback(png_structp png_ptr, png_infop info_ptr) * using educated guesses for display-system exponents; do preferences * later */ -#if defined(XP_MAC) +#if defined(XP_MAC) || defined(XP_MACOSX) LUT_exponent = 1.8 / 2.61; #elif defined(XP_UNIX) # if defined(__sgi) @@ -378,7 +378,7 @@ row_callback(png_structp png_ptr, png_bytep new_row, switch (format) { case gfxIFormats::RGB: case gfxIFormats::BGR: -#ifdef XP_MAC +#if defined(XP_MAC) || defined(XP_MACOSX) cptr = decoder->colorLine; for (PRUint32 x=0; xalphaLine; memset(aptr, 0, abpr); for (PRUint32 x=0; xcolorLine; aptr = decoder->alphaLine; for (PRUint32 x=0; xcolorLine; aptr = decoder->alphaLine; diff --git a/modules/libreg/src/Makefile.in b/modules/libreg/src/Makefile.in index 02c6df522a1f..f49a7b716de4 100644 --- a/modules/libreg/src/Makefile.in +++ b/modules/libreg/src/Makefile.in @@ -30,6 +30,10 @@ include $(srcdir)/objs.mk MODULE = libreg LIBRARY_NAME = mozreg_s +# MacOSX requires the MoreFiles module +ifeq ($(OS_ARCH),Darwin) +REQUIRES = macmorefiles +endif CSRCS = reg.c VerReg.c vr_stubs.c nr_bufio.c diff --git a/modules/libreg/src/VerReg.c b/modules/libreg/src/VerReg.c index 39cacb585f1b..a93ed5bf9b0e 100644 --- a/modules/libreg/src/VerReg.c +++ b/modules/libreg/src/VerReg.c @@ -60,7 +60,7 @@ #include "NSReg.h" #include "VerReg.h" -#ifdef XP_MAC +#if defined(XP_MAC) || defined(XP_MACOSX) #include #endif @@ -101,7 +101,7 @@ static char *app_dir = NULL; char *verRegName = NULL; -#if defined(XP_UNIX) +#if defined(XP_UNIX) && !defined(XP_MACOSX) /* Extra Unix variables to deal with two registries * "vreg" is always the writable registry. * If "vreg" is the local registry then "unixreg" will @@ -142,7 +142,7 @@ static REGERR vr_GetUninstallItemPath(char *regPackageName, char *regbuf, uint32 static REGERR vr_convertPackageName(char *regPackageName, char *convertedPackageName, uint32 convertedDataLength); static REGERR vr_unmanglePackageName(char *mangledPackageName, char *regPackageName, uint32 regPackageLength); -#ifdef XP_MAC +#if defined(XP_MAC) || defined(XP_MACOSX) static void vr_MacAliasFromPath(const char * fileName, void ** alias, int32 * length); static char * vr_PathFromMacAlias(const void * alias, uint32 aliasLength); #endif @@ -154,11 +154,11 @@ static REGERR vr_Init(void) REGERR err = REGERR_OK; char *regname = vr_findVerRegName(); -#if defined(XP_UNIX) || defined(STANDALONE_REGISTRY) +#if defined(XP_UNIX) && !defined(XP_MACOSX) || defined(STANDALONE_REGISTRY) char curstr[MAXREGNAMELEN]; RKEY navKey; #endif -#ifdef XP_UNIX +#if defined(XP_UNIX) && !defined(XP_MACOSX) char *regbuf = NULL; #endif @@ -170,7 +170,7 @@ static REGERR vr_Init(void) if (!isInited) { -#ifdef XP_UNIX +#if defined(XP_UNIX) && !defined(XP_MACOSX) /* need browser directory to find the correct registry */ if (app_dir != NULL) { regbuf = (char*)XP_ALLOC( 10 + XP_STRLEN(app_dir) ); @@ -204,7 +204,7 @@ static REGERR vr_Init(void) } } -#ifdef XP_UNIX +#if defined(XP_UNIX) && !defined(XP_MACOSX) /* try to open shared Unix registry, but not an error if you can't */ unixreg = NULL; if (!bGlobalRegistry && err == REGERR_OK ) { @@ -262,7 +262,7 @@ static REGERR vr_Init(void) done: PR_Unlock(vr_lock); -#if defined(XP_UNIX) && !defined(STANDALONE_REGISTRY) +#if defined(XP_UNIX) && !defined(XP_MACOSX) && !defined(STANDALONE_REGISTRY) XP_FREEIF(regbuf); #endif return err; @@ -274,7 +274,7 @@ done: #ifdef XP_PC #define VR_FILE_SEP '\\' #endif -#ifdef XP_MAC +#if defined(XP_MAC) || defined(XP_MACOSX) #define VR_FILE_SEP ':' #endif #ifdef XP_BEOS @@ -302,7 +302,7 @@ static XP_Bool vr_CompareDirs( char *dir1, char *dir2 ) if ( len1 != len2 ) return FALSE; -#ifdef XP_UNIX +#if defined(XP_UNIX) && !defined(XP_MACOSX) return ( XP_STRNCMP(dir1, dir2, len1) == 0 ); #else return ( XP_STRNCASECMP(dir1, dir2, len1) == 0 ); @@ -436,7 +436,7 @@ static REGERR vr_GetPathname(HREG reg, RKEY key, char *entry, char *buf, uint32 info.size = sizeof(REGINFO); -#ifndef XP_MAC +#if !defined(XP_MAC) && !defined(XP_MACOSX) err = NR_RegGetEntry( reg, key, entry, (void*)buf, &sizebuf ); return err; #else @@ -640,7 +640,7 @@ static REGERR vr_FindKey(char *component_path, HREG *hreg, RKEY *key) REGERR err; RKEY rootkey; -#if !defined(STANDALONE_REGISTRY) && defined(XP_UNIX) +#if !defined(STANDALONE_REGISTRY) && defined(XP_UNIX) && !defined(XP_MACOSX) if (unixreg != NULL) { *hreg = unixreg; rootkey = UNIX_ROOT(component_path); @@ -696,14 +696,14 @@ VR_INTERFACE(REGERR) VR_CreateRegistry( char *installation, char *programPath, c { REGERR err; char * regname = vr_findVerRegName(); -#ifdef XP_UNIX +#if defined(XP_UNIX) && !defined(XP_MACOSX) char * regbuf = NULL; #endif if ( installation == NULL || *installation == '\0' ) return REGERR_PARAM; -#ifdef XP_UNIX +#if defined(XP_UNIX) && !defined(XP_MACOSX) #ifndef STANDALONE_REGISTRY if (bGlobalRegistry) #endif @@ -737,7 +737,7 @@ VR_INTERFACE(REGERR) VR_CreateRegistry( char *installation, char *programPath, c PR_Unlock(vr_lock); -#if defined(XP_UNIX) +#if defined(XP_UNIX) && !defined(XP_MACOSX) XP_FREEIF( regbuf ); #endif return err; @@ -757,7 +757,7 @@ VR_INTERFACE(REGERR) VR_Close(void) PR_Lock(vr_lock); if (isInited) { -#if !defined(STANDALONE_REGISTRY) && defined(XP_UNIX) +#if !defined(STANDALONE_REGISTRY) && defined(XP_UNIX) && !defined(XP_MACOSX) if ( unixreg != NULL ) NR_RegClose( unixreg ); #endif diff --git a/modules/libreg/src/nr_bufio.c b/modules/libreg/src/nr_bufio.c index 3c86ca8a79e5..138b40723036 100644 --- a/modules/libreg/src/nr_bufio.c +++ b/modules/libreg/src/nr_bufio.c @@ -36,7 +36,7 @@ #include #include #include -#if defined(XP_MAC) +#if defined(XP_MAC) || defined(XP_MACOSX) #include #endif @@ -144,7 +144,7 @@ BufioFile* bufio_Open(const char* name, const char* mode) switch (errno) { /* file not found */ -#ifdef XP_MAC +#if defined(XP_MAC) || defined(XP_MACOSX) case fnfErr: #else case ENOENT: @@ -153,7 +153,7 @@ BufioFile* bufio_Open(const char* name, const char* mode) break; /* file in use */ -#ifdef XP_MAC +#if defined(XP_MAC) || defined(XP_MACOSX) case opWrErr: #else case EACCES: diff --git a/modules/libreg/src/reg.c b/modules/libreg/src/reg.c index db5bae882782..3990ccd6d8d0 100644 --- a/modules/libreg/src/reg.c +++ b/modules/libreg/src/reg.c @@ -54,7 +54,7 @@ #include #include -#if defined(XP_MAC) +#if defined(XP_MAC) || defined(XP_MACOSX) #include #endif @@ -74,7 +74,9 @@ #include "reg.h" #include "NSReg.h" -#if defined(XP_UNIX) +#if defined(XP_MAC) || defined(XP_MACOSX) +#define MAX_PATH 512 +#elif defined(XP_UNIX) #ifndef MAX_PATH #define MAX_PATH 1024 #endif @@ -84,8 +86,6 @@ #endif #elif defined(WIN32) #define MAX_PATH _MAX_PATH -#elif defined(XP_MAC) -#define MAX_PATH 512 #elif defined(XP_BEOS) #include #define MAX_PATH PATH_MAX @@ -141,7 +141,7 @@ static char *user_name = NULL; -#ifdef XP_MAC +#if defined(XP_MAC) || defined(XP_MACOSX) void nr_MacAliasFromPath(const char * fileName, void ** alias, int32 * length); char * nr_PathFromMacAlias(const void * alias, uint32 aliasLength); @@ -305,7 +305,7 @@ static REGFILE* vr_findRegFile(char *filename) pReg = RegList; while( pReg != NULL ) { -#if defined XP_UNIX || defined XP_BEOS +#if defined(XP_UNIX) && !defined(XP_MACOSX) || defined XP_BEOS if ( 0 == XP_STRCMP( filename, pReg->filename ) ) { #else if ( 0 == XP_STRCASECMP( filename, pReg->filename ) ) { @@ -345,14 +345,14 @@ static REGERR nr_OpenFile(char *path, FILEHANDLE *fh) { switch (errno) { -#ifdef XP_MAC +#if defined(XP_MAC) || defined(XP_MACOSX) case fnfErr: #else case ENOENT: /* file not found */ #endif return REGERR_NOFILE; -#ifdef XP_MAC +#if defined(XP_MAC) || defined(XP_MACOSX) case opWrErr: #else #ifndef XP_OS2_VACPP @@ -454,7 +454,7 @@ static REGERR nr_ReadFile(FILEHANDLE fh, REGOFF offset, int32 len, void *buffer) readlen = XP_FileRead(buffer, len, fh ); /* PR_READ() returns an unreliable length, check EOF separately */ if (readlen < 0) { -#if !defined(STANDALONE_REGISTRY) || !defined(XP_MAC) +#if !defined(STANDALONE_REGISTRY) || !defined(XP_MAC) || !defined(XP_MACOSX) #if defined(STANDALONE_REGISTRY) if (errno == EBADF) /* bad file handle, not open for read, etc. */ #else @@ -3037,7 +3037,7 @@ VR_INTERFACE(REGERR) NR_RegGetEntry( HREG hReg, RKEY key, char *name, case REGTYPE_ENTRY_FILE: err = nr_ReadData( reg, &desc, *size, (char*)buffer ); -#ifdef XP_MAC +#if defined(XP_MAC) || defined(XP_MACOSX) if (err == 0) { tmpbuf = nr_PathFromMacAlias(buffer, *size); @@ -3199,7 +3199,7 @@ VR_INTERFACE(REGERR) NR_RegSetEntry( HREG hReg, RKEY key, char *name, uint16 typ case REGTYPE_ENTRY_FILE: -#ifdef XP_MAC +#if defined(XP_MAC) || defined(XP_MACOSX) nr_MacAliasFromPath(buffer, &data, &datalen); if (data) needFree = TRUE; @@ -3955,7 +3955,7 @@ extern PRLock *vr_lock; -#if defined(XP_UNIX) && !defined(STANDALONE_REGISTRY) +#if defined(XP_UNIX) && !defined(XP_MACOSX) && !defined(STANDALONE_REGISTRY) extern XP_Bool bGlobalRegistry; #endif @@ -3993,7 +3993,7 @@ VR_INTERFACE(REGERR) NR_StartupRegistry(void) /* initialization for version registry */ vr_lock = PR_NewLock(); XP_ASSERT( vr_lock != NULL ); -#ifdef XP_UNIX +#if defined(XP_UNIX) && !defined(XP_MACOSX) bGlobalRegistry = ( getenv(UNIX_GLOBAL_FLAG) != NULL ); #endif #endif diff --git a/modules/libreg/src/vr_stubs.c b/modules/libreg/src/vr_stubs.c index 9f17176bd082..e2c8462c435c 100644 --- a/modules/libreg/src/vr_stubs.c +++ b/modules/libreg/src/vr_stubs.c @@ -53,7 +53,7 @@ #include "vr_stubs.h" -#ifdef XP_MAC +#if defined(XP_MAC) || defined(XP_MACOSX) #include #include #include @@ -217,7 +217,7 @@ int FAR PASCAL _export WEP(int nParam) * ------------------------------------------------------------------ */ -#ifdef XP_MAC +#if defined(XP_MAC) || defined(XP_MACOSX) #include #include "FullPath.h" @@ -443,6 +443,7 @@ char *strdup(const char *source) return newAllocation; } +#ifndef XP_MACOSX int strcasecmp(const char *str1, const char *str2) { char currentChar1, currentChar2; @@ -501,6 +502,7 @@ int strncasecmp(const char *str1, const char *str2, int length) return currentChar1 - currentChar2; } +#endif /* XP_MACOSX */ #endif /* STANDALONE_REGISTRY */ #endif /* XP_MAC */ @@ -531,14 +533,14 @@ char *TheRegistry = "registry"; char *Flist; /* WARNING: build hackery */ -#if defined(STANDALONE_REGISTRY) && !defined(XP_MAC) +#if defined(STANDALONE_REGISTRY) && !defined(XP_MAC) && !defined(XP_MACOSX) long BUILDNUM = NS_BUILD_ID; #endif REGERR vr_ParseVersion(char *verstr, VERSION *result); -#ifdef XP_UNIX +#if defined(XP_UNIX) && !defined(XP_MACOSX) #ifdef STANDALONE_REGISTRY extern XP_File vr_fileOpen (const char *name, const char * mode) diff --git a/modules/libreg/src/vr_stubs.h b/modules/libreg/src/vr_stubs.h index a7de8903423f..7c7fc242bb18 100644 --- a/modules/libreg/src/vr_stubs.h +++ b/modules/libreg/src/vr_stubs.h @@ -272,7 +272,7 @@ typedef int XP_Bool; typedef struct stat XP_StatStruct; #define XP_Stat(file,data) stat((file),(data)) -#ifdef XP_MAC +#if defined(XP_MAC) || defined(XP_MACOSX) extern int nr_RenameFile(char *from, char *to); #else XP_BEGIN_PROTOS diff --git a/modules/libreg/standalone/Makefile.in b/modules/libreg/standalone/Makefile.in index 0ce5c1f211c2..99b1b2e6a4fd 100644 --- a/modules/libreg/standalone/Makefile.in +++ b/modules/libreg/standalone/Makefile.in @@ -31,6 +31,11 @@ include $(srcdir)/../src/objs.mk MODULE = libreg LIBRARY_NAME = mozregsa_s +# MacOSX requires the MoreFiles module +ifeq ($(OS_ARCH),Darwin) +REQUIRES = macmorefiles +endif + CSRCS = $(MODULES_LIBREG_SRC_LCSRCS) FORCE_STATIC_LIB = 1 diff --git a/modules/libreg/xpcom/nsRegistry.cpp b/modules/libreg/xpcom/nsRegistry.cpp index 2194576f3fed..3e948c6d73d8 100644 --- a/modules/libreg/xpcom/nsRegistry.cpp +++ b/modules/libreg/xpcom/nsRegistry.cpp @@ -446,7 +446,7 @@ NS_IMETHODIMP nsRegistry::Open( const char *regFile ) { static void EnsureDefaultRegistryDirectory() { - #ifdef XP_UNIX + #if defined(XP_UNIX) && !defined(XP_MACOSX) // Create ~/.mozilla as that is the default place for the registry file /* The default registry on the unix system is $HOME/.mozilla/registry per diff --git a/modules/plugin/base/public/nsPluginDefs.idl b/modules/plugin/base/public/nsPluginDefs.idl index cddc67cf6ac6..d5db733dd0ac 100644 --- a/modules/plugin/base/public/nsPluginDefs.idl +++ b/modules/plugin/base/public/nsPluginDefs.idl @@ -65,7 +65,7 @@ # include "prtypes.h" #endif -#if defined(XP_MAC) || defined(RHAPSODY) +#if defined(XP_MAC) || defined(XP_MACOSX) # include # include # include @@ -211,7 +211,7 @@ enum nsPluginWindowType { nsPluginWindowType_Drawable }; -#if defined(XP_MAC) || defined(RHAPSODY) +#if defined(XP_MAC) || defined(XP_MACOSX) struct nsPluginPort { CGrafPtr port; /* Grafport */ @@ -281,7 +281,7 @@ struct nsPluginPrint { struct nsPluginEvent { -#if defined(XP_MAC) || defined(RHAPSODY) +#if defined(XP_MAC) || defined(XP_MACOSX) EventRecord* event; nsPluginPlatformWindowRef window; @@ -306,13 +306,13 @@ struct nsPluginEvent { * Non-standard event types that can be passed to HandleEvent */ enum nsPluginEventType { -#if defined(XP_MAC) || defined(RHAPSODY) +#if defined(XP_MAC) || defined(XP_MACOSX) nsPluginEventType_GetFocusEvent = (osEvt + 16), nsPluginEventType_LoseFocusEvent, nsPluginEventType_AdjustCursorEvent, nsPluginEventType_MenuCommandEvent, nsPluginEventType_ClippingChangedEvent, -#endif /* XP_MAC */ +#endif /* XP_MAC || XP_MACOSX */ nsPluginEventType_Idle = 0 }; diff --git a/modules/plugin/base/public/nsplugindefs.h b/modules/plugin/base/public/nsplugindefs.h index 4f46344e79a8..4658845a025a 100644 --- a/modules/plugin/base/public/nsplugindefs.h +++ b/modules/plugin/base/public/nsplugindefs.h @@ -64,7 +64,7 @@ #include "prtypes.h" #endif -#if defined(XP_MAC) || defined(RHAPSODY) +#if defined(XP_MAC) || defined(XP_MACOSX) # include # include # include @@ -245,7 +245,7 @@ enum nsPluginWindowType { nsPluginWindowType_Drawable }; -#if defined(XP_MAC) || defined(RHAPSODY) +#if defined(XP_MAC) || defined(XP_MACOSX) struct nsPluginPort { CGrafPtr port; /* Grafport */ @@ -315,7 +315,7 @@ struct nsPluginPrint { struct nsPluginEvent { -#if defined(XP_MAC) || defined(RHAPSODY) +#if defined(XP_MAC) || defined(XP_MACOSX) EventRecord* event; nsPluginPlatformWindowRef window; @@ -340,13 +340,13 @@ struct nsPluginEvent { * Non-standard event types that can be passed to HandleEvent */ enum nsPluginEventType { -#if defined(XP_MAC) || defined(RHAPSODY) +#if defined(XP_MAC) || defined(XP_MACOSX) nsPluginEventType_GetFocusEvent = (osEvt + 16), nsPluginEventType_LoseFocusEvent, nsPluginEventType_AdjustCursorEvent, nsPluginEventType_MenuCommandEvent, nsPluginEventType_ClippingChangedEvent, -#endif /* XP_MAC */ +#endif /* XP_MAC || XP_MACOSX */ nsPluginEventType_Idle = 0 }; diff --git a/modules/plugin/base/src/nsPluginHostImpl.cpp b/modules/plugin/base/src/nsPluginHostImpl.cpp index ec51a5e5987f..4f3af8b4552c 100644 --- a/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -2472,7 +2472,7 @@ NS_IMETHODIMP nsPluginHostImpl::GetValue(nsPluginManagerVariable aVariable, void NS_ENSURE_ARG_POINTER(aValue); -#if defined(XP_UNIX) && !defined(MACOSX) && !defined(NO_X11) +#if defined(XP_UNIX) && !defined(XP_MACOSX) && !defined(NO_X11) if (nsPluginManagerVariable_XDisplay == aVariable) { Display** value = NS_REINTERPRET_CAST(Display**, aValue); #if defined(MOZ_WIDGET_GTK) diff --git a/netwerk/protocol/http/src/nsHttpHandler.cpp b/netwerk/protocol/http/src/nsHttpHandler.cpp index 4849bdc52b26..a4c97d4960a9 100644 --- a/netwerk/protocol/http/src/nsHttpHandler.cpp +++ b/netwerk/protocol/http/src/nsHttpHandler.cpp @@ -943,14 +943,12 @@ nsHttpHandler::InitUserAgentComponents() "OS/2" #elif defined(XP_PC) "Windows" -#elif defined(RHAPSODY) +#elif defined(XP_MAC) || defined(XP_MACOSX) "Macintosh" #elif defined (XP_UNIX) "X11" #elif defined(XP_BEOS) "BeOS" -#elif defined(XP_MAC) - "Macintosh" #endif )); diff --git a/webshell/src/Makefile.in b/webshell/src/Makefile.in index b871b31f2d99..7c980480d07f 100644 --- a/webshell/src/Makefile.in +++ b/webshell/src/Makefile.in @@ -32,7 +32,7 @@ EXPORT_LIBRARY = 1 SHORT_LIBNAME = gkweb EXTRA_DSO_LIBS = jsdom docshell -ifeq ($(OS_ARCH),Rhapsody) +ifeq ($(OS_ARCH),Darwin) IS_COMPONENT = 1 endif diff --git a/webshell/tests/viewer/Makefile.in b/webshell/tests/viewer/Makefile.in index 88ae765f6fa9..d3c180c21c83 100644 --- a/webshell/tests/viewer/Makefile.in +++ b/webshell/tests/viewer/Makefile.in @@ -160,8 +160,8 @@ install:: include $(topsrcdir)/config/rules.mk -ifeq ($(OS_ARCH),Rhapsody) -INCLUDES += -I$(topsrcdir)/widget/src/mac +ifeq ($(OS_ARCH),Darwin) +LOCAL_INCLUDES += -I$(topsrcdir)/widget/src/mac endif CXXFLAGS += $(MOZ_TOOLKIT_REGISTRY_CFLAGS) diff --git a/webshell/tests/viewer/nsMacMain.cpp b/webshell/tests/viewer/nsMacMain.cpp index 17dcbe81f1f1..fc3fc5e5120d 100644 --- a/webshell/tests/viewer/nsMacMain.cpp +++ b/webshell/tests/viewer/nsMacMain.cpp @@ -43,40 +43,44 @@ #include "nsIServiceManager.h" #include "resources.h" -#include // MacOS includes +#include // MacOS includes #include #include #include #include #include -#include "nsMacMessagePump.h" // for the windowless menu event handler +#include "nsMacMessagePump.h" // for the windowless menu event handler +#ifdef GC_LEAK_DETECTOR #include "nsILeakDetector.h" +#endif +#ifndef XP_MACOSX #include "macstdlibextras.h" +#endif -typedef SInt32 MessageT; +typedef SInt32 MessageT; typedef PRUint32 Uint32; -const MessageT cmd_Undo = 11; // nil -const MessageT cmd_Cut = 12; // nil -const MessageT cmd_Copy = 13; // nil -const MessageT cmd_Paste = 14; // nil -const MessageT cmd_Clear = 15; // nil -const MessageT cmd_SelectAll = 16; // nil +const MessageT cmd_Undo = 11; // nil +const MessageT cmd_Cut = 12; // nil +const MessageT cmd_Copy = 13; // nil +const MessageT cmd_Paste = 14; // nil +const MessageT cmd_Clear = 15; // nil +const MessageT cmd_SelectAll = 16; // nil -const MessageT cmd_About = 1; // nil +const MessageT cmd_About = 1; // nil - // File Menu -const MessageT cmd_New = 2; // nil -const MessageT cmd_Open = 3; // nil -const MessageT cmd_Close = 4; // nil -const MessageT cmd_Save = 5; // nil -const MessageT cmd_SaveAs = 6; // nil -const MessageT cmd_Revert = 7; // nil -const MessageT cmd_PageSetup = 8; // nil -const MessageT cmd_Print = 9; // nil -const MessageT cmd_PrintOne = 17; // nil -const MessageT cmd_Quit = 10; // nil -const MessageT cmd_Preferences = 27; // nil + // File Menu +const MessageT cmd_New = 2; // nil +const MessageT cmd_Open = 3; // nil +const MessageT cmd_Close = 4; // nil +const MessageT cmd_Save = 5; // nil +const MessageT cmd_SaveAs = 6; // nil +const MessageT cmd_Revert = 7; // nil +const MessageT cmd_PageSetup = 8; // nil +const MessageT cmd_Print = 9; // nil +const MessageT cmd_PrintOne = 17; // nil +const MessageT cmd_Quit = 10; // nil +const MessageT cmd_Preferences = 27; // nil enum @@ -86,66 +90,66 @@ enum enum { - menu_First = 128, - menu_Apple = menu_First, - menu_File, - menu_Edit, - menu_Sample, - menu_Debug, - menu_Tools, - menu_URLS, - menu_Last = menu_URLS, + menu_First = 128, + menu_Apple = menu_First, + menu_File, + menu_Edit, + menu_Sample, + menu_Debug, + menu_Tools, + menu_URLS, + menu_Last = menu_URLS, - submenu_Print = 16, - submenu_CompatibilityMode = 32, - - cmd_Sample0 = 1000, - cmd_FirstXPToolkitSample = 1100, - cmd_PrintOneColumn = 2000, - cmd_Find = 3000, + submenu_Print = 16, + submenu_CompatibilityMode = 32, + + cmd_Sample0 = 1000, + cmd_FirstXPToolkitSample = 1100, + cmd_PrintOneColumn = 2000, + cmd_Find = 3000, - cmd_ViewSource = 2200, - cmd_PrintSetup, + cmd_ViewSource = 2200, + cmd_PrintSetup, - cmd_DebugMode = 4000, - cmd_ReflowTest, - cmd_DumpContents, - cmd_DumpFrames, - cmd_DumpViews, - cmd_DumpStyleSheets, - cmd_DumpStyleContexts, - cmd_ShowContentSize, - cmd_ShowFrameSize, - cmd_ShowStyleSize, - cmd_DebugSave, - cmd_DebugOutputText, - cmd_DebugOutputHTML, - cmd_DebugToggleSelection, - cmd_DebugRobot, - cmd_ShowContentQuality, - cmd_GFXWidgetMode, - cmd_NativeWidgetMode, - cmd_GFXScrollBars, - cmd_NativeScrollBars, - cmd_DumpLeaks, + cmd_DebugMode = 4000, + cmd_ReflowTest, + cmd_DumpContents, + cmd_DumpFrames, + cmd_DumpViews, + cmd_DumpStyleSheets, + cmd_DumpStyleContexts, + cmd_ShowContentSize, + cmd_ShowFrameSize, + cmd_ShowStyleSize, + cmd_DebugSave, + cmd_DebugOutputText, + cmd_DebugOutputHTML, + cmd_DebugToggleSelection, + cmd_DebugRobot, + cmd_ShowContentQuality, + cmd_GFXWidgetMode, + cmd_NativeWidgetMode, + cmd_GFXScrollBars, + cmd_NativeScrollBars, + cmd_DumpLeaks, - item_GFXWidgetMode = 24, - item_NativeWidgetMode, + item_GFXWidgetMode = 24, + item_NativeWidgetMode, - cmd_Compatibility_UseDTD = 4200, - cmd_Compatibility_NavQuirks, - cmd_Compatibility_Standard, - - cmd_JSConsole = 5000, - cmd_EditorMode, - cmd_Top100, - cmd_TableInspector, - cmd_ImageInspector, - - cmd_SaveURL1 = 6000, - cmd_SaveURL2, - cmd_LoadURL1, - cmd_LoadURL2 + cmd_Compatibility_UseDTD = 4200, + cmd_Compatibility_NavQuirks, + cmd_Compatibility_Standard, + + cmd_JSConsole = 5000, + cmd_EditorMode, + cmd_Top100, + cmd_TableInspector, + cmd_ImageInspector, + + cmd_SaveURL1 = 6000, + cmd_SaveURL2, + cmd_LoadURL1, + cmd_LoadURL2 }; @@ -156,7 +160,7 @@ static nsNativeViewerApp* gTheApp; nsNativeViewerApp::nsNativeViewerApp() { - //nsMacMessagePump::SetWindowlessMenuEventHandler(DispatchMenuItemWithoutWindow); + //nsMacMessagePump::SetWindowlessMenuEventHandler(DispatchMenuItemWithoutWindow); } nsNativeViewerApp::~nsNativeViewerApp() @@ -173,44 +177,44 @@ nsNativeViewerApp::Run() void nsNativeViewerApp::DispatchMenuItemWithoutWindow(PRInt32 menuResult) { - long menuID = HiWord(menuResult); - long menuItem = LoWord(menuResult); - switch (menuID) - { - case menu_Apple: - switch (menuItem) - { - case cmd_About: - ::Alert(128, nil); - break; - default: - Str255 daName; - GetMenuItemText(GetMenuHandle(menu_Apple), menuItem, daName); - #if !TARGET_CARBON - OpenDeskAcc(daName); - #endif - break; - } - break; + long menuID = HiWord(menuResult); + long menuItem = LoWord(menuResult); + switch (menuID) + { + case menu_Apple: + switch (menuItem) + { + case cmd_About: + ::Alert(128, nil); + break; + default: + Str255 daName; + GetMenuItemText(GetMenuHandle(menu_Apple), menuItem, daName); + #if !TARGET_CARBON + OpenDeskAcc(daName); + #endif + break; + } + break; - case menu_File: - - switch (menuItem) - { - case cmd_New: - gTheApp->OpenWindow(); - break; - case cmd_Open: - nsBrowserWindow * newWindow; - gTheApp->OpenWindow((PRUint32)0, newWindow); - newWindow->DoFileOpen(); - break; - case cmd_Quit: - gTheApp->Exit(); - break; - } - break; - } + case menu_File: + + switch (menuItem) + { + case cmd_New: + gTheApp->OpenWindow(); + break; + case cmd_Open: + nsBrowserWindow * newWindow; + gTheApp->OpenWindow((PRUint32)0, newWindow); + newWindow->DoFileOpen(); + break; + case cmd_Quit: + gTheApp->Exit(); + break; + } + break; + } } #pragma mark - @@ -228,40 +232,42 @@ nsNativeBrowserWindow::~nsNativeBrowserWindow() nsresult nsNativeBrowserWindow::InitNativeWindow() { - // this is where we get a chance to set up the window refCon - NS_PRECONDITION(nsnull != mWindow, "Null window in InitNativeWindow"); - - WindowPtr wind = (WindowPtr)mWindow->GetNativeData(NS_NATIVE_DISPLAY); - if (!wind) return NS_ERROR_NULL_POINTER; + // this is where we get a chance to set up the window refCon + NS_PRECONDITION(nsnull != mWindow, "Null window in InitNativeWindow"); + + WindowPtr wind = (WindowPtr)mWindow->GetNativeData(NS_NATIVE_DISPLAY); + if (!wind) return NS_ERROR_NULL_POINTER; - ::SetWRefCon(wind, (long)this); - return NS_OK; + ::SetWRefCon(wind, (long)this); + return NS_OK; } static void CloseFrontWindow() { - WindowPtr wind = ::FrontWindow(); - if (!wind) return; - - nsBrowserWindow *browserWindow = (nsBrowserWindow *)GetWRefCon(wind); - if (!browserWindow) return; - - browserWindow->Destroy(); + WindowPtr wind = ::FrontWindow(); + if (!wind) return; + + nsBrowserWindow *browserWindow = (nsBrowserWindow *)GetWRefCon(wind); + if (!browserWindow) return; + + browserWindow->Destroy(); } nsresult nsNativeBrowserWindow::CreateMenuBar(PRInt32 aWidth) { - for (int i = menu_First; i <= menu_Last; i++) - { - InsertMenu(GetMenu(i), 0); - } - InsertMenu(GetMenu(submenu_Print), -1); - InsertMenu(GetMenu(submenu_CompatibilityMode), -1); - AppendResMenu(GetMenuHandle(menu_Apple), 'DRVR'); - DrawMenuBar(); - return NS_OK; + for (int i = menu_First; i <= menu_Last; i++) + { + MenuHandle menu = GetMenu(i); + NS_ASSERTION(menu, "menu failed to load"); + if (menu) InsertMenu(menu, 0); + } + InsertMenu(GetMenu(submenu_Print), -1); + InsertMenu(GetMenu(submenu_CompatibilityMode), -1); + AppendResMenu(GetMenuHandle(menu_Apple), 'DRVR'); + DrawMenuBar(); + return NS_OK; } nsresult @@ -277,193 +283,212 @@ nsNativeBrowserWindow::GetMenuBarHeight(PRInt32 * aHeightOut) nsEventStatus nsNativeBrowserWindow::DispatchMenuItem(PRInt32 aID) { - nsEventStatus status = nsEventStatus_eIgnore; - PRInt32 xpID = 0; - long menuID = HiWord(aID); - long menuItem = LoWord(aID); - - switch (menuID) - { - case menu_Apple: - switch (menuItem) - { - case cmd_About: - ::Alert(128, nil); - break; - default: - Str255 daName; - GetMenuItemText(GetMenuHandle(menu_Apple), menuItem, daName); - #if !TARGET_CARBON - OpenDeskAcc(daName); - #endif - break; - } - break; + nsEventStatus status = nsEventStatus_eIgnore; + PRInt32 xpID = 0; + long menuID = HiWord(aID); + long menuItem = LoWord(aID); + + switch (menuID) + { + case menu_Apple: + switch (menuItem) + { + case cmd_About: + ::Alert(128, nil); + break; + default: + Str255 daName; + GetMenuItemText(GetMenuHandle(menu_Apple), menuItem, daName); + #if !TARGET_CARBON + OpenDeskAcc(daName); + #endif + break; + } + break; - case menu_File: - switch (menuItem) - { - case cmd_New: xpID = VIEWER_WINDOW_OPEN; break; - case cmd_Open: xpID = VIEWER_FILE_OPEN; break; - case cmd_Close: - CloseFrontWindow(); - status = nsEventStatus_eConsumeNoDefault; - break; + case menu_File: + switch (menuItem) + { + case cmd_New: xpID = VIEWER_WINDOW_OPEN; break; + case cmd_Open: xpID = VIEWER_FILE_OPEN; break; + case cmd_Close: + CloseFrontWindow(); + status = nsEventStatus_eConsumeNoDefault; + break; - case cmd_ViewSource: xpID = VIEW_SOURCE; break; - case cmd_Save: /*n.a.*/ break; - case cmd_SaveAs: /*n.a.*/ break; - case cmd_Revert: /*n.a.*/ break; - case cmd_PageSetup: /*n.a.*/ break; - case cmd_Print: xpID = VIEWER_PRINT; break; - case cmd_PrintSetup: xpID = VIEWER_PRINT_SETUP; break; - case cmd_Quit: xpID = VIEWER_EXIT; break; - } - break; + case cmd_ViewSource: xpID = VIEW_SOURCE; break; + case cmd_Save: /*n.a.*/ break; + case cmd_SaveAs: /*n.a.*/ break; + case cmd_Revert: /*n.a.*/ break; + case cmd_PageSetup: /*n.a.*/ break; + case cmd_Print: xpID = VIEWER_PRINT; break; + case cmd_PrintSetup: xpID = VIEWER_PRINT_SETUP; break; + case cmd_Quit: xpID = VIEWER_EXIT; break; + } + break; - case menu_Edit: - switch (menuItem) - { - case cmd_Undo: /*n.a.*/ break; - case cmd_Cut: xpID = VIEWER_EDIT_CUT; break; - case cmd_Copy: xpID = VIEWER_EDIT_COPY; break; - case cmd_Paste: xpID = VIEWER_EDIT_PASTE; break; - case cmd_Clear: /*n.a.*/ break; - case cmd_SelectAll: xpID = VIEWER_EDIT_SELECTALL; break; - case cmd_Find: xpID = VIEWER_EDIT_FINDINPAGE; break; - case cmd_Preferences: xpID = VIEWER_PREFS; break; - } - break; + case menu_Edit: + switch (menuItem) + { + case cmd_Undo: /*n.a.*/ break; + case cmd_Cut: xpID = VIEWER_EDIT_CUT; break; + case cmd_Copy: xpID = VIEWER_EDIT_COPY; break; + case cmd_Paste: xpID = VIEWER_EDIT_PASTE; break; + case cmd_Clear: /*n.a.*/ break; + case cmd_SelectAll: xpID = VIEWER_EDIT_SELECTALL; break; + case cmd_Find: xpID = VIEWER_EDIT_FINDINPAGE; break; + case cmd_Preferences: xpID = VIEWER_PREFS; break; + } + break; - case menu_Sample: - if ( menuItem < cmd_FirstXPToolkitSample ) - xpID = VIEWER_DEMO0 + menuItem - cmd_Sample0; - else - xpID = VIEWER_XPTOOLKITDEMOBASE + (menuItem - cmd_FirstXPToolkitSample); - break; + case menu_Sample: + if ( menuItem < cmd_FirstXPToolkitSample ) + xpID = VIEWER_DEMO0 + menuItem - cmd_Sample0; + else + xpID = VIEWER_XPTOOLKITDEMOBASE + (menuItem - cmd_FirstXPToolkitSample); + break; - case menu_Debug: - switch (menuItem) - { - case cmd_DebugMode: xpID = VIEWER_VISUAL_DEBUGGING; break; - case cmd_ReflowTest: xpID = VIEWER_REFLOW_TEST; break; + case menu_Debug: + switch (menuItem) + { + case cmd_DebugMode: xpID = VIEWER_VISUAL_DEBUGGING; break; + case cmd_ReflowTest: xpID = VIEWER_REFLOW_TEST; break; - case cmd_DumpContents: xpID = VIEWER_DUMP_CONTENT; break; - case cmd_DumpFrames: xpID = VIEWER_DUMP_FRAMES; break; - case cmd_DumpViews: xpID = VIEWER_DUMP_VIEWS; break; + case cmd_DumpContents: xpID = VIEWER_DUMP_CONTENT; break; + case cmd_DumpFrames: xpID = VIEWER_DUMP_FRAMES; break; + case cmd_DumpViews: xpID = VIEWER_DUMP_VIEWS; break; - case cmd_DumpStyleSheets: xpID = VIEWER_DUMP_STYLE_SHEETS; break; - case cmd_DumpStyleContexts: xpID = VIEWER_DUMP_STYLE_CONTEXTS; break; + case cmd_DumpStyleSheets: xpID = VIEWER_DUMP_STYLE_SHEETS; break; + case cmd_DumpStyleContexts: xpID = VIEWER_DUMP_STYLE_CONTEXTS; break; - case cmd_ShowContentSize: xpID = VIEWER_SHOW_CONTENT_SIZE; break; - case cmd_ShowFrameSize: xpID = VIEWER_SHOW_FRAME_SIZE; break; - case cmd_ShowStyleSize: xpID = VIEWER_SHOW_STYLE_SIZE; break; - - case cmd_DebugSave: xpID = VIEWER_DEBUGSAVE; break; - case cmd_DebugOutputText: xpID = VIEWER_DISPLAYTEXT; break; - case cmd_DebugOutputHTML: xpID = VIEWER_DISPLAYHTML; break; - case cmd_DebugToggleSelection: xpID = VIEWER_TOGGLE_SELECTION; break; - case cmd_DebugRobot: xpID = VIEWER_DEBUGROBOT; break; - case cmd_ShowContentQuality: xpID =VIEWER_SHOW_CONTENT_QUALITY; break; - case cmd_DumpLeaks: - { - nsresult rv; - nsCOMPtr leakDetector = - do_GetService("@mozilla.org/xpcom/leakdetector;1", &rv); - if (NS_SUCCEEDED(rv)) - leakDetector->DumpLeaks(); - } - break; - case cmd_GFXScrollBars: xpID =VIEWER_GFX_SCROLLBARS_ON; break; - case cmd_NativeScrollBars: xpID =VIEWER_GFX_SCROLLBARS_OFF; break; - } - break; - - case menu_Tools: - switch (menuItem) - { - case cmd_JSConsole: xpID = JS_CONSOLE; break; - case cmd_EditorMode: xpID = EDITOR_MODE; break; - case cmd_Top100: xpID = VIEWER_TOP100; break; - case cmd_TableInspector: xpID = VIEWER_TABLE_INSPECTOR; break; - case cmd_ImageInspector: xpID = VIEWER_IMAGE_INSPECTOR; break; - } - break; - + case cmd_ShowContentSize: xpID = VIEWER_SHOW_CONTENT_SIZE; break; + case cmd_ShowFrameSize: xpID = VIEWER_SHOW_FRAME_SIZE; break; + case cmd_ShowStyleSize: xpID = VIEWER_SHOW_STYLE_SIZE; break; + + case cmd_DebugSave: xpID = VIEWER_DEBUGSAVE; break; + case cmd_DebugOutputText: xpID = VIEWER_DISPLAYTEXT; break; + case cmd_DebugOutputHTML: xpID = VIEWER_DISPLAYHTML; break; + case cmd_DebugToggleSelection: xpID = VIEWER_TOGGLE_SELECTION; break; + case cmd_DebugRobot: xpID = VIEWER_DEBUGROBOT; break; + case cmd_ShowContentQuality: xpID =VIEWER_SHOW_CONTENT_QUALITY; break; +#ifdef GC_LEAK_DETECTOR + case cmd_DumpLeaks: + { + nsresult rv; + nsCOMPtr leakDetector = + do_GetService("@mozilla.org/xpcom/leakdetector;1", &rv); + if (NS_SUCCEEDED(rv)) + leakDetector->DumpLeaks(); + } + break; +#endif + case cmd_GFXScrollBars: xpID =VIEWER_GFX_SCROLLBARS_ON; break; + case cmd_NativeScrollBars: xpID =VIEWER_GFX_SCROLLBARS_OFF; break; + } + break; + + case menu_Tools: + switch (menuItem) + { + case cmd_JSConsole: xpID = JS_CONSOLE; break; + case cmd_EditorMode: xpID = EDITOR_MODE; break; + case cmd_Top100: xpID = VIEWER_TOP100; break; + case cmd_TableInspector: xpID = VIEWER_TABLE_INSPECTOR; break; + case cmd_ImageInspector: xpID = VIEWER_IMAGE_INSPECTOR; break; + } + break; + case menu_URLS: - switch (menuItem) - { - case cmd_SaveURL1: xpID = VIEWER_SAVE_TEST_URL1; break; - case cmd_SaveURL2: xpID = VIEWER_SAVE_TEST_URL2; break; - case cmd_LoadURL1: xpID = VIEWER_GOTO_TEST_URL1; break; - case cmd_LoadURL2: xpID = VIEWER_GOTO_TEST_URL2; break; - } - break; - - case submenu_Print: - xpID = VIEWER_ONE_COLUMN + menuItem - cmd_PrintOneColumn; - break; - - case submenu_CompatibilityMode: - switch (menuItem) - { - case cmd_Compatibility_UseDTD: xpID = VIEWER_USE_DTD_MODE; break; - case cmd_Compatibility_NavQuirks: xpID = VIEWER_NAV_QUIRKS_MODE; break; - case cmd_Compatibility_Standard: xpID = VIEWER_STANDARD_MODE; break; - } - break; - } + switch (menuItem) + { + case cmd_SaveURL1: xpID = VIEWER_SAVE_TEST_URL1; break; + case cmd_SaveURL2: xpID = VIEWER_SAVE_TEST_URL2; break; + case cmd_LoadURL1: xpID = VIEWER_GOTO_TEST_URL1; break; + case cmd_LoadURL2: xpID = VIEWER_GOTO_TEST_URL2; break; + } + break; + + case submenu_Print: + xpID = VIEWER_ONE_COLUMN + menuItem - cmd_PrintOneColumn; + break; + + case submenu_CompatibilityMode: + switch (menuItem) + { + case cmd_Compatibility_UseDTD: xpID = VIEWER_USE_DTD_MODE; break; + case cmd_Compatibility_NavQuirks: xpID = VIEWER_NAV_QUIRKS_MODE; break; + case cmd_Compatibility_Standard: xpID = VIEWER_STANDARD_MODE; break; + } + break; + } - // Dispatch xp menu items - if (xpID != 0) { - // beard: nsBrowserWindow::DispatchMenuItem almost always returns nsEventStatus_eIgnore. - // this causes double menu item dispatching for most items except for VIEWER_EXIT! - nsBrowserWindow::DispatchMenuItem(xpID); - status = nsEventStatus_eConsumeNoDefault; - } - return status; + // Dispatch xp menu items + if (xpID != 0) { + // beard: nsBrowserWindow::DispatchMenuItem almost always returns nsEventStatus_eIgnore. + // this causes double menu item dispatching for most items except for VIEWER_EXIT! + nsBrowserWindow::DispatchMenuItem(xpID); + status = nsEventStatus_eConsumeNoDefault; + } + return status; } /** * Quit AppleEvent handler. */ -static pascal OSErr handleQuitApplication(const AppleEvent*, AppleEvent*, UInt32) +static pascal OSErr handleQuitApplication(const AppleEvent*, AppleEvent*, long) { - if (gTheApp != nsnull) { - gTheApp->Exit(); - } else { - ExitToShell(); - } - return noErr; + if (gTheApp != nsnull) { + gTheApp->Exit(); + } else { + ExitToShell(); + } + return noErr; } #pragma mark - //---------------------------------------------------------------------- int main(int argc, char **argv) { - // Set up the toolbox and (if DEBUG) the console - InitializeMacToolbox(); +#if !TARGET_CARBON + // Set up the toolbox and (if DEBUG) the console + InitializeMacToolbox(); +#endif - // Install an a Quit AppleEvent handler. - OSErr err = AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, - NewAEEventHandlerProc(handleQuitApplication), 0, false); - NS_ASSERTION((err==noErr), "AEInstallEventHandler failed"); + // Install an a Quit AppleEvent handler. + OSErr err = AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, + NewAEEventHandlerUPP(handleQuitApplication), 0, false); + NS_ASSERTION((err==noErr), "AEInstallEventHandler failed"); - // Start up XPCOM? - nsresult rv = NS_InitXPCOM2(nsnull, nsnull, nsnull); - NS_ASSERTION(NS_SUCCEEDED(rv), "NS_InitXPCOM failed"); +#ifdef XP_MACOSX + // use the location of the executable to learn where everything is, this + // is because the current working directory is ill-defined when the + // application is double-clicked from the Finder. + { + char* path = strdup(argv[0]); + char* lastSlash = strrchr(path, '/'); + if (lastSlash) { + *lastSlash = '\0'; + setenv("MOZILLA_FIVE_HOME", path, 1); + } + free(path); + } +#endif - gTheApp = new nsNativeViewerApp(); - if (gTheApp != nsnull) { - NS_ADDREF(gTheApp); - if (gTheApp->Initialize(argc, argv) == NS_OK) - gTheApp->Run(); - NS_RELEASE(gTheApp); - } + // Start up XPCOM? + nsresult rv = NS_InitXPCOM2(nsnull, nsnull, nsnull); + NS_ASSERTION(NS_SUCCEEDED(rv), "NS_InitXPCOM failed"); - // Shutdown XPCOM? - rv = NS_ShutdownXPCOM(nsnull); - NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed"); + gTheApp = new nsNativeViewerApp(); + if (gTheApp != nsnull) { + NS_ADDREF(gTheApp); + if (gTheApp->Initialize(argc, argv) == NS_OK) + gTheApp->Run(); + NS_RELEASE(gTheApp); + } - return 0; + // Shutdown XPCOM? + rv = NS_ShutdownXPCOM(nsnull); + NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed"); + + return 0; } diff --git a/webshell/tests/viewer/nsViewerApp.cpp b/webshell/tests/viewer/nsViewerApp.cpp index 40354066a232..c516012a6d95 100644 --- a/webshell/tests/viewer/nsViewerApp.cpp +++ b/webshell/tests/viewer/nsViewerApp.cpp @@ -458,6 +458,11 @@ nsViewerApp::ProcessArguments(int argc, char** argv) old |= _CRTDBG_CHECK_ALWAYS_DF; _CrtSetDbgFlag(old); } +#endif +#if defined(XP_MACOSX) + else if (PL_strncmp(argv[i], "-psn_", 5) == 0) { + continue; + } #endif else if (PL_strncmp(argv[i], "-p", 2) == 0) { char *optionalSampleStopIndex = &(argv[i][2]); diff --git a/webshell/tests/viewer/nsViewerApp.h b/webshell/tests/viewer/nsViewerApp.h index e9a047a6d4eb..3f8ecc5348a5 100644 --- a/webshell/tests/viewer/nsViewerApp.h +++ b/webshell/tests/viewer/nsViewerApp.h @@ -108,7 +108,7 @@ public: ~nsNativeViewerApp(); virtual int Run(); -#if defined(XP_MAC) || defined(RHAPSODY) +#if defined(XP_MAC) || defined(XP_MACOSX) static void DispatchMenuItemWithoutWindow(PRInt32 menuResult); #endif }; diff --git a/widget/src/mac/nsAppShell.cpp b/widget/src/mac/nsAppShell.cpp index 40704dbe86c7..acec707b3fbf 100644 --- a/widget/src/mac/nsAppShell.cpp +++ b/widget/src/mac/nsAppShell.cpp @@ -57,13 +57,15 @@ #include #include #include +#ifndef XP_MACOSX #include +#endif #include #include #include -#ifndef RHAPSODY +#ifndef XP_MACOSX #include "macstdlibextras.h" #endif PRBool nsAppShell::mInitializedToolbox = PR_FALSE; diff --git a/widget/src/mac/nsDragService.cpp b/widget/src/mac/nsDragService.cpp index ec9f620c7297..2ae8f9c9cd4d 100644 --- a/widget/src/mac/nsDragService.cpp +++ b/widget/src/mac/nsDragService.cpp @@ -56,7 +56,9 @@ #include "nsCOMPtr.h" #include "nsXPIDLString.h" #include "nsPrimitiveHelpers.h" +#ifndef XP_MACOSX #include "nsILocalFileMac.h" +#endif #include "nsWatchTask.h" // rjc @@ -516,9 +518,11 @@ printf("looking for data in type %s, mac flavor %ld\n", NS_STATIC_CAST(const cha // we have a HFSFlavor struct in |dataBuff|. Create an nsLocalFileMac object. HFSFlavor* fileData = NS_REINTERPRET_CAST(HFSFlavor*, dataBuff); NS_ASSERTION ( sizeof(HFSFlavor) == dataSize, "Ooops, we realy don't have a HFSFlavor" ); +#ifndef XP_MACOSX nsCOMPtr file; if ( NS_SUCCEEDED(NS_NewLocalFileWithFSSpec(&fileData->fileSpec, PR_TRUE, getter_AddRefs(file))) ) genericDataWrapper = do_QueryInterface(file); +#endif } else { // we probably have some form of text. The DOM only wants LF, so convert k diff --git a/widget/src/mac/nsFilePicker.cpp b/widget/src/mac/nsFilePicker.cpp index e05b99ec8a7b..2b7e0d8e6cf0 100644 --- a/widget/src/mac/nsFilePicker.cpp +++ b/widget/src/mac/nsFilePicker.cpp @@ -26,7 +26,9 @@ #include "nsNetUtil.h" #include "nsIComponentManager.h" #include "nsILocalFile.h" +#ifndef XP_MACOSX #include "nsILocalFileMac.h" +#endif #include "nsIURL.h" #include "nsVoidArray.h" #include "nsIFileChannel.h" @@ -149,6 +151,7 @@ NS_IMETHODIMP nsFilePicker::Show(PRInt16 *retval) // Clean up filter buffers delete[] filterBuffer; +#ifndef XP_MACOSX if (userClicksOK == returnOK || userClicksOK == returnReplace) { nsCOMPtr localFile(do_CreateInstance("@mozilla.org/file/local;1")); @@ -159,6 +162,7 @@ NS_IMETHODIMP nsFilePicker::Show(PRInt16 *retval) mFile = do_QueryInterface(macFile); } +#endif *retval = userClicksOK; return NS_OK; diff --git a/widget/src/mac/nsMacEventHandler.cpp b/widget/src/mac/nsMacEventHandler.cpp index 1d07e3f9ea2f..3d07fa73f303 100644 --- a/widget/src/mac/nsMacEventHandler.cpp +++ b/widget/src/mac/nsMacEventHandler.cpp @@ -52,7 +52,7 @@ #include "nsIMenuRollup.h" #include "nsTSMStrategy.h" -#ifndef RHAPSODY +#ifndef XP_MACOSX #include #endif diff --git a/widget/src/mac/nsMacMessagePump.cpp b/widget/src/mac/nsMacMessagePump.cpp index 89cfa8d6049c..7938ce40a97d 100644 --- a/widget/src/mac/nsMacMessagePump.cpp +++ b/widget/src/mac/nsMacMessagePump.cpp @@ -70,7 +70,9 @@ #include #include +#ifndef XP_MACOSX #include +#endif #include #include #include @@ -90,7 +92,7 @@ #define botRight(r) (((Point *) &(r))[1]) #endif -#if DEBUG && !defined(MACOSX) +#if DEBUG && !defined(XP_MACOSX) #include #include "macstdlibextras.h" #endif @@ -237,7 +239,7 @@ WindowPtr nsMacMessagePump::GetFrontApplicationWindow() { WindowPtr firstAppWindow = ::FrontWindow(); -#if DEBUG +#if DEBUG && !defined(XP_MACOSX) if (IsSIOUXWindow(firstAppWindow)) firstAppWindow = ::GetNextWindow(firstAppWindow); #endif @@ -411,7 +413,7 @@ void nsMacMessagePump::DispatchEvent(PRBool aRealEvent, EventRecord *anEvent) if (aRealEvent == PR_TRUE) { -#if DEBUG && !defined(MACOSX) +#if DEBUG && !defined(XP_MACOSX) if ((anEvent->what != kHighLevelEvent) && SIOUXHandleOneEvent(anEvent)) return; #endif diff --git a/widget/src/mac/nsMacResources.cpp b/widget/src/mac/nsMacResources.cpp index 202d2631396d..16b3c5acb8ba 100644 --- a/widget/src/mac/nsMacResources.cpp +++ b/widget/src/mac/nsMacResources.cpp @@ -42,6 +42,7 @@ short nsMacResources::mRefNum = kResFileNotOpened; short nsMacResources::mSaveResFile = 0; +#if !TARGET_CARBON pascal OSErr __NSInitialize(const CFragInitBlock *theInitBlock); pascal OSErr __initializeResources(const CFragInitBlock *theInitBlock); @@ -76,6 +77,7 @@ pascal void __terminateResources(void) ::CloseResFile(nsMacResources::GetLocalResourceFile()); __NSTerminate(); } +#endif /*!TARGET_CARBON*/ //---------------------------------------------------------------------------------------- // @@ -83,6 +85,14 @@ pascal void __terminateResources(void) nsresult nsMacResources::OpenLocalResourceFile() { +#ifdef XP_MACOSX + // XXX quick and dirty hack to make resources available so we don't crash. + if (mRefNum == kResFileNotOpened) { + FSSpec spec = { 0, 0, "\plibwidget.rsrc" }; + if (FindFolder(kUserDomain, kDomainLibraryFolderType, false, &spec.vRefNum, &spec.parID) == noErr) + mRefNum = FSpOpenResFile(&spec, fsRdPerm); + } +#endif if (mRefNum == kResFileNotOpened) return NS_ERROR_NOT_INITIALIZED; diff --git a/widget/src/mac/nsMacWindow.cpp b/widget/src/mac/nsMacWindow.cpp index fcc813365f0d..7a5d7436d147 100644 --- a/widget/src/mac/nsMacWindow.cpp +++ b/widget/src/mac/nsMacWindow.cpp @@ -1225,13 +1225,22 @@ NS_IMETHODIMP nsMacWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepai Rect macRect; ::GetWindowPortBounds ( mWindowPtr, &macRect ); - if (((macRect.right - macRect.left) != aWidth) - || ((macRect.bottom - macRect.top) != aHeight)) + short w = macRect.right - macRect.left; + short h = macRect.bottom - macRect.top; + Boolean needReposition = (w == 1 && h == 1); + + if ((w != aWidth) || (h != aHeight)) { // make sure that we don't infinitely recurse if live-resize is on mResizeIsFromUs = PR_TRUE; ::SizeWindow(mWindowPtr, aWidth, aHeight, aRepaint); mResizeIsFromUs = PR_FALSE; + +#if defined(XP_MACOSX) + // workaround for bug in MacOSX if windows start life as 1x1. + if (needReposition) + RepositionWindow(mWindowPtr, NULL, kWindowCascadeOnMainScreen); +#endif } } Inherited::Resize(aWidth, aHeight, aRepaint); diff --git a/widget/src/mac/nsMenuBar.cpp b/widget/src/mac/nsMenuBar.cpp index a10c3ce90fc9..8f5c021a60b7 100644 --- a/widget/src/mac/nsMenuBar.cpp +++ b/widget/src/mac/nsMenuBar.cpp @@ -62,7 +62,9 @@ #include #include #include +#ifndef XP_MACOSX #include +#endif #include #include #include "nsMacResources.h" diff --git a/widget/src/mac/nsSound.cpp b/widget/src/mac/nsSound.cpp index e08f421783bd..f116b0f36218 100644 --- a/widget/src/mac/nsSound.cpp +++ b/widget/src/mac/nsSound.cpp @@ -926,8 +926,10 @@ nsMovieSoundRequest::ImportMovie(Handle inDataHandle, long inDataSize, const nsA // ensure that the track never draws on screen, otherwise we might be // suspecptible to spoofing attacks - Rect movieRect = {0}; - ::SetMovieBox(mMovie, &movieRect); + { + Rect movieRect = {0}; + ::SetMovieBox(mMovie, &movieRect); + } ::GoToEndOfMovie(mMovie); // simplifies the logic in PlaySound() diff --git a/widget/src/mac/nsToolkit.h b/widget/src/mac/nsToolkit.h index 808b71f76df7..149283e0817f 100644 --- a/widget/src/mac/nsToolkit.h +++ b/widget/src/mac/nsToolkit.h @@ -42,9 +42,7 @@ #include "nsRepeater.h" #include "nsCOMPtr.h" - -class nsIEventQueue; -class nsIEventQueueService; +#include "nsIEventQueueService.h" /** * The toolkit abstraction is necessary because the message pump must diff --git a/widget/src/mac/nsWidgetFactory.cpp b/widget/src/mac/nsWidgetFactory.cpp index 60929026724d..c382c4647d26 100644 --- a/widget/src/mac/nsWidgetFactory.cpp +++ b/widget/src/mac/nsWidgetFactory.cpp @@ -88,6 +88,160 @@ #include "nsBidiKeyboard.h" #endif +#ifdef XP_MACOSX + +#include "nsIGenericFactory.h" + +NS_GENERIC_FACTORY_CONSTRUCTOR(nsTimerImpl) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsMacWindow) +NS_GENERIC_FACTORY_CONSTRUCTOR(ChildWindow) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsButton) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsFilePicker) +//NS_GENERIC_FACTORY_CONSTRUCTOR(nsFileWidget) +#if USE_NATIVE_VERSION +NS_GENERIC_FACTORY_CONSTRUCTOR(nsCheckButton) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsComboBox) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsRadioButton) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsListBox) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsTextAreaWidget) +#endif +NS_GENERIC_FACTORY_CONSTRUCTOR(nsTextWidget) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsAppShell) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsToolkit) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsLookAndFeel) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsLabel) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsMenuBar) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsMenu) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsMenuItem) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsSound) +//NS_GENERIC_FACTORY_CONSTRUCTOR(nsFileSpecWithUIImpl) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService) +#ifdef IBMBIDI +NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard) +#endif + + +#define NS_GENERIC_SCROLLBAR_CONSTRUCTOR(type, isVertical) \ +static NS_IMETHODIMP \ +type ## ScrollbarConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult) \ +{ \ + if (aOuter) return NS_ERROR_NO_AGGREGATION; \ + if (!aResult) return NS_ERROR_NULL_POINTER; \ + *aResult = NULL; \ + nsCOMPtr scrollbar = new nsScrollbar(isVertical); \ + if (!scrollbar) return NS_ERROR_OUT_OF_MEMORY; \ + return scrollbar->QueryInterface(aIID, aResult); \ +} + +NS_GENERIC_SCROLLBAR_CONSTRUCTOR(Vertical, PR_TRUE) +NS_GENERIC_SCROLLBAR_CONSTRUCTOR(Horizontal, PR_FALSE) + +static nsModuleComponentInfo components[] = +{ + { "Timer", + NS_TIMER_CID, + "@mozilla.org/timer;1", + nsTimerImplConstructor }, + { "nsWindow", + NS_WINDOW_CID, + "@mozilla.org/widgets/window/mac;1", + nsMacWindowConstructor }, + { "Popup nsWindow", + NS_POPUP_CID, + "@mozilla.org/widgets/popup/mac;1", + nsMacWindowConstructor }, + { "Child nsWindow", + NS_CHILD_CID, + "@mozilla.org/widgets/childwindow/mac;1", + ChildWindowConstructor }, + { "Button", + NS_BUTTON_CID, + "@mozilla.org/widgets/button/mac;1", + nsButtonConstructor }, + { "File Picker", + NS_FILEPICKER_CID, + "@mozilla.org/filepicker;1", + nsFilePickerConstructor }, + { "Horiz Scrollbar", + NS_HORZSCROLLBAR_CID, + "@mozilla.org/widgets/horizscroll/mac;1", + HorizontalScrollbarConstructor }, + { "Vert Scrollbar", + NS_VERTSCROLLBAR_CID, + "@mozilla.org/widgets/vertscroll/mac;1", + VerticalScrollbarConstructor }, + { "Text Field", + NS_TEXTFIELD_CID, + "@mozilla.org/widgets/textfield/mac;1", + nsTextWidgetConstructor }, + { "AppShell", + NS_APPSHELL_CID, + "@mozilla.org/widget/appshell/mac;1", + nsAppShellConstructor }, + { "Toolkit", + NS_TOOLKIT_CID, + "@mozilla.org/widget/toolkit/mac;1", + nsToolkitConstructor }, + { "Look And Feel", + NS_LOOKANDFEEL_CID, + "@mozilla.org/widget/lookandfeel/mac;1", + nsLookAndFeelConstructor }, + { "Label", + NS_LABEL_CID, + "@mozilla.org/widget/label/mac;1", + nsLabelConstructor }, + { "Menubar", + NS_MENUBAR_CID, + "@mozilla.org/widget/menubar/mac;1", + nsMenuBarConstructor }, + { "Menu", + NS_MENU_CID, + "@mozilla.org/widget/menu/mac;1", + nsMenuConstructor }, + { "MenuItem", + NS_MENUITEM_CID, + "@mozilla.org/widget/menuitem/mac;1", + nsMenuItemConstructor }, + { "Sound", + NS_SOUND_CID, + "@mozilla.org/sound;1", + nsSoundConstructor }, + { "Transferable", + NS_TRANSFERABLE_CID, + "@mozilla.org/widget/transferable;1", + nsTransferableConstructor }, + { "HTML Format Converter", + NS_HTMLFORMATCONVERTER_CID, + "@mozilla.org/widget/htmlformatconverter/mac;1", + nsHTMLFormatConverterConstructor }, + { "Clipboard", + NS_CLIPBOARD_CID, + "@mozilla.org/widget/clipboard;1", + nsClipboardConstructor }, + { "Clipboard Helper", + NS_CLIPBOARDHELPER_CID, + "@mozilla.org/widget/clipboardhelper;1", + nsClipboardHelperConstructor }, + { "Drag Service", + NS_DRAGSERVICE_CID, + "@mozilla.org/widget/dragservice;1", + nsDragServiceConstructor }, +#ifdef IBMBIDI + { "Gtk Bidi Keyboard", + NS_BIDIKEYBOARD_CID, + "@mozilla.org/widget/bidikeyboard;1", + nsBidiKeyboardConstructor }, +#endif // IBMBIDI +}; + +NS_IMPL_NSGETMODULE(nsWidgetModule, components) + +#else + // NOTE the following does not match MAC_STATIC actually used below in this file! #define MACSTATIC @@ -318,3 +472,5 @@ NSGetFactory(nsISupports* serviceMgr, return (*aFactory)->QueryInterface(NS_GET_IID(nsIFactory), (void**)aFactory); } + +#endif diff --git a/xpcom/base/nsISupportsUtils.h b/xpcom/base/nsISupportsUtils.h index 9a7402a50f45..720df82d7362 100644 --- a/xpcom/base/nsISupportsUtils.h +++ b/xpcom/base/nsISupportsUtils.h @@ -251,7 +251,7 @@ NS_SPECIALIZE_TEMPLATE struct nsCOMTypeInfo { static const nsIID& GetIID() { - static const nsIID iid = NS_ISUPPORTS_IID; return iid; + static const nsIID iid_NS_ISUPPORTS_IID = NS_ISUPPORTS_IID; return iid_NS_ISUPPORTS_IID; } }; diff --git a/xpcom/build/Makefile.in b/xpcom/build/Makefile.in index b9a85b9a39f3..43dbe79685d5 100644 --- a/xpcom/build/Makefile.in +++ b/xpcom/build/Makefile.in @@ -38,6 +38,11 @@ EXPORTS = \ nsXPCOM.h \ $(NULL) +# pull in MoreFiles for MacOSX +ifeq ($(MOZ_WIDGET_TOOLKIT),mac) +REQUIRES += macmorefiles +endif + CPPSRCS = nsXPComInit.cpp ifdef XPCOM_USE_LEA @@ -80,6 +85,11 @@ ifdef GC_LEAK_DETECTOR EXTRA_DSO_LDOPTS += -lboehm endif +# pull in MoreFiles for MacOSX +ifeq ($(MOZ_WIDGET_TOOLKIT),mac) +EXTRA_DSO_LDOPTS += $(DEPTH)/dist/lib/libmacmorefiles_s.a +endif + # Turn off grep filter for .def files ifeq ($(MOZ_WIDGET_TOOLKIT),os2) XPCOM_SWITCH = 1 diff --git a/xpcom/components/nsComponentManager.h b/xpcom/components/nsComponentManager.h index 2a6d4f8fcdcd..95db53e4c928 100644 --- a/xpcom/components/nsComponentManager.h +++ b/xpcom/components/nsComponentManager.h @@ -229,7 +229,7 @@ protected: #define NS_ERROR_IS_DIR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_XPCOM, 24) -#ifdef XP_UNIX +#if defined(XP_UNIX) && !defined(XP_MACOSX) /* The default registry on the unix system is $HOME/.mozilla/registry per * vr_findGlobalRegName(). vr_findRegFile() will create the registry file * if it doesn't exist. But it wont create directories. diff --git a/xpcom/components/nsNativeComponentLoader.cpp b/xpcom/components/nsNativeComponentLoader.cpp index 433169083ac7..7364f771cd6b 100644 --- a/xpcom/components/nsNativeComponentLoader.cpp +++ b/xpcom/components/nsNativeComponentLoader.cpp @@ -46,7 +46,7 @@ #include "nsITimelineService.h" -#ifdef XP_MAC // sdagley dougt fix +#if defined(XP_MAC) // sdagley dougt fix #include #include #include "nsILocalFileMac.h" @@ -726,7 +726,7 @@ nsNativeComponentLoader::AutoRegisterComponent(PRInt32 when, ".so", /* Unix */ ".shlb", /* Mac ? */ ".dso", /* Unix ? */ - ".dylib", /* Unix: Rhapsody */ + ".dylib", /* Unix: Mach */ ".so.1.0", /* Unix: BSD */ ".sl", /* Unix: HP-UX */ #if defined(VMS) @@ -754,7 +754,7 @@ nsNativeComponentLoader::AutoRegisterComponent(PRInt32 when, // deal only with files that have a valid extension PRBool validExtension = PR_FALSE; -#ifdef XP_MAC // sdagley dougt fix +#if defined(XP_MAC) // sdagley dougt fix // rjc - on Mac, check the file's type code (skip checking the creator code) nsCOMPtr localFileMac = do_QueryInterface(component); diff --git a/xpcom/components/nsRegistry.cpp b/xpcom/components/nsRegistry.cpp index 2194576f3fed..3e948c6d73d8 100644 --- a/xpcom/components/nsRegistry.cpp +++ b/xpcom/components/nsRegistry.cpp @@ -446,7 +446,7 @@ NS_IMETHODIMP nsRegistry::Open( const char *regFile ) { static void EnsureDefaultRegistryDirectory() { - #ifdef XP_UNIX + #if defined(XP_UNIX) && !defined(XP_MACOSX) // Create ~/.mozilla as that is the default place for the registry file /* The default registry on the unix system is $HOME/.mozilla/registry per diff --git a/xpcom/glue/nsISupportsUtils.h b/xpcom/glue/nsISupportsUtils.h index 9a7402a50f45..720df82d7362 100644 --- a/xpcom/glue/nsISupportsUtils.h +++ b/xpcom/glue/nsISupportsUtils.h @@ -251,7 +251,7 @@ NS_SPECIALIZE_TEMPLATE struct nsCOMTypeInfo { static const nsIID& GetIID() { - static const nsIID iid = NS_ISUPPORTS_IID; return iid; + static const nsIID iid_NS_ISUPPORTS_IID = NS_ISUPPORTS_IID; return iid_NS_ISUPPORTS_IID; } }; diff --git a/xpcom/io/Makefile.in b/xpcom/io/Makefile.in index 69e4df0b5409..f76b9bac4034 100644 --- a/xpcom/io/Makefile.in +++ b/xpcom/io/Makefile.in @@ -61,9 +61,14 @@ CPPSRCS = \ ifeq ($(MOZ_WIDGET_TOOLKIT),os2) CPPSRCS += nsLocalFileOS2.cpp +#else +#ifeq ($(MOZ_WIDGET_TOOLKIT),mac) +#CPPSRCS += nsLocalFileMac.cpp +#CSRCS += macDirectoryCopy.c else CPPSRCS += nsLocalFileUnix.cpp endif +#endif EXPORTS = \ nsAppDirectoryServiceDefs.h \ @@ -89,8 +94,12 @@ EXPORTS = \ ifeq ($(MOZ_WIDGET_TOOLKIT),os2) EXPORTS += nsLocalFileOS2.h else +#ifeq ($(MOZ_WIDGET_TOOLKIT),mac) +#EXPORTS += nsLocalFileMac.h nsILocalFileMac.h +#else EXPORTS += nsLocalFileUnix.h endif +#endif XPIDLSRCS = \ nsIBinaryInputStream.idl \ diff --git a/xpcom/io/nsAppFileLocationProvider.cpp b/xpcom/io/nsAppFileLocationProvider.cpp index f021eda44aad..cf7074d0695c 100755 --- a/xpcom/io/nsAppFileLocationProvider.cpp +++ b/xpcom/io/nsAppFileLocationProvider.cpp @@ -30,14 +30,13 @@ #include "nsString.h" #include "nsXPIDLString.h" -#if defined(XP_MAC) +#if defined(XP_MAC) /* || defined(XP_MACOSX) REMIND HACKING FOR MACOS X!!! */ #include #include #include #include #include "nsILocalFileMac.h" -#endif -#if defined(XP_OS2) +#elif defined(XP_OS2) #define INCL_DOSPROCESS #define INCL_DOSMODULEMGR #include @@ -59,7 +58,7 @@ // WARNING: These hard coded names need to go away. They need to // come from localizable resources -#ifdef XP_MAC +#if defined(XP_MAC) /* || defined(XP_MACOSX) REMIND HACKING FOR MACOS X!!! */ #define APP_REGISTRY_NAME "Application Registry" #elif defined(XP_WIN) || defined(XP_OS2) #define APP_REGISTRY_NAME "registry.dat" @@ -250,7 +249,7 @@ NS_METHOD nsAppFileLocationProvider::GetProductDirectory(nsILocalFile **aLocalFi PRBool exists; nsCOMPtr localDir; -#if defined(XP_MAC) +#if defined(XP_MAC) /* || defined(XP_MACOSX) REMIND HACKING FOR MACOS X!!! */ nsCOMPtr directoryService = do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv); if (NS_FAILED(rv)) return rv; @@ -329,7 +328,7 @@ NS_METHOD nsAppFileLocationProvider::GetDefaultUserProfileRoot(nsILocalFile **aL rv = GetProductDirectory(getter_AddRefs(localDir)); if (NS_FAILED(rv)) return rv; -#if defined(XP_MAC) || defined(XP_OS2) || defined(XP_PC) +#if defined(XP_MAC) || defined(XP_MACOSX) || defined(XP_OS2) || defined(XP_PC) // These 3 platforms share this part of the path - do them as one rv = localDir->AppendRelativePath("Profiles"); if (NS_FAILED(rv)) return rv; diff --git a/xpcom/io/nsDirectoryService.cpp b/xpcom/io/nsDirectoryService.cpp index 5cba726d8c6f..b5b80084a5aa 100644 --- a/xpcom/io/nsDirectoryService.cpp +++ b/xpcom/io/nsDirectoryService.cpp @@ -43,17 +43,20 @@ #include "nsLocalFile.h" #include "nsDebug.h" -#ifdef XP_MAC +#if defined(XP_MAC) #include #include #include #include +#ifdef XP_MACOSX +#include "prenv.h" +#endif #elif defined(XP_WIN) #include #include #include #include -#elif defined(XP_UNIX) +#elif defined(XP_UNIX) || defined(XP_MACOSX) #include #include #include @@ -73,7 +76,7 @@ #include "nsSpecialSystemDirectory.h" -#ifdef XP_MAC +#if defined(XP_MAC) #define COMPONENT_REGISTRY_NAME "Component Registry" #define COMPONENT_DIRECTORY "Components" #else @@ -81,7 +84,7 @@ #define COMPONENT_DIRECTORY "components" #endif -#ifdef XP_MAC +#if defined(XP_MAC) #define APP_REGISTRY_NAME "Application Registry" #elif defined(XP_WIN) || defined(XP_OS2) #define APP_REGISTRY_NAME "registry.dat" @@ -95,7 +98,7 @@ #define HOME_DIR NS_WIN_APPDATA_DIR #elif defined (XP_MAC) #define HOME_DIR NS_MAC_HOME_DIR -#elif defined (XP_UNIX) +#elif defined (XP_UNIX) || defined(XP_MACOSX) #define HOME_DIR NS_UNIX_HOME_DIR #elif defined (XP_OS2) #define HOME_DIR NS_OS2_HOME_DIR @@ -106,7 +109,7 @@ // define default product directory #if defined(XP_WIN) || defined(XP_MAC) || defined(XP_OS2) || defined(XP_BEOS) #define DEFAULT_PRODUCT_DIR "Mozilla" -#elif defined (XP_UNIX) +#elif defined (XP_UNIX) || defined(XP_MACOSX) #define DEFAULT_PRODUCT_DIR ".mozilla" #endif @@ -163,36 +166,72 @@ nsDirectoryService::GetCurrentProcessDirectory(nsILocalFile** aFile) // get info for the the current process to determine the directory // its located in OSErr err; - ProcessSerialNumber psn; - if (!(err = GetCurrentProcess(&psn))) + ProcessSerialNumber psn = {kNoProcess, kCurrentProcess}; + ProcessInfoRec pInfo; + FSSpec tempSpec; + + // initialize ProcessInfoRec before calling + // GetProcessInformation() or die horribly. + pInfo.processName = nil; + pInfo.processAppSpec = &tempSpec; + pInfo.processInfoLength = sizeof(ProcessInfoRec); + + err = GetProcessInformation(&psn, &pInfo); + if (!err) { - ProcessInfoRec pInfo; - FSSpec tempSpec; + FSSpec appFSSpec = *(pInfo.processAppSpec); + + // Truncate the nsame so the spec is just to the app directory + appFSSpec.name[0] = 0; - // initialize ProcessInfoRec before calling - // GetProcessInformation() or die horribly. - pInfo.processName = nil; - pInfo.processAppSpec = &tempSpec; - pInfo.processInfoLength = sizeof(ProcessInfoRec); - - if (!(err = GetProcessInformation(&psn, &pInfo))) + nsCOMPtr localFileMac = do_QueryInterface((nsIFile*)localFile); + if (localFileMac) { - FSSpec appFSSpec = *(pInfo.processAppSpec); - - // Truncate the nsame so the spec is just to the app directory - appFSSpec.name[0] = 0; - - nsCOMPtr localFileMac = do_QueryInterface((nsIFile*)localFile); - if (localFileMac) - { - localFileMac->InitWithFSSpec(&appFSSpec); + localFileMac->InitWithFSSpec(&appFSSpec); *aFile = localFile; return NS_OK; - } } } +#if defined(DEBUG) && defined(XP_MACOSX) + else + { + // In the absence of a good way to get the executable directory let + // us try this for unix: + // - if MOZILLA_FIVE_HOME is defined, that is it + char *moz5 = PR_GetEnv("MOZILLA_FIVE_HOME"); + if (moz5) + { + printf( "nsDirectoryService::MOZILLA_FIVE_HOME is set to %s\n", moz5 ); + Str255 pascalpath; + FSSpec ioSpec; + + int srcLength = strlen(moz5); + pascalpath[0] = srcLength; + memcpy(&pascalpath[1], moz5, srcLength); + err = ::FSMakeFSSpec(0, 0, pascalpath, &ioSpec); + + nsCOMPtr localFileMac = do_QueryInterface((nsIFile*)localFile); + if (localFileMac) + { + localFileMac->InitWithFSSpec(&ioSpec); + *aFile = localFile; + return NS_OK; + } + } + else + { + static PRBool firstWarning = PR_TRUE; -#elif defined(XP_UNIX) + if(firstWarning) { + // Warn that MOZILLA_FIVE_HOME not set, once. + printf("***Warning: MOZILLA_FIVE_HOME not set.\n"); + firstWarning = PR_FALSE; + } + } + } +#endif /* DEBUG && XP_MACOSX */ + +#elif defined(XP_UNIX) || defined(XP_MACOSX) // In the absence of a good way to get the executable directory let // us try this for unix: @@ -302,7 +341,7 @@ nsIAtom* nsDirectoryService::sOS_DriveDirectory = nsnull; nsIAtom* nsDirectoryService::sOS_TemporaryDirectory = nsnull; nsIAtom* nsDirectoryService::sOS_CurrentProcessDirectory = nsnull; nsIAtom* nsDirectoryService::sOS_CurrentWorkingDirectory = nsnull; -#ifdef XP_MAC +#if defined(XP_MAC) nsIAtom* nsDirectoryService::sDirectory = nsnull; nsIAtom* nsDirectoryService::sDesktopDirectory = nsnull; nsIAtom* nsDirectoryService::sTrashDirectory = nsnull; @@ -345,7 +384,7 @@ nsIAtom* nsDirectoryService::sCommon_Startup = nsnull; nsIAtom* nsDirectoryService::sCommon_Desktopdirectory = nsnull; nsIAtom* nsDirectoryService::sAppdata = nsnull; nsIAtom* nsDirectoryService::sPrinthood = nsnull; -#elif defined (XP_UNIX) +#elif defined (XP_UNIX) || defined(XP_MACOSX) nsIAtom* nsDirectoryService::sLocalDirectory = nsnull; nsIAtom* nsDirectoryService::sLibDirectory = nsnull; nsIAtom* nsDirectoryService::sHomeDirectory = nsnull; @@ -401,7 +440,7 @@ nsDirectoryService::Init() nsDirectoryService::sOS_TemporaryDirectory = NS_NewAtom(NS_OS_TEMP_DIR); nsDirectoryService::sOS_CurrentProcessDirectory = NS_NewAtom(NS_OS_CURRENT_PROCESS_DIR); nsDirectoryService::sOS_CurrentWorkingDirectory = NS_NewAtom(NS_OS_CURRENT_WORKING_DIR); -#ifdef XP_MAC +#if defined(XP_MAC) nsDirectoryService::sDirectory = NS_NewAtom(NS_OS_SYSTEM_DIR); nsDirectoryService::sDesktopDirectory = NS_NewAtom(NS_MAC_DESKTOP_DIR); nsDirectoryService::sTrashDirectory = NS_NewAtom(NS_MAC_TRASH_DIR); @@ -444,7 +483,7 @@ nsDirectoryService::Init() nsDirectoryService::sCommon_Desktopdirectory = NS_NewAtom(NS_WIN_COMMON_DESKTOP_DIRECTORY); nsDirectoryService::sAppdata = NS_NewAtom(NS_WIN_APPDATA_DIR); nsDirectoryService::sPrinthood = NS_NewAtom(NS_WIN_PRINTHOOD); -#elif defined (XP_UNIX) +#elif defined (XP_UNIX) || defined(XP_MACOSX) nsDirectoryService::sLocalDirectory = NS_NewAtom(NS_UNIX_LOCAL_DIR); nsDirectoryService::sLibDirectory = NS_NewAtom(NS_UNIX_LIB_DIR); nsDirectoryService::sHomeDirectory = NS_NewAtom(NS_UNIX_HOME_DIR); @@ -482,7 +521,7 @@ nsDirectoryService::~nsDirectoryService() NS_IF_RELEASE(nsDirectoryService::sOS_TemporaryDirectory); NS_IF_RELEASE(nsDirectoryService::sOS_CurrentProcessDirectory); NS_IF_RELEASE(nsDirectoryService::sOS_CurrentWorkingDirectory); -#ifdef XP_MAC +#if defined(XP_MAC) NS_IF_RELEASE(nsDirectoryService::sDirectory); NS_IF_RELEASE(nsDirectoryService::sDesktopDirectory); NS_IF_RELEASE(nsDirectoryService::sTrashDirectory); @@ -524,7 +563,7 @@ nsDirectoryService::~nsDirectoryService() NS_IF_RELEASE(nsDirectoryService::sCommon_Desktopdirectory); NS_IF_RELEASE(nsDirectoryService::sAppdata); NS_IF_RELEASE(nsDirectoryService::sPrinthood); -#elif defined (XP_UNIX) +#elif defined (XP_UNIX) || defined(XP_MACOSX) NS_IF_RELEASE(nsDirectoryService::sLocalDirectory); NS_IF_RELEASE(nsDirectoryService::sLibDirectory); NS_IF_RELEASE(nsDirectoryService::sHomeDirectory); @@ -763,7 +802,7 @@ nsDirectoryService::GetFile(const char *prop, PRBool *persistent, nsIFile **_ret rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); } -#ifdef XP_MAC +#if defined(XP_MAC) else if (inAtom == nsDirectoryService::sDirectory) { nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Mac_SystemDirectory); @@ -970,7 +1009,7 @@ nsDirectoryService::GetFile(const char *prop, PRBool *persistent, nsIFile **_ret nsSpecialSystemDirectory fileSpec(nsSpecialSystemDirectory::Win_Printhood); rv = NS_FileSpecToIFile(&fileSpec, getter_AddRefs(localFile)); } -#elif defined (XP_UNIX) +#elif defined (XP_UNIX) || defined(XP_MACOSX) else if (inAtom == nsDirectoryService::sLocalDirectory) { diff --git a/xpcom/io/nsDirectoryService.h b/xpcom/io/nsDirectoryService.h index 8f51d93242fe..c2fe3872f401 100644 --- a/xpcom/io/nsDirectoryService.h +++ b/xpcom/io/nsDirectoryService.h @@ -82,7 +82,7 @@ private: static nsIAtom *sOS_TemporaryDirectory; static nsIAtom *sOS_CurrentProcessDirectory; static nsIAtom *sOS_CurrentWorkingDirectory; -#ifdef XP_MAC +#if defined(XP_MAC) static nsIAtom *sDirectory; static nsIAtom *sDesktopDirectory; static nsIAtom *sTrashDirectory; @@ -125,7 +125,7 @@ private: static nsIAtom *sCommon_Desktopdirectory; static nsIAtom *sAppdata; static nsIAtom *sPrinthood; -#elif defined (XP_UNIX) +#elif defined (XP_UNIX) || defined(XP_MACOSX) static nsIAtom *sLocalDirectory; static nsIAtom *sLibDirectory; static nsIAtom *sHomeDirectory; diff --git a/xpcom/io/nsDirectoryServiceDefs.h b/xpcom/io/nsDirectoryServiceDefs.h index 593d52806c9a..f0f940a86bd4 100755 --- a/xpcom/io/nsDirectoryServiceDefs.h +++ b/xpcom/io/nsDirectoryServiceDefs.h @@ -62,11 +62,18 @@ #define NS_OS_CURRENT_PROCESS_DIR "CurProcD" #define NS_OS_CURRENT_WORKING_DIR "CurWorkD" -#if !defined (XP_UNIX) +#if !defined (XP_UNIX) || defined(XP_MACOSX) #define NS_OS_SYSTEM_DIR "SysD" #endif -#ifdef XP_MAC +// for MacOSX we need the UNIX entries, plus the MAC entries +#if defined (XP_UNIX) || defined(XP_MACOSX) + #define NS_UNIX_LOCAL_DIR "Locl" + #define NS_UNIX_LIB_DIR "LibD" + #define NS_UNIX_HOME_DIR "Home" +#endif + +#if defined(XP_MAC) || defined(XP_MACOSX) #define NS_MAC_DESKTOP_DIR "Desk" #define NS_MAC_TRASH_DIR "Trsh" #define NS_MAC_STARTUP_DIR "Strt" @@ -107,10 +114,6 @@ #define NS_WIN_COMMON_DESKTOP_DIRECTORY "CmDeskP" #define NS_WIN_APPDATA_DIR "AppData" #define NS_WIN_PRINTHOOD "PrntHd" -#elif defined (XP_UNIX) - #define NS_UNIX_LOCAL_DIR "Locl" - #define NS_UNIX_LIB_DIR "LibD" - #define NS_UNIX_HOME_DIR "Home" #elif defined (XP_OS2) #define NS_OS2_DIR "OS2Dir" #define NS_OS2_HOME_DIR "Home" diff --git a/xpcom/io/nsFileSpec.cpp b/xpcom/io/nsFileSpec.cpp index eeca725a7d5a..3377e43ff748 100644 --- a/xpcom/io/nsFileSpec.cpp +++ b/xpcom/io/nsFileSpec.cpp @@ -66,7 +66,7 @@ extern unsigned char* _mbsrchr( const unsigned char*, int); #endif -#ifdef XP_MAC +#if defined(XP_MAC) #include #include #endif @@ -305,7 +305,7 @@ NS_NAMESPACE nsFileSpecHelpers , kMaxAltDigitLength = 5 , kMaxCoreLeafNameLength = (kMaxFilenameLength - (kMaxAltDigitLength + 1)) }; -#ifndef XP_MAC +#if !defined(XP_MAC) NS_NAMESPACE_PROTOTYPE void Canonify(nsSimpleCharString& ioPath, PRBool inMakeDirs); NS_NAMESPACE_PROTOTYPE void MakeAllDirectories(const char* inPath, int mode); #endif @@ -426,7 +426,7 @@ char* nsSimpleCharString::GetLeaf(char inSeparator) const #pragma mark - #endif -#if defined(XP_UNIX) || defined(XP_WIN) || defined(XP_OS2) || defined(XP_BEOS) +#if (defined(XP_UNIX) || defined(XP_WIN) || defined(XP_OS2) || defined(XP_BEOS)) //---------------------------------------------------------------------------------------- void nsFileSpecHelpers::MakeAllDirectories(const char* inPath, int mode) @@ -509,12 +509,9 @@ void nsFileSpecHelpers::MakeAllDirectories(const char* inPath, int mode) #elif defined(XP_MAC) //#include "nsFileSpecMac.cpp" // Macintosh-specific implementations // we include the .cpp file in the project now. -#elif defined(RHAPSODY) -#include "nsFileSpecMac.cpp" // Macintosh-specific implementations -#include "nsFileSpecUnix.cpp" // Unix-specific implementations #elif defined(XP_BEOS) #include "nsFileSpecBeOS.cpp" // BeOS-specific implementations -#elif defined(XP_UNIX) +#elif defined(XP_UNIX) || defined(XP_MACOSX) #include "nsFileSpecUnix.cpp" // Unix-specific implementations #elif defined(XP_OS2) #include "nsFileSpecOS2.cpp" // OS/2-specific implementations @@ -524,7 +521,7 @@ void nsFileSpecHelpers::MakeAllDirectories(const char* inPath, int mode) // nsFileURL implementation //======================================================================================== -#ifndef XP_MAC +#if !defined(XP_MAC) //---------------------------------------------------------------------------------------- nsFileURL::nsFileURL(const char* inString, PRBool inCreateDirs) //---------------------------------------------------------------------------------------- @@ -542,7 +539,7 @@ nsFileURL::nsFileURL(const char* inString, PRBool inCreateDirs) } // nsFileURL::nsFileURL #endif -#ifndef XP_MAC +#if !defined(XP_MAC) //---------------------------------------------------------------------------------------- nsFileURL::nsFileURL(const nsString& inString, PRBool inCreateDirs) //---------------------------------------------------------------------------------------- @@ -566,13 +563,13 @@ nsFileURL::nsFileURL(const nsString& inString, PRBool inCreateDirs) nsFileURL::nsFileURL(const nsFileURL& inOther) //---------------------------------------------------------------------------------------- : mURL(inOther.mURL) -#ifdef XP_MAC +#if defined(XP_MAC) , mFileSpec(inOther.GetFileSpec()) #endif { } // nsFileURL::nsFileURL -#ifndef XP_MAC +#if !defined(XP_MAC) //---------------------------------------------------------------------------------------- nsFileURL::nsFileURL(const nsFilePath& inOther) //---------------------------------------------------------------------------------------- @@ -581,7 +578,7 @@ nsFileURL::nsFileURL(const nsFilePath& inOther) } // nsFileURL::nsFileURL #endif -#ifndef XP_MAC +#if !defined(XP_MAC) //---------------------------------------------------------------------------------------- nsFileURL::nsFileURL(const nsFileSpec& inOther) //---------------------------------------------------------------------------------------- @@ -596,7 +593,7 @@ nsFileURL::~nsFileURL() { } -#ifndef XP_MAC +#if !defined(XP_MAC) //---------------------------------------------------------------------------------------- void nsFileURL::operator = (const char* inString) //---------------------------------------------------------------------------------------- @@ -616,7 +613,7 @@ void nsFileURL::operator +=(const char* inRelativeUnixPath) char* escapedPath = nsEscape(inRelativeUnixPath, url_Path); mURL += escapedPath; nsCRT::free(escapedPath); -#ifdef XP_MAC +#if defined(XP_MAC) mFileSpec += inRelativeUnixPath; #endif } // nsFileURL::operator += @@ -635,12 +632,12 @@ void nsFileURL::operator = (const nsFileURL& inOther) //---------------------------------------------------------------------------------------- { mURL = inOther.mURL; -#ifdef XP_MAC +#if defined(XP_MAC) mFileSpec = inOther.GetFileSpec(); #endif } // nsFileURL::operator = -#ifndef XP_MAC +#if !defined(XP_MAC) //---------------------------------------------------------------------------------------- void nsFileURL::operator = (const nsFilePath& inOther) //---------------------------------------------------------------------------------------- @@ -664,7 +661,7 @@ void nsFileURL::operator = (const nsFilePath& inOther) } // nsFileURL::operator = #endif -#ifndef XP_MAC +#if !defined(XP_MAC) //---------------------------------------------------------------------------------------- void nsFileURL::operator = (const nsFileSpec& inOther) //---------------------------------------------------------------------------------------- @@ -687,13 +684,13 @@ void nsFileURL::operator = (const nsFileSpec& inOther) nsFilePath::nsFilePath(const nsFilePath& inPath) //---------------------------------------------------------------------------------------- : mPath(inPath.mPath) -#ifdef XP_MAC +#if defined(XP_MAC) , mFileSpec(inPath.mFileSpec) #endif { } -#ifndef XP_MAC +#if !defined(XP_MAC) //---------------------------------------------------------------------------------------- nsFilePath::nsFilePath(const char* inString, PRBool inCreateDirs) //---------------------------------------------------------------------------------------- @@ -716,7 +713,7 @@ nsFilePath::nsFilePath(const char* inString, PRBool inCreateDirs) } #endif -#ifndef XP_MAC +#if !defined(XP_MAC) //---------------------------------------------------------------------------------------- nsFilePath::nsFilePath(const nsString& inString, PRBool inCreateDirs) //---------------------------------------------------------------------------------------- @@ -738,7 +735,7 @@ nsFilePath::nsFilePath(const nsString& inString, PRBool inCreateDirs) } #endif -#ifndef XP_MAC +#if !defined(XP_MAC) //---------------------------------------------------------------------------------------- nsFilePath::nsFilePath(const nsFileURL& inOther) //---------------------------------------------------------------------------------------- @@ -748,7 +745,7 @@ nsFilePath::nsFilePath(const nsFileURL& inOther) } #endif -#if defined XP_UNIX || defined XP_BEOS +#if (defined XP_UNIX || defined XP_BEOS) //---------------------------------------------------------------------------------------- nsFilePath::nsFilePath(const nsFileSpec& inOther) //---------------------------------------------------------------------------------------- @@ -763,7 +760,7 @@ nsFilePath::~nsFilePath() { } -#if defined XP_UNIX || defined XP_BEOS +#if (defined XP_UNIX || defined XP_BEOS) //---------------------------------------------------------------------------------------- void nsFilePath::operator = (const nsFileSpec& inOther) //---------------------------------------------------------------------------------------- @@ -774,7 +771,7 @@ void nsFilePath::operator = (const nsFileSpec& inOther) } #endif // XP_UNIX -#ifndef XP_MAC +#if !defined(XP_MAC) //---------------------------------------------------------------------------------------- void nsFilePath::operator = (const char* inString) //---------------------------------------------------------------------------------------- @@ -795,7 +792,7 @@ void nsFilePath::operator = (const char* inString) } #endif // XP_MAC -#ifndef XP_MAC +#if !defined(XP_MAC) //---------------------------------------------------------------------------------------- void nsFilePath::operator = (const nsFileURL& inOther) //---------------------------------------------------------------------------------------- @@ -809,7 +806,7 @@ void nsFilePath::operator = (const nsFilePath& inOther) //---------------------------------------------------------------------------------------- { mPath = inOther.mPath; -#ifdef XP_MAC +#if defined(XP_MAC) mFileSpec = inOther.GetFileSpec(); #endif } @@ -823,7 +820,7 @@ void nsFilePath::operator +=(const char* inRelativeUnixPath) char* escapedPath = nsEscape(inRelativeUnixPath, url_Path); mPath += escapedPath; nsCRT::free(escapedPath); -#ifdef XP_MAC +#if defined(XP_MAC) mFileSpec += inRelativeUnixPath; #endif } // nsFilePath::operator += @@ -852,7 +849,7 @@ nsFilePath nsFilePath::operator +(const char* inRelativeUnixPath) const static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID); #endif /* XPCOM_STANDALONE */ -#ifndef XP_MAC +#if !defined(XP_MAC) //---------------------------------------------------------------------------------------- nsFileSpec::nsFileSpec() //---------------------------------------------------------------------------------------- @@ -952,7 +949,7 @@ void nsFileSpec::operator = (const nsPersistentFileDescriptor& inDescriptor) PRInt32 dataSize; inDescriptor.GetData(data, dataSize); -#ifdef XP_MAC +#if defined(XP_MAC) char* decodedData = PL_Base64Decode((const char*)data, (int)dataSize, nsnull); // Cast to an alias record and resolve. AliasHandle aliasH = nsnull; @@ -975,7 +972,7 @@ void nsFileSpec::operator = (const nsPersistentFileDescriptor& inDescriptor) // UNIX & WIN nsFileSpec implementation //======================================================================================== -#if defined XP_UNIX || defined XP_BEOS +#if (defined XP_UNIX || defined XP_BEOS) //---------------------------------------------------------------------------------------- nsFileSpec::nsFileSpec(const nsFilePath& inPath) //---------------------------------------------------------------------------------------- @@ -994,7 +991,7 @@ void nsFileSpec::operator = (const nsFilePath& inPath) } #endif //XP_UNIX -#if defined(XP_UNIX) || defined(XP_WIN) || defined(XP_OS2) || defined(XP_BEOS) +#if (defined(XP_UNIX) || defined(XP_WIN) || defined(XP_OS2) || defined(XP_BEOS)) //---------------------------------------------------------------------------------------- nsFileSpec::nsFileSpec(const nsFileSpec& inSpec) //---------------------------------------------------------------------------------------- @@ -1061,7 +1058,7 @@ PRBool nsFileSpec::operator == (const nsFileSpec& inOther) const //---------------------------------------------------------------------------------------- { -#ifdef XP_MAC +#if defined(XP_MAC) if ( inOther.mSpec.vRefNum == mSpec.vRefNum && inOther.mSpec.parID == mSpec.parID && EqualString(inOther.mSpec.name, mSpec.name, false, true)) @@ -1117,7 +1114,7 @@ PRBool nsFileSpec::operator != (const nsFileSpec& inOther) const return (! (*this == inOther) ); } -#ifndef XP_MAC +#if !defined(XP_MAC) //---------------------------------------------------------------------------------------- // This is the only automatic conversion to const char* // that is provided, and it allows the @@ -1312,7 +1309,7 @@ nsPersistentFileDescriptor::nsPersistentFileDescriptor(const nsFileSpec& inSpec) void nsPersistentFileDescriptor::operator = (const nsFileSpec& inSpec) //---------------------------------------------------------------------------------------- { -#ifdef XP_MAC +#if defined(XP_MAC) if (inSpec.Error()) return; AliasHandle aliasH; @@ -1431,7 +1428,7 @@ NS_FileSpecToIFile(nsFileSpec* fileSpec, nsILocalFile* *result) if (!file) return NS_ERROR_FAILURE; -#if defined(XP_MAC) || defined(RHAPSODY) +#if defined(XP_MAC) { FSSpec spec = fileSpec->GetFSSpec(); nsCOMPtr psmAppMacFile = do_QueryInterface(file, &rv); diff --git a/xpcom/io/nsFileSpec.h b/xpcom/io/nsFileSpec.h index d70b882c67fc..a0baa57887f5 100644 --- a/xpcom/io/nsFileSpec.h +++ b/xpcom/io/nsFileSpec.h @@ -176,12 +176,10 @@ #include "nsILocalFile.h" #include "nsCOMPtr.h" -#if defined(XP_MAC) || defined(RHAPSODY) +#if defined(XP_MAC) #include #include "nsILocalFileMac.h" -#endif -// this can't be elif because rhapsody needs both headers -#if defined(XP_UNIX) || defined (XP_OS2) || defined(XP_BEOS) || defined(RHAPSODY) +#elif defined(XP_UNIX) || defined (XP_OS2) || defined(XP_BEOS) #if defined(XP_OS2) #define INCL_DOS #define INCL_DOSERRORS @@ -373,7 +371,7 @@ class NS_COM nsFileSpec PRBool IsChildOf(nsFileSpec &possibleParent); -#if defined(XP_MAC) || defined(RHAPSODY) +#if defined(XP_MAC) // For Macintosh people, this is meant to be useful in its own right as a C++ version // of the FSSpec struct. nsFileSpec( @@ -409,10 +407,10 @@ class NS_COM nsFileSpec PRBool Valid() const { return NS_SUCCEEDED(Error()); } nsresult Error() const { - #ifndef XP_MAC +#if !defined(XP_MAC) if (mPath.IsEmpty() && NS_SUCCEEDED(mError)) ((nsFileSpec*)this)->mError = NS_ERROR_NOT_INITIALIZED; - #endif +#endif return mError; } PRBool Failed() const { return (PRBool)NS_FAILED(Error()); } @@ -544,7 +542,7 @@ class NS_COM nsFileSpec friend class nsFilePath; friend class nsFileURL; friend class nsDirectoryIterator; -#if defined(XP_MAC) || defined(RHAPSODY) +#if defined(XP_MAC) FSSpec mSpec; #endif nsSimpleCharString mPath; @@ -592,7 +590,7 @@ class NS_COM nsFileURL const char* GetAsString() const { return (const char*)mURL; } // Not allocated, so don't free it. -#ifdef XP_MAC +#if defined(XP_MAC) // Accessor to allow quick assignment to a mFileSpec const nsFileSpec& GetFileSpec() const { return mFileSpec; } #endif @@ -605,7 +603,7 @@ class NS_COM nsFileURL friend class nsFilePath; // to allow construction of nsFilePath nsSimpleCharString mURL; -#ifdef XP_MAC +#if defined(XP_MAC) // Since the path on the macintosh does not uniquely specify a file (volumes // can have the same name), stash the secret nsFileSpec, too. nsFileSpec mFileSpec; @@ -645,7 +643,7 @@ class NS_COM nsFilePath void operator +=(const char* inRelativeUnixPath); nsFilePath operator +(const char* inRelativeUnixPath) const; -#ifdef XP_MAC +#if defined(XP_MAC) public: // Accessor to allow quick assignment to a mFileSpec const nsFileSpec& GetFileSpec() const { return mFileSpec; } @@ -658,7 +656,7 @@ class NS_COM nsFilePath private: nsSimpleCharString mPath; -#ifdef XP_MAC +#if defined(XP_MAC) // Since the path on the macintosh does not uniquely specify a file (volumes // can have the same name), stash the secret nsFileSpec, too. nsFileSpec mFileSpec; @@ -734,7 +732,7 @@ class NS_COM nsDirectoryIterator public: nsDirectoryIterator( const nsFileSpec& parent, PRBool resoveSymLinks); -#ifndef XP_MAC +#if !defined(XP_MAC) // Macintosh currently doesn't allocate, so needn't clean up. virtual ~nsDirectoryIterator(); #endif @@ -763,19 +761,19 @@ class NS_COM nsDirectoryIterator PRBool mExists; PRBool mResoveSymLinks; -#if defined(XP_UNIX) || defined(XP_BEOS) || defined (XP_WIN) || defined(XP_OS2) +#if (defined(XP_UNIX) || defined(XP_BEOS) || defined (XP_WIN) || defined(XP_OS2)) nsFileSpec mStarting; #endif -#if defined(XP_UNIX) || defined(XP_BEOS) +#if defined(XP_MAC) + short mVRefNum; + long mParID; + short mIndex; + short mMaxIndex; +#elif defined(XP_UNIX) || defined(XP_BEOS) DIR* mDir; #elif defined(XP_WIN) || defined(XP_OS2) PRDir* mDir; // XXX why not use PRDir for Unix too? -#elif defined(XP_MAC) - short mVRefNum; - long mParID; - short mIndex; - short mMaxIndex; #endif }; // class nsDirectoryIterator diff --git a/xpcom/io/nsFileSpecMac.cpp b/xpcom/io/nsFileSpecMac.cpp index 0d36f55d261c..26ae215bb738 100644 --- a/xpcom/io/nsFileSpecMac.cpp +++ b/xpcom/io/nsFileSpecMac.cpp @@ -44,15 +44,12 @@ #include "prtypes.h" #include "nscore.h" -#ifndef RHAPSODY #include "FullPath.h" #include "FileCopy.h" #include "MoreFilesExtras.h" -#endif #include #include -#include #include #include #include @@ -63,7 +60,6 @@ #include "nsXPIDLString.h" -#ifndef RHAPSODY const unsigned char* kAliasHavenFolderName = "\pnsAliasHaven"; //======================================================================================== @@ -558,7 +554,6 @@ char* MacFileHelpers::PathNameFromFSSpec( const FSSpec& inSpec ) return result; } // MacFileHelpers::PathNameFromFSSpec -#endif #pragma mark - @@ -566,7 +561,6 @@ char* MacFileHelpers::PathNameFromFSSpec( const FSSpec& inSpec ) // Macintosh nsFileSpec implementation //======================================================================================== -#ifndef RHAPSODY //---------------------------------------------------------------------------------------- nsFileSpec::nsFileSpec() //---------------------------------------------------------------------------------------- @@ -574,7 +568,6 @@ nsFileSpec::nsFileSpec() // NS_ASSERTION(0, "nsFileSpec is unsupported - use nsIFile!"); Clear(); } -#endif //---------------------------------------------------------------------------------------- nsFileSpec::nsFileSpec(const FSSpec& inSpec, PRBool resolveAlias) @@ -598,7 +591,6 @@ void nsFileSpec::operator = (const FSSpec& inSpec) mError = NS_OK; } -#ifndef RHAPSODY //---------------------------------------------------------------------------------------- nsFileSpec::nsFileSpec(const nsFileSpec& inSpec) //---------------------------------------------------------------------------------------- @@ -1394,8 +1386,8 @@ nsDirectoryIterator::nsDirectoryIterator( //---------------------------------------------------------------------------------------- : mCurrent(inDirectory) , mExists(false) - , mIndex(-1) , mResoveSymLinks(resolveSymLinks) + , mIndex(-1) { CInfoPBRec pb; OSErr err = inDirectory.GetCatInfo(pb); @@ -1472,4 +1464,3 @@ nsDirectoryIterator& nsDirectoryIterator::operator ++ () return *this; } // nsDirectoryIterator::operator ++ -#endif diff --git a/xpcom/io/nsILocalFileMac.h b/xpcom/io/nsILocalFileMac.h index c77328fb6e01..812b305b8f9b 100644 --- a/xpcom/io/nsILocalFileMac.h +++ b/xpcom/io/nsILocalFileMac.h @@ -115,4 +115,7 @@ public: extern "C" NS_EXPORT nsresult NS_NewLocalFileWithFSSpec(FSSpec* inSpec, PRBool followSymlinks, nsILocalFileMac* *result); +extern "C" NS_EXPORT nsresult +NS_NewLocalFile(const char* path, PRBool followLinks, nsILocalFile* *result); + #endif diff --git a/xpcom/io/nsLocalFile.h b/xpcom/io/nsLocalFile.h index 838bacc76d70..03d79fa643e6 100644 --- a/xpcom/io/nsLocalFile.h +++ b/xpcom/io/nsLocalFile.h @@ -40,9 +40,9 @@ #ifdef XP_WIN #include "nsLocalFileWin.h" -#elif defined(XP_MAC) || defined(MACOSX) +#elif defined(XP_MAC) && !defined(XP_MACOSX) #include "nsLocalFileMac.h" -#elif defined(XP_UNIX) || defined(XP_BEOS) +#elif defined(XP_UNIX) || defined(XP_BEOS) || defined(XP_MACOSX) #include "nsLocalFileUnix.h" #elif defined(XP_OS2) #include "nsLocalFileOS2.h" diff --git a/xpcom/io/nsLocalFileMac.cpp b/xpcom/io/nsLocalFileMac.cpp index d5e1ed1f1145..6a1acdee80de 100644 --- a/xpcom/io/nsLocalFileMac.cpp +++ b/xpcom/io/nsLocalFileMac.cpp @@ -40,7 +40,7 @@ #include "nsReadableUtils.h" -#ifdef MACOSX +#ifdef XP_MACOSX #include "nsXPIDLString.h" #include "private/pprio.h" @@ -75,7 +75,7 @@ // Stupid @#$% header looks like its got extern mojo but it doesn't really extern "C" { -#ifndef MACOSX +#ifndef XP_MACOSX // BADPINK - this MSL header doesn't exist under macosx :-( #include #endif @@ -1323,7 +1323,7 @@ nsLocalFile::OpenANSIFileDesc(const char *mode, FILE * *_retval) spec = mTargetSpec; } -#ifdef MACOSX +#ifdef XP_MACOSX // BADPINK - FSp_fopen() doesn't exist under macosx :-( *_retval = nsnull; #else @@ -1677,6 +1677,22 @@ nsLocalFile::GetPath(char **_retval) if ((*_retval)[lastChar] == ':') (*_retval)[lastChar] = '\0'; +#ifdef XP_MACOSX + // Watch out for a really big hack, coming soon to this space! + char* slashified = (char*) nsMemory::Alloc(sizeof("/Volumes/") + strlen(*_retval)); + if (slashified) { + strcpy(slashified, "/Volumes/"); + strcat(slashified, *_retval); + nsMemory::Free(*_retval); + *_retval = slashified; + char *colon = strchr(slashified, ':'); + while (colon != NULL) { + *colon = '/'; + colon = strchr(colon + 1, ':'); + } + } +#endif + return NS_OK; } diff --git a/xpcom/io/nsSpecialSystemDirectory.cpp b/xpcom/io/nsSpecialSystemDirectory.cpp index 71358fe9b20f..e070a03cebae 100644 --- a/xpcom/io/nsSpecialSystemDirectory.cpp +++ b/xpcom/io/nsSpecialSystemDirectory.cpp @@ -253,41 +253,63 @@ static void GetCurrentProcessDirectory(nsFileSpec& aFileSpec) // get info for the the current process to determine the directory // its located in OSErr err; - ProcessSerialNumber psn; - if (!(err = GetCurrentProcess(&psn))) + ProcessSerialNumber psn = {kNoProcess, kCurrentProcess}; + ProcessInfoRec pInfo; + FSSpec tempSpec; + + // initialize ProcessInfoRec before calling + // GetProcessInformation() or die horribly. + pInfo.processName = nil; + pInfo.processAppSpec = &tempSpec; + pInfo.processInfoLength = sizeof(ProcessInfoRec); + + if (!(err = GetProcessInformation(&psn, &pInfo))) { - ProcessInfoRec pInfo; - FSSpec tempSpec; + FSSpec appFSSpec = *(pInfo.processAppSpec); + long theDirID = appFSSpec.parID; - // initialize ProcessInfoRec before calling - // GetProcessInformation() or die horribly. - pInfo.processName = nil; - pInfo.processAppSpec = &tempSpec; - pInfo.processInfoLength = sizeof(ProcessInfoRec); + Str255 name; + CInfoPBRec catInfo; + catInfo.dirInfo.ioCompletion = NULL; + catInfo.dirInfo.ioNamePtr = (StringPtr)&name; + catInfo.dirInfo.ioVRefNum = appFSSpec.vRefNum; + catInfo.dirInfo.ioDrDirID = theDirID; + catInfo.dirInfo.ioFDirIndex = -1; // -1 = query dir in ioDrDirID - if (!(err = GetProcessInformation(&psn, &pInfo))) + if (!(err = PBGetCatInfoSync(&catInfo))) { - FSSpec appFSSpec = *(pInfo.processAppSpec); - long theDirID = appFSSpec.parID; + aFileSpec = nsFileSpec(appFSSpec.vRefNum, + catInfo.dirInfo.ioDrParID, + name, + PR_TRUE); + return; + } + } +#if defined(DEBUG) + else + { + // In the absence of a good way to get the executable directory let + // us try this for unix: + // - if MOZILLA_FIVE_HOME is defined, that is it + char *moz5 = PR_GetEnv("MOZILLA_FIVE_HOME"); + if (moz5) + { + printf( "nsSpecialSystemDirectory::MOZILLA_FIVE_HOME is set to %s\n", moz5 ); + aFileSpec = moz5; + return; + } + else + { + static PRBool firstWarning = PR_TRUE; - Str255 name; - CInfoPBRec catInfo; - catInfo.dirInfo.ioCompletion = NULL; - catInfo.dirInfo.ioNamePtr = (StringPtr)&name; - catInfo.dirInfo.ioVRefNum = appFSSpec.vRefNum; - catInfo.dirInfo.ioDrDirID = theDirID; - catInfo.dirInfo.ioFDirIndex = -1; // -1 = query dir in ioDrDirID - - if (!(err = PBGetCatInfoSync(&catInfo))) - { - aFileSpec = nsFileSpec(appFSSpec.vRefNum, - catInfo.dirInfo.ioDrParID, - name, - PR_TRUE); - return; + if(firstWarning) { + // Warn that MOZILLA_FIVE_HOME not set, once. + printf("***Warning: MOZILLA_FIVE_HOME not set.\n"); + firstWarning = PR_FALSE; } } } +#endif /* DEBUG */ #elif defined(XP_UNIX) @@ -502,7 +524,7 @@ void nsSpecialSystemDirectory::operator = (SystemDirectories aSystemSystemDirect if (needToAppend) { // XXX We need to unify these names across all platforms -#ifdef XP_MAC +#if defined(XP_MAC) *this += "Component Registry"; #else *this += "component.reg"; @@ -540,7 +562,7 @@ void nsSpecialSystemDirectory::operator = (SystemDirectories aSystemSystemDirect if (needToAppend) { // XXX We need to unify these names across all platforms -#ifdef XP_MAC +#if defined(XP_MAC) *this += "Components"; #else *this += "components"; @@ -567,7 +589,7 @@ void nsSpecialSystemDirectory::operator = (SystemDirectories aSystemSystemDirect } break; -#ifdef XP_MAC +#if defined(XP_MAC) case Mac_SystemDirectory: *this = kSystemFolderType; break; @@ -827,7 +849,7 @@ void nsSpecialSystemDirectory::operator = (SystemDirectories aSystemSystemDirect } #endif // XP_WIN -#ifdef XP_UNIX +#if defined(XP_UNIX) case Unix_LocalDirectory: *this = "/usr/local/netscape/"; break; @@ -997,7 +1019,7 @@ nsSpecialSystemDirectory::Set(SystemDirectories dirToSet, nsFileSpec *dirSpec) return; } -#ifdef XP_MAC +#if defined(XP_MAC) //---------------------------------------------------------------------------------------- nsSpecialSystemDirectory::nsSpecialSystemDirectory(OSType folderType) //---------------------------------------------------------------------------------------- diff --git a/xpcom/io/nsSpecialSystemDirectory.h b/xpcom/io/nsSpecialSystemDirectory.h index 30dcc6f081b9..398df8eba915 100644 --- a/xpcom/io/nsSpecialSystemDirectory.h +++ b/xpcom/io/nsSpecialSystemDirectory.h @@ -29,7 +29,7 @@ #include "nscore.h" #include "nsFileSpec.h" -#ifdef XP_MAC +#if defined(XP_MAC) || defined(XP_MACOSX) #include #endif @@ -122,7 +122,7 @@ class NS_COM nsSpecialSystemDirectory : public nsFileSpec void operator = (SystemDirectories aSystemSystemDirectory); -#ifdef XP_MAC +#if defined(XP_MAC) || defined(XP_MACOSX) void operator = (OSType folderType); nsSpecialSystemDirectory(OSType folderType); enum { diff --git a/xpcom/io/nsStdFileStream.cpp b/xpcom/io/nsStdFileStream.cpp index a2a384198e48..3f786bb88514 100644 --- a/xpcom/io/nsStdFileStream.cpp +++ b/xpcom/io/nsStdFileStream.cpp @@ -96,7 +96,7 @@ PRFileDesc* nsFileStreamHelpers::open( if (!nspr_modes[ind]) return 0; -#ifdef XP_MAC +#if defined(XP_MAC) // Use the file spec to open the file, because one path can be common to // several files on the Macintosh (you can have several volumes with the // same name, see). diff --git a/xpcom/reflect/xptcall/src/md/unix/Makefile.in b/xpcom/reflect/xptcall/src/md/unix/Makefile.in index c8013b389fe3..565d6468b59a 100644 --- a/xpcom/reflect/xptcall/src/md/unix/Makefile.in +++ b/xpcom/reflect/xptcall/src/md/unix/Makefile.in @@ -214,7 +214,7 @@ CPPSRCS := xptcinvoke_ppc_netbsd.cpp xptcstubs_ppc_netbsd.cpp ASFILES := xptcinvoke_asm_ppc_netbsd.s xptcstubs_asm_ppc_netbsd.s endif -ifeq ($(OS_ARCH),Rhapsody) +ifeq ($(OS_ARCH),Darwin) CPPSRCS := xptcinvoke_ppc_rhapsody.cpp xptcstubs_ppc_rhapsody.cpp ASFILES := xptcinvoke_asm_ppc_rhapsody.s xptcstubs_asm_ppc_rhapsody.s endif diff --git a/xpcom/tests/FilesTest.cpp b/xpcom/tests/FilesTest.cpp index a4aa541bc245..7a5e1cc526ba 100644 --- a/xpcom/tests/FilesTest.cpp +++ b/xpcom/tests/FilesTest.cpp @@ -127,7 +127,7 @@ void FilesTest::WriteStuff(nsOutputStream& s) //---------------------------------------------------------------------------------------- { // Initialize a URL from a string without suffix. Change the path to suit your machine. - nsFileURL fileURL("file:///Development/MPW/MPW%20Shell", PR_FALSE); + nsFileURL fileURL("file:///X/Developer/Headers", PR_FALSE); s << "File URL initialized to: \"" << fileURL << "\""<< nsEndl; // Initialize a Unix path from a URL @@ -147,7 +147,7 @@ void FilesTest::WriteStuff(nsOutputStream& s) s << "File URL assigned from spec: \"" << fileURL.GetURLString() << "\""<< nsEndl; // Assign a unix path using a string with a suffix. - filePath = "/Development/MPW/SysErrs.err"; + filePath = "/X/Developer/Headers/FlatCarbon/vfp.h"; s << "File path reassigned to: \"" << (const char*)filePath << "\""<< nsEndl; // Assign to a file spec using a unix path. diff --git a/xpcom/threads/plevent.c b/xpcom/threads/plevent.c index b63687962a69..65a5c8d76b56 100644 --- a/xpcom/threads/plevent.c +++ b/xpcom/threads/plevent.c @@ -47,14 +47,14 @@ #include #endif -#if defined(RHAPSODY) +#if defined(XP_MACOSX) #undef XP_UNIX #define XP_MAC 1 #endif #if defined(XP_MAC) #include -#if !defined(RHAPSODY) +#if !defined(DARWIN) #include "pprthred.h" #endif #else diff --git a/xpfe/appshell/src/nsWebShellWindow.cpp b/xpfe/appshell/src/nsWebShellWindow.cpp index f67b7e809fed..7d1d28fc6dd3 100644 --- a/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/xpfe/appshell/src/nsWebShellWindow.cpp @@ -130,14 +130,14 @@ // HACK for M4, should be removed by M5 // ... its now M15 -#if defined(XP_MAC) || defined(RHAPSODY) +#if defined(XP_MAC) || defined(XP_MACOSX) #include #endif #include "nsIMenuItem.h" #include "nsIDOMXULDocument.h" // End hack -#if defined(XP_MAC) || defined(RHAPSODY) +#if defined(XP_MAC) || defined(XP_MACOSX) #define USE_NATIVE_MENUS #endif diff --git a/xpfe/bootstrap/Makefile.in b/xpfe/bootstrap/Makefile.in index 1e16025fed22..3dcfc439237f 100644 --- a/xpfe/bootstrap/Makefile.in +++ b/xpfe/bootstrap/Makefile.in @@ -211,6 +211,11 @@ endif include $(topsrcdir)/config/rules.mk +ifeq ($(OS_ARCH),Darwin) +# don't let us build with "-dynamiclib" +EXTRA_DSO_LDOPTS = -execute +endif + # This code removes the console from release builds # (unless you've set MOZ_WINCONSOLE=1). ifndef MOZ_WINCONSOLE @@ -290,3 +295,11 @@ nsStaticComponents.cpp: nsStaticComponents.cpp.in Makefile Makefile.in $(FINAL_L sed -e "s|%MODULE_LIST%|$(foreach m, $(_COMPONENT_LIST),MODULE($(m)),)|" \ > $@ +ifeq ($(MOZ_WIDGET_TOOLKIT),mac) +install:: $(PROGRAM) + rm -rf $(DIST)/Mozilla.app + mkdir $(DIST)/Mozilla.app + cp -R $(srcdir)/macbuild/Contents $(DIST)/Mozilla.app + cp -RL $(DIST)/bin $(DIST)/Mozilla.app/Contents/MacOS +endif + diff --git a/xpfe/bootstrap/nsAppRunner.cpp b/xpfe/bootstrap/nsAppRunner.cpp index 9fe26b17fddf..c39fd1a2f932 100644 --- a/xpfe/bootstrap/nsAppRunner.cpp +++ b/xpfe/bootstrap/nsAppRunner.cpp @@ -246,6 +246,24 @@ public: }; #endif // XP_MAC +#if defined(XP_MACOSX) + +static void InitializeMacOSXApp(int argc, char* argv[]) +{ + // use the location of the executable to learn where everything is, this + // is because the current working directory is ill-defined when the + // application is double-clicked from the Finder. + char* path = strdup(argv[0]); + char* lastSlash = strrchr(path, '/'); + if (lastSlash) { + *lastSlash = '\0'; + setenv("MOZILLA_FIVE_HOME", path, 1); + } + free(path); +} + +#endif /* XP_MACOSX */ + #ifdef MOZ_WIDGET_GTK #include #endif //MOZ_WIDGET_GTK @@ -1527,6 +1545,10 @@ int main(int argc, char* argv[]) return 1; #endif +#if defined(XP_MACOSX) + InitializeMacOSXApp(argc, argv); +#endif + // Handle -help and -version command line arguments. // They should% return quick, so we deal with them here. if (HandleDumpArguments(argc, argv)) diff --git a/xpinstall/cleanup/Makefile.in b/xpinstall/cleanup/Makefile.in index 6e2e21b435b8..f1020673d4b0 100644 --- a/xpinstall/cleanup/Makefile.in +++ b/xpinstall/cleanup/Makefile.in @@ -53,6 +53,10 @@ LIBS = \ -lmozregsa_s \ $(NULL) +ifeq ($(OS_ARCH),Darwin) +LIBS += -lmacmorefiles_s +endif + DEFINES += -DSTANDALONE_REGISTRY include $(topsrcdir)/config/rules.mk diff --git a/xpinstall/src/nsInstall.cpp b/xpinstall/src/nsInstall.cpp index 5aba76f35659..a61f1700be87 100644 --- a/xpinstall/src/nsInstall.cpp +++ b/xpinstall/src/nsInstall.cpp @@ -246,14 +246,12 @@ nsInstall::GetInstallPlatform(nsCString& aPlatform) mInstallPlatform = "OS/2"; #elif defined(XP_PC) mInstallPlatform = "Windows"; -#elif defined(RHAPSODY) +#elif defined(XP_MAC) || defined(XP_MACOSX) mInstallPlatform = "Macintosh"; #elif defined (XP_UNIX) mInstallPlatform = "X11"; #elif defined(XP_BEOS) mInstallPlatform = "BeOS"; -#elif defined(XP_MAC) - mInstallPlatform = "Macintosh"; #endif mInstallPlatform += "; ";