remove 10.3-specific code from Cocoa widgets. b=388444 r=cbarrett sr=roc
git-svn-id: svn://10.0.0.236/trunk@230158 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -101,13 +101,6 @@ static void blinkRgn(RgnHandle rgn);
|
||||
nsIRollupListener * gRollupListener = nsnull;
|
||||
nsIWidget * gRollupWidget = nsnull;
|
||||
|
||||
// This mask is only defined on 10.4 and up.
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_4
|
||||
enum {
|
||||
NSDeviceIndependentModifierFlagsMask = 0xffff0000U
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
@interface ChildView(Private)
|
||||
|
||||
@@ -1706,9 +1699,6 @@ NS_IMETHODIMP nsChildView::GetToggledKeyState(PRUint32 aKeyCode,
|
||||
key = alphaLock;
|
||||
break;
|
||||
case NS_VK_NUM_LOCK:
|
||||
// 10.3 doesn't return the NUM_LOCK state.
|
||||
if (nsToolkit::OSXVersion() < MAC_OS_X_VERSION_10_4_HEX)
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
key = kEventKeyModifierNumLockMask;
|
||||
break;
|
||||
// Mac doesn't support SCROLL_LOCK state.
|
||||
@@ -2353,7 +2343,7 @@ NSEvent* globalDragEvent = nil;
|
||||
}
|
||||
|
||||
|
||||
// A panther-only method, allows us to turn off setting up the clip region
|
||||
// Allows us to turn off setting up the clip region
|
||||
// before each drawRect. We already clip within gecko.
|
||||
- (BOOL)wantsDefaultClipping
|
||||
{
|
||||
|
||||
@@ -54,18 +54,6 @@
|
||||
#include "gfxQuartzSurface.h"
|
||||
#include "gfxImageSurface.h"
|
||||
|
||||
// These symbols don't exist on 10.3, but we use them on 10.4 and greater
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAX_OS_X_VERSION_10_4
|
||||
extern PMSessionGetCGGraphicsContext(PMPrintSession, CGContextRef *);
|
||||
extern PMSessionBeginCGDocumentNoDialog(PMPrintSession, PMPrintSettings, PMPageFormat);
|
||||
#endif
|
||||
|
||||
// These functions don't exist on 10.3, which we build against. However, we want to be able to use them on
|
||||
// 10.4, so we need to access them at runtime.
|
||||
typedef OSStatus (*fpPMSessionBeginCGDocumentNoDialog_type)(PMPrintSession, PMPrintSettings, PMPageFormat);
|
||||
typedef OSStatus (*fpPMSessionGetCGGraphicsContext_type)(PMPrintSession, CGContextRef*);
|
||||
static fpPMSessionBeginCGDocumentNoDialog_type fpPMSessionBeginCGDocumentNoDialog = NULL;
|
||||
static fpPMSessionGetCGGraphicsContext_type fpPMSessionGetCGGraphicsContext = NULL;
|
||||
|
||||
/** -------------------------------------------------------
|
||||
* Construct the nsDeviceContextSpecX
|
||||
@@ -77,16 +65,6 @@ nsDeviceContextSpecX::nsDeviceContextSpecX()
|
||||
, mPrintSettings(kPMNoPrintSettings)
|
||||
, mBeganPrinting(PR_FALSE)
|
||||
{
|
||||
//We have to load these at runtime to use them on 10.4, since we build against 10.3.
|
||||
if (nsToolkit::OnTigerOrLater()) {
|
||||
CFBundleRef bundle = ::CFBundleGetBundleWithIdentifier(CFSTR("com.apple.ApplicationServices"));
|
||||
if (bundle) {
|
||||
fpPMSessionBeginCGDocumentNoDialog = (fpPMSessionBeginCGDocumentNoDialog_type)
|
||||
::CFBundleGetFunctionPointerForName(bundle, CFSTR("PMSessionBeginCGDocumentNoDialog"));
|
||||
fpPMSessionGetCGGraphicsContext = (fpPMSessionGetCGGraphicsContext_type)
|
||||
::CFBundleGetFunctionPointerForName(bundle, CFSTR("PMSessionGetCGGraphicsContext"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** -------------------------------------------------------
|
||||
@@ -100,11 +78,8 @@ nsDeviceContextSpecX::~nsDeviceContextSpecX()
|
||||
ClosePrintManager();
|
||||
}
|
||||
|
||||
#ifdef MOZ_CAIRO_GFX
|
||||
NS_IMPL_ISUPPORTS1(nsDeviceContextSpecX, nsIDeviceContextSpec)
|
||||
#else
|
||||
NS_IMPL_ISUPPORTS2(nsDeviceContextSpecX, nsIDeviceContextSpec, nsIPrintingContext)
|
||||
#endif
|
||||
|
||||
/** -------------------------------------------------------
|
||||
* Initialize the nsDeviceContextSpecMac
|
||||
* @update dc 12/02/98
|
||||
@@ -173,26 +148,9 @@ NS_IMETHODIMP nsDeviceContextSpecX::BeginDocument(PRUnichar* aTitle,
|
||||
status = ::PMSetLastPage(mPrintSettings, aEndPage, false);
|
||||
NS_ASSERTION(status == noErr, "PMSetLastPage failed");
|
||||
|
||||
if (nsToolkit::OnTigerOrLater() && fpPMSessionBeginCGDocumentNoDialog) {
|
||||
//On 10.4 and above, we can easily use CoreGraphics
|
||||
status = fpPMSessionBeginCGDocumentNoDialog(mPrintSession, mPrintSettings, mPageFormat);
|
||||
} else {
|
||||
//Not so on 10.3. The following (taken from Apple sample code) allows us to get a CGContextRef later on 10.3
|
||||
CFStringRef strings[1];
|
||||
CFArrayRef graphicsContextsArray;
|
||||
|
||||
strings[0] = kPMGraphicsContextCoreGraphics;
|
||||
graphicsContextsArray = ::CFArrayCreate(kCFAllocatorDefault, (const void **)strings, 1, &kCFTypeArrayCallBacks);
|
||||
|
||||
if (graphicsContextsArray != NULL) {
|
||||
::PMSessionSetDocumentFormatGeneration(mPrintSession, kPMDocumentFormatPDF, graphicsContextsArray, NULL);
|
||||
::CFRelease(graphicsContextsArray);
|
||||
}
|
||||
//Actually create the document
|
||||
status = ::PMSessionBeginDocumentNoDialog(mPrintSession, mPrintSettings, mPageFormat);
|
||||
}
|
||||
|
||||
if (status != noErr) return NS_ERROR_ABORT;
|
||||
status = ::PMSessionBeginCGDocumentNoDialog(mPrintSession, mPrintSettings, mPageFormat);
|
||||
if (status != noErr)
|
||||
return NS_ERROR_ABORT;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -258,14 +216,9 @@ NS_IMETHODIMP nsDeviceContextSpecX::GetSurfaceForPrinter(gfxASurface **surface)
|
||||
const double width = right - left;
|
||||
const double height = bottom - top;
|
||||
|
||||
//On 10.4 or later, just use CG natively. On 10.3, though, we have to request CG specifically.
|
||||
CGContextRef context;
|
||||
if (nsToolkit::OnTigerOrLater() && fpPMSessionGetCGGraphicsContext) {
|
||||
fpPMSessionGetCGGraphicsContext(mPrintSession, &context);
|
||||
} else {
|
||||
::PMSessionGetGraphicsContext(mPrintSession, kPMGraphicsContextCoreGraphics, (void **)&context);
|
||||
}
|
||||
|
||||
::PMSessionGetCGGraphicsContext(mPrintSession, &context);
|
||||
|
||||
nsRefPtr<gfxASurface> newSurface;
|
||||
|
||||
if (context) {
|
||||
|
||||
@@ -1207,9 +1207,7 @@ static pascal OSStatus MyMenuEventHandler(EventHandlerCallRef myHandler, EventRe
|
||||
else if (kind == kEventMenuOpening || kind == kEventMenuClosed) {
|
||||
if (kind == kEventMenuOpening && gRollupListener != nsnull && gRollupWidget != nsnull) {
|
||||
gRollupListener->Rollup();
|
||||
// returning userCanceledErr crashes on Panther. See bug 351230.
|
||||
if (nsToolkit::OnTigerOrLater())
|
||||
return userCanceledErr;
|
||||
return userCanceledErr;
|
||||
}
|
||||
|
||||
nsISupports* supports = reinterpret_cast<nsISupports*>(userData);
|
||||
@@ -1273,7 +1271,7 @@ static OSStatus InstallMyMenuEventHandler(MenuRef menuRef, void* userData, Event
|
||||
// and that doesn't work for us. We don't need any carbon events until after the
|
||||
// first time the menu is shown, so when that happens we install the carbon
|
||||
// event handler. This works because at this point we can get a MenuRef without
|
||||
// much trouble. This call is 10.3+, so this stuff won't work on 10.2.x or less.
|
||||
// much trouble.
|
||||
- (void)menuNeedsUpdate:(NSMenu*)aMenu
|
||||
{
|
||||
if (!mHaveInstalledCarbonEvents) {
|
||||
|
||||
@@ -184,16 +184,11 @@ nsNativeThemeCocoa::DrawButton(CGContextRef cgContext, ThemeButtonKind inKind,
|
||||
[image setSize:NSMakeSize(inBoxRect.size.width, inBoxRect.size.height)];
|
||||
|
||||
// render to the given CGContextRef
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
|
||||
// graphicsContextWithGraphicsPort is only available on 10.4+
|
||||
[NSGraphicsContext saveGraphicsState];
|
||||
[NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithGraphicsPort:cgContext flipped:YES]];
|
||||
#endif
|
||||
[image compositeToPoint:NSMakePoint(inBoxRect.origin.x, inBoxRect.origin.y + inBoxRect.size.height)
|
||||
operation:NSCompositeSourceOver];
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
|
||||
[NSGraphicsContext restoreGraphicsState];
|
||||
#endif
|
||||
[image release];
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -67,8 +67,6 @@
|
||||
* per nsToolkit.
|
||||
*/
|
||||
|
||||
#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
|
||||
|
||||
@@ -85,8 +83,6 @@ public:
|
||||
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);
|
||||
|
||||
@@ -359,22 +359,13 @@ long nsToolkit::OSXVersion()
|
||||
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;
|
||||
NS_ERROR("Couldn't determine OS X version, assuming 10.4");
|
||||
gOSXVersion = MAC_OS_X_VERSION_10_4_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()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user