зеркало из https://github.com/mozilla/pjs.git
If we're in the middle of printing when window.close() is called, then defer closing the window until printing completes. This avoids tearing down the presentation while the print engine is still using it. Bug 172921, r=jkeiser, sr=dbaron.
This commit is contained in:
Родитель
42eea7d687
Коммит
983bfe41ff
|
@ -422,6 +422,7 @@ protected:
|
|||
PRPackedBool mEnableRendering;
|
||||
PRPackedBool mStopped;
|
||||
PRPackedBool mLoaded;
|
||||
PRPackedBool mDeferredWindowClose;
|
||||
PRInt16 mNumURLStarts;
|
||||
PRInt16 mDestroyRefCount; // a second "refcount" for the document viewer's "destroy"
|
||||
|
||||
|
@ -486,6 +487,7 @@ void DocumentViewerImpl::PrepareToStartLoad()
|
|||
mEnableRendering = PR_TRUE;
|
||||
mStopped = PR_FALSE;
|
||||
mLoaded = PR_FALSE;
|
||||
mDeferredWindowClose = PR_FALSE;
|
||||
|
||||
#ifdef NS_PRINTING
|
||||
mPrintIsPending = PR_FALSE;
|
||||
|
@ -1585,6 +1587,21 @@ DocumentViewerImpl::GetEnableRendering(PRBool* aResult)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DocumentViewerImpl::RequestWindowClose(PRBool* aCanClose)
|
||||
{
|
||||
#ifdef NS_PRINTING
|
||||
if (mPrintIsPending || (mPrintEngine && mPrintEngine->GetIsPrinting())) {
|
||||
*aCanClose = PR_FALSE;
|
||||
mDeferredWindowClose = PR_TRUE;
|
||||
} else
|
||||
#endif
|
||||
*aCanClose = PR_TRUE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DocumentViewerImpl::ForceRefresh()
|
||||
{
|
||||
|
@ -3817,7 +3834,12 @@ DocumentViewerImpl::OnDonePrinting()
|
|||
}
|
||||
|
||||
// We are done printing, now cleanup
|
||||
if (mClosingWhilePrinting) {
|
||||
if (mDeferredWindowClose) {
|
||||
mDeferredWindowClose = PR_FALSE;
|
||||
nsCOMPtr<nsIDOMWindowInternal> win = do_GetInterface(mContainer);
|
||||
if (win)
|
||||
win->Close();
|
||||
} else if (mClosingWhilePrinting) {
|
||||
if (mDocument) {
|
||||
mDocument->SetScriptGlobalObject(nsnull);
|
||||
mDocument = nsnull;
|
||||
|
|
|
@ -59,4 +59,12 @@ interface nsIContentViewer : nsISupports
|
|||
attribute boolean enableRendering;
|
||||
|
||||
attribute boolean sticky;
|
||||
|
||||
/*
|
||||
* This is called when the DOM window wants to be closed. Returns true
|
||||
* if the window can close immediately. Otherwise, returns false and will
|
||||
* close the DOM window as soon as practical.
|
||||
*/
|
||||
|
||||
boolean requestWindowClose();
|
||||
};
|
||||
|
|
|
@ -3344,6 +3344,20 @@ GlobalWindowImpl::Close()
|
|||
}
|
||||
}
|
||||
|
||||
// Ask the content viewer whether the toplevel window can close.
|
||||
// If the content viewer returns false, it is responsible for calling
|
||||
// Close() as soon as it is possible for the window to close.
|
||||
// This allows us to not close the window while printing is happening.
|
||||
|
||||
nsCOMPtr<nsIContentViewer> cv;
|
||||
mDocShell->GetContentViewer(getter_AddRefs(cv));
|
||||
if (cv) {
|
||||
PRBool canClose;
|
||||
cv->RequestWindowClose(&canClose);
|
||||
if (!canClose)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Fire a DOM event notifying listeners that this window is about to
|
||||
// be closed. The tab UI code may choose to cancel the default
|
||||
// action for this event, if so, we won't actually close the window
|
||||
|
|
|
@ -422,6 +422,7 @@ protected:
|
|||
PRPackedBool mEnableRendering;
|
||||
PRPackedBool mStopped;
|
||||
PRPackedBool mLoaded;
|
||||
PRPackedBool mDeferredWindowClose;
|
||||
PRInt16 mNumURLStarts;
|
||||
PRInt16 mDestroyRefCount; // a second "refcount" for the document viewer's "destroy"
|
||||
|
||||
|
@ -486,6 +487,7 @@ void DocumentViewerImpl::PrepareToStartLoad()
|
|||
mEnableRendering = PR_TRUE;
|
||||
mStopped = PR_FALSE;
|
||||
mLoaded = PR_FALSE;
|
||||
mDeferredWindowClose = PR_FALSE;
|
||||
|
||||
#ifdef NS_PRINTING
|
||||
mPrintIsPending = PR_FALSE;
|
||||
|
@ -1585,6 +1587,21 @@ DocumentViewerImpl::GetEnableRendering(PRBool* aResult)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DocumentViewerImpl::RequestWindowClose(PRBool* aCanClose)
|
||||
{
|
||||
#ifdef NS_PRINTING
|
||||
if (mPrintIsPending || (mPrintEngine && mPrintEngine->GetIsPrinting())) {
|
||||
*aCanClose = PR_FALSE;
|
||||
mDeferredWindowClose = PR_TRUE;
|
||||
} else
|
||||
#endif
|
||||
*aCanClose = PR_TRUE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DocumentViewerImpl::ForceRefresh()
|
||||
{
|
||||
|
@ -3817,7 +3834,12 @@ DocumentViewerImpl::OnDonePrinting()
|
|||
}
|
||||
|
||||
// We are done printing, now cleanup
|
||||
if (mClosingWhilePrinting) {
|
||||
if (mDeferredWindowClose) {
|
||||
mDeferredWindowClose = PR_FALSE;
|
||||
nsCOMPtr<nsIDOMWindowInternal> win = do_GetInterface(mContainer);
|
||||
if (win)
|
||||
win->Close();
|
||||
} else if (mClosingWhilePrinting) {
|
||||
if (mDocument) {
|
||||
mDocument->SetScriptGlobalObject(nsnull);
|
||||
mDocument = nsnull;
|
||||
|
|
Загрузка…
Ссылка в новой задаче