Bumping manifests a=b2g-bump
[gecko.git] / layout / build / nsLayoutStatics.cpp
blob94168353245995067d4aedbc6f8c10a20ddd91a2
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"
8 #include "nscore.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"
28 #include "nsFrame.h"
29 #include "nsGlobalWindow.h"
30 #include "nsGkAtoms.h"
31 #include "nsImageFrame.h"
32 #include "nsLayoutStylesheetCache.h"
33 #include "nsRange.h"
34 #include "nsRegion.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"
72 #ifdef MOZ_XUL
73 #include "nsXULPopupManager.h"
74 #include "nsXULContentUtils.h"
75 #include "nsXULPrototypeCache.h"
76 #include "nsXULTooltipListener.h"
78 #include "inDOMView.h"
80 #include "nsMenuBarListener.h"
81 #endif
83 #include "nsHTMLEditor.h"
84 #include "nsTextServicesDocument.h"
86 #ifdef MOZ_WEBSPEECH
87 #include "nsSynthVoiceRegistry.h"
88 #endif
90 #ifdef MOZ_ANDROID_OMX
91 #include "AndroidMediaPluginHost.h"
92 #endif
94 #ifdef MOZ_WMF
95 #include "WMFDecoder.h"
96 #endif
98 #ifdef MOZ_GSTREAMER
99 #include "GStreamerFormatHelper.h"
100 #endif
102 #ifdef MOZ_FFMPEG
103 #include "FFmpegRuntimeLinker.h"
104 #endif
106 #include "CubebUtils.h"
107 #include "Latency.h"
108 #include "WebAudioUtils.h"
110 #ifdef MOZ_WIDGET_GONK
111 #include "nsVolumeService.h"
112 #include "SpeakerManagerService.h"
113 using namespace mozilla::system;
114 #endif
116 #include "nsError.h"
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;
145 nsresult
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);
155 nsresult rv;
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();
170 if (NS_FAILED(rv)) {
171 NS_ERROR("Could not initialize nsRegion");
172 return rv;
175 nsGlobalWindow::Init();
176 Navigator::Init();
177 nsXBLService::Init();
179 rv = nsContentUtils::Init();
180 if (NS_FAILED(rv)) {
181 NS_ERROR("Could not initialize nsContentUtils");
182 return rv;
185 rv = nsAttrValue::Init();
186 if (NS_FAILED(rv)) {
187 NS_ERROR("Could not initialize nsAttrValue");
188 return rv;
191 rv = nsTextFragment::Init();
192 if (NS_FAILED(rv)) {
193 NS_ERROR("Could not initialize nsTextFragment");
194 return rv;
197 nsCellMap::Init();
199 nsCSSRendering::Init();
201 nsTextFrameTextRunCache::Init();
203 rv = nsHTMLDNSPrefetch::Initialize();
204 if (NS_FAILED(rv)) {
205 NS_ERROR("Could not initialize HTML DNS prefetch");
206 return rv;
209 #ifdef MOZ_XUL
210 rv = nsXULContentUtils::Init();
211 if (NS_FAILED(rv)) {
212 NS_ERROR("Could not initialize nsXULContentUtils");
213 return rv;
216 #endif
218 nsMathMLOperators::AddRefTable();
220 nsTextServicesDocument::RegisterAtoms();
222 #ifdef DEBUG
223 nsFrame::DisplayReflowStartup();
224 #endif
225 Attr::Initialize();
227 rv = txMozillaXSLTProcessor::Startup();
228 if (NS_FAILED(rv)) {
229 NS_ERROR("Could not initialize txMozillaXSLTProcessor");
230 return rv;
233 rv = DOMStorageObserver::Init();
234 if (NS_FAILED(rv)) {
235 NS_ERROR("Could not initialize DOMStorageObserver");
236 return rv;
239 rv = nsCCUncollectableMarker::Init();
240 if (NS_FAILED(rv)) {
241 NS_ERROR("Could not initialize nsCCUncollectableMarker");
242 return rv;
245 rv = nsCSSRuleProcessor::Startup();
246 if (NS_FAILED(rv)) {
247 NS_ERROR("Could not initialize nsCSSRuleProcessor");
248 return rv;
251 #ifdef MOZ_XUL
252 rv = nsXULPopupManager::Init();
253 if (NS_FAILED(rv)) {
254 NS_ERROR("Could not initialize nsXULPopupManager");
255 return rv;
257 #endif
259 rv = nsFocusManager::Init();
260 if (NS_FAILED(rv)) {
261 NS_ERROR("Could not initialize nsFocusManager");
262 return rv;
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();
282 nsSVGUtils::Init();
284 ProcessPriorityManager::Init();
286 nsPermissionManager::AppClearDataObserverInit();
287 nsCookieService::AppClearDataObserverInit();
288 nsApplicationCacheService::AppClearDataObserverInit();
290 HTMLVideoElement::Init();
292 #ifdef MOZ_XUL
293 nsMenuBarListener::InitializeStatics();
294 #endif
296 CacheObserver::Init();
298 CounterStyleManager::InitializeBuiltinCounterStyles();
300 CameraPreferences::Initialize();
302 IMEStateManager::Init();
304 #ifdef MOZ_B2G
305 RequestSyncWifiService::Init();
306 #endif
308 return NS_OK;
311 void
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();
319 #ifdef MOZ_XUL
320 nsXULPopupManager::Shutdown();
321 #endif
322 DOMStorageObserver::Shutdown();
323 txMozillaXSLTProcessor::Shutdown();
324 Attr::Shutdown();
325 EventListenerManager::Shutdown();
326 IMEStateManager::Shutdown();
327 nsCSSParser::Shutdown();
328 nsCSSRuleProcessor::Shutdown();
329 nsTextFrameTextRunCache::Shutdown();
330 nsHTMLDNSPrefetch::Shutdown();
331 nsCSSRendering::Shutdown();
332 #ifdef DEBUG
333 nsFrame::DisplayReflowShutdown();
334 #endif
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();
344 nsBox::Shutdown();
346 #ifdef MOZ_XUL
347 nsXULContentUtils::Finish();
348 nsXULPrototypeCache::ReleaseGlobals();
349 nsSprocketLayout::Shutdown();
350 #endif
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();
376 #endif
378 #ifdef MOZ_GSTREAMER
379 GStreamerFormatHelper::Shutdown();
380 #endif
382 #ifdef MOZ_FFMPEG
383 FFmpegRuntimeLinker::Unlink();
384 #endif
386 CubebUtils::ShutdownLibrary();
387 AsyncLatencyLogger::ShutdownLogger();
388 WebAudioUtils::Shutdown();
390 #ifdef MOZ_WMF
391 WMFDecoder::UnloadDLLs();
392 #endif
394 #ifdef MOZ_WIDGET_GONK
395 nsVolumeService::Shutdown();
396 SpeakerManagerService::Shutdown();
397 #endif
399 #ifdef MOZ_WEBSPEECH
400 nsSynthVoiceRegistry::Shutdown();
401 #endif
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();