From aea34406c21d276d3f0a69c6783f3db57e172cf4 Mon Sep 17 00:00:00 2001 From: "jst%netscape.com" Date: Wed, 24 Apr 2002 00:33:56 +0000 Subject: [PATCH] Fixing regression bug 138663. Cached mail compose windows open up blank. r=harishd@netscape.com, sr=jband@netscape.com git-svn-id: svn://10.0.0.236/trunk@119660 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/base/src/nsDocumentViewer.cpp | 31 +++++++++++++++++-- mozilla/docshell/base/nsIContentViewer.idl | 2 ++ mozilla/layout/base/nsDocumentViewer.cpp | 31 +++++++++++++++++-- .../compose/src/nsMsgComposeService.cpp | 25 +++++++++++++++ .../plugin/base/src/nsPluginViewer.cpp | 14 +++++++++ 5 files changed, 97 insertions(+), 6 deletions(-) diff --git a/mozilla/content/base/src/nsDocumentViewer.cpp b/mozilla/content/base/src/nsDocumentViewer.cpp index 85b2e657403..a313bb7afc6 100644 --- a/mozilla/content/base/src/nsDocumentViewer.cpp +++ b/mozilla/content/base/src/nsDocumentViewer.cpp @@ -733,7 +733,9 @@ protected: // document management data // these items are specific to markup documents (html and xml) // may consider splitting these out into a subclass - PRBool mAllowPlugins; + PRPackedBool mAllowPlugins; + PRPackedBool mIsSticky; + /* character set member data */ nsString mDefaultCharacterSet; nsString mHintCharset; @@ -1115,11 +1117,10 @@ void DocumentViewerImpl::PrepareToStartLoad() } DocumentViewerImpl::DocumentViewerImpl(nsIPresContext* aPresContext) - : mPresContext(aPresContext) + : mPresContext(aPresContext), mAllowPlugins(PR_TRUE), mIsSticky(PR_FALSE) { NS_INIT_ISUPPORTS(); mHintCharsetSource = kCharsetUninitialized; - mAllowPlugins = PR_TRUE; PrepareToStartLoad(); } @@ -2081,6 +2082,14 @@ DocumentViewerImpl::Hide(void) mPreviousViewer = nsnull; } + if (mIsSticky) { + // This window is sticky, that means that it might be shown again + // and we don't want the presshell n' all that to be thrown away + // just because the window is hidden. + + return NS_OK; + } + if (mDeviceContext) { mDeviceContext->FlushFontCache(); } @@ -4923,6 +4932,22 @@ DocumentViewerImpl::SetEnableRendering(PRBool aOn) return NS_OK; } +NS_IMETHODIMP +DocumentViewerImpl::GetSticky(PRBool *aSticky) +{ + *aSticky = mIsSticky; + + return NS_OK; +} + +NS_IMETHODIMP +DocumentViewerImpl::SetSticky(PRBool aSticky) +{ + mIsSticky = aSticky; + + return NS_OK; +} + NS_IMETHODIMP DocumentViewerImpl::GetEnableRendering(PRBool* aResult) { diff --git a/mozilla/docshell/base/nsIContentViewer.idl b/mozilla/docshell/base/nsIContentViewer.idl index 98dbf307562..6b2b00fcba3 100644 --- a/mozilla/docshell/base/nsIContentViewer.idl +++ b/mozilla/docshell/base/nsIContentViewer.idl @@ -57,4 +57,6 @@ interface nsIContentViewer : nsISupports void hide(); attribute boolean enableRendering; + + attribute boolean sticky; }; diff --git a/mozilla/layout/base/nsDocumentViewer.cpp b/mozilla/layout/base/nsDocumentViewer.cpp index 85b2e657403..a313bb7afc6 100644 --- a/mozilla/layout/base/nsDocumentViewer.cpp +++ b/mozilla/layout/base/nsDocumentViewer.cpp @@ -733,7 +733,9 @@ protected: // document management data // these items are specific to markup documents (html and xml) // may consider splitting these out into a subclass - PRBool mAllowPlugins; + PRPackedBool mAllowPlugins; + PRPackedBool mIsSticky; + /* character set member data */ nsString mDefaultCharacterSet; nsString mHintCharset; @@ -1115,11 +1117,10 @@ void DocumentViewerImpl::PrepareToStartLoad() } DocumentViewerImpl::DocumentViewerImpl(nsIPresContext* aPresContext) - : mPresContext(aPresContext) + : mPresContext(aPresContext), mAllowPlugins(PR_TRUE), mIsSticky(PR_FALSE) { NS_INIT_ISUPPORTS(); mHintCharsetSource = kCharsetUninitialized; - mAllowPlugins = PR_TRUE; PrepareToStartLoad(); } @@ -2081,6 +2082,14 @@ DocumentViewerImpl::Hide(void) mPreviousViewer = nsnull; } + if (mIsSticky) { + // This window is sticky, that means that it might be shown again + // and we don't want the presshell n' all that to be thrown away + // just because the window is hidden. + + return NS_OK; + } + if (mDeviceContext) { mDeviceContext->FlushFontCache(); } @@ -4923,6 +4932,22 @@ DocumentViewerImpl::SetEnableRendering(PRBool aOn) return NS_OK; } +NS_IMETHODIMP +DocumentViewerImpl::GetSticky(PRBool *aSticky) +{ + *aSticky = mIsSticky; + + return NS_OK; +} + +NS_IMETHODIMP +DocumentViewerImpl::SetSticky(PRBool aSticky) +{ + mIsSticky = aSticky; + + return NS_OK; +} + NS_IMETHODIMP DocumentViewerImpl::GetEnableRendering(PRBool* aResult) { diff --git a/mozilla/mailnews/compose/src/nsMsgComposeService.cpp b/mozilla/mailnews/compose/src/nsMsgComposeService.cpp index b61f52e51e2..58ac44e08d8 100644 --- a/mozilla/mailnews/compose/src/nsMsgComposeService.cpp +++ b/mozilla/mailnews/compose/src/nsMsgComposeService.cpp @@ -58,6 +58,7 @@ #include "nsIWindowWatcher.h" #include "nsIDOMWindow.h" #include "nsEscape.h" +#include "nsIContentViewer.h" #include "nsIDocShell.h" #include "nsIScriptGlobalObject.h" @@ -118,6 +119,28 @@ static PRUint32 GetMessageSizeFromURI(const char * originalMsgURI) } #endif +void +SetWindowSticky(nsIDOMWindowInternal *aWindow) +{ + nsCOMPtr globalObj(do_QueryInterface(aWindow)); + if (globalObj) + { + nsCOMPtr docshell; + globalObj->GetDocShell(getter_AddRefs(docshell)); + + if (docshell) + { + nsCOMPtr contentViewer; + docshell->GetContentViewer(getter_AddRefs(contentViewer)); + + if (contentViewer) + { + contentViewer->SetSticky(PR_TRUE); + } + } + } +} + nsMsgComposeService::nsMsgComposeService() { #ifdef NS_DEBUG @@ -742,6 +765,8 @@ nsMsgComposeService::CacheWindow(nsIDOMWindowInternal *aWindow, PRBool aComposeH { if (!mCachedWindows[i].window) { + SetWindowSticky(aWindow); + rv = ShowCachedComposeWindow(aWindow, PR_FALSE); if (NS_SUCCEEDED(rv)) mCachedWindows[i].Initialize(aWindow, aListener, aComposeHTML); diff --git a/mozilla/modules/plugin/base/src/nsPluginViewer.cpp b/mozilla/modules/plugin/base/src/nsPluginViewer.cpp index 34a3ef3ebfa..30badde5818 100644 --- a/mozilla/modules/plugin/base/src/nsPluginViewer.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginViewer.cpp @@ -705,6 +705,20 @@ PluginViewerImpl::GetEnableRendering(PRBool* aResult) return NS_OK; } +NS_IMETHODIMP +PluginViewerImpl::SetSticky(PRBool aSticky) +{ + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP +PluginViewerImpl::GetSticky(PRBool *aSticky) +{ + *aSticky = PR_FALSE; + + return NS_OK; +} + void PluginViewerImpl::ForceRefresh() {