Bug 367548. Add global convenience methods to check the version of Mac OS X at runtime. Patch by Colin Barrett <cbarrett@mozilla.com>. r=josh, sr=stuart

This commit is contained in:
sayrer%gmail.com 2007-01-23 01:06:42 +00:00
Родитель 0b45f0db27
Коммит 091299fd42
3 изменённых файлов: 24 добавлений и 3 удалений

Просмотреть файл

@ -1151,9 +1151,8 @@ static pascal OSStatus MyMenuEventHandler(EventHandlerCallRef myHandler, EventRe
else if (kind == kEventMenuOpening || kind == kEventMenuClosed) {
if (kind == kEventMenuOpening && gRollupListener != nsnull && gRollupWidget != nsnull) {
gRollupListener->Rollup();
// We can only return userCanceledErr on Tiger or later because it crashes on Panther.
// See bug 351230.
if (nsToolkit::OSXVersion() >= MAC_OS_X_VERSION_10_4_HEX)
// returning userCanceledErr crashes on Panther. See bug 351230.
if (nsToolkit::OnTigerOrLater())
return userCanceledErr;
}

Просмотреть файл

@ -69,6 +69,7 @@
#define MAC_OS_X_VERSION_10_2_HEX 0x00001020
#define MAC_OS_X_VERSION_10_3_HEX 0x00001030
#define MAC_OS_X_VERSION_10_4_HEX 0x00001040
#define MAC_OS_X_VERSION_10_5_HEX 0x00001050
class nsToolkit : public nsIToolkit
{
@ -82,6 +83,11 @@ public:
// Returns the OS X version as returned from Gestalt(gestaltSystemVersion, ...)
static long OSXVersion();
// Convenience functions to check the OS version
static PRBool OnPantherOrLater();
static PRBool OnTigerOrLater();
static PRBool OnLeopardOrLater();
static void PostSleepWakeNotification(const char* aNotification);
protected:

Просмотреть файл

@ -216,9 +216,25 @@ long nsToolkit::OSXVersion()
if (gOSXVersion == 0x0) {
OSErr err = ::Gestalt(gestaltSystemVersion, &gOSXVersion);
if (err != noErr) {
//This should probably be changed when our minimum version changes
NS_ERROR("Couldn't determine OS X version, assuming 10.3");
gOSXVersion = MAC_OS_X_VERSION_10_3_HEX;
}
}
return gOSXVersion;
}
PRBool nsToolkit::OnPantherOrLater()
{
return (OSXVersion() >= MAC_OS_X_VERSION_10_3_HEX) ? PR_TRUE : PR_FALSE;
}
PRBool nsToolkit::OnTigerOrLater()
{
return (OSXVersion() >= MAC_OS_X_VERSION_10_4_HEX) ? PR_TRUE : PR_FALSE;
}
PRBool nsToolkit::OnLeopardOrLater()
{
return (OSXVersion() >= MAC_OS_X_VERSION_10_5_HEX) ? PR_TRUE : PR_FALSE;
}