aWindow->GetClientData(data); if (data == nsnull) rv = NS_ERROR_NULL_POINTER; else { nsWebShellWindow* window = (nsWebShellWindow *) data; nsIWebShellContainer* wsc; rv = window->QueryInterface(kIWebShellContainerIID, (void **) &wsc); if (NS_SUCCEEDED(rv)) { mWindowList->RemoveElement(wsc); NS_RELEASE(wsc); }
mWindowList->RemoveElement(aWindow);  PRUint32 cnt; rv = mWindowList->Count(&cnt); if (NS_FAILED(rv)) return rv; if (0 == cnt) { if (!mQuitOnLastWindowClosing) return NS_OK;  #if XP_MAC     nsCOMPtr<nsIBaseWindow> hiddenWin(do_QueryInterface(mHiddenWindow)); if (!hiddenWin) Quit(); #else  PRBool serverMode = PR_FALSE; if (mNativeAppSupport) mNativeAppSupport->GetIsServerMode(&serverMode); if (serverMode) return NS_OK;  Quit(); #endif
nsAppShellService::UnregisterTopLevelWindow(nsIWidget* aWindow){  nsresult rv;  void* data;  aWindow->GetClientData(data);  if (data == nsnull)    rv = NS_ERROR_NULL_POINTER;  else {    nsWebShellWindow* window = (nsWebShellWindow *) data;    nsIWebShellContainer* wsc;    rv = window->QueryInterface(kIWebShellContainerIID, (void **) &wsc);    if (NS_SUCCEEDED(rv)) {      mWindowList->RemoveElement(wsc);      NS_RELEASE(wsc);    }  }  return rv;}