Bug 1218875 Deal with fallout from bug 1216401 rs=jcranmer CLOSED TREE
authorNeil Rashbrook <neil@parkwaycc.co.uk>
Tue, 27 Oct 2015 17:09:16 +0000
changeset 18512 f213d36d9e16b3cf58b1a8e475e116a3fc6b08af
parent 18511 b36d991075f18c379bacefe4c408604e417ecc54
child 18513 e0033c7a85976a17355ecae6988c71a94942ab52
push id11329
push userneil@parkwaycc.co.uk
push dateTue, 27 Oct 2015 17:09:26 +0000
treeherdercomm-central@f213d36d9e16 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjcranmer
bugs1218875, 1216401
Bug 1218875 Deal with fallout from bug 1216401 rs=jcranmer CLOSED TREE
mailnews/addrbook/src/nsAbContentHandler.cpp
mailnews/base/src/nsMessengerOSXIntegration.mm
mailnews/base/src/nsMessengerUnixIntegration.cpp
mailnews/base/src/nsMsgMailSession.cpp
mailnews/base/src/nsMsgPrintEngine.cpp
mailnews/base/src/nsMsgPrintEngine.h
mailnews/base/src/nsMsgProgress.cpp
mailnews/compose/src/nsMsgCompose.cpp
mailnews/compose/src/nsMsgComposeContentHandler.cpp
mailnews/compose/src/nsMsgComposeService.cpp
mailnews/compose/src/nsMsgSend.cpp
mailnews/compose/src/nsMsgSend.h
mailnews/news/src/nsNNTPNewsgroupList.cpp
--- a/mailnews/addrbook/src/nsAbContentHandler.cpp
+++ b/mailnews/addrbook/src/nsAbContentHandler.cpp
@@ -6,16 +6,17 @@
 #include "nsAbContentHandler.h"
 #include "nsAbBaseCID.h"
 #include "nsNetUtil.h"
 #include "nsCOMPtr.h"
 #include "nsAutoPtr.h"
 #include "nsNullPrincipal.h"
 #include "nsISupportsPrimitives.h"
 #include "plstr.h"
+#include "nsPIDOMWindow.h"
 #include "nsIDOMWindow.h"
 #include "nsMsgUtils.h"
 #include "nsIMsgVCardService.h"
 #include "nsIAbCard.h"
 #include "nsIAbManager.h"
 #include "nsVCard.h"
 #include "nsIChannel.h"
 //
@@ -61,17 +62,18 @@ nsAbContentHandler::HandleContent(const 
             
             // XXX todo, explain why we is escaped twice
             MsgUnescapeString(nsDependentCString(startOfVCard + strlen("add?vcard=")), 
                                                  0, unescapedData);
 
             if (!aWindowContext)
                 return NS_ERROR_FAILURE;
 
-            nsCOMPtr<nsIDOMWindow> parentWindow = do_GetInterface(aWindowContext);
+            nsCOMPtr<nsIDOMWindow> domWindow = do_GetInterface(aWindowContext);
+            nsCOMPtr<nsPIDOMWindow> parentWindow = do_QueryInterface(domWindow);
             if (!parentWindow)
                 return NS_ERROR_FAILURE;
 
             nsCOMPtr<nsIAbManager> ab =
               do_GetService(NS_ABMANAGER_CONTRACTID, &rv);
             NS_ENSURE_SUCCESS(rv, rv);
 
             nsCOMPtr <nsIAbCard> cardFromVCard;
@@ -158,17 +160,18 @@ nsAbContentHandler::OnStreamComplete(nsI
         do_GetService(NS_ABMANAGER_CONTRACTID, &rv);
       NS_ENSURE_SUCCESS(rv, rv);
 
       nsCOMPtr <nsIAbCard> cardFromVCard;
       rv = ab->EscapedVCardToAbCard(vCard.get(),
                                     getter_AddRefs(cardFromVCard));
       NS_ENSURE_SUCCESS(rv, rv);
 
-      nsCOMPtr<nsIDOMWindow> parentWindow = do_GetInterface(aContext);
+      nsCOMPtr<nsIDOMWindow> domWindow = do_GetInterface(aContext);
+      nsCOMPtr<nsPIDOMWindow> parentWindow = do_QueryInterface(domWindow);
       NS_ENSURE_TRUE(parentWindow, NS_ERROR_FAILURE);
 
       nsCOMPtr<nsIDOMWindow> dialogWindow;
       rv = parentWindow->OpenDialog(
            NS_LITERAL_STRING("chrome://messenger/content/addressbook/abNewCardDialog.xul"),
            EmptyString(),
            NS_LITERAL_STRING("chrome,resizable=no,titlebar,modal,centerscreen"),
            cardFromVCard, getter_AddRefs(dialogWindow));
--- a/mailnews/base/src/nsMessengerOSXIntegration.mm
+++ b/mailnews/base/src/nsMessengerOSXIntegration.mm
@@ -135,18 +135,19 @@ static void openMailWindow(const nsCStri
         if (windowCommands)
           windowCommands->SelectFolder(aUri);
       }
     }
 
     FocusAppNative();
     nsCOMPtr<nsIDOMWindow> domWindow;
     topMostMsgWindow->GetDomWindow(getter_AddRefs(domWindow));
-    if (domWindow)
-      domWindow->Focus();
+    nsCOMPtr<nsPIDOMWindow> privateWindow(do_QueryInterface(domWindow));
+    if (privateWindow)
+      privateWindow->Focus();
   }
   else
   {
     // the user doesn't have a mail window open already so open one for them...
     nsCOMPtr<nsIMessengerWindowService> messengerWindowService =
       do_GetService(NS_MESSENGERWINDOWSERVICE_CONTRACTID);
     // if we want to preselect the first account with new mail,
     // here is where we would try to generate a uri to pass in
--- a/mailnews/base/src/nsMessengerUnixIntegration.cpp
+++ b/mailnews/base/src/nsMessengerUnixIntegration.cpp
@@ -79,17 +79,18 @@ static void openMailWindow(const nsACStr
       nsCOMPtr<nsIMsgWindowCommands> windowCommands;
       topMostMsgWindow->GetWindowCommands(getter_AddRefs(windowCommands));
       if (windowCommands)
         windowCommands->SelectFolder(aFolderUri);
     }
 
     nsCOMPtr<nsIDOMWindow> domWindow;
     topMostMsgWindow->GetDomWindow(getter_AddRefs(domWindow));
-    domWindow->Focus();
+    nsCOMPtr<nsPIDOMWindow> privateWindow(do_QueryInterface(domWindow));
+    privateWindow->Focus();
   }
   else
   {
     // the user doesn't have a mail window open already so open one for them...
     nsCOMPtr<nsIMessengerWindowService> messengerWindowService =
       do_GetService(NS_MESSENGERWINDOWSERVICE_CONTRACTID);
     // if we want to preselect the first account with new mail,
     // here is where we would try to generate a uri to pass in
--- a/mailnews/base/src/nsMsgMailSession.cpp
+++ b/mailnews/base/src/nsMsgMailSession.cpp
@@ -9,16 +9,17 @@
 #include "nsIMsgMessageService.h"
 #include "nsMsgUtils.h"
 #include "nsIMsgAccountManager.h"
 #include "nsIChromeRegistry.h"
 #include "nsIDirectoryService.h"
 #include "nsAppDirectoryServiceDefs.h"
 #include "nsPIDOMWindow.h"
 #include "nsIDocShell.h"
+#include "nsIDocument.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMElement.h"
 #include "nsIObserverService.h"
 #include "nsIAppStartup.h"
 #include "nsToolkitCompsCID.h"
 #include "nsISupportsPrimitives.h"
 #include "nsIAppShellService.h"
 #include "nsAppShellCID.h"
@@ -290,17 +291,17 @@ nsresult nsMsgMailSession::GetTopmostMsg
       rv = windowEnum->GetNext(getter_AddRefs(windowSupports));
       NS_ENSURE_SUCCESS(rv, rv);
       NS_ENSURE_TRUE(windowSupports, NS_ERROR_FAILURE);
 
       topMostWindow = do_QueryInterface(windowSupports, &rv);
       NS_ENSURE_SUCCESS(rv, rv);
       NS_ENSURE_TRUE(topMostWindow, NS_ERROR_FAILURE);
 
-      rv = topMostWindow->GetDocument(getter_AddRefs(domDocument));
+      domDocument = do_QueryInterface(topMostWindow->GetDoc());
       NS_ENSURE_SUCCESS(rv, rv);
       NS_ENSURE_TRUE(domDocument, NS_ERROR_FAILURE);
 
       rv = domDocument->GetDocumentElement(getter_AddRefs(domElement));
       NS_ENSURE_SUCCESS(rv, rv);
       NS_ENSURE_TRUE(domElement, NS_ERROR_FAILURE);
 
       rv = domElement->GetAttribute(NS_LITERAL_STRING("windowtype"), windowType);
--- a/mailnews/base/src/nsMsgPrintEngine.cpp
+++ b/mailnews/base/src/nsMsgPrintEngine.cpp
@@ -214,25 +214,23 @@ nsMsgPrintEngine::SetWindow(nsIDOMWindow
 {
 	if (!aWin)
   {
     // It isn't an error to pass in null for aWin, in fact it means we are shutting
     // down and we should start cleaning things up...
 		return NS_OK;
   }
 
-  mWindow = aWin;
+  mWindow = do_QueryInterface(aWin);
+  NS_ENSURE_TRUE(mWindow, NS_ERROR_FAILURE);
 
-  nsCOMPtr<nsPIDOMWindow> win( do_QueryInterface(aWin) );
-  NS_ENSURE_TRUE(win, NS_ERROR_FAILURE);
-
-  win->GetDocShell()->SetAppType(nsIDocShell::APP_TYPE_MAIL);
+  mWindow->GetDocShell()->SetAppType(nsIDocShell::APP_TYPE_MAIL);
 
   nsCOMPtr<nsIDocShellTreeItem> docShellAsItem =
-    do_QueryInterface(win->GetDocShell());
+    do_QueryInterface(mWindow->GetDocShell());
   NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE);
 
   nsCOMPtr<nsIDocShellTreeItem> rootAsItem;
   docShellAsItem->GetSameTypeRootTreeItem(getter_AddRefs(rootAsItem));
 
   nsCOMPtr<nsIDocShellTreeItem> childItem;
   rootAsItem->FindChildWithName(MOZ_UTF16("content"), true,
 				false, nullptr, nullptr,
@@ -256,22 +254,18 @@ NS_IMETHODIMP nsMsgPrintEngine::SetParen
 
 NS_IMETHODIMP
 nsMsgPrintEngine::ShowWindow(bool aShow)
 {
   nsresult rv;
 
   NS_ENSURE_TRUE(mWindow, NS_ERROR_NOT_INITIALIZED);
 
-  nsCOMPtr <nsPIDOMWindow> win = do_QueryInterface(mWindow, &rv);
-
-  NS_ENSURE_SUCCESS(rv,rv);
-
   nsCOMPtr <nsIDocShellTreeItem> treeItem =
-    do_QueryInterface(win->GetDocShell(), &rv);
+    do_QueryInterface(mWindow->GetDocShell(), &rv);
   NS_ENSURE_SUCCESS(rv,rv);
 
   nsCOMPtr <nsIDocShellTreeOwner> treeOwner;
   rv = treeItem->GetTreeOwner(getter_AddRefs(treeOwner));
   NS_ENSURE_SUCCESS(rv,rv);
   
   if (treeOwner) {
     // disable (enable) the window
--- a/mailnews/base/src/nsMsgPrintEngine.h
+++ b/mailnews/base/src/nsMsgPrintEngine.h
@@ -60,17 +60,17 @@ protected:
   nsresult    FireThatLoadOperation(const nsString& uri);
   void        InitializeDisplayCharset();
   void        SetupObserver();
   nsresult    SetStatusMessage(const nsString& aMsgString);
   void GetString(const char16_t *aStringName, nsString& aOutString);
   nsresult    ShowProgressDialog(bool aIsForPrinting, bool& aDoNotify);
 
   nsCOMPtr<nsIDocShell>       mDocShell;
-  nsCOMPtr<nsIDOMWindow>      mWindow;
+  nsCOMPtr<nsPIDOMWindow>     mWindow;
   nsCOMPtr<nsIDOMWindow>      mParentWindow;
   int32_t                     mURICount;
   nsTArray<nsString>          mURIArray;
   int32_t                     mCurrentlyPrintingURI;
 
   nsCOMPtr<nsIContentViewer>  mContentViewer;
   nsCOMPtr<nsIStringBundle>   mStringBundle;    // String bundles...
   nsCOMPtr<nsIMsgStatusFeedback> mFeedback;     // Tell the user something why don't ya'
--- a/mailnews/base/src/nsMsgProgress.cpp
+++ b/mailnews/base/src/nsMsgProgress.cpp
@@ -7,16 +7,17 @@
 
 #include "nsIBaseWindow.h"
 #include "nsXPCOM.h"
 #include "nsIMutableArray.h"
 #include "nsISupportsPrimitives.h"
 #include "nsIComponentManager.h"
 #include "nsError.h"
 #include "nsIWindowWatcher.h"
+#include "nsPIDOMWindow.h"
 #include "nsServiceManagerUtils.h"
 #include "nsComponentManagerUtils.h"
 #include "nsMsgUtils.h"
 #include "mozilla/Services.h"
 
 NS_IMPL_ISUPPORTS(nsMsgProgress, nsIMsgStatusFeedback, nsIMsgProgress,
   nsIWebProgressListener, nsIProgressEventSink, nsISupportsWeakReference)
 
@@ -29,31 +30,32 @@ nsMsgProgress::nsMsgProgress()
   m_pendingStateValue = NS_OK;
 }
 
 nsMsgProgress::~nsMsgProgress()
 {
   (void)ReleaseListeners();
 }
 
-NS_IMETHODIMP nsMsgProgress::OpenProgressDialog(nsIDOMWindow *parent, 
+NS_IMETHODIMP nsMsgProgress::OpenProgressDialog(nsIDOMWindow *parentDOMWindow, 
                                                 nsIMsgWindow *aMsgWindow, 
                                                 const char *dialogURL, 
                                                 bool inDisplayModal, 
                                                 nsISupports *parameters)
 {
   nsresult rv;
 
   if (aMsgWindow)
   {
     SetMsgWindow(aMsgWindow);
     aMsgWindow->SetStatusFeedback(this);
   }
 
   NS_ENSURE_ARG_POINTER(dialogURL);
+  nsCOMPtr<nsPIDOMWindow> parent(do_QueryInterface(parentDOMWindow));
   NS_ENSURE_ARG_POINTER(parent);
 
   // Set up window.arguments[0]...
   nsCOMPtr<nsIMutableArray> array(do_CreateInstance(NS_ARRAY_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsISupportsInterfacePointer> ifptr =
     do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID, &rv);
--- a/mailnews/compose/src/nsMsgCompose.cpp
+++ b/mailnews/compose/src/nsMsgCompose.cpp
@@ -1136,18 +1136,19 @@ nsresult nsMsgCompose::_SendMsg(MSG_Deli
 NS_IMETHODIMP nsMsgCompose::SendMsg(MSG_DeliverMode deliverMode, nsIMsgIdentity *identity, const char *accountKey, nsIMsgWindow *aMsgWindow, nsIMsgProgress *progress)
 {
 
   NS_ENSURE_TRUE(m_compFields, NS_ERROR_NOT_INITIALIZED);
   nsresult rv = NS_OK;
   nsCOMPtr<nsIPrompt> prompt;
 
   // i'm assuming the compose window is still up at this point...
-  if (!prompt && m_window)
-     m_window->GetPrompter(getter_AddRefs(prompt));
+  nsCOMPtr<nsPIDOMWindow> window(do_QueryInterface(m_window));
+  if (window)
+    window->GetPrompter(getter_AddRefs(prompt));
 
   // Set content type based on which type of compose window we had.
   nsString contentType = (m_composeHTML) ? NS_LITERAL_STRING("text/html"):
                                            NS_LITERAL_STRING("text/plain");
   nsString msgBody;
   if (m_editor)
   {
     // Reset message body previously stored in the compose fields
@@ -2650,19 +2651,20 @@ NS_IMETHODIMP QuotingOutputStreamListene
           compFields->SetTo(EmptyString());
       }
 
       if (!followUpTo.IsEmpty())
       {
         // Handle "followup-to: poster" magic keyword here
         if (followUpTo.EqualsLiteral("poster"))
         {
-          nsCOMPtr<nsIDOMWindow> composeWindow;
+          nsCOMPtr<nsIDOMWindow> domWindow;
           nsCOMPtr<nsIPrompt> prompt;
-          compose->GetDomWindow(getter_AddRefs(composeWindow));
+          compose->GetDomWindow(getter_AddRefs(domWindow));
+          nsCOMPtr<nsPIDOMWindow> composeWindow(do_QueryInterface(domWindow));
           if (composeWindow)
             composeWindow->GetPrompter(getter_AddRefs(prompt));
           nsMsgDisplayMessageByName(prompt, MOZ_UTF16("followupToSenderMessage"));
 
           if (!replyTo.IsEmpty())
           {
             compFields->SetTo(replyTo);
           }
--- a/mailnews/compose/src/nsMsgComposeContentHandler.cpp
+++ b/mailnews/compose/src/nsMsgComposeContentHandler.cpp
@@ -7,17 +7,19 @@
 #include "nsMsgComposeService.h"
 #include "nsMsgBaseCID.h"
 #include "nsMsgCompCID.h"
 #include "nsIChannel.h"
 #include "nsIURI.h"
 #include "plstr.h"
 #include "nsServiceManagerUtils.h"
 #include "nsCOMPtr.h"
+#include "nsPIDOMWindow.h"
 #include "nsIDOMWindow.h"
+#include "nsIDocument.h"
 #include "nsIDOMDocument.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIMsgMailNewsUrl.h"
 #include "nsNetUtil.h"
 #include "nsIMsgFolder.h"
 #include "nsIMsgIncomingServer.h"
 #include "nsIMsgAccountManager.h"
@@ -39,24 +41,23 @@ nsMsgComposeContentHandler::~nsMsgCompos
 // Try to get an appropriate nsIMsgIdentity by going through the window, getting
 // the document's URI, then the corresponding nsIMsgDBHdr. Then find the server
 // associated with that header and get the first identity for it.
 nsresult nsMsgComposeContentHandler::GetBestIdentity(
   nsIInterfaceRequestor* aWindowContext, nsIMsgIdentity **aIdentity)
 {
   nsresult rv;
 
-  nsCOMPtr<nsIDOMWindow> window = do_GetInterface(aWindowContext);
+  nsCOMPtr<nsIDOMWindow> domWindow = do_GetInterface(aWindowContext);
+  nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(domWindow);
   if (!window)
     return NS_ERROR_FAILURE;
 
-  nsCOMPtr<nsIDOMDocument> document;
-  window->GetDocument(getter_AddRefs(document));
   nsAutoString documentURIString;
-  document->GetDocumentURI(documentURIString);
+  window->GetDoc()->GetDocumentURI(documentURIString);
 
   nsCOMPtr<nsIURI> documentURI;
   rv = NS_NewURI(getter_AddRefs(documentURI), documentURIString);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIMsgMessageUrl> msgURI = do_QueryInterface(documentURI);
   if (!msgURI)
     return NS_ERROR_FAILURE;
--- a/mailnews/compose/src/nsMsgComposeService.cpp
+++ b/mailnews/compose/src/nsMsgComposeService.cpp
@@ -415,19 +415,20 @@ nsMsgComposeService::GetOrigWindowSelect
                                        true, false, nullptr, nullptr, getter_AddRefs(childAsItem));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(childAsItem, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIDOMWindow> domWindow(do_GetInterface(childAsItem, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
-  nsCOMPtr<nsISelection> sel;
-  rv = domWindow->GetSelection(getter_AddRefs(sel));
+  nsCOMPtr<nsPIDOMWindow> privateWindow(do_QueryInterface(domWindow, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
+  nsCOMPtr<nsISelection> sel = privateWindow->GetSelection();
+  NS_ENSURE_TRUE(sel, NS_ERROR_FAILURE);
 
   bool requireMultipleWords = true;
   nsAutoCString charsOnlyIf;
   prefs->GetBoolPref(PREF_MAILNEWS_REPLY_QUOTING_SELECTION_MULTI_WORD, &requireMultipleWords);
   prefs->GetCharPref(PREF_MAILNEWS_REPLY_QUOTING_SELECTION_ONLY_IF, getter_Copies(charsOnlyIf));
   if (sel && (requireMultipleWords || !charsOnlyIf.IsEmpty()))
   {
     nsAutoString selPlain;
--- a/mailnews/compose/src/nsMsgSend.cpp
+++ b/mailnews/compose/src/nsMsgSend.cpp
@@ -4047,17 +4047,17 @@ nsMsgComposeAndSend::CreateAndSendMessag
               MSG_ComposeType                   aType
               )
 {
   nsresult      rv;
   /* First thing to do is to reset the send errors report */
   mSendReport->Reset();
   mSendReport->SetDeliveryMode(mode);
 
-  mParentWindow = parentWindow;
+  mParentWindow = do_QueryInterface(parentWindow);
   mSendProgress = progress;
   mListener = aListener;
 
   // Set the editor for MHTML operations if necessary
   if (aEditor)
     mEditor = aEditor;
 
   rv = Init(aUserIdentity, aAccountKey, (nsMsgCompFields *)fields, nullptr,
--- a/mailnews/compose/src/nsMsgSend.h
+++ b/mailnews/compose/src/nsMsgSend.h
@@ -120,16 +120,17 @@
 #include "nsIDOMNode.h"
 #include "nsIEditor.h"
 #include "nsIUrlListener.h"
 #include "nsIMsgStatusFeedback.h"
 #include "nsIMsgIdentity.h"
 #include "nsIMsgHdr.h"
 #include "nsIMsgIdentity.h"
 #include "nsWeakReference.h"
+#include "nsPIDOMWindow.h"
 #include "nsIDOMWindow.h"
 #include "nsIMsgComposeSecure.h"
 #include "nsAutoPtr.h"
 #include "nsISupportsArray.h"
 #include "nsMsgAttachmentData.h"
 #include "nsIMsgFilterService.h"
 #include "nsIMsgOperationListener.h"
 
@@ -277,17 +278,17 @@ public:
                                                  // created, instead of actually delivering message.
   nsMsgDeliverMode          m_deliver_mode;      // nsMsgDeliverNow, nsMsgQueueForLater, nsMsgSaveAsDraft,
                                                  // nsMsgSaveAsTemplate and nsMsgSendUnsent
   nsCOMPtr<nsIMsgDBHdr>     mMsgToReplace;       // If the mode is nsMsgSaveAsDraft, this is the message it will
                                                  // replace
   nsString mSavedToFolderName; // Name of folder we're saving to, used when
                                // displaying error on save.
   // These are needed for callbacks to the FE...
-  nsCOMPtr<nsIDOMWindow>          mParentWindow;
+  nsCOMPtr<nsPIDOMWindow>         mParentWindow;
   nsCOMPtr<nsIMsgProgress>        mSendProgress;
   nsCOMPtr<nsIMsgSendListener>    mListener;
   nsCOMPtr<nsIMsgStatusFeedback>  mStatusFeedback;
   nsCOMPtr<nsIRequest>      mRunningRequest;
   bool                      mSendMailAlso;
   nsCOMPtr<nsIFile>         mReturnFile;     // a holder for file spec's to be returned to caller
 
   // File where we stored our HTML so that we could make the plaintext form.
--- a/mailnews/news/src/nsNNTPNewsgroupList.cpp
+++ b/mailnews/news/src/nsNNTPNewsgroupList.cpp
@@ -13,16 +13,17 @@
 
 #include "msgCore.h"    // precompiled header...
 #include "MailNewsTypes.h"
 #include "nsCOMPtr.h"
 #include "nsIDBFolderInfo.h"
 #include "nsINewsDatabase.h"
 #include "nsIMsgStatusFeedback.h"
 #include "nsCOMPtr.h"
+#include "nsPIDOMWindow.h"
 #include "nsIDOMWindow.h"
 #include "nsIMsgMailNewsUrl.h"
 #include "nsIMsgAccountManager.h"
 #include "nsIMsgIncomingServer.h"
 #include "nsINntpIncomingServer.h"
 #include "nsMsgBaseCID.h"
 #include "nsIMsgFilter.h"
 #include "nsNNTPNewsgroupList.h"
@@ -220,17 +221,18 @@ openWindow(nsIMsgWindow *aMsgWindow, con
 {
   nsresult rv;
   NS_ENSURE_ARG_POINTER(aMsgWindow);
   nsCOMPtr<nsIDocShell> docShell;
   rv = aMsgWindow->GetRootDocShell(getter_AddRefs(docShell));
   if (NS_FAILED(rv))
       return rv;
 
-  nsCOMPtr<nsIDOMWindow> parentWindow(do_GetInterface(docShell));
+  nsCOMPtr<nsIDOMWindow> domWindow(do_GetInterface(docShell));
+  nsCOMPtr<nsPIDOMWindow> parentWindow(do_QueryInterface(domWindow));
   NS_ENSURE_TRUE(parentWindow, NS_ERROR_FAILURE);
 
   nsCOMPtr<nsISupportsInterfacePointer> ifptr = do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   ifptr->SetData(param);
   ifptr->SetDataIID(&NS_GET_IID(nsINewsDownloadDialogArgs));