From a8ddb2eb2f79fbd8e85fb6c424829189a61f106c Mon Sep 17 00:00:00 2001 From: "danm%netscape.com" Date: Mon, 12 Mar 2001 23:08:29 +0000 Subject: [PATCH] Removing IsModal,ShowModal,ExitModalLoop methods from nsIDocShellTreeOwner. General API cleanup. bug 70481 r=ccarlen,hyatt --- docshell/base/nsIDocShellTreeOwner.idl | 18 ------------ .../src/control/WebBrowserContainer.cpp | 22 -------------- .../browser/gtk/src/GtkMozEmbedChrome.cpp | 21 +------------- .../browser/photon/src/PhMozEmbedChrome.cpp | 21 +------------- .../webBrowser/nsDocShellTreeOwner.cpp | 24 --------------- .../windowwatcher/src/nsWindowWatcher.cpp | 26 ++++++++++++++--- profile/pref-migrator/src/nsPrefMigration.cpp | 10 ++++++- xpfe/appshell/src/nsChromeTreeOwner.cpp | 29 +++++-------------- xpfe/appshell/src/nsContentTreeOwner.cpp | 23 +++------------ 9 files changed, 44 insertions(+), 150 deletions(-) diff --git a/docshell/base/nsIDocShellTreeOwner.idl b/docshell/base/nsIDocShellTreeOwner.idl index 1bb260edec5c..4c7166a87e37 100644 --- a/docshell/base/nsIDocShellTreeOwner.idl +++ b/docshell/base/nsIDocShellTreeOwner.idl @@ -27,7 +27,6 @@ */ interface nsIDocShellTreeItem; -interface nsIWebBrowserChrome; [scriptable, uuid(80F30E10-A7CF-11d3-AFC5-00A024FFC08C)] interface nsIDocShellTreeOwner : nsISupports @@ -66,23 +65,6 @@ interface nsIDocShellTreeOwner : nsISupports */ void sizeShellTo(in nsIDocShellTreeItem shell, in long cx, in long cy); - /* - Shows the window as a modal window. - */ - void showModal(); - - /** - Is the window modal (that is, currently executing a modal loop)? - @return true if it's a modal window - */ - boolean isModal(); - - /** - Exit a modal loop if we're in one - @param aStatus - the result code to return from showModal - */ - void exitModalLoop(in nsresult aStatus); - /* Tells the implementer of this interface to create a new window. This is a new logical window. Meaning in some implementations the result may not diff --git a/embedding/browser/activex/src/control/WebBrowserContainer.cpp b/embedding/browser/activex/src/control/WebBrowserContainer.cpp index 2d678741f464..263af93de384 100644 --- a/embedding/browser/activex/src/control/WebBrowserContainer.cpp +++ b/embedding/browser/activex/src/control/WebBrowserContainer.cpp @@ -481,28 +481,6 @@ CWebBrowserContainer::SizeShellTo(nsIDocShellTreeItem* aShell, } -NS_IMETHODIMP -CWebBrowserContainer::ShowModal() -{ - // Ignore request to be shown modally - return NS_OK; -} - -NS_IMETHODIMP -CWebBrowserContainer::IsModal(PRBool *_retval) -{ - // we're not - *_retval = PR_FALSE; - return NS_OK; -} - -NS_IMETHODIMP -CWebBrowserContainer::ExitModalLoop(nsresult aStatus) -{ - // Ignore request to exit modal loop - return NS_OK; -} - NS_IMETHODIMP CWebBrowserContainer::GetNewWindow(PRInt32 aChromeFlags, nsIDocShellTreeItem** aDocShellTreeItem) { diff --git a/embedding/browser/gtk/src/GtkMozEmbedChrome.cpp b/embedding/browser/gtk/src/GtkMozEmbedChrome.cpp index 2c788ae80afe..229711c8208d 100644 --- a/embedding/browser/gtk/src/GtkMozEmbedChrome.cpp +++ b/embedding/browser/gtk/src/GtkMozEmbedChrome.cpp @@ -497,7 +497,7 @@ NS_IMETHODIMP GtkMozEmbedChrome::IsWindowModal(PRBool *_retval) NS_IMETHODIMP GtkMozEmbedChrome::ExitModalEventLoop(nsresult aStatus) { - PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("GtkMozEmbedChrome::ExitModalLoop\n")); + PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("GtkMozEmbedChrome::ExitModalEventLoop\n")); return NS_ERROR_NOT_IMPLEMENTED; } @@ -697,25 +697,6 @@ NS_IMETHODIMP GtkMozEmbedChrome::SizeShellTo(nsIDocShellTreeItem *shell, return NS_OK; } -NS_IMETHODIMP GtkMozEmbedChrome::ShowModal(void) -{ - PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("GtkMozEmbedChrome::ShowModal\n")); - return NS_OK; -} - -NS_IMETHODIMP GtkMozEmbedChrome::IsModal(PRBool *_retval) -{ - PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("GtkMozEmbedChrome::IsModal\n")); - *_retval = PR_FALSE; - return NS_OK; -} - -NS_IMETHODIMP GtkMozEmbedChrome::ExitModalLoop(nsresult aStatus) -{ - PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("GtkMozEmbedChrome::ExitModalLoop\n")); - return NS_OK; -} - NS_IMETHODIMP GtkMozEmbedChrome::GetNewWindow(PRInt32 aChromeFlags, nsIDocShellTreeItem **_retval) { diff --git a/embedding/browser/photon/src/PhMozEmbedChrome.cpp b/embedding/browser/photon/src/PhMozEmbedChrome.cpp index f85e1f2fbcd7..44c916660826 100644 --- a/embedding/browser/photon/src/PhMozEmbedChrome.cpp +++ b/embedding/browser/photon/src/PhMozEmbedChrome.cpp @@ -447,7 +447,7 @@ NS_IMETHODIMP PhMozEmbedChrome::IsWindowModal(PRBool *_retval) NS_IMETHODIMP PhMozEmbedChrome::ExitModalEventLoop(nsresult aStatus) { - PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("PhMozEmbedChrome::ExitModalLoop\n")); + PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("PhMozEmbedChrome::ExitModalEventLoop\n")); return NS_ERROR_NOT_IMPLEMENTED; } @@ -608,25 +608,6 @@ NS_IMETHODIMP PhMozEmbedChrome::SizeShellTo(nsIDocShellTreeItem *shell, return NS_OK; } -NS_IMETHODIMP PhMozEmbedChrome::ShowModal(void) -{ - PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("PhMozEmbedChrome::ShowModal\n")); - return NS_OK; -} - -NS_IMETHODIMP PhMozEmbedChrome::IsModal(PRBool *_retval) -{ - PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("PhMozEmbedChrome::IsModal\n")); - *_retval = PR_FALSE; - return NS_OK; -} - -NS_IMETHODIMP PhMozEmbedChrome::ExitModalLoop(nsresult aStatus) -{ - PR_LOG(mozEmbedLm, PR_LOG_DEBUG, ("PhMozEmbedChrome::ExitModalLoop\n")); - return NS_OK; -} - NS_IMETHODIMP PhMozEmbedChrome::GetNewWindow(PRInt32 aChromeFlags, nsIDocShellTreeItem **_retval) { diff --git a/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp b/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp index 20a80c072d1f..ccb58ead324e 100644 --- a/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp +++ b/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp @@ -369,30 +369,6 @@ NS_IMETHODIMP nsDocShellTreeOwner::SizeShellTo(nsIDocShellTreeItem* aShellItem, return mWebBrowserChrome->SizeBrowserTo(browserCX, browserCY); } -NS_IMETHODIMP nsDocShellTreeOwner::ShowModal() -{ - if(mTreeOwner) - return mTreeOwner->ShowModal(); - - return mWebBrowserChrome->ShowAsModal(); -} - -NS_IMETHODIMP nsDocShellTreeOwner::IsModal(PRBool *_retval) -{ - if(mTreeOwner) - return mTreeOwner->IsModal(_retval); - - return mWebBrowserChrome->IsWindowModal(_retval); -} - -NS_IMETHODIMP nsDocShellTreeOwner::ExitModalLoop(nsresult aStatus) -{ - if(mTreeOwner) - return mTreeOwner->ExitModalLoop(aStatus); - - return mWebBrowserChrome->ExitModalEventLoop(aStatus); -} - NS_IMETHODIMP nsDocShellTreeOwner::GetNewWindow(PRInt32 aChromeFlags, nsIDocShellTreeItem** aDocShellTreeItem) { diff --git a/embedding/components/windowwatcher/src/nsWindowWatcher.cpp b/embedding/components/windowwatcher/src/nsWindowWatcher.cpp index c739d1447b8a..657904330a6e 100644 --- a/embedding/components/windowwatcher/src/nsWindowWatcher.cpp +++ b/embedding/components/windowwatcher/src/nsWindowWatcher.cpp @@ -436,9 +436,18 @@ nsWindowWatcher::OpenWindowJS(nsIDOMWindow *aParent, // no extant window? make a new one. if (!newDocShellItem) { windowIsNew = PR_TRUE; + + // is the parent (if any) modal? if so, we must be, too. PRBool weAreModal = PR_FALSE; - if (parentTreeOwner) - parentTreeOwner->IsModal(&weAreModal); + if (parentTreeOwner) { + nsCOMPtr parentRequestor(do_QueryInterface(parentTreeOwner)); + if (parentRequestor) { + nsCOMPtr parentChrome; + parentRequestor->GetInterface(NS_GET_IID(nsIWebBrowserChrome), getter_AddRefs(parentChrome)); + if (parentChrome) + parentChrome->IsWindowModal(&weAreModal); + } + } if (weAreModal || (chromeFlags & nsIWebBrowserChrome::CHROME_MODAL)) { rv = queueGuard.Push(); if (NS_SUCCEEDED(rv)) { @@ -592,12 +601,21 @@ nsWindowWatcher::OpenWindowJS(nsIDOMWindow *aParent, if (windowIsNew) SizeOpenedDocShellItem(newDocShellItem, aParent, features, chromeFlags); + if (windowIsModal) { nsCOMPtr newTreeOwner; - newDocShellItem->GetTreeOwner(getter_AddRefs(newTreeOwner)); + nsCOMPtr newRequestor; + nsCOMPtr newChrome; + newDocShellItem->GetTreeOwner(getter_AddRefs(newTreeOwner)); if (newTreeOwner) - newTreeOwner->ShowModal(); + newRequestor = do_QueryInterface(newTreeOwner); + if (newRequestor) + newRequestor->GetInterface(NS_GET_IID(nsIWebBrowserChrome), getter_AddRefs(newChrome)); + + if (newChrome) + newChrome->ShowAsModal(); + NS_ASSERTION(newChrome, "show modal window failed: no available chrome"); } return NS_OK; diff --git a/profile/pref-migrator/src/nsPrefMigration.cpp b/profile/pref-migrator/src/nsPrefMigration.cpp index d2505c46d0fc..92e11a81fbf7 100644 --- a/profile/pref-migrator/src/nsPrefMigration.cpp +++ b/profile/pref-migrator/src/nsPrefMigration.cpp @@ -333,7 +333,15 @@ nsPrefMigration::ProcessPrefs(PRBool showProgressAsModalWindow) if (NS_FAILED(rv)) return rv; if (showProgressAsModalWindow) { - mPMProgressWindow->ShowModal(); + nsCOMPtr progressRequestor(do_QueryInterface(mPMProgressWindow)); + nsCOMPtr progressChrome; + + if (progressRequestor) + progressRequestor->GetInterface(NS_GET_IID(nsIWebBrowserChrome), getter_AddRefs(progressChrome)); + + if (progressChrome) + progressChrome->ShowAsModal(); + NS_ASSERTION(progressChrome, "show modal window failed: no available chrome"); } else { // we are automatically migrating the profile, so there is no diff --git a/xpfe/appshell/src/nsChromeTreeOwner.cpp b/xpfe/appshell/src/nsChromeTreeOwner.cpp index a68609a19704..b9aeaa1ab0be 100644 --- a/xpfe/appshell/src/nsChromeTreeOwner.cpp +++ b/xpfe/appshell/src/nsChromeTreeOwner.cpp @@ -72,15 +72,15 @@ NS_INTERFACE_MAP_END NS_IMETHODIMP nsChromeTreeOwner::GetInterface(const nsIID& aIID, void** aSink) { - NS_ENSURE_ARG_POINTER(aSink); + NS_ENSURE_ARG_POINTER(aSink); - if(aIID.Equals(NS_GET_IID(nsIPrompt))) - return mXULWindow->GetInterface(aIID, aSink); - else - return QueryInterface(aIID, aSink); + if(aIID.Equals(NS_GET_IID(nsIPrompt))) + return mXULWindow->GetInterface(aIID, aSink); - NS_IF_ADDREF(((nsISupports*)*aSink)); - return NS_OK; + if(aIID.Equals(NS_GET_IID(nsIWebBrowserChrome))) + return mXULWindow->GetInterface(aIID, aSink); + + return QueryInterface(aIID, aSink); } //***************************************************************************** @@ -177,21 +177,6 @@ NS_IMETHODIMP nsChromeTreeOwner::SizeShellTo(nsIDocShellTreeItem* aShellItem, { return mXULWindow->SizeShellTo(aShellItem, aCX, aCY); } -NS_IMETHODIMP nsChromeTreeOwner::ShowModal() -{ - return mXULWindow->ShowModal(); -} - -NS_IMETHODIMP nsChromeTreeOwner::IsModal(PRBool *_retval) -{ - *_retval = mXULWindow->mContinueModalLoop; - return NS_OK; -} - -NS_IMETHODIMP nsChromeTreeOwner::ExitModalLoop(nsresult aStatus) -{ - return mXULWindow->ExitModalLoop(aStatus); -} NS_IMETHODIMP nsChromeTreeOwner::GetNewWindow(PRInt32 aChromeFlags, nsIDocShellTreeItem** aDocShellTreeItem) diff --git a/xpfe/appshell/src/nsContentTreeOwner.cpp b/xpfe/appshell/src/nsContentTreeOwner.cpp index 40f39dcc407c..0eb6f7ab0d31 100644 --- a/xpfe/appshell/src/nsContentTreeOwner.cpp +++ b/xpfe/appshell/src/nsContentTreeOwner.cpp @@ -206,22 +206,6 @@ NS_IMETHODIMP nsContentTreeOwner::SizeShellTo(nsIDocShellTreeItem* aShellItem, return mXULWindow->SizeShellTo(aShellItem, aCX, aCY); } -NS_IMETHODIMP nsContentTreeOwner::ShowModal() -{ - return mXULWindow->ShowModal(); -} - -NS_IMETHODIMP nsContentTreeOwner::IsModal(PRBool *_retval) -{ - *_retval = mXULWindow->mContinueModalLoop; - return NS_OK; -} - -NS_IMETHODIMP nsContentTreeOwner::ExitModalLoop(nsresult aStatus) -{ - return mXULWindow->ExitModalLoop(aStatus); -} - NS_IMETHODIMP nsContentTreeOwner::GetNewWindow(PRInt32 aChromeFlags, nsIDocShellTreeItem** aDocShellTreeItem) { @@ -400,17 +384,18 @@ NS_IMETHODIMP nsContentTreeOwner::SizeBrowserTo(PRInt32 aCX, PRInt32 aCY) NS_IMETHODIMP nsContentTreeOwner::ShowAsModal() { - return ShowModal(); + return mXULWindow->ShowModal(); } NS_IMETHODIMP nsContentTreeOwner::IsWindowModal(PRBool *_retval) { - return IsModal(_retval); + *_retval = mXULWindow->mContinueModalLoop; + return NS_OK; } NS_IMETHODIMP nsContentTreeOwner::ExitModalEventLoop(nsresult aStatus) { - return ExitModalLoop(aStatus); + return mXULWindow->ExitModalLoop(aStatus); } //*****************************************************************************