зеркало из https://github.com/mozilla/gecko-dev.git
Changed to do the Close on the treeOwner rather than trying to do so on the old webShell interfaces. Fixed a leak of the top object after it has been retrieved. r=hyatt
This commit is contained in:
Родитель
ce4cfbc25b
Коммит
ad895a4fe1
|
@ -33,6 +33,9 @@
|
|||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsWalletPreview.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIDocShellTreeOwner.h"
|
||||
#include "nsIBaseWindow.h"
|
||||
|
||||
static NS_DEFINE_IID(kWalletServiceCID, NS_WALLETSERVICE_CID);
|
||||
|
||||
|
@ -67,9 +70,9 @@ WalletPreviewImpl::GetPrefillValue(PRUnichar** aValue)
|
|||
return res;
|
||||
}
|
||||
|
||||
static void DOMWindowToWebShellWindow(
|
||||
static void DOMWindowToTreeOwner(
|
||||
nsIDOMWindow *DOMWindow,
|
||||
nsCOMPtr<nsIWebShellWindow> *webWindow)
|
||||
nsIDocShellTreeOwner** aTreeOwner)
|
||||
{
|
||||
if (!DOMWindow) {
|
||||
return; // with webWindow unchanged -- its constructor gives it a null ptr
|
||||
|
@ -79,13 +82,11 @@ static void DOMWindowToWebShellWindow(
|
|||
if (globalScript) {
|
||||
globalScript->GetDocShell(getter_AddRefs(docShell));
|
||||
}
|
||||
nsCOMPtr<nsIWebShell> webshell(do_QueryInterface(docShell));
|
||||
nsCOMPtr<nsIWebShell> rootWebshell;
|
||||
if(!webshell)
|
||||
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(docShell));
|
||||
if(!docShellAsItem)
|
||||
return;
|
||||
nsCOMPtr<nsIWebShellContainer> topLevelWindow;
|
||||
webshell->GetTopLevelWindow(getter_AddRefs(topLevelWindow));
|
||||
*webWindow = do_QueryInterface(topLevelWindow);
|
||||
|
||||
docShellAsItem->GetTreeOwner(aTreeOwner);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -100,12 +101,15 @@ WalletPreviewImpl::SetValue(const PRUnichar* aValue, nsIDOMWindow* win)
|
|||
if (!top) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsCOMPtr<nsIWebShellWindow> parent;
|
||||
DOMWindowToWebShellWindow(top, &parent);
|
||||
if (parent) {
|
||||
parent->Close();
|
||||
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
|
||||
DOMWindowToTreeOwner(top, getter_AddRefs(treeOwner));
|
||||
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin(do_QueryInterface(treeOwner));
|
||||
if (treeOwnerAsWin) {
|
||||
treeOwnerAsWin->Destroy();
|
||||
}
|
||||
NS_IF_RELEASE(win);
|
||||
NS_RELEASE(top);
|
||||
|
||||
/* process the value */
|
||||
NS_PRECONDITION(aValue != nsnull, "null ptr");
|
||||
|
|
Загрузка…
Ссылка в новой задаче