Bugzilla
Quick Search
Browse
Advanced Search
Reports
Quick Search Help
Documentation
New Account
Log In
Login with GitHub
Remember
Forgot Password
Mozilla Home
Privacy
Cookies
Legal
Attachment 8861270 Details for
Bug 1356558
[patch]
(v1) Do not clean up ScriptRunner in the intermediate state when destroying PreShell, PresContext, etc at Hide().
1356558_v1.patch (text/plain), 10.12 KB, created by
Bevis Tseng[:bevis][:btseng](Exited)
(
hide
)
Description:
(v1) Do not clean up ScriptRunner in the intermediate state when destroying PreShell, PresContext, etc at Hide().
Filename:
MIME Type:
Creator:
Bevis Tseng[:bevis][:btseng](Exited)
Size:
10.12 KB
patch
obsolete
># HG changeset patch ># User Bevis Tseng <btseng@mozilla.com> ># Date 1493032398 -28800 ># Mon Apr 24 19:13:18 2017 +0800 ># Node ID 8a739398e85da8199a8b0ad3ac953000cb856e02 ># Parent 8e969cc9aff49f845678cba5b35d9dd8aa340f16 >Bug 1356558 - Do not clean up ScriptRunner in the intermediate state when destroying PreShell, PresContext, etc at Hide(). r=bz > >Flushing could be triggered by ScriptRunners in DestroyPresShell(). >Add nsAutoScriptBlocker in Hide() to supress the ScriptRunner to run >until the cleanup of PresShell, PresContext, ViewManager, etc are >dismissed. > >diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp >--- a/layout/base/nsDocumentViewer.cpp >+++ b/layout/base/nsDocumentViewer.cpp >@@ -304,8 +304,8 @@ private: > #ifdef NS_PRINTING > // Called when the DocViewer is notified that the state > // of Printing or PP has changed >- void SetIsPrintingInDocShellTree(nsIDocShellTreeItem* aParentNode, >- bool aIsPrintingOrPP, >+ void SetIsPrintingInDocShellTree(nsIDocShellTreeItem* aParentNode, >+ bool aIsPrintingOrPP, > bool aStartAtTop); > #endif // NS_PRINTING > >@@ -398,7 +398,7 @@ protected: > int32_t mHintCharsetSource; > nsCString mHintCharset; > nsCString mForceCharacterSet; >- >+ > bool mIsPageMode; > bool mInitializedForPrintPreview; > bool mHidden; >@@ -847,7 +847,7 @@ nsDocumentViewer::InitInternal(nsIWidget > } > NS_ENSURE_TRUE(mPresContext, NS_ERROR_OUT_OF_MEMORY); > >- nsresult rv = mPresContext->Init(mDeviceContext); >+ nsresult rv = mPresContext->Init(mDeviceContext); > if (NS_FAILED(rv)) { > mPresContext = nullptr; > return rv; >@@ -1464,7 +1464,7 @@ nsDocumentViewer::Open(nsISupports *aSta > AttachContainerRecurse(shell); > } > } >- >+ > SyncParentSubDocMap(); > > if (mFocusListener && mDocument) { >@@ -1598,7 +1598,7 @@ nsDocumentViewer::Destroy() > NS_ASSERTION(mDocument, "No document in Destroy()!"); > > #ifdef NS_PRINTING >- // Here is where we check to see if the document was still being prepared >+ // Here is where we check to see if the document was still being prepared > // for printing when it was asked to be destroy from someone externally > // This usually happens if the document is unloaded while the user is in the > // Print Dialog >@@ -2194,19 +2194,26 @@ nsDocumentViewer::Hide(void) > mPresShell->CaptureHistoryState(getter_AddRefs(layoutState)); > } > >- DestroyPresShell(); >- >- DestroyPresContext(); >- >- mViewManager = nullptr; >- mWindow = nullptr; >- mDeviceContext = nullptr; >- mParentWidget = nullptr; >- >- nsCOMPtr<nsIBaseWindow> base_win(mContainer); >- >- if (base_win && !mAttachedToParent) { >- base_win->SetParentWidget(nullptr); >+ { >+ // Flushing could be triggered by ScriptRunners in DestroyPresShell() >+ // which causes further reentry to Show() that we don't expect in this >+ // intermediate state between DestroyPresShell() starting and finishing up >+ // Hide. >+ nsAutoScriptBlocker blockScripts; >+ DestroyPresShell(); >+ >+ DestroyPresContext(); >+ >+ mViewManager = nullptr; >+ mWindow = nullptr; >+ mDeviceContext = nullptr; >+ mParentWidget = nullptr; >+ >+ nsCOMPtr<nsIBaseWindow> base_win(mContainer); >+ >+ if (base_win && !mAttachedToParent) { >+ base_win->SetParentWidget(nullptr); >+ } > } > > return NS_OK; >@@ -2260,7 +2267,7 @@ nsDocumentViewer::CreateStyleSet(nsIDocu > } > > styleSet->BeginUpdate(); >- >+ > // The document will fill in the document sheets when we create the presshell > > if (aDocument->IsBeingUsedAsImage()) { >@@ -2576,7 +2583,7 @@ nsDocumentViewer::CreateDeviceContext(ns > NS_PRECONDITION(!mPresShell && !mWindow, > "This will screw up our existing presentation"); > NS_PRECONDITION(mDocument, "Gotta have a document here"); >- >+ > nsIDocument* doc = mDocument->GetDisplayDocument(); > if (doc) { > NS_ASSERTION(!aContainerView, "External resource document embedded somewhere?"); >@@ -2590,7 +2597,7 @@ nsDocumentViewer::CreateDeviceContext(ns > } > } > } >- >+ > // Create a device context even if we already have one, since our widget > // might have changed. > nsIWidget* widget = nullptr; >@@ -2737,7 +2744,7 @@ NS_IMETHODIMP nsDocumentViewer::GetConte > if (selectionOnly) { > nsCopySupport::GetSelectionForCopy(mDocument, getter_AddRefs(sel)); > NS_ENSURE_TRUE(sel, NS_ERROR_FAILURE); >- >+ > bool isCollapsed; > sel->GetIsCollapsed(&isCollapsed); > if (isCollapsed) >@@ -3824,7 +3831,7 @@ nsDocumentViewer::Print(nsIPrintSettings > // Indicate there is a print pending and cache the args for later > uint32_t busyFlags = nsIDocShell::BUSY_FLAGS_NONE; > if ((NS_FAILED(docShell->GetBusyFlags(&busyFlags)) || >- (busyFlags != nsIDocShell::BUSY_FLAGS_NONE && busyFlags & nsIDocShell::BUSY_FLAGS_PAGE_LOADING)) && >+ (busyFlags != nsIDocShell::BUSY_FLAGS_NONE && busyFlags & nsIDocShell::BUSY_FLAGS_PAGE_LOADING)) && > !mPrintDocIsFullyLoaded) { > if (!mPrintIsPending) { > mCachedPrintSettings = aPrintSettings; >@@ -3873,7 +3880,7 @@ nsDocumentViewer::Print(nsIPrintSettings > NS_ENSURE_STATE(mDeviceContext); > mPrintEngine = new nsPrintEngine(); > >- rv = mPrintEngine->Initialize(this, mContainer, mDocument, >+ rv = mPrintEngine->Initialize(this, mContainer, mDocument, > float(mDeviceContext->AppUnitsPerCSSInch()) / > float(mDeviceContext->AppUnitsPerDevPixel()) / > mPageZoom, >@@ -3906,8 +3913,8 @@ nsDocumentViewer::Print(nsIPrintSettings > } > > NS_IMETHODIMP >-nsDocumentViewer::PrintPreview(nsIPrintSettings* aPrintSettings, >- mozIDOMWindowProxy* aChildDOMWin, >+nsDocumentViewer::PrintPreview(nsIPrintSettings* aPrintSettings, >+ mozIDOMWindowProxy* aChildDOMWin, > nsIWebProgressListener* aWebProgressListener) > { > #if defined(NS_PRINTING) && defined(NS_PRINT_PREVIEW) >@@ -4097,12 +4104,12 @@ NS_IMETHODIMP > nsDocumentViewer::GetDoingPrint(bool *aDoingPrint) > { > NS_ENSURE_ARG_POINTER(aDoingPrint); >- >+ > *aDoingPrint = false; > if (mPrintEngine) { > // XXX shouldn't this be GetDoingPrint() ? > return mPrintEngine->GetDoingPrintPreview(aDoingPrint); >- } >+ } > return NS_OK; > } > >@@ -4131,7 +4138,7 @@ nsDocumentViewer::GetCurrentPrintSetting > } > > >-NS_IMETHODIMP >+NS_IMETHODIMP > nsDocumentViewer::GetCurrentChildDOMWindow(mozIDOMWindowProxy** aCurrentChildDOMWindow) > { > NS_ENSURE_ARG_POINTER(aCurrentChildDOMWindow); >@@ -4176,7 +4183,7 @@ nsDocumentViewer::EnumerateDocumentNames > #endif > } > >-NS_IMETHODIMP >+NS_IMETHODIMP > nsDocumentViewer::GetIsFramesetFrameSelected(bool *aIsFramesetFrameSelected) > { > #ifdef NS_PRINTING >@@ -4215,7 +4222,7 @@ nsDocumentViewer::GetIsFramesetDocument( > #endif > } > >-NS_IMETHODIMP >+NS_IMETHODIMP > nsDocumentViewer::GetIsIFrameSelected(bool *aIsIFrameSelected) > { > #ifdef NS_PRINTING >@@ -4228,7 +4235,7 @@ nsDocumentViewer::GetIsIFrameSelected(bo > #endif > } > >-NS_IMETHODIMP >+NS_IMETHODIMP > nsDocumentViewer::GetIsRangeSelection(bool *aIsRangeSelection) > { > #ifdef NS_PRINTING >@@ -4247,9 +4254,9 @@ nsDocumentViewer::GetIsRangeSelection(bo > > //---------------------------------------------------------------------------------- > // Walks the document tree and tells each DocShell whether Printing/PP is happening >-void >-nsDocumentViewer::SetIsPrintingInDocShellTree(nsIDocShellTreeItem* aParentNode, >- bool aIsPrintingOrPP, >+void >+nsDocumentViewer::SetIsPrintingInDocShellTree(nsIDocShellTreeItem* aParentNode, >+ bool aIsPrintingOrPP, > bool aStartAtTop) > { > nsCOMPtr<nsIDocShellTreeItem> parentItem(do_QueryInterface(aParentNode)); >@@ -4335,7 +4342,7 @@ nsDocumentViewer::GetIsPrinting() > return mPrintEngine->GetIsPrinting(); > } > #endif >- return false; >+ return false; > } > > //------------------------------------------------------------ >@@ -4372,7 +4379,7 @@ nsDocumentViewer::GetIsPrintPreview() > return mPrintEngine->GetIsPrintPreview(); > } > #endif >- return false; >+ return false; > } > > //------------------------------------------------------------ >@@ -4430,7 +4437,7 @@ ResetFocusState(nsIDocShell* aDocShell) > aDocShell->GetDocShellEnumerator(nsIDocShellTreeItem::typeContent, > nsIDocShell::ENUMERATE_FORWARDS, > getter_AddRefs(docShellEnumerator)); >- >+ > nsCOMPtr<nsISupports> currentContainer; > bool hasMoreDocShells; > while (NS_SUCCEEDED(docShellEnumerator->HasMoreElements(&hasMoreDocShells)) >@@ -4474,16 +4481,16 @@ nsDocumentViewer::ReturnToGalleyPresenta > // This called ONLY when printing has completed and the DV > // is being notified that it should get rid of the PrintEngine. > // >-// BUT, if we are in Print Preview then we want to ignore the >+// BUT, if we are in Print Preview then we want to ignore the > // notification (we do not get rid of the PrintEngine) >-// >-// One small caveat: >+// >+// One small caveat: > // This IS called from two places in this module for cleaning >-// up when an error occurred during the start up printing >+// up when an error occurred during the start up printing > // and print preview > // > void >-nsDocumentViewer::OnDonePrinting() >+nsDocumentViewer::OnDonePrinting() > { > #if defined(NS_PRINTING) && defined(NS_PRINT_PREVIEW) > if (mPrintEngine) { >@@ -4495,7 +4502,7 @@ nsDocumentViewer::OnDonePrinting() > pe->Destroy(); > } > >- // We are done printing, now cleanup >+ // We are done printing, now cleanup > if (mDeferredWindowClose) { > mDeferredWindowClose = false; > if (mContainer) { >@@ -4542,7 +4549,7 @@ NS_IMETHODIMP nsDocumentViewer::SetPageM > > NS_ENSURE_STATE(mDocument); > if (aPageMode) >- { >+ { > mPresContext = CreatePresContext(mDocument, > nsPresContext::eContext_PageLayout, FindContainerView()); > NS_ENSURE_TRUE(mPresContext, NS_ERROR_OUT_OF_MEMORY);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
|
Diff
|
Review
Attachments on
bug 1356558
:
8860904
|
8861270
|
8861342
|
8862749
|
8863995
|
8865332