printf("EmbeddedEventHandler(%lx): Init the WebShell...\n", initContext);
printf("EmbeddedEventHandler(%lx): Init the WebShell...%p\n", initContext, initContext->env);
EmbeddedEventHandler (void * arg) {    WebShellInitContext * initContext = (WebShellInitContext *) arg;    nsIEventQueueService * aEventQService = nsnull;    nsresult rv;    PRBool allowPlugins = PR_FALSE;    //TODO Add tracing from nspr.    #if DEBUG_RAPTOR_CANVAS    printf("EmbeddedEventHandler(%lx): Create the Event Queue for the UI thread...\n", initContext);#endif        // Create the Event Queue for the UI thread...    rv = nsServiceManager::GetService(kEventQueueServiceCID,                                      kIEventQueueServiceIID,                                      (nsISupports **) &aEventQService);        if (NS_FAILED(rv)) {        initContext->initFailCode = kEventQueueError;        return;    }        // Create the event queue.    rv = aEventQService->CreateThreadEventQueue();#ifndef NECKO        NS_InitINetService();#endif    // HACK(mark): On Unix, embeddedThread isn't set until after this method returns!!    initContext->embeddedThread = PR_GetCurrentThread();    // Create the action queue    if (initContext->embeddedThread) {#if DEBUG_RAPTOR_CANVAS		printf("EmbeddedEventHandler(%lx): embeddedThread != NULL\n", initContext);#endif		if (initContext->actionQueue == NULL) {#if DEBUG_RAPTOR_CANVAS			printf("EmbeddedEventHandler(%lx): Create the action queue\n", initContext);#endif#ifdef XP_UNIX            // We need to do something different for Unix            nsIEventQueue * EQueue = nsnull;                        rv = aEventQService->GetThreadEventQueue(PR_GetCurrentThread(), &EQueue);            gdk_input_add(EQueue->GetEventQueueSelectFD(),                          GDK_INPUT_READ,                          event_processor_callback,                          EQueue);            PLEventQueue * plEventQueue = nsnull;            EQueue->GetPLEventQueue(&plEventQueue);            initContext->actionQueue = plEventQueue;#else			initContext->actionQueue = ::PL_CreateMonitoredEventQueue("Action Queue", initContext->embeddedThread);#endif		}	}#if DEBUG_RAPTOR_CANVAS	printf("EmbeddedEventHandler(%lx): Create the WebShell...\n", initContext);#endif    // Create the WebShell.    rv = nsRepository::CreateInstance(kWebShellCID, nsnull, kIWebShellIID, (void**)&initContext->webShell);    if (NS_FAILED(rv)) {        initContext->initFailCode = kCreateWebShellError;        return;    }    #if DEBUG_RAPTOR_CANVAS	printf("EmbeddedEventHandler(%lx): Init the WebShell...\n", initContext);#endif        rv = initContext->webShell->Init((nsNativeWidget *)initContext->parentHWnd,                                     initContext->x, initContext->y, initContext->w, initContext->h);    if (NS_FAILED(rv)) {        initContext->initFailCode = kInitWebShellError;        return;    }#if DEBUG_RAPTOR_CANVAS	printf("EmbeddedEventHandler(%lx): Install Prefs in the Webshell...\n", initContext);#endif    nsIPref *prefs;        rv = nsServiceManager::GetService(kPrefCID,                                       nsIPref::GetIID(),                                       (nsISupports **)&prefs);    if (NS_SUCCEEDED(rv)) {        // Set the prefs in the outermost webshell.        initContext->webShell->SetPrefs(prefs);        nsServiceManager::ReleaseService(kPrefCID, prefs);    }    rv = nsComponentManager::CreateInstance(kSessionHistoryCID, nsnull, kISessionHistoryIID,                                             (void**)&gHistory);	if (NS_FAILED(rv)) {        initContext->initFailCode = kHistoryWebShellError;        return;    }        initContext->webShell->SetSessionHistory(gHistory);        #if DEBUG_RAPTOR_CANVAS	printf("EmbeddedEventHandler(%lx): Show the WebShell...\n", initContext);#endif    nsCOMPtr<nsIBaseWindow> baseWindow;        rv = initContext->webShell->QueryInterface(NS_GET_IID(nsIBaseWindow),                                               getter_AddRefs(baseWindow));        if (NS_FAILED(rv)) {        initContext->initFailCode = kShowWebShellError;        return;    }    rv = baseWindow->SetVisibility(PR_TRUE);    if (NS_FAILED(rv)) {        initContext->initFailCode = kShowWebShellError;        return;    }        initContext->initComplete = TRUE;    #if DEBUG_RAPTOR_CANVAS    printf("EmbeddedEventHandler(%lx): enter event loop\n", initContext);#endif    // Don't loop here. The looping will be handled by a Java Thread     // (see org.mozilla.webclient.motif.NativeEventThread).#ifndef XP_UNIX	    do {        if (!processEventLoop(initContext)) {            break;        }    } while (PR_TRUE);#else    // Just need to loop once for Unix    processEventLoop(initContext);#endif}