mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Code style cleanup for toolkit/xre Mac OS X code. No bug.
This commit is contained in:
parent
1396b23fe4
commit
f8d3d3ccd3
@ -39,8 +39,8 @@
|
||||
// This file defines the interface between Cocoa-specific Obj-C++ and generic C++,
|
||||
// so it itself cannot have any Obj-C bits in it.
|
||||
|
||||
#ifndef __MacApplicationDelegate_h__
|
||||
#define __MacApplicationDelegate_h__
|
||||
#ifndef MacApplicationDelegate_h_
|
||||
#define MacApplicationDelegate_h_
|
||||
|
||||
void EnsureUseCocoaDockAPI(void);
|
||||
void SetupMacApplicationDelegate(void);
|
||||
|
@ -36,8 +36,8 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __MacLaunchHelper_h__
|
||||
#define __MacLaunchHelper_h__
|
||||
#ifndef MacLaunchHelper_h_
|
||||
#define MacLaunchHelper_h_
|
||||
|
||||
extern "C" {
|
||||
void LaunchChildMac(int aArgc, char** aArgv);
|
||||
|
@ -42,7 +42,6 @@
|
||||
|
||||
#include "nsCommandLineServiceMac.h"
|
||||
|
||||
// Mozilla
|
||||
#include "nsDebug.h"
|
||||
#include "nsILocalFileMac.h"
|
||||
#include "nsDebug.h"
|
||||
@ -65,7 +64,6 @@
|
||||
#include "nsICommandLineRunner.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
|
||||
// NSPR
|
||||
#include "prmem.h"
|
||||
#include "plstr.h"
|
||||
#include "prenv.h"
|
||||
@ -101,21 +99,15 @@ static PRInt32 ReadLine(FILE* inStream, char* buf, PRInt32 bufSize)
|
||||
return (c == EOF && !charsRead) ? -1 : charsRead;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsMacCommandLine::nsMacCommandLine()
|
||||
: mArgs(NULL)
|
||||
, mArgsAllocated(0)
|
||||
, mArgsUsed(0)
|
||||
, mStartedUp(PR_FALSE)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsMacCommandLine::~nsMacCommandLine()
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (mArgs) {
|
||||
for (PRUint32 i = 0; i < mArgsUsed; i++)
|
||||
@ -124,10 +116,7 @@ nsMacCommandLine::~nsMacCommandLine()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsresult nsMacCommandLine::Initialize(int& argc, char**& argv)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
mArgs = static_cast<char **>(malloc(kArgsGrowSize * sizeof(char *)));
|
||||
if (!mArgs)
|
||||
@ -154,9 +143,7 @@ nsresult nsMacCommandLine::Initialize(int& argc, char**& argv)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void nsMacCommandLine::SetupCommandLine(int& argc, char**& argv)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
// Initializes the command line from Apple Events and other sources,
|
||||
// as appropriate for OS X.
|
||||
@ -190,9 +177,7 @@ void nsMacCommandLine::SetupCommandLine(int& argc, char**& argv)
|
||||
argv = mArgs;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsresult nsMacCommandLine::AddToCommandLine(const char* inArgText)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
if (mArgsUsed >= mArgsAllocated - 1) {
|
||||
// realloc does not free the given pointer if allocation fails.
|
||||
@ -210,10 +195,7 @@ nsresult nsMacCommandLine::AddToCommandLine(const char* inArgText)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsresult nsMacCommandLine::AddToCommandLine(const char* inOptionString, const FSRef* inFSRef)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
CFURLRef url = ::CFURLCreateFromFSRef(nsnull, inFSRef);
|
||||
if (!url)
|
||||
@ -248,50 +230,40 @@ nsresult nsMacCommandLine::AddToCommandLine(const char* inOptionString, const FS
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
nsresult nsMacCommandLine::AddToEnvironmentVars(const char* inArgText)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
(void)PR_SetEnv(inArgText);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
OSErr nsMacCommandLine::HandleOpenOneDoc(const FSRef* inFSRef, OSType inFileType)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
nsCOMPtr<nsILocalFileMac> inFile;
|
||||
nsresult rv = NS_NewLocalFileWithFSRef(inFSRef, PR_TRUE, getter_AddRefs(inFile));
|
||||
if (NS_FAILED(rv))
|
||||
return errAEEventNotHandled;
|
||||
|
||||
if (!mStartedUp)
|
||||
{
|
||||
if (!mStartedUp) {
|
||||
// Is it the right type to be a command-line file?
|
||||
if (inFileType == 'TEXT' || inFileType == 'CMDL')
|
||||
{
|
||||
if (inFileType == 'TEXT' || inFileType == 'CMDL') {
|
||||
// Can we open the file?
|
||||
FILE *fp = 0;
|
||||
rv = inFile->OpenANSIFileDesc("r", &fp);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
Boolean foundArgs = false;
|
||||
Boolean foundEnv = false;
|
||||
char chars[1024];
|
||||
static const char kCommandLinePrefix[] = "ARGS:";
|
||||
static const char kEnvVarLinePrefix[] = "ENV:";
|
||||
|
||||
while (ReadLine(fp, chars, sizeof(chars)) != -1)
|
||||
{ // See if there are any command line or environment var settings
|
||||
if (PL_strstr(chars, kCommandLinePrefix) == chars)
|
||||
{
|
||||
(void)AddToCommandLine(chars + sizeof(kCommandLinePrefix) - 1);
|
||||
while (ReadLine(fp, chars, sizeof(chars)) != -1) {
|
||||
// See if there are any command line or environment var settings
|
||||
if (PL_strstr(chars, kCommandLinePrefix) == chars) {
|
||||
AddToCommandLine(chars + sizeof(kCommandLinePrefix) - 1);
|
||||
foundArgs = true;
|
||||
}
|
||||
else if (PL_strstr(chars, kEnvVarLinePrefix) == chars)
|
||||
{
|
||||
(void)AddToEnvironmentVars(chars + sizeof(kEnvVarLinePrefix) - 1);
|
||||
else if (PL_strstr(chars, kEnvVarLinePrefix) == chars) {
|
||||
AddToEnvironmentVars(chars + sizeof(kEnvVarLinePrefix) - 1);
|
||||
foundEnv = true;
|
||||
}
|
||||
}
|
||||
@ -336,9 +308,7 @@ OSErr nsMacCommandLine::HandleOpenOneDoc(const FSRef* inFSRef, OSType inFileType
|
||||
return (NS_SUCCEEDED(rv)) ? noErr : errAEEventNotHandled;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
OSErr nsMacCommandLine::HandlePrintOneDoc(const FSRef* inFSRef, OSType fileType)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
// If we are starting up the application,
|
||||
// add a command-line "-print" argument to the global list. This means that if
|
||||
@ -352,10 +322,7 @@ OSErr nsMacCommandLine::HandlePrintOneDoc(const FSRef* inFSRef, OSType fileType)
|
||||
return errAEEventNotHandled;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
OSErr nsMacCommandLine::DispatchURLToNewBrowser(const char* url)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
OSErr err = errAEEventNotHandled;
|
||||
err = AddToCommandLine("-url");
|
||||
@ -367,9 +334,7 @@ OSErr nsMacCommandLine::DispatchURLToNewBrowser(const char* url)
|
||||
|
||||
#pragma mark -
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
void SetupMacCommandLine(int& argc, char**& argv)
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
nsMacCommandLine& cmdLine = nsMacCommandLine::GetMacCommandLine();
|
||||
return cmdLine.SetupCommandLine(argc, argv);
|
||||
|
@ -102,7 +102,6 @@ nsNativeAppSupportCocoa::Enable()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* boolean start (); */
|
||||
NS_IMETHODIMP nsNativeAppSupportCocoa::Start(PRBool *_retval)
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||
@ -116,8 +115,7 @@ NS_IMETHODIMP nsNativeAppSupportCocoa::Start(PRBool *_retval)
|
||||
// alert here. But the alert's message and buttons would require custom
|
||||
// localization. So (for now at least) we just log an English message
|
||||
// to the console before quitting.
|
||||
if ((err != noErr) || response < 0x00001040)
|
||||
{
|
||||
if ((err != noErr) || response < 0x00001040) {
|
||||
NSLog(@"Requires Mac OS X version 10.4 or newer");
|
||||
return PR_FALSE;
|
||||
}
|
||||
@ -142,35 +140,29 @@ nsNativeAppSupportCocoa::ReOpen()
|
||||
|
||||
nsCOMPtr<nsIWindowMediator>
|
||||
wm(do_GetService(NS_WINDOWMEDIATOR_CONTRACTID));
|
||||
if (!wm)
|
||||
{
|
||||
if (!wm) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
nsCOMPtr<nsISimpleEnumerator> windowList;
|
||||
wm->GetXULWindowEnumerator(nsnull, getter_AddRefs(windowList));
|
||||
PRBool more;
|
||||
windowList->HasMoreElements(&more);
|
||||
while (more)
|
||||
{
|
||||
while (more) {
|
||||
nsCOMPtr<nsISupports> nextWindow = nsnull;
|
||||
windowList->GetNext(getter_AddRefs(nextWindow));
|
||||
nsCOMPtr<nsIBaseWindow> baseWindow(do_QueryInterface(nextWindow));
|
||||
if (!baseWindow)
|
||||
{
|
||||
if (!baseWindow) {
|
||||
windowList->HasMoreElements(&more);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
haveOpenWindows = PR_TRUE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWidget> widget = nsnull;
|
||||
baseWindow->GetMainWidget(getter_AddRefs(widget));
|
||||
if (!widget)
|
||||
{
|
||||
if (!widget) {
|
||||
windowList->HasMoreElements(&more);
|
||||
continue;
|
||||
}
|
||||
@ -182,14 +174,12 @@ nsNativeAppSupportCocoa::ReOpen()
|
||||
windowList->HasMoreElements(&more);
|
||||
} // end while
|
||||
|
||||
if (!haveNonMiniaturized)
|
||||
{
|
||||
if (!haveNonMiniaturized) {
|
||||
// Deminiaturize the most recenty used window
|
||||
nsCOMPtr<nsIDOMWindowInternal> mru = nsnull;
|
||||
wm->GetMostRecentWindow(nsnull, getter_AddRefs(mru));
|
||||
|
||||
if (mru)
|
||||
{
|
||||
if (mru) {
|
||||
NSWindow *cocoaMru = nil;
|
||||
GetNativeWindowPointerFromDOMWindow(mru, &cocoaMru);
|
||||
if (cocoaMru) {
|
||||
@ -200,8 +190,7 @@ nsNativeAppSupportCocoa::ReOpen()
|
||||
|
||||
} // end if have non miniaturized
|
||||
|
||||
if (!haveOpenWindows && !done)
|
||||
{
|
||||
if (!haveOpenWindows && !done) {
|
||||
char* argv[] = { nsnull };
|
||||
|
||||
// use an empty command line to make the right kind(s) of window open
|
||||
@ -230,20 +219,16 @@ GetNativeWindowPointerFromDOMWindow(nsIDOMWindowInternal *a_window, NSWindow **a
|
||||
if (!a_window) return NS_ERROR_INVALID_ARG;
|
||||
|
||||
nsCOMPtr<nsIWebNavigation> mruWebNav(do_GetInterface(a_window));
|
||||
if (mruWebNav)
|
||||
{
|
||||
if (mruWebNav) {
|
||||
nsCOMPtr<nsIDocShellTreeItem> mruTreeItem(do_QueryInterface(mruWebNav));
|
||||
nsCOMPtr<nsIDocShellTreeOwner> mruTreeOwner = nsnull;
|
||||
mruTreeItem->GetTreeOwner(getter_AddRefs(mruTreeOwner));
|
||||
if(mruTreeOwner)
|
||||
{
|
||||
if(mruTreeOwner) {
|
||||
nsCOMPtr<nsIBaseWindow> mruBaseWindow(do_QueryInterface(mruTreeOwner));
|
||||
if (mruBaseWindow)
|
||||
{
|
||||
if (mruBaseWindow) {
|
||||
nsCOMPtr<nsIWidget> mruWidget = nsnull;
|
||||
mruBaseWindow->GetMainWidget(getter_AddRefs(mruWidget));
|
||||
if (mruWidget)
|
||||
{
|
||||
if (mruWidget) {
|
||||
*a_nativeWindow = (NSWindow*)mruWidget->GetNativeData(NS_NATIVE_WINDOW);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user