зеркало из https://github.com/mozilla/gecko-dev.git
Merge backout of db7e931c4410 (CLOSED TREE)
This commit is contained in:
Коммит
d39051be3a
|
@ -64,21 +64,6 @@
|
|||
#include "nsIStandaloneNativeMenu.h"
|
||||
#include "nsILocalFileMac.h"
|
||||
#include "nsString.h"
|
||||
#include "nsCommandLineServiceMac.h"
|
||||
|
||||
class AutoAutoreleasePool {
|
||||
public:
|
||||
AutoAutoreleasePool()
|
||||
{
|
||||
mLocalPool = [[NSAutoreleasePool alloc] init];
|
||||
}
|
||||
~AutoAutoreleasePool()
|
||||
{
|
||||
[mLocalPool release];
|
||||
}
|
||||
private:
|
||||
NSAutoreleasePool *mLocalPool;
|
||||
};
|
||||
|
||||
@interface MacApplicationDelegate : NSObject
|
||||
{
|
||||
|
@ -107,7 +92,7 @@ SetupMacApplicationDelegate()
|
|||
|
||||
// this is called during startup, outside an event loop, and therefore
|
||||
// needs an autorelease pool to avoid cocoa object leakage (bug 559075)
|
||||
AutoAutoreleasePool pool;
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
// This call makes it so that application:openFile: doesn't get bogus calls
|
||||
// from Cocoa doing its own parsing of the argument string. And yes, we need
|
||||
|
@ -119,6 +104,8 @@ SetupMacApplicationDelegate()
|
|||
MacApplicationDelegate *delegate = [[MacApplicationDelegate alloc] init];
|
||||
[NSApp setDelegate:delegate];
|
||||
|
||||
[pool release];
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||
}
|
||||
|
||||
|
@ -141,11 +128,6 @@ SetupMacApplicationDelegate()
|
|||
forEventClass:'WWW!'
|
||||
andEventID:'OURL'];
|
||||
|
||||
[aeMgr setEventHandler:self
|
||||
andSelector:@selector(handleAppleEvent:withReplyEvent:)
|
||||
forEventClass:kCoreEventClass
|
||||
andEventID:kAEOpenDocuments];
|
||||
|
||||
if (![NSApp windowsMenu]) {
|
||||
// If the application has a windows menu, it will keep it up to date and
|
||||
// prepend the window list to the Dock menu automatically.
|
||||
|
@ -166,7 +148,6 @@ SetupMacApplicationDelegate()
|
|||
NSAppleEventManager *aeMgr = [NSAppleEventManager sharedAppleEventManager];
|
||||
[aeMgr removeEventHandlerForEventClass:kInternetEventClass andEventID:kAEGetURL];
|
||||
[aeMgr removeEventHandlerForEventClass:'WWW!' andEventID:'OURL'];
|
||||
[aeMgr removeEventHandlerForEventClass:kCoreEventClass andEventID:kAEOpenDocuments];
|
||||
[super dealloc];
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||
|
@ -194,20 +175,10 @@ SetupMacApplicationDelegate()
|
|||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
|
||||
|
||||
NSURL *url = [NSURL fileURLWithPath:filename];
|
||||
if (!url)
|
||||
return NO;
|
||||
|
||||
NSString *urlString = [url absoluteString];
|
||||
if (!urlString)
|
||||
return NO;
|
||||
|
||||
// Add the URL to any command line we're currently setting up.
|
||||
if (CommandLineServiceMac::AddURLToCurrentCommandLine([urlString UTF8String]))
|
||||
return YES;
|
||||
NSString *escapedPath = [filename stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
||||
|
||||
nsCOMPtr<nsILocalFileMac> inFile;
|
||||
nsresult rv = NS_NewLocalFileWithCFURL((CFURLRef)url, PR_TRUE, getter_AddRefs(inFile));
|
||||
nsresult rv = NS_NewLocalFileWithCFURL((CFURLRef)[NSURL URLWithString:escapedPath], PR_TRUE, getter_AddRefs(inFile));
|
||||
if (NS_FAILED(rv))
|
||||
return NO;
|
||||
|
||||
|
@ -336,8 +307,6 @@ SetupMacApplicationDelegate()
|
|||
if (!event)
|
||||
return;
|
||||
|
||||
AutoAutoreleasePool pool;
|
||||
|
||||
if (([event eventClass] == kInternetEventClass && [event eventID] == kAEGetURL) ||
|
||||
([event eventClass] == 'WWW!' && [event eventID] == 'OURL')) {
|
||||
NSString* urlString = [[event paramDescriptorForKeyword:keyDirectObject] stringValue];
|
||||
|
@ -351,10 +320,6 @@ SetupMacApplicationDelegate()
|
|||
return;
|
||||
}
|
||||
|
||||
// Add the URL to any command line we're currently setting up.
|
||||
if (CommandLineServiceMac::AddURLToCurrentCommandLine([urlString UTF8String]))
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsICommandLineRunner> cmdLine(do_CreateInstance("@mozilla.org/toolkit/command-line;1"));
|
||||
if (!cmdLine) {
|
||||
NS_ERROR("Couldn't create command line!");
|
||||
|
@ -370,26 +335,6 @@ SetupMacApplicationDelegate()
|
|||
return;
|
||||
rv = cmdLine->Run();
|
||||
}
|
||||
else if ([event eventClass] == kCoreEventClass && [event eventID] == kAEOpenDocuments) {
|
||||
NSAppleEventDescriptor* fileListDescriptor = [event paramDescriptorForKeyword:keyDirectObject];
|
||||
if (!fileListDescriptor)
|
||||
return;
|
||||
|
||||
// Descriptor list indexing is one-based...
|
||||
NSInteger numberOfFiles = [fileListDescriptor numberOfItems];
|
||||
for (NSInteger i = 1; i <= numberOfFiles; i++) {
|
||||
NSString* urlString = [[fileListDescriptor descriptorAtIndex:i] stringValue];
|
||||
if (!urlString)
|
||||
continue;
|
||||
|
||||
// We need a path, not a URL
|
||||
NSURL* url = [NSURL URLWithString:urlString];
|
||||
if (!url)
|
||||
continue;
|
||||
|
||||
[self application:NSApp openFile:[url path]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -3586,10 +3586,6 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
|
|||
#endif
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
// Set up ability to respond to system (Apple) events. This must be
|
||||
// done before setting up the command line service.
|
||||
SetupMacApplicationDelegate();
|
||||
|
||||
// we re-initialize the command-line service and do appleevents munging
|
||||
// after we are sure that we're not restarting
|
||||
cmdLine = do_CreateInstance("@mozilla.org/toolkit/command-line;1");
|
||||
|
@ -3600,6 +3596,9 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
|
|||
rv = cmdLine->Init(gArgc, gArgv,
|
||||
workingDir, nsICommandLine::STATE_INITIAL_LAUNCH);
|
||||
NS_ENSURE_SUCCESS(rv, 1);
|
||||
|
||||
// Set up ability to respond to system (Apple) events.
|
||||
SetupMacApplicationDelegate();
|
||||
#endif
|
||||
|
||||
MOZ_SPLASHSCREEN_UPDATE(70);
|
||||
|
|
|
@ -51,8 +51,6 @@ static char** sArgs = NULL;
|
|||
static int sArgsAllocated = 0;
|
||||
static int sArgsUsed = 0;
|
||||
|
||||
static PRBool sBuildingCommandLine = PR_FALSE;
|
||||
|
||||
void AddToCommandLine(const char* inArgText)
|
||||
{
|
||||
if (sArgsUsed >= sArgsAllocated - 1) {
|
||||
|
@ -83,8 +81,6 @@ void SetupMacCommandLine(int& argc, char**& argv, PRBool forRestart)
|
|||
sArgs[0] = NULL;
|
||||
sArgsUsed = 0;
|
||||
|
||||
sBuildingCommandLine = PR_TRUE;
|
||||
|
||||
// Copy args, stripping anything we don't want.
|
||||
for (int arg = 0; arg < argc; arg++) {
|
||||
char* flag = argv[arg];
|
||||
|
@ -93,27 +89,10 @@ void SetupMacCommandLine(int& argc, char**& argv, PRBool forRestart)
|
|||
AddToCommandLine(flag);
|
||||
}
|
||||
|
||||
// Force processing of any pending Apple Events while we're building the
|
||||
// command line. The handlers will append to the command line rather than
|
||||
// act directly so there is no chance we'll process them during a XUL window
|
||||
// load and accidentally open unnecessary windows and home pages.
|
||||
const EventTypeSpec kAppleEventList[] = {
|
||||
{ kEventClassAppleEvent, kEventAppleEvent },
|
||||
};
|
||||
EventRef carbonEvent;
|
||||
while (::ReceiveNextEvent(GetEventTypeCount(kAppleEventList),
|
||||
kAppleEventList,
|
||||
kEventDurationNoWait,
|
||||
PR_TRUE,
|
||||
&carbonEvent) == noErr) {
|
||||
::AEProcessEvent(carbonEvent);
|
||||
::ReleaseEvent(carbonEvent);
|
||||
}
|
||||
|
||||
if (forRestart) {
|
||||
// If the process will be relaunched, the child should be in the foreground
|
||||
// if the parent is in the foreground. This will be communicated in a
|
||||
// command-line argument to the child.
|
||||
if (forRestart) {
|
||||
Boolean isForeground = false;
|
||||
ProcessSerialNumber psnSelf, psnFront;
|
||||
if (::GetCurrentProcess(&psnSelf) == noErr &&
|
||||
|
@ -124,22 +103,8 @@ void SetupMacCommandLine(int& argc, char**& argv, PRBool forRestart)
|
|||
}
|
||||
}
|
||||
|
||||
sBuildingCommandLine = PR_FALSE;
|
||||
|
||||
argc = sArgsUsed;
|
||||
argv = sArgs;
|
||||
}
|
||||
|
||||
PRBool AddURLToCurrentCommandLine(const char* aURL)
|
||||
{
|
||||
if (!sBuildingCommandLine) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
AddToCommandLine("-url");
|
||||
AddToCommandLine(aURL);
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
} // namespace CommandLineServiceMac
|
||||
|
|
|
@ -42,11 +42,6 @@
|
|||
|
||||
namespace CommandLineServiceMac {
|
||||
void SetupMacCommandLine(int& argc, char**& argv, PRBool forRestart);
|
||||
|
||||
// Add a URL to the command line currently being set up via
|
||||
// SetupMacCommandLine. Returns false if no command line is
|
||||
// being set up or the addition fails for any other reason.
|
||||
PRBool AddURLToCurrentCommandLine(const char* aURL);
|
||||
}
|
||||
|
||||
#endif // nsCommandLineServiceMac_h_
|
||||
|
|
Загрузка…
Ссылка в новой задаче