Bug 331117 - Layout module should not shut down until all documents and windows have been released, r+a=dbaron

git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_BRANCH@202241 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
benjamin%smedbergs.us
2006-07-17 19:06:13 +00:00
parent 526d3bfdb1
commit 238260dc86
6 changed files with 59 additions and 202 deletions

View File

@@ -138,6 +138,8 @@ static NS_DEFINE_CID(kDOMEventGroupCID, NS_DOMEVENTGROUP_CID);
#include "nsDateTimeFormatCID.h"
#include "nsIDateTimeFormat.h"
#include "nsLayoutStatics.h"
#ifdef MOZ_LOGGING
// so we can get logging even in release builds
#define FORCE_PR_LOG 1
@@ -779,6 +781,8 @@ nsDocument::nsDocument()
: nsIDocument(),
mVisible(PR_TRUE)
{
nsLayoutStatics::AddRef();
#ifdef PR_LOGGING
if (!gDocumentLeakPRLog)
gDocumentLeakPRLog = PR_NewLogModule("DocumentLeak");
@@ -902,6 +906,7 @@ nsDocument::~nsDocument()
delete mBoxObjectTable;
}
delete mXPathDocument;
nsLayoutStatics::Release();
}
PRBool gCheckedForXPathDOM = PR_FALSE;

View File

@@ -41,6 +41,11 @@
#include "nsIDOMEvent.h"
#include "nsIDOMEventListener.h"
// X.h defines KeyPress
#ifdef KeyPress
#undef KeyPress
#endif
/*
* Key pressed / released / typed listener interface.
*/

View File

@@ -69,6 +69,7 @@
#include "nsIJVMManager.h"
#endif
#include "nsContentCID.h"
#include "nsLayoutStatics.h"
// Interfaces Needed
#include "nsIWidget.h"
@@ -329,6 +330,8 @@ nsGlobalWindow::nsGlobalWindow(nsGlobalWindow *aOuterWindow)
, mSetOpenerWindowCalled(PR_FALSE)
#endif
{
nsLayoutStatics::AddRef();
// Initialize the PRCList (this).
PR_INIT_CLIST(this);
@@ -424,6 +427,8 @@ nsGlobalWindow::~nsGlobalWindow()
CleanUp();
delete mPendingStorageEvents;
nsLayoutStatics::Release();
}
// static

View File

@@ -109,11 +109,13 @@ CPPSRCS = \
nsLayoutModule.cpp \
nsContentHTTPStartup.cpp \
nsContentDLF.cpp \
nsLayoutStatics.cpp \
$(NULL)
EXPORTS = \
nsLayoutCID.h \
nsContentDLF.h \
nsLayoutStatics.h \
$(NULL)
SHARED_LIBRARY_LIBS = \

View File

@@ -35,33 +35,21 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsXBLAtoms.h" // to addref/release table
#include "nsCSSPseudoElements.h" // to addref/release table
#include "nsCSSPseudoClasses.h" // to addref/release table
#include "nsCSSAnonBoxes.h" // to addref/release table
#include "nsCSSKeywords.h" // to addref/release table
#include "nsCSSProps.h" // to addref/release table
#include "nsColorNames.h" // to addref/release table
#include "nsLayoutStatics.h"
#include "nsContentCID.h"
#include "nsContentHTTPStartup.h"
#include "nsContentDLF.h"
#include "nsContentPolicyUtils.h"
#include "nsContentUtils.h"
#include "nsDataDocumentContentPolicy.h"
#include "nsLayoutStylesheetCache.h"
#include "nsDOMCID.h"
#include "nsCSSOMFactory.h"
#include "nsInspectorCSSUtils.h"
#include "nsEventListenerManager.h"
#include "nsGenericElement.h"
#include "nsHTMLAtoms.h"
#include "nsHTMLAtoms.h"
#include "nsHTMLContentSerializer.h"
#include "nsHTMLParts.h"
#include "nsGenericHTMLElement.h"
#include "nsICSSLoader.h"
#include "nsICSSParser.h"
#include "nsCSSScanner.h"
#include "nsICSSStyleSheet.h"
#include "nsICategoryManager.h"
#include "nsIComponentManager.h"
@@ -98,34 +86,18 @@
#include "nsISelection.h"
#include "nsIXBLService.h"
#include "nsICaret.h"
#include "nsJSEnvironment.h"
#include "nsLayoutAtoms.h"
#include "nsPlainTextSerializer.h"
#include "mozSanitizingSerializer.h"
#include "nsRange.h"
#include "nsComputedDOMStyle.h"
#include "nsXMLContentSerializer.h"
#include "nsRuleNode.h"
#include "nsWyciwygProtocolHandler.h"
#include "nsContentAreaDragDrop.h"
#include "nsContentList.h"
#include "nsISyncLoadDOMService.h"
#include "nsCSSFrameConstructor.h"
#include "nsRepeatService.h"
#include "nsSprocketLayout.h"
#include "nsStackLayout.h"
#include "nsBox.h"
#include "nsSpaceManager.h"
#include "nsTextTransformer.h"
#include "nsIFrameTraversal.h"
#include "nsISelectionImageService.h"
#include "nsCSSLoader.h"
#include "nsXULAtoms.h"
#include "nsLayoutCID.h"
#include "nsStyleSet.h"
#include "nsImageFrame.h"
#include "nsILanguageAtomService.h"
#include "nsTextControlFrame.h"
#include "nsStyleSheetService.h"
#include "nsNoDataProtocolContentPolicy.h"
@@ -137,21 +109,15 @@
#include "nsViewsCID.h"
#include "nsViewManager.h"
#include "nsContentCreatorFunctions.h"
#include "nsFrame.h"
#include "nsXBLWindowKeyHandler.h"
// DOM includes
#include "nsDOMException.h"
#include "nsGlobalWindowCommands.h"
#include "nsIControllerCommandTable.h"
#include "nsJSProtocolHandler.h"
#include "nsGlobalWindow.h"
#include "nsDOMClassInfo.h"
#include "nsScriptNameSpaceManager.h"
#include "nsIControllerContext.h"
#include "nsDOMScriptObjectFactory.h"
#include "nsAutoCopyListener.h"
#include "nsDOMAttribute.h"
#include "nsDOMStorage.h"
#include "nsHTMLCanvasFrame.h"
@@ -190,14 +156,13 @@ class nsIDocumentLoaderFactory;
static NS_DEFINE_CID(kWindowCommandTableCID, NS_WINDOWCOMMANDTABLE_CID);
#ifdef MOZ_XUL
#include "nsIBoxObject.h"
#include "nsIXULDocument.h"
#include "nsIXULPopupListener.h"
#include "nsIXULPrototypeCache.h"
#include "nsIXULPrototypeDocument.h"
#include "nsIXULPrototypeDocument.h"
#include "nsIXULSortService.h"
#include "nsXULContentUtils.h"
#include "nsXULElement.h"
NS_IMETHODIMP
NS_NewXULContentBuilder(nsISupports* aOuter, REFNSIID aIID, void** aResult);
@@ -209,19 +174,12 @@ NS_NewXULTreeBuilder(nsISupports* aOuter, REFNSIID aIID, void** aResult);
PR_STATIC_CALLBACK(nsresult) Initialize(nsIModule* aSelf);
static void Shutdown();
#ifdef MOZ_MATHML
#include "nsMathMLAtoms.h"
#include "nsMathMLOperators.h"
#endif
#ifdef MOZ_XTF
#include "nsIXTFService.h"
#include "nsIXMLContentBuilder.h"
#endif
#ifdef MOZ_SVG
#include "nsSVGAtoms.h"
#include "nsSVGTypeCIDs.h"
#include "nsISVGRenderer.h"
#include "nsSVGRect.h"
#include "nsSVGUtils.h"
@@ -234,7 +192,7 @@ void NS_FreeSVGRendererLibartGlobals();
void NS_InitSVGRendererGDIPlusGlobals();
void NS_FreeSVGRendererGDIPlusGlobals();
#endif
#endif
#endif // MOZ_SVG
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDOMSerializer)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsXMLHttpRequest)
@@ -284,80 +242,11 @@ Initialize(nsIModule* aSelf)
gInitialized = PR_TRUE;
nsJSEnvironment::Startup();
nsresult rv = nsContentUtils::Init();
nsresult rv = nsLayoutStatics::Initialize();
if (NS_FAILED(rv)) {
NS_ERROR("Could not initialize nsContentUtils");
Shutdown();
return rv;
}
rv = nsAttrValue::Init();
if (NS_FAILED(rv)) {
NS_ERROR("Could not initialize nsAttrValue");
Shutdown();
return rv;
}
// Register all of our atoms once
nsCSSAnonBoxes::AddRefAtoms();
nsCSSPseudoClasses::AddRefAtoms();
nsCSSPseudoElements::AddRefAtoms();
nsCSSKeywords::AddRefTable();
nsCSSProps::AddRefTable();
nsColorNames::AddRefTable();
nsHTMLAtoms::AddRefAtoms();
nsXBLAtoms::AddRefAtoms();
nsLayoutAtoms::AddRefAtoms();
nsXULAtoms::AddRefAtoms();
#ifndef MOZ_NO_INSPECTOR_APIS
inDOMView::InitAtoms();
#endif
#ifdef MOZ_XUL
rv = nsXULContentUtils::Init();
if (NS_FAILED(rv)) {
NS_ERROR("Could not initialize nsXULContentUtils");
Shutdown();
return rv;
}
#endif
#ifdef MOZ_MATHML
nsMathMLOperators::AddRefTable();
nsMathMLAtoms::AddRefAtoms();
#endif
#ifdef MOZ_SVG
if (nsSVGUtils::SVGEnabled())
nsContentDLF::RegisterSVG();
nsSVGAtoms::AddRefAtoms();
#ifdef MOZ_SVG_RENDERER_LIBART
NS_InitSVGRendererLibartGlobals();
#endif
#ifdef MOZ_SVG_RENDERER_GDIPLUS
NS_InitSVGRendererGDIPlusGlobals();
#endif
#endif
#ifdef DEBUG
nsFrame::DisplayReflowStartup();
#endif
rv = nsTextTransformer::Initialize();
if (NS_FAILED(rv)) {
NS_ERROR("Could not initialize nsTextTransformer");
Shutdown();
return rv;
}
nsDOMAttribute::Initialize();
// Add our shutdown observer.
nsCOMPtr<nsIObserverService> observerService =
@@ -393,68 +282,7 @@ Shutdown()
gInitialized = PR_FALSE;
nsDOMAttribute::Shutdown();
nsRange::Shutdown();
nsGenericElement::Shutdown();
nsEventListenerManager::Shutdown();
nsContentList::Shutdown();
nsComputedDOMStyle::Shutdown();
CSSLoaderImpl::Shutdown();
#ifdef DEBUG
nsFrame::DisplayReflowShutdown();
#endif
// Release all of our atoms
nsColorNames::ReleaseTable();
nsCSSProps::ReleaseTable();
nsCSSKeywords::ReleaseTable();
nsRepeatService::Shutdown();
nsStackLayout::Shutdown();
nsBox::Shutdown();
#ifdef MOZ_XUL
nsXULContentUtils::Finish();
nsXULElement::ReleaseGlobals();
nsXULPrototypeElement::ReleaseGlobals();
nsXULPrototypeScript::ReleaseGlobals();
nsSprocketLayout::Shutdown();
#endif
#ifdef MOZ_MATHML
nsMathMLOperators::ReleaseTable();
#endif
#ifdef MOZ_SVG
#ifdef MOZ_SVG_RENDERER_LIBART
NS_FreeSVGRendererLibartGlobals();
#endif
#ifdef MOZ_SVG_RENDERER_GDIPLUS
NS_FreeSVGRendererGDIPlusGlobals();
#endif
#endif
nsCSSFrameConstructor::ReleaseGlobals();
nsTextTransformer::Shutdown();
nsSpaceManager::Shutdown();
nsImageFrame::ReleaseGlobals();
nsCSSScanner::ReleaseGlobals();
NS_IF_RELEASE(nsContentDLF::gUAStyleSheet);
NS_IF_RELEASE(nsRuleNode::gLangService);
nsGenericHTMLElement::Shutdown();
nsAttrValue::Shutdown();
nsContentUtils::Shutdown();
nsLayoutStylesheetCache::Shutdown();
NS_NameSpaceManagerShutdown();
nsStyleSet::FreeGlobals();
nsGlobalWindow::ShutDown();
nsDOMClassInfo::ShutDown();
nsTextControlFrame::ShutDown();
nsXBLWindowKeyHandler::ShutDown();
nsAutoCopyListener::Shutdown();
nsLayoutStatics::Release();
}
#ifdef NS_DEBUG

View File

@@ -55,7 +55,6 @@
#include "nsICSSStyleSheet.h"
#include "nsDOMAttribute.h"
#include "nsDOMClassInfo.h"
#include "nsDOMScriptObjectFactory.h"
#include "nsEventListenerManager.h"
#include "nsFrame.h"
#include "nsGenericElement.h" // for nsDOMEventRTTearoff
@@ -63,6 +62,7 @@
#include "nsGlobalWindow.h"
#include "nsHTMLAtoms.h"
#include "nsImageFrame.h"
#include "nsJSEnvironment.h"
#include "nsLayoutAtoms.h"
#include "nsLayoutStylesheetCache.h"
#include "nsNodeInfo.h"
@@ -76,7 +76,6 @@
#include "nsTextTransformer.h"
#include "nsXBLAtoms.h"
#include "nsXBLWindowKeyHandler.h"
#include "txXSLTProcessor.h"
#ifdef MOZ_XUL
#include "nsXULContentUtils.h"
@@ -106,7 +105,7 @@ nsresult
nsLayoutStatics::Initialize()
{
#ifdef NS_BUILD_REFCNT_LOGGING
NS_LogCtor(&sLayoutStaticRefcnt, "nsLayoutStatics", 1);
nsTraceRefcnt::LogCtor(&sLayoutStaticRefcnt, "nsLayoutStatics", 0);
#endif
NS_ASSERTION(sLayoutStaticRefcnt == 0,
@@ -118,22 +117,21 @@ nsLayoutStatics::Initialize()
nsresult rv;
nsDOMScriptObjectFactory::Startup();
nsJSEnvironment::Startup();
rv = nsContentUtils::Init();
if (NS_FAILED(rv)) {
NS_ERROR("Could not initialize nsContentUtils");
Shutdown();
return rv;
}
rv = nsAttrValue::Init();
if (NS_FAILED(rv)) {
NS_ERROR("Could not initialize nsAttrValue");
return rv;
}
rv = nsTextFragment::Init();
if (NS_FAILED(rv)) {
NS_ERROR("Could not initialize nsTextFragment");
Shutdown();
return rv;
}
@@ -144,7 +142,10 @@ nsLayoutStatics::Initialize()
nsCSSKeywords::AddRefTable();
nsCSSProps::AddRefTable();
nsColorNames::AddRefTable();
nsGkAtoms::AddRefAtoms();
nsHTMLAtoms::AddRefAtoms();
nsXBLAtoms::AddRefAtoms();
nsLayoutAtoms::AddRefAtoms();
nsXULAtoms::AddRefAtoms();
#ifndef MOZ_NO_INSPECTOR_APIS
inDOMView::InitAtoms();
@@ -154,32 +155,37 @@ nsLayoutStatics::Initialize()
rv = nsXULContentUtils::Init();
if (NS_FAILED(rv)) {
NS_ERROR("Could not initialize nsXULContentUtils");
Shutdown();
return rv;
}
#endif
#ifdef MOZ_MATHML
nsMathMLOperators::AddRefTable();
nsMathMLAtoms::AddRefAtoms();
#endif
#ifdef MOZ_SVG
if (nsSVGUtils::SVGEnabled())
nsContentDLF::RegisterSVG();
nsSVGAtoms::AddRefAtoms();
#ifdef MOZ_SVG_RENDERER_LIBART
NS_InitSVGRendererLibartGlobals();
#endif
#ifdef MOZ_SVG_RENDERER_GDIPLUS
NS_InitSVGRendererGDIPlusGlobals();
#endif
#endif
#ifdef DEBUG
nsFrame::DisplayReflowStartup();
#endif
rv = nsTextTransformer::Initialize();
if (NS_FAILED(rv)) {
NS_ERROR("Could not initialize nsTextTransformer");
return rv;
}
nsDOMAttribute::Initialize();
NS_ENSURE_SUCCESS(rv, rv);
if (!txXSLTProcessor::init()) {
return NS_ERROR_OUT_OF_MEMORY;
}
nsDOMAttribute::Initialize();
return NS_OK;
}
@@ -188,13 +194,12 @@ void
nsLayoutStatics::Shutdown()
{
#ifdef NS_BUILD_REFCNT_LOGGING
NS_LogDtor(&sLayoutStaticRefcnt, "nsLayoutStatics", 1);
nsTraceRefcnt::LogDtor(&sLayoutStaticRefcnt, "nsLayoutStatics", 0);
#endif
txXSLTProcessor::shutdown();
nsDOMAttribute::Shutdown();
nsRange::Shutdown();
nsDOMEventRTTearoff::Shutdown();
nsGenericElement::Shutdown();
nsEventListenerManager::Shutdown();
nsContentList::Shutdown();
nsComputedDOMStyle::Shutdown();
@@ -223,6 +228,15 @@ nsLayoutStatics::Shutdown()
nsMathMLOperators::ReleaseTable();
#endif
#ifdef MOZ_SVG
#ifdef MOZ_SVG_RENDERER_LIBART
NS_FreeSVGRendererLibartGlobals();
#endif
#ifdef MOZ_SVG_RENDERER_GDIPLUS
NS_FreeSVGRendererGDIPlusGlobals();
#endif
#endif
nsCSSFrameConstructor::ReleaseGlobals();
nsTextTransformer::Shutdown();
nsSpaceManager::Shutdown();
@@ -234,8 +248,6 @@ nsLayoutStatics::Shutdown()
NS_IF_RELEASE(nsRuleNode::gLangService);
nsGenericHTMLElement::Shutdown();
nsTextFragment::Shutdown();
nsAttrValue::Shutdown();
nsContentUtils::Shutdown();
nsLayoutStylesheetCache::Shutdown();