From cf055b0421f4ead20e1f614b6acedbd46ca7389b Mon Sep 17 00:00:00 2001 From: "hyatt%netscape.com" Date: Sun, 16 May 1999 08:10:27 +0000 Subject: [PATCH] More savory popup goodness. --- xpfe/appshell/src/nsWebShellWindow.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/xpfe/appshell/src/nsWebShellWindow.cpp b/xpfe/appshell/src/nsWebShellWindow.cpp index 3c683fb146d7..266da198b47e 100644 --- a/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/xpfe/appshell/src/nsWebShellWindow.cpp @@ -30,6 +30,8 @@ #include "nsIScriptGlobalObject.h" #include "nsIDOMWindow.h" +#include "nsIXULParentDocument.h" + #include "nsGUIEvent.h" #include "nsWidgetsCID.h" #include "nsIWidget.h" @@ -989,11 +991,26 @@ nsWebShellWindow::CreatePopup(nsIDOMElement* aElement, nsIDOMElement* aPopupCont NS_ERROR("Unable to retrieve the DOM window from the new web shell."); return rv; } - + domWindow->SetOpener(aWindow); + // (3) We need to create a new document that clones the original document's popup // content. This new document must use the different root and a different global script // context (window object) but everything else about it is the same (namespaces, URLs, // stylesheets). + nsCOMPtr content = do_QueryInterface(aElement); + nsCOMPtr document; + content->GetDocument(*getter_AddRefs(document)); + if (document == nsnull) + return NS_ERROR_FAILURE; + nsCOMPtr parentDocument = do_QueryInterface(document); + if (parentDocument == nsnull) + return NS_ERROR_FAILURE; + + nsCOMPtr popupDocument; + if (NS_FAILED(rv = parentDocument->CreatePopupDocument(aPopupContent, getter_AddRefs(popupDocument)))) { + NS_ERROR("Unable to create the child popup document."); + return rv; + } // The tricky part now is bypassing the normal load process and just putting a document into // the webshell. This is particularly nasty, since webshells don't normally even know