From f8d3d3ccd39e6b8c4f633c4351fdb329f19bc7d9 Mon Sep 17 00:00:00 2001 From: Josh Aas Date: Mon, 9 Mar 2009 17:27:48 -0400 Subject: [PATCH] Code style cleanup for toolkit/xre Mac OS X code. No bug. --- toolkit/xre/MacApplicationDelegate.h | 4 +- toolkit/xre/MacLaunchHelper.h | 4 +- toolkit/xre/nsCommandLineServiceMac.cpp | 53 +++++-------------------- toolkit/xre/nsNativeAppSupportCocoa.mm | 43 +++++++------------- 4 files changed, 27 insertions(+), 77 deletions(-) diff --git a/toolkit/xre/MacApplicationDelegate.h b/toolkit/xre/MacApplicationDelegate.h index 0bd1856e3de..567932434c3 100644 --- a/toolkit/xre/MacApplicationDelegate.h +++ b/toolkit/xre/MacApplicationDelegate.h @@ -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); diff --git a/toolkit/xre/MacLaunchHelper.h b/toolkit/xre/MacLaunchHelper.h index d29fb5398f6..d22d2637f16 100644 --- a/toolkit/xre/MacLaunchHelper.h +++ b/toolkit/xre/MacLaunchHelper.h @@ -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); diff --git a/toolkit/xre/nsCommandLineServiceMac.cpp b/toolkit/xre/nsCommandLineServiceMac.cpp index 0387e4e7a7a..ff5b14154c9 100644 --- a/toolkit/xre/nsCommandLineServiceMac.cpp +++ b/toolkit/xre/nsCommandLineServiceMac.cpp @@ -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(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 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); diff --git a/toolkit/xre/nsNativeAppSupportCocoa.mm b/toolkit/xre/nsNativeAppSupportCocoa.mm index cbc2bce8680..ce6be094640 100644 --- a/toolkit/xre/nsNativeAppSupportCocoa.mm +++ b/toolkit/xre/nsNativeAppSupportCocoa.mm @@ -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 wm(do_GetService(NS_WINDOWMEDIATOR_CONTRACTID)); - if (!wm) - { + if (!wm) { return NS_ERROR_FAILURE; } - else - { + else { nsCOMPtr windowList; wm->GetXULWindowEnumerator(nsnull, getter_AddRefs(windowList)); PRBool more; windowList->HasMoreElements(&more); - while (more) - { + while (more) { nsCOMPtr nextWindow = nsnull; windowList->GetNext(getter_AddRefs(nextWindow)); nsCOMPtr baseWindow(do_QueryInterface(nextWindow)); - if (!baseWindow) - { + if (!baseWindow) { windowList->HasMoreElements(&more); continue; } - else - { + else { haveOpenWindows = PR_TRUE; } nsCOMPtr 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 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 mruWebNav(do_GetInterface(a_window)); - if (mruWebNav) - { + if (mruWebNav) { nsCOMPtr mruTreeItem(do_QueryInterface(mruWebNav)); nsCOMPtr mruTreeOwner = nsnull; mruTreeItem->GetTreeOwner(getter_AddRefs(mruTreeOwner)); - if(mruTreeOwner) - { + if(mruTreeOwner) { nsCOMPtr mruBaseWindow(do_QueryInterface(mruTreeOwner)); - if (mruBaseWindow) - { + if (mruBaseWindow) { nsCOMPtr mruWidget = nsnull; mruBaseWindow->GetMainWidget(getter_AddRefs(mruWidget)); - if (mruWidget) - { + if (mruWidget) { *a_nativeWindow = (NSWindow*)mruWidget->GetNativeData(NS_NATIVE_WINDOW); } }