mWebBrowser->SetParentURIContentListener(nsnull);   nsCOMPtr <nsIDocShell> docShell = do_GetInterface(mWebBrowser); nsCOMPtr <nsIWebProgress> webProgress; webProgress = do_GetInterface(docShell); webProgress->RemoveProgressListener(mChromeProgress);   RemoveEventListener();    nsCOMPtr<nsIDocShellTreeItem> browserAsItem; browserAsItem = do_QueryInterface(mWebBrowser);  nsCOMPtr<nsIDocShellTreeOwner> treeOwner; browserAsItem->GetTreeOwner(getter_AddRefs(treeOwner)); NS_ASSERTION(treeOwner, "failed to get tree owner");  nsCOMPtr<nsIDocShellTreeItem> contentItem; treeOwner->GetPrimaryContentShell(getter_AddRefs(contentItem)); NS_ASSERTION(contentItem, "failed to get content item");   contentItem->SetTreeOwner(nsnull);  webProgress = do_GetInterface(docShell);  webProgress->RemoveProgressListener(mContentProgress);     browserAsItem = do_QueryInterface(mWebBrowser); browserAsItem->SetTreeOwner(nsnull);   nsCOMPtr<nsIBaseWindow> webBrowserBaseWindow = do_QueryInterface(mWebBrowser); webBrowserBaseWindow->Destroy();  mMozWindow = 0; mWebBrowser = nsnull; mEmbed = nsnull;
gtk_signal_emit(GTK_OBJECT(mEmbed), moz_embed_signals[DESTROY_BROWSER]);
GtkMozEmbedPrivate::Destroy(void){  // remove ourselves as the parent URI content listener  mWebBrowser->SetParentURIContentListener(nsnull);    // remove ourselves as the progress listener for the chrome object  nsCOMPtr <nsIDocShell> docShell = do_GetInterface(mWebBrowser);  nsCOMPtr <nsIWebProgress> webProgress;  webProgress = do_GetInterface(docShell);  webProgress->RemoveProgressListener(mChromeProgress);  // remove our key press listener  RemoveEventListener();  // get the content item  // get the browser as an item  nsCOMPtr<nsIDocShellTreeItem> browserAsItem;  browserAsItem = do_QueryInterface(mWebBrowser);  // get the owner for that item  nsCOMPtr<nsIDocShellTreeOwner> treeOwner;  browserAsItem->GetTreeOwner(getter_AddRefs(treeOwner));  NS_ASSERTION(treeOwner, "failed to get tree owner");  // get the primary content shell as an item  nsCOMPtr<nsIDocShellTreeItem> contentItem;  treeOwner->GetPrimaryContentShell(getter_AddRefs(contentItem));  NS_ASSERTION(contentItem, "failed to get content item");  // remove our chrome object as the tree owner for the content  // docShell.  contentItem->SetTreeOwner(nsnull);  // get the nsIWebProgress object for that docshell  webProgress = do_GetInterface(docShell);  // remove the mContentProgress object from that docshell  webProgress->RemoveProgressListener(mContentProgress);    // now that we have removed ourselves as the tree owner for the  // content item, remove ourselves as the tree owner for the  // browser  browserAsItem = do_QueryInterface(mWebBrowser);  browserAsItem->SetTreeOwner(nsnull);    // destroy the native windows  nsCOMPtr<nsIBaseWindow> webBrowserBaseWindow =     do_QueryInterface(mWebBrowser);  webBrowserBaseWindow->Destroy();    mMozWindow = 0;  mWebBrowser = nsnull;  mEmbed = nsnull;}