nsIURL *url; rv = NS_NewURL( &url, "resource:/res/samples/finddialog.xul" );   nsFindDialog *dialog = new nsFindDialog( this, context );  rv = mAppShell->CreateTopLevelWindow( nsnull, url, controllerCID, newWindow, nsnull, dialog, 425, 200 );  if ( NS_SUCCEEDED( rv ) ) {  dialog->SetWindow( newWindow );
nsCOMPtr<nsIWebShell> ws; rv = context->GetTargetWebShell( getter_AddRefs( ws ) ); if ( NS_SUCCEEDED( rv ) && ws ) { nsCOMPtr<nsIWebShellContainer> topLevelWindow; rv = ws->GetTopLevelWindow(getter_AddRefs(topLevelWindow));  nsCOMPtr<nsIWebShellWindow> rootWindow(do_QueryInterface(topLevelWindow)); if ( rootWindow ) {  nsCOMPtr<nsIDOMWindow> domWindow; rv = rootWindow->GetDOMWindow(getter_AddRefs( domWindow ) ); if ( NS_SUCCEEDED( rv ) && domWindow ) {  rv = OpenDialogWithArg( domWindow, context, urlStr ); } else { DEBUG_PRINTF( PR_STDOUT, "%s %d:  Error getting DOM window from web shell, rv=0x%08X\n", (char*)__FILE__, (int)__LINE__, (int)rv ); } } else { DEBUG_PRINTF( PR_STDOUT, "%s %d:  QueryInterface (for nsIWebShellWindow) failed, rv=0x%08X\n", (char*)__FILE__, (int)__LINE__, (int)rv ); } } else { DEBUG_PRINTF( PR_STDOUT, "%s %d: GetTargetWebShell failed, rv=0x%08X\n", __FILE__, (int)__LINE__, (int)rv );
nsFindComponent::Find( nsISupports *aContext ) {    nsresult rv = NS_OK;    if ( aContext && mAppShell ) {        Context *context = (Context*)aContext;        // Open Find dialog and prompt for search parameters.        nsString controllerCID = "43147b80-8a39-11d2-9938-0080c7cb1081";        nsIWebShellWindow *newWindow;        // Make url for dialog xul.        nsIURL *url;        rv = NS_NewURL( &url, "resource:/res/samples/finddialog.xul" );        // Create callbacks object for the find dialog.        nsFindDialog *dialog = new nsFindDialog( this, context );        rv = mAppShell->CreateTopLevelWindow( nsnull,                                              url,                                              controllerCID,                                              newWindow,                                              nsnull,                                              dialog,                                              425,                                              200 );        if ( NS_SUCCEEDED( rv ) ) {            // Tell the dialog its nsIWebShellWindow.            dialog->SetWindow( newWindow );        }        // Release the url for the xul file.        NS_RELEASE( url );    } else {        rv = NS_ERROR_NULL_POINTER;    }    return rv;}