Bug 273877 - Embedders should intialize the widget toolkit (XUL apps in nsAppRunner.cpp), instead of using nsIAppShell::Create) r=darin sr=roc

git-svn-id: svn://10.0.0.236/trunk@166898 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bsmedberg%covad.net 2004-12-20 21:53:33 +00:00
parent d18903be1c
commit 8dc0b7ab78
10 changed files with 31 additions and 79 deletions

View File

@ -92,16 +92,7 @@ nsAppStartup::Init()
mAppShell = do_CreateInstance(kAppShellCID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsICmdLineService> cmdLineService
(do_GetService(NS_COMMANDLINESERVICE_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
PRInt32 argc = 0;
char** argv = nsnull;
cmdLineService->GetArgc(&argc);
cmdLineService->GetArgv(&argv);
rv = mAppShell->Create(&argc, argv);
rv = mAppShell->Create(nsnull, nsnull);
NS_ENSURE_SUCCESS(rv, rv);
// listen to EventQueues' comings and goings. do this after the appshell

View File

@ -306,6 +306,9 @@ static nsresult InitializeBeOSApp(void)
#include <gtk/gtk.h>
#endif //MOZ_WIDGET_GTK || MOZ_WIDGET_GTK2
#if defined(MOZ_WIDGET_QT)
#include <qapplication.h>
#endif
static PRBool
strimatch(const char* lowerstr, const char* mixedstr)
@ -1871,6 +1874,14 @@ int xre_main(int argc, char* argv[], const nsXREAppData* aAppData)
gtk_widget_set_default_visual(gdk_rgb_get_visual());
gtk_widget_set_default_colormap(gdk_rgb_get_cmap());
#endif /* MOZ_WIDGET_GTK || MOZ_WIDGET_GTK2 */
#if defined(MOZ_WIDGET_QT)
QAppliction qapp(argc, argv);
#endif
// #if defined(MOZ_WIDGET_XLIB)
// XXXtimeless fix me! How do we get a Display from here to nsAppShell.cpp ?
// #endif
// Call the code to install our handler
#ifdef MOZ_JPROF

View File

@ -55,7 +55,6 @@
#include "glib.h"
#include "nsVoidArray.h"
static PRBool sInitialized = PR_FALSE;
static PLHashTable *sQueueHashTable = nsnull;
static PLHashTable *sCountHashTable = nsnull;
static nsVoidArray *sEventQueueList = nsnull;
@ -196,14 +195,6 @@ static void event_processor_callback(gpointer data,
NS_IMETHODIMP nsAppShell::Create(int *bac, char **bav)
{
#ifdef DEBUG_APPSHELL
printf("nsAppShell::Create()\n");
#endif
if (sInitialized)
return NS_OK;
sInitialized = PR_TRUE;
return NS_OK;
}

View File

@ -119,9 +119,6 @@ nsAppShell::Create(int *argc, char **argv)
sInitialized = PR_TRUE;
// XXX add all of the command line handling
if (PR_GetEnv("MOZ_DEBUG_PAINTS")) {
gdk_window_set_debug_updates(TRUE);
}

View File

@ -135,24 +135,6 @@ static int event_processor_callback(int fd, void *data, unsigned mode)
NS_IMETHODIMP nsAppShell::Create(int *bac, char **bav)
{
int argc = bac ? *bac : 0;
char **argv = bav;
nsresult rv;
nsCOMPtr<nsICmdLineService> cmdLineArgs =
do_GetService(kCmdLineServiceCID, &rv);
if (NS_SUCCEEDED(rv))
{
rv = cmdLineArgs->GetArgc(&argc);
if(NS_FAILED(rv))
argc = bac ? *bac : 0;
rv = cmdLineArgs->GetArgv(&argv);
if(NS_FAILED(rv))
argv = bav;
}
/*
This used to be done in the init function of nsToolkit. It was moved here because the phoenix
browser may ( when -ProfileManager is used ) create/ListenToEventQueue of an nsAppShell before

View File

@ -63,24 +63,6 @@ NS_IMPL_ISUPPORTS1(nsAppShell, nsIAppShell)
NS_IMETHODIMP
nsAppShell::Create(int *argc, char **argv)
{
qDebug("Qt: nsAppShell::create");
/**
* If !qApp then it means we're not embedding
* but running a full application.
*/
if (!qApp) {
//oh, this is fun. yes, argc can be null here
int argcSafe = 0;
if (argc)
argcSafe = *argc;
new QApplication(argcSafe, argv);
if (argc)
*argc = argcSafe;
}
return NS_OK;
}

View File

@ -369,6 +369,10 @@ static void InitializeMacOSXApp(int argc, char* argv[])
#endif /* XP_MACOSX */
#if defined(MOZ_WIDGET_QT)
#include <qapplication.h>
#endif
#ifdef MOZ_X11
#include <X11/Xlib.h>
#endif /* MOZ_X11 */
@ -1199,7 +1203,7 @@ static nsresult main1(int argc, char* argv[], nsISupports *nativeApp )
NS_TIMELINE_ENTER("appStartup->Initialize");
// Create the Application Shell instance...
rv = appStartup->Initialize(cmdLineArgs, nativeAppOwner);
rv = appStartup->Initialize(nativeAppOwner);
NS_TIMELINE_LEAVE("appStartup->Initialize");
@ -1711,6 +1715,15 @@ int main(int argc, char* argv[])
gtk_widget_set_default_visual(gdk_rgb_get_visual());
gtk_widget_set_default_colormap(gdk_rgb_get_cmap());
#endif /* MOZ_WIDGET_GTK || MOZ_WIDGET_GTK2 */
#if defined(MOZ_WIDGET_QT)
QApplication qapp(argc, argv);
#endif
// #if defined(MOZ_WIDGET_XLIB)
// XXXtimeless fix me! Because we don't have external shared libs holding global
// refs, there isn't an easy way to get a Display from here to the widget component.
// #endif
// Call the code to install our handler
#ifdef MOZ_JPROF

View File

@ -41,22 +41,17 @@
interface nsICmdLineService;
interface nsINativeAppSupport;
[scriptable, uuid(413e5d30-1b92-416a-acca-1c8ee4f66d08)]
[scriptable, uuid(0f4ae035-4643-44c5-a596-ff81b8c29f08)]
interface nsIAppStartup : nsISupports
{
/**
* Required initialization routine.
* @param aCmdLineService
* This is stored and passed to appshell components as they are
* initialized.
* @param aNativeAppSupportOrSplashScreen
* This is an object that can be QI'd to either an
* nsINativeAppSupport or nsISplashScreen; this object will be
* used to implement HideSplashScreen.
*/
void initialize(in nsICmdLineService aCmdLineService,
in nsISupports nativeAppSupportOrSplashScreen);
void initialize(in nsISupports nativeAppSupportOrSplashScreen);
/**
* Create the hidden window. Only bootstrap code (nsAppRunner.cpp) should call

View File

@ -43,6 +43,7 @@
#include "nsIAppShellService.h"
#include "nsICloseAllWindows.h"
#include "nsICmdLineService.h"
#include "nsIDOMWindowInternal.h"
#include "nsIEventQueue.h"
#include "nsIEventQueueService.h"
@ -101,14 +102,10 @@ NS_IMPL_ISUPPORTS5(nsAppStartup,
//
NS_IMETHODIMP
nsAppStartup::Initialize(nsICmdLineService *aCmdLineService,
nsISupports *aNativeAppSupportOrSplashScreen)
nsAppStartup::Initialize(nsISupports *aNativeAppSupportOrSplashScreen)
{
nsresult rv;
// Remember cmd line service.
mCmdLineService = aCmdLineService;
// Remember where the native app support lives.
mNativeAppSupport = do_QueryInterface(aNativeAppSupportOrSplashScreen);
@ -120,12 +117,7 @@ nsAppStartup::Initialize(nsICmdLineService *aCmdLineService,
mAppShell = do_CreateInstance(kAppShellCID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
PRInt32 argc = 0;
char** argv = nsnull;
aCmdLineService->GetArgc(&argc);
aCmdLineService->GetArgv(&argv);
rv = mAppShell->Create(&argc, argv);
rv = mAppShell->Create(nsnull, nsnull);
NS_ENSURE_SUCCESS(rv, rv);
// listen to EventQueues' comings and goings. do this after the appshell

View File

@ -45,7 +45,6 @@
#include "nsIObserver.h"
#include "nsWeakReference.h"
#include "nsICmdLineService.h"
#include "nsISplashScreen.h"
#include "nsINativeAppSupport.h"
#include "nsIAppShell.h"
@ -91,7 +90,6 @@ private:
nsresult OpenBrowserWindow(PRInt32 height, PRInt32 width);
nsCOMPtr<nsIAppShell> mAppShell;
nsCOMPtr<nsICmdLineService> mCmdLineService;
nsCOMPtr<nsISplashScreen> mSplashScreen;
nsCOMPtr<nsINativeAppSupport> mNativeAppSupport;