michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "base/basictypes.h" michael@0: michael@0: #include "nsLayoutStatics.h" michael@0: #include "nscore.h" michael@0: michael@0: #include "nsAttrValue.h" michael@0: #include "nsAutoCopyListener.h" michael@0: #include "nsColorNames.h" michael@0: #include "nsComputedDOMStyle.h" michael@0: #include "nsContentDLF.h" michael@0: #include "nsContentUtils.h" michael@0: #include "nsCSSAnonBoxes.h" michael@0: #include "mozilla/css/ErrorReporter.h" michael@0: #include "nsCSSKeywords.h" michael@0: #include "nsCSSParser.h" michael@0: #include "nsCSSProps.h" michael@0: #include "nsCSSPseudoClasses.h" michael@0: #include "nsCSSPseudoElements.h" michael@0: #include "nsCSSRendering.h" michael@0: #include "mozilla/dom/Attr.h" michael@0: #include "nsDOMClassInfo.h" michael@0: #include "nsEditorEventListener.h" michael@0: #include "mozilla/EventListenerManager.h" michael@0: #include "nsFrame.h" michael@0: #include "nsGlobalWindow.h" michael@0: #include "nsGkAtoms.h" michael@0: #include "nsImageFrame.h" michael@0: #include "nsLayoutStylesheetCache.h" michael@0: #include "nsNodeInfo.h" michael@0: #include "nsRange.h" michael@0: #include "nsRegion.h" michael@0: #include "nsRepeatService.h" michael@0: #include "nsFloatManager.h" michael@0: #include "nsSprocketLayout.h" michael@0: #include "nsStackLayout.h" michael@0: #include "nsStyleSet.h" michael@0: #include "nsTextControlFrame.h" michael@0: #include "nsXBLService.h" michael@0: #include "txMozillaXSLTProcessor.h" michael@0: #include "nsTreeSanitizer.h" michael@0: #include "nsCellMap.h" michael@0: #include "nsTextFrame.h" michael@0: #include "nsCCUncollectableMarker.h" michael@0: #include "nsTextFragment.h" michael@0: #include "nsCSSRuleProcessor.h" michael@0: #include "nsCrossSiteListenerProxy.h" michael@0: #include "nsHTMLDNSPrefetch.h" michael@0: #include "nsHtml5Module.h" michael@0: #include "mozilla/dom/FallbackEncoding.h" michael@0: #include "nsFocusManager.h" michael@0: #include "nsListControlFrame.h" michael@0: #include "mozilla/dom/HTMLInputElement.h" michael@0: #include "SVGElementFactory.h" michael@0: #include "nsSVGUtils.h" michael@0: #include "nsMathMLAtoms.h" michael@0: #include "nsMathMLOperators.h" michael@0: #include "Navigator.h" michael@0: #include "DOMStorageObserver.h" michael@0: #include "CacheObserver.h" michael@0: #include "DisplayItemClip.h" michael@0: #include "ActiveLayerTracker.h" michael@0: michael@0: #include "AudioChannelService.h" michael@0: michael@0: #ifdef MOZ_XUL michael@0: #include "nsXULPopupManager.h" michael@0: #include "nsXULContentUtils.h" michael@0: #include "nsXULPrototypeCache.h" michael@0: #include "nsXULTooltipListener.h" michael@0: michael@0: #include "inDOMView.h" michael@0: michael@0: #include "nsMenuBarListener.h" michael@0: #endif michael@0: michael@0: #include "nsHTMLEditor.h" michael@0: #include "nsTextServicesDocument.h" michael@0: michael@0: #ifdef MOZ_WEBSPEECH michael@0: #include "nsSynthVoiceRegistry.h" michael@0: #endif michael@0: michael@0: #ifdef MOZ_MEDIA_PLUGINS michael@0: #include "MediaPluginHost.h" michael@0: #endif michael@0: michael@0: #ifdef MOZ_WMF michael@0: #include "WMFDecoder.h" michael@0: #endif michael@0: michael@0: #ifdef MOZ_GSTREAMER michael@0: #include "GStreamerFormatHelper.h" michael@0: #endif michael@0: michael@0: #ifdef MOZ_FFMPEG michael@0: #include "FFmpegRuntimeLinker.h" michael@0: #endif michael@0: michael@0: #include "AudioStream.h" michael@0: #include "Latency.h" michael@0: #include "WebAudioUtils.h" michael@0: michael@0: #ifdef MOZ_WIDGET_GONK michael@0: #include "nsVolumeService.h" michael@0: #include "SpeakerManagerService.h" michael@0: using namespace mozilla::system; michael@0: #endif michael@0: michael@0: #include "nsError.h" michael@0: michael@0: #include "nsJSEnvironment.h" michael@0: #include "nsContentSink.h" michael@0: #include "nsFrameMessageManager.h" michael@0: #include "nsRefreshDriver.h" michael@0: #include "nsDOMMutationObserver.h" michael@0: #include "nsHyphenationManager.h" michael@0: #include "nsEditorSpellCheck.h" michael@0: #include "nsWindowMemoryReporter.h" michael@0: #include "mozilla/dom/ContentParent.h" michael@0: #include "mozilla/ProcessPriorityManager.h" michael@0: #include "nsPermissionManager.h" michael@0: #include "nsCookieService.h" michael@0: #include "nsApplicationCacheService.h" michael@0: #include "mozilla/dom/time/DateCacheCleaner.h" michael@0: #include "mozilla/EventDispatcher.h" michael@0: #include "mozilla/IMEStateManager.h" michael@0: #include "nsDocument.h" michael@0: #include "mozilla/dom/HTMLVideoElement.h" michael@0: michael@0: using namespace mozilla; michael@0: using namespace mozilla::net; michael@0: using namespace mozilla::dom; michael@0: using namespace mozilla::dom::ipc; michael@0: michael@0: nsrefcnt nsLayoutStatics::sLayoutStaticRefcnt = 0; michael@0: michael@0: nsresult michael@0: nsLayoutStatics::Initialize() michael@0: { michael@0: NS_ASSERTION(sLayoutStaticRefcnt == 0, michael@0: "nsLayoutStatics isn't zero!"); michael@0: michael@0: sLayoutStaticRefcnt = 1; michael@0: NS_LOG_ADDREF(&sLayoutStaticRefcnt, sLayoutStaticRefcnt, michael@0: "nsLayoutStatics", 1); michael@0: michael@0: nsresult rv; michael@0: michael@0: ContentParent::StartUp(); michael@0: michael@0: // Register all of our atoms once michael@0: nsCSSAnonBoxes::AddRefAtoms(); michael@0: nsCSSPseudoClasses::AddRefAtoms(); michael@0: nsCSSPseudoElements::AddRefAtoms(); michael@0: nsCSSKeywords::AddRefTable(); michael@0: nsCSSProps::AddRefTable(); michael@0: nsColorNames::AddRefTable(); michael@0: nsGkAtoms::AddRefAtoms(); michael@0: michael@0: StartupJSEnvironment(); michael@0: rv = nsRegion::InitStatic(); michael@0: if (NS_FAILED(rv)) { michael@0: NS_ERROR("Could not initialize nsRegion"); michael@0: return rv; michael@0: } michael@0: michael@0: nsGlobalWindow::Init(); michael@0: Navigator::Init(); michael@0: nsXBLService::Init(); michael@0: michael@0: rv = nsContentUtils::Init(); michael@0: if (NS_FAILED(rv)) { michael@0: NS_ERROR("Could not initialize nsContentUtils"); michael@0: return rv; michael@0: } michael@0: michael@0: rv = nsAttrValue::Init(); michael@0: if (NS_FAILED(rv)) { michael@0: NS_ERROR("Could not initialize nsAttrValue"); michael@0: return rv; michael@0: } michael@0: michael@0: rv = nsTextFragment::Init(); michael@0: if (NS_FAILED(rv)) { michael@0: NS_ERROR("Could not initialize nsTextFragment"); michael@0: return rv; michael@0: } michael@0: michael@0: nsCellMap::Init(); michael@0: michael@0: nsCSSRendering::Init(); michael@0: michael@0: nsTextFrameTextRunCache::Init(); michael@0: michael@0: rv = nsHTMLDNSPrefetch::Initialize(); michael@0: if (NS_FAILED(rv)) { michael@0: NS_ERROR("Could not initialize HTML DNS prefetch"); michael@0: return rv; michael@0: } michael@0: michael@0: #ifdef MOZ_XUL michael@0: rv = nsXULContentUtils::Init(); michael@0: if (NS_FAILED(rv)) { michael@0: NS_ERROR("Could not initialize nsXULContentUtils"); michael@0: return rv; michael@0: } michael@0: michael@0: #endif michael@0: michael@0: nsMathMLOperators::AddRefTable(); michael@0: michael@0: nsEditProperty::RegisterAtoms(); michael@0: nsTextServicesDocument::RegisterAtoms(); michael@0: michael@0: #ifdef DEBUG michael@0: nsFrame::DisplayReflowStartup(); michael@0: #endif michael@0: Attr::Initialize(); michael@0: michael@0: rv = txMozillaXSLTProcessor::Startup(); michael@0: if (NS_FAILED(rv)) { michael@0: NS_ERROR("Could not initialize txMozillaXSLTProcessor"); michael@0: return rv; michael@0: } michael@0: michael@0: rv = DOMStorageObserver::Init(); michael@0: if (NS_FAILED(rv)) { michael@0: NS_ERROR("Could not initialize DOMStorageObserver"); michael@0: return rv; michael@0: } michael@0: michael@0: rv = nsCCUncollectableMarker::Init(); michael@0: if (NS_FAILED(rv)) { michael@0: NS_ERROR("Could not initialize nsCCUncollectableMarker"); michael@0: return rv; michael@0: } michael@0: michael@0: rv = nsCSSRuleProcessor::Startup(); michael@0: if (NS_FAILED(rv)) { michael@0: NS_ERROR("Could not initialize nsCSSRuleProcessor"); michael@0: return rv; michael@0: } michael@0: michael@0: #ifdef MOZ_XUL michael@0: rv = nsXULPopupManager::Init(); michael@0: if (NS_FAILED(rv)) { michael@0: NS_ERROR("Could not initialize nsXULPopupManager"); michael@0: return rv; michael@0: } michael@0: #endif michael@0: michael@0: rv = nsFocusManager::Init(); michael@0: if (NS_FAILED(rv)) { michael@0: NS_ERROR("Could not initialize nsFocusManager"); michael@0: return rv; michael@0: } michael@0: michael@0: AsyncLatencyLogger::InitializeStatics(); michael@0: AudioStream::InitLibrary(); michael@0: michael@0: nsContentSink::InitializeStatics(); michael@0: nsHtml5Module::InitializeStatics(); michael@0: mozilla::dom::FallbackEncoding::Initialize(); michael@0: nsLayoutUtils::Initialize(); michael@0: nsIPresShell::InitializeStatics(); michael@0: nsRefreshDriver::InitializeStatics(); michael@0: michael@0: nsCORSListenerProxy::Startup(); michael@0: michael@0: NS_SealStaticAtomTable(); michael@0: michael@0: nsWindowMemoryReporter::Init(); michael@0: michael@0: SVGElementFactory::Init(); michael@0: nsSVGUtils::Init(); michael@0: michael@0: ProcessPriorityManager::Init(); michael@0: michael@0: nsPermissionManager::AppClearDataObserverInit(); michael@0: nsCookieService::AppClearDataObserverInit(); michael@0: nsApplicationCacheService::AppClearDataObserverInit(); michael@0: michael@0: HTMLVideoElement::Init(); michael@0: michael@0: #ifdef MOZ_XUL michael@0: nsMenuBarListener::InitializeStatics(); michael@0: #endif michael@0: michael@0: CacheObserver::Init(); michael@0: michael@0: return NS_OK; michael@0: } michael@0: michael@0: void michael@0: nsLayoutStatics::Shutdown() michael@0: { michael@0: // Don't need to shutdown nsWindowMemoryReporter, that will be done by the michael@0: // memory reporter manager. michael@0: michael@0: nsFrameScriptExecutor::Shutdown(); michael@0: nsFocusManager::Shutdown(); michael@0: #ifdef MOZ_XUL michael@0: nsXULPopupManager::Shutdown(); michael@0: #endif michael@0: DOMStorageObserver::Shutdown(); michael@0: txMozillaXSLTProcessor::Shutdown(); michael@0: Attr::Shutdown(); michael@0: EventListenerManager::Shutdown(); michael@0: IMEStateManager::Shutdown(); michael@0: nsComputedDOMStyle::Shutdown(); michael@0: nsCSSParser::Shutdown(); michael@0: nsCSSRuleProcessor::Shutdown(); michael@0: nsTextFrameTextRunCache::Shutdown(); michael@0: nsHTMLDNSPrefetch::Shutdown(); michael@0: nsCSSRendering::Shutdown(); michael@0: #ifdef DEBUG michael@0: nsFrame::DisplayReflowShutdown(); michael@0: #endif michael@0: nsCellMap::Shutdown(); michael@0: ActiveLayerTracker::Shutdown(); michael@0: michael@0: // Release all of our atoms michael@0: nsColorNames::ReleaseTable(); michael@0: nsCSSProps::ReleaseTable(); michael@0: nsCSSKeywords::ReleaseTable(); michael@0: nsRepeatService::Shutdown(); michael@0: nsStackLayout::Shutdown(); michael@0: nsBox::Shutdown(); michael@0: michael@0: #ifdef MOZ_XUL michael@0: nsXULContentUtils::Finish(); michael@0: nsXULPrototypeCache::ReleaseGlobals(); michael@0: nsSprocketLayout::Shutdown(); michael@0: #endif michael@0: michael@0: SVGElementFactory::Shutdown(); michael@0: nsMathMLOperators::ReleaseTable(); michael@0: michael@0: nsFloatManager::Shutdown(); michael@0: nsImageFrame::ReleaseGlobals(); michael@0: michael@0: mozilla::css::ErrorReporter::ReleaseGlobals(); michael@0: michael@0: nsTextFragment::Shutdown(); michael@0: michael@0: nsAttrValue::Shutdown(); michael@0: nsContentUtils::Shutdown(); michael@0: nsLayoutStylesheetCache::Shutdown(); michael@0: michael@0: ShutdownJSEnvironment(); michael@0: nsGlobalWindow::ShutDown(); michael@0: nsDOMClassInfo::ShutDown(); michael@0: nsListControlFrame::Shutdown(); michael@0: nsXBLService::Shutdown(); michael@0: nsAutoCopyListener::Shutdown(); michael@0: FrameLayerBuilder::Shutdown(); michael@0: michael@0: #ifdef MOZ_MEDIA_PLUGINS michael@0: MediaPluginHost::Shutdown(); michael@0: #endif michael@0: michael@0: #ifdef MOZ_GSTREAMER michael@0: GStreamerFormatHelper::Shutdown(); michael@0: #endif michael@0: michael@0: #ifdef MOZ_FFMPEG michael@0: FFmpegRuntimeLinker::Unlink(); michael@0: #endif michael@0: michael@0: AudioStream::ShutdownLibrary(); michael@0: AsyncLatencyLogger::ShutdownLogger(); michael@0: WebAudioUtils::Shutdown(); michael@0: michael@0: #ifdef MOZ_WMF michael@0: WMFDecoder::UnloadDLLs(); michael@0: #endif michael@0: michael@0: #ifdef MOZ_WIDGET_GONK michael@0: nsVolumeService::Shutdown(); michael@0: SpeakerManagerService::Shutdown(); michael@0: #endif michael@0: michael@0: #ifdef MOZ_WEBSPEECH michael@0: nsSynthVoiceRegistry::Shutdown(); michael@0: #endif michael@0: michael@0: nsCORSListenerProxy::Shutdown(); michael@0: michael@0: nsIPresShell::ReleaseStatics(); michael@0: michael@0: nsTreeSanitizer::ReleaseStatics(); michael@0: michael@0: nsHtml5Module::ReleaseStatics(); michael@0: michael@0: mozilla::dom::FallbackEncoding::Shutdown(); michael@0: michael@0: nsRegion::ShutdownStatic(); michael@0: michael@0: mozilla::EventDispatcher::Shutdown(); michael@0: michael@0: HTMLInputElement::DestroyUploadLastDir(); michael@0: michael@0: nsLayoutUtils::Shutdown(); michael@0: michael@0: nsHyphenationManager::Shutdown(); michael@0: nsDOMMutationObserver::Shutdown(); michael@0: michael@0: AudioChannelService::Shutdown(); michael@0: michael@0: ContentParent::ShutDown(); michael@0: michael@0: nsRefreshDriver::Shutdown(); michael@0: michael@0: DisplayItemClip::Shutdown(); michael@0: michael@0: nsDocument::XPCOMShutdown(); michael@0: michael@0: CacheObserver::Shutdown(); michael@0: }