1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #include "base/basictypes.h"
7 #include "nsLayoutStatics.h"
10 #include "nsAttrValue.h"
11 #include "nsAutoCopyListener.h"
12 #include "nsColorNames.h"
13 #include "nsComputedDOMStyle.h"
14 #include "nsContentDLF.h"
15 #include "nsContentUtils.h"
16 #include "nsCSSAnonBoxes.h"
17 #include "mozilla/css/ErrorReporter.h"
18 #include "nsCSSKeywords.h"
19 #include "nsCSSParser.h"
20 #include "nsCSSProps.h"
21 #include "nsCSSPseudoClasses.h"
22 #include "nsCSSPseudoElements.h"
23 #include "nsCSSRendering.h"
24 #include "mozilla/dom/Attr.h"
25 #include "nsDOMClassInfo.h"
26 #include "nsEditorEventListener.h"
27 #include "mozilla/EventListenerManager.h"
29 #include "nsGlobalWindow.h"
30 #include "nsGkAtoms.h"
31 #include "nsImageFrame.h"
32 #include "nsLayoutStylesheetCache.h"
35 #include "nsRepeatService.h"
36 #include "nsFloatManager.h"
37 #include "nsSprocketLayout.h"
38 #include "nsStackLayout.h"
39 #include "nsStyleSet.h"
40 #include "nsTextControlFrame.h"
41 #include "nsXBLService.h"
42 #include "txMozillaXSLTProcessor.h"
43 #include "nsTreeSanitizer.h"
44 #include "nsCellMap.h"
45 #include "nsTextFrame.h"
46 #include "nsCCUncollectableMarker.h"
47 #include "nsTextFragment.h"
48 #include "nsCSSRuleProcessor.h"
49 #include "nsCORSListenerProxy.h"
50 #include "nsHTMLDNSPrefetch.h"
51 #include "nsHtml5Module.h"
52 #include "mozilla/dom/FallbackEncoding.h"
53 #include "nsFocusManager.h"
54 #include "nsListControlFrame.h"
55 #include "mozilla/dom/HTMLInputElement.h"
56 #include "SVGElementFactory.h"
57 #include "nsSVGUtils.h"
58 #include "nsMathMLAtoms.h"
59 #include "nsMathMLOperators.h"
60 #include "Navigator.h"
61 #include "DOMStorageObserver.h"
62 #include "CacheObserver.h"
63 #include "DisplayItemClip.h"
64 #include "ActiveLayerTracker.h"
65 #include "CounterStyleManager.h"
66 #include "FrameLayerBuilder.h"
67 #include "mozilla/dom/RequestSyncWifiService.h"
69 #include "AudioChannelService.h"
70 #include "mozilla/dom/DataStoreService.h"
73 #include "nsXULPopupManager.h"
74 #include "nsXULContentUtils.h"
75 #include "nsXULPrototypeCache.h"
76 #include "nsXULTooltipListener.h"
78 #include "inDOMView.h"
80 #include "nsMenuBarListener.h"
83 #include "nsHTMLEditor.h"
84 #include "nsTextServicesDocument.h"
87 #include "nsSynthVoiceRegistry.h"
90 #ifdef MOZ_ANDROID_OMX
91 #include "AndroidMediaPluginHost.h"
95 #include "WMFDecoder.h"
99 #include "GStreamerFormatHelper.h"
103 #include "FFmpegRuntimeLinker.h"
106 #include "CubebUtils.h"
108 #include "WebAudioUtils.h"
110 #ifdef MOZ_WIDGET_GONK
111 #include "nsVolumeService.h"
112 #include "SpeakerManagerService.h"
113 using namespace mozilla::system
;
118 #include "nsJSEnvironment.h"
119 #include "nsContentSink.h"
120 #include "nsFrameMessageManager.h"
121 #include "nsRefreshDriver.h"
122 #include "nsDOMMutationObserver.h"
123 #include "nsHyphenationManager.h"
124 #include "nsEditorSpellCheck.h"
125 #include "nsWindowMemoryReporter.h"
126 #include "mozilla/dom/ContentParent.h"
127 #include "mozilla/ProcessPriorityManager.h"
128 #include "nsPermissionManager.h"
129 #include "nsCookieService.h"
130 #include "nsApplicationCacheService.h"
131 #include "mozilla/dom/time/DateCacheCleaner.h"
132 #include "mozilla/EventDispatcher.h"
133 #include "mozilla/IMEStateManager.h"
134 #include "nsDocument.h"
135 #include "mozilla/dom/HTMLVideoElement.h"
136 #include "CameraPreferences.h"
138 using namespace mozilla
;
139 using namespace mozilla::net
;
140 using namespace mozilla::dom
;
141 using namespace mozilla::dom::ipc
;
143 nsrefcnt
nsLayoutStatics::sLayoutStaticRefcnt
= 0;
146 nsLayoutStatics::Initialize()
148 NS_ASSERTION(sLayoutStaticRefcnt
== 0,
149 "nsLayoutStatics isn't zero!");
151 sLayoutStaticRefcnt
= 1;
152 NS_LOG_ADDREF(&sLayoutStaticRefcnt
, sLayoutStaticRefcnt
,
153 "nsLayoutStatics", 1);
157 ContentParent::StartUp();
159 // Register all of our atoms once
160 nsCSSAnonBoxes::AddRefAtoms();
161 nsCSSPseudoClasses::AddRefAtoms();
162 nsCSSPseudoElements::AddRefAtoms();
163 nsCSSKeywords::AddRefTable();
164 nsCSSProps::AddRefTable();
165 nsColorNames::AddRefTable();
166 nsGkAtoms::AddRefAtoms();
168 StartupJSEnvironment();
169 rv
= nsRegion::InitStatic();
171 NS_ERROR("Could not initialize nsRegion");
175 nsGlobalWindow::Init();
177 nsXBLService::Init();
179 rv
= nsContentUtils::Init();
181 NS_ERROR("Could not initialize nsContentUtils");
185 rv
= nsAttrValue::Init();
187 NS_ERROR("Could not initialize nsAttrValue");
191 rv
= nsTextFragment::Init();
193 NS_ERROR("Could not initialize nsTextFragment");
199 nsCSSRendering::Init();
201 nsTextFrameTextRunCache::Init();
203 rv
= nsHTMLDNSPrefetch::Initialize();
205 NS_ERROR("Could not initialize HTML DNS prefetch");
210 rv
= nsXULContentUtils::Init();
212 NS_ERROR("Could not initialize nsXULContentUtils");
218 nsMathMLOperators::AddRefTable();
220 nsTextServicesDocument::RegisterAtoms();
223 nsFrame::DisplayReflowStartup();
227 rv
= txMozillaXSLTProcessor::Startup();
229 NS_ERROR("Could not initialize txMozillaXSLTProcessor");
233 rv
= DOMStorageObserver::Init();
235 NS_ERROR("Could not initialize DOMStorageObserver");
239 rv
= nsCCUncollectableMarker::Init();
241 NS_ERROR("Could not initialize nsCCUncollectableMarker");
245 rv
= nsCSSRuleProcessor::Startup();
247 NS_ERROR("Could not initialize nsCSSRuleProcessor");
252 rv
= nsXULPopupManager::Init();
254 NS_ERROR("Could not initialize nsXULPopupManager");
259 rv
= nsFocusManager::Init();
261 NS_ERROR("Could not initialize nsFocusManager");
265 AsyncLatencyLogger::InitializeStatics();
266 CubebUtils::InitLibrary();
268 nsContentSink::InitializeStatics();
269 nsHtml5Module::InitializeStatics();
270 mozilla::dom::FallbackEncoding::Initialize();
271 nsLayoutUtils::Initialize();
272 nsIPresShell::InitializeStatics();
273 nsRefreshDriver::InitializeStatics();
275 nsCORSListenerProxy::Startup();
277 NS_SealStaticAtomTable();
279 nsWindowMemoryReporter::Init();
281 SVGElementFactory::Init();
284 ProcessPriorityManager::Init();
286 nsPermissionManager::AppClearDataObserverInit();
287 nsCookieService::AppClearDataObserverInit();
288 nsApplicationCacheService::AppClearDataObserverInit();
290 HTMLVideoElement::Init();
293 nsMenuBarListener::InitializeStatics();
296 CacheObserver::Init();
298 CounterStyleManager::InitializeBuiltinCounterStyles();
300 CameraPreferences::Initialize();
302 IMEStateManager::Init();
305 RequestSyncWifiService::Init();
312 nsLayoutStatics::Shutdown()
314 // Don't need to shutdown nsWindowMemoryReporter, that will be done by the
315 // memory reporter manager.
317 nsFrameScriptExecutor::Shutdown();
318 nsFocusManager::Shutdown();
320 nsXULPopupManager::Shutdown();
322 DOMStorageObserver::Shutdown();
323 txMozillaXSLTProcessor::Shutdown();
325 EventListenerManager::Shutdown();
326 IMEStateManager::Shutdown();
327 nsCSSParser::Shutdown();
328 nsCSSRuleProcessor::Shutdown();
329 nsTextFrameTextRunCache::Shutdown();
330 nsHTMLDNSPrefetch::Shutdown();
331 nsCSSRendering::Shutdown();
333 nsFrame::DisplayReflowShutdown();
335 nsCellMap::Shutdown();
336 ActiveLayerTracker::Shutdown();
338 // Release all of our atoms
339 nsColorNames::ReleaseTable();
340 nsCSSProps::ReleaseTable();
341 nsCSSKeywords::ReleaseTable();
342 nsRepeatService::Shutdown();
343 nsStackLayout::Shutdown();
347 nsXULContentUtils::Finish();
348 nsXULPrototypeCache::ReleaseGlobals();
349 nsSprocketLayout::Shutdown();
352 SVGElementFactory::Shutdown();
353 nsMathMLOperators::ReleaseTable();
355 nsFloatManager::Shutdown();
356 nsImageFrame::ReleaseGlobals();
358 mozilla::css::ErrorReporter::ReleaseGlobals();
360 nsTextFragment::Shutdown();
362 nsAttrValue::Shutdown();
363 nsContentUtils::Shutdown();
364 nsLayoutStylesheetCache::Shutdown();
366 ShutdownJSEnvironment();
367 nsGlobalWindow::ShutDown();
368 nsDOMClassInfo::ShutDown();
369 nsListControlFrame::Shutdown();
370 nsXBLService::Shutdown();
371 nsAutoCopyListener::Shutdown();
372 FrameLayerBuilder::Shutdown();
374 #ifdef MOZ_ANDROID_OMX
375 AndroidMediaPluginHost::Shutdown();
379 GStreamerFormatHelper::Shutdown();
383 FFmpegRuntimeLinker::Unlink();
386 CubebUtils::ShutdownLibrary();
387 AsyncLatencyLogger::ShutdownLogger();
388 WebAudioUtils::Shutdown();
391 WMFDecoder::UnloadDLLs();
394 #ifdef MOZ_WIDGET_GONK
395 nsVolumeService::Shutdown();
396 SpeakerManagerService::Shutdown();
400 nsSynthVoiceRegistry::Shutdown();
403 nsCORSListenerProxy::Shutdown();
405 nsIPresShell::ReleaseStatics();
407 nsTreeSanitizer::ReleaseStatics();
409 nsHtml5Module::ReleaseStatics();
411 mozilla::dom::FallbackEncoding::Shutdown();
413 nsRegion::ShutdownStatic();
415 mozilla::EventDispatcher::Shutdown();
417 HTMLInputElement::DestroyUploadLastDir();
419 nsLayoutUtils::Shutdown();
421 nsHyphenationManager::Shutdown();
422 nsDOMMutationObserver::Shutdown();
424 AudioChannelService::Shutdown();
426 DataStoreService::Shutdown();
428 ContentParent::ShutDown();
430 nsRefreshDriver::Shutdown();
432 DisplayItemClip::Shutdown();
434 nsDocument::XPCOMShutdown();
436 CacheObserver::Shutdown();
438 CameraPreferences::Shutdown();