Backed out changeset 5a28afa66e38 (bug 1051633) for bustage.
[gecko.git] / layout / build / nsLayoutStatics.cpp
blob67c421559d385e2806a174cbe84301643a18f189
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 "nsCrossSiteListenerProxy.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"
68 #include "AudioChannelService.h"
69 #include "mozilla/dom/DataStoreService.h"
71 #ifdef MOZ_XUL
72 #include "nsXULPopupManager.h"
73 #include "nsXULContentUtils.h"
74 #include "nsXULPrototypeCache.h"
75 #include "nsXULTooltipListener.h"
77 #include "inDOMView.h"
79 #include "nsMenuBarListener.h"
80 #endif
82 #include "nsHTMLEditor.h"
83 #include "nsTextServicesDocument.h"
85 #ifdef MOZ_WEBSPEECH
86 #include "nsSynthVoiceRegistry.h"
87 #endif
89 #ifdef MOZ_ANDROID_OMX
90 #include "AndroidMediaPluginHost.h"
91 #endif
93 #ifdef MOZ_WMF
94 #include "WMFDecoder.h"
95 #endif
97 #ifdef MOZ_GSTREAMER
98 #include "GStreamerFormatHelper.h"
99 #endif
101 #ifdef MOZ_FFMPEG
102 #include "FFmpegRuntimeLinker.h"
103 #endif
105 #include "CubebUtils.h"
106 #include "Latency.h"
107 #include "WebAudioUtils.h"
109 #ifdef MOZ_WIDGET_GONK
110 #include "nsVolumeService.h"
111 #include "SpeakerManagerService.h"
112 using namespace mozilla::system;
113 #endif
115 #include "nsError.h"
117 #include "nsJSEnvironment.h"
118 #include "nsContentSink.h"
119 #include "nsFrameMessageManager.h"
120 #include "nsRefreshDriver.h"
121 #include "nsDOMMutationObserver.h"
122 #include "nsHyphenationManager.h"
123 #include "nsEditorSpellCheck.h"
124 #include "nsWindowMemoryReporter.h"
125 #include "mozilla/dom/ContentParent.h"
126 #include "mozilla/ProcessPriorityManager.h"
127 #include "nsPermissionManager.h"
128 #include "nsCookieService.h"
129 #include "nsApplicationCacheService.h"
130 #include "mozilla/dom/time/DateCacheCleaner.h"
131 #include "mozilla/EventDispatcher.h"
132 #include "mozilla/IMEStateManager.h"
133 #include "nsDocument.h"
134 #include "mozilla/dom/HTMLVideoElement.h"
135 #include "CameraPreferences.h"
137 using namespace mozilla;
138 using namespace mozilla::net;
139 using namespace mozilla::dom;
140 using namespace mozilla::dom::ipc;
142 nsrefcnt nsLayoutStatics::sLayoutStaticRefcnt = 0;
144 nsresult
145 nsLayoutStatics::Initialize()
147 NS_ASSERTION(sLayoutStaticRefcnt == 0,
148 "nsLayoutStatics isn't zero!");
150 sLayoutStaticRefcnt = 1;
151 NS_LOG_ADDREF(&sLayoutStaticRefcnt, sLayoutStaticRefcnt,
152 "nsLayoutStatics", 1);
154 nsresult rv;
156 ContentParent::StartUp();
158 // Register all of our atoms once
159 nsCSSAnonBoxes::AddRefAtoms();
160 nsCSSPseudoClasses::AddRefAtoms();
161 nsCSSPseudoElements::AddRefAtoms();
162 nsCSSKeywords::AddRefTable();
163 nsCSSProps::AddRefTable();
164 nsColorNames::AddRefTable();
165 nsGkAtoms::AddRefAtoms();
167 StartupJSEnvironment();
168 rv = nsRegion::InitStatic();
169 if (NS_FAILED(rv)) {
170 NS_ERROR("Could not initialize nsRegion");
171 return rv;
174 nsGlobalWindow::Init();
175 Navigator::Init();
176 nsXBLService::Init();
178 rv = nsContentUtils::Init();
179 if (NS_FAILED(rv)) {
180 NS_ERROR("Could not initialize nsContentUtils");
181 return rv;
184 rv = nsAttrValue::Init();
185 if (NS_FAILED(rv)) {
186 NS_ERROR("Could not initialize nsAttrValue");
187 return rv;
190 rv = nsTextFragment::Init();
191 if (NS_FAILED(rv)) {
192 NS_ERROR("Could not initialize nsTextFragment");
193 return rv;
196 nsCellMap::Init();
198 nsCSSRendering::Init();
200 nsTextFrameTextRunCache::Init();
202 rv = nsHTMLDNSPrefetch::Initialize();
203 if (NS_FAILED(rv)) {
204 NS_ERROR("Could not initialize HTML DNS prefetch");
205 return rv;
208 #ifdef MOZ_XUL
209 rv = nsXULContentUtils::Init();
210 if (NS_FAILED(rv)) {
211 NS_ERROR("Could not initialize nsXULContentUtils");
212 return rv;
215 #endif
217 nsMathMLOperators::AddRefTable();
219 nsTextServicesDocument::RegisterAtoms();
221 #ifdef DEBUG
222 nsFrame::DisplayReflowStartup();
223 #endif
224 Attr::Initialize();
226 rv = txMozillaXSLTProcessor::Startup();
227 if (NS_FAILED(rv)) {
228 NS_ERROR("Could not initialize txMozillaXSLTProcessor");
229 return rv;
232 rv = DOMStorageObserver::Init();
233 if (NS_FAILED(rv)) {
234 NS_ERROR("Could not initialize DOMStorageObserver");
235 return rv;
238 rv = nsCCUncollectableMarker::Init();
239 if (NS_FAILED(rv)) {
240 NS_ERROR("Could not initialize nsCCUncollectableMarker");
241 return rv;
244 rv = nsCSSRuleProcessor::Startup();
245 if (NS_FAILED(rv)) {
246 NS_ERROR("Could not initialize nsCSSRuleProcessor");
247 return rv;
250 #ifdef MOZ_XUL
251 rv = nsXULPopupManager::Init();
252 if (NS_FAILED(rv)) {
253 NS_ERROR("Could not initialize nsXULPopupManager");
254 return rv;
256 #endif
258 rv = nsFocusManager::Init();
259 if (NS_FAILED(rv)) {
260 NS_ERROR("Could not initialize nsFocusManager");
261 return rv;
264 AsyncLatencyLogger::InitializeStatics();
265 CubebUtils::InitLibrary();
267 nsContentSink::InitializeStatics();
268 nsHtml5Module::InitializeStatics();
269 mozilla::dom::FallbackEncoding::Initialize();
270 nsLayoutUtils::Initialize();
271 nsIPresShell::InitializeStatics();
272 nsRefreshDriver::InitializeStatics();
274 nsCORSListenerProxy::Startup();
276 NS_SealStaticAtomTable();
278 nsWindowMemoryReporter::Init();
280 SVGElementFactory::Init();
281 nsSVGUtils::Init();
283 ProcessPriorityManager::Init();
285 nsPermissionManager::AppClearDataObserverInit();
286 nsCookieService::AppClearDataObserverInit();
287 nsApplicationCacheService::AppClearDataObserverInit();
289 HTMLVideoElement::Init();
291 #ifdef MOZ_XUL
292 nsMenuBarListener::InitializeStatics();
293 #endif
295 CacheObserver::Init();
297 CounterStyleManager::InitializeBuiltinCounterStyles();
299 CameraPreferences::Initialize();
301 IMEStateManager::Init();
303 return NS_OK;
306 void
307 nsLayoutStatics::Shutdown()
309 // Don't need to shutdown nsWindowMemoryReporter, that will be done by the
310 // memory reporter manager.
312 nsFrameScriptExecutor::Shutdown();
313 nsFocusManager::Shutdown();
314 #ifdef MOZ_XUL
315 nsXULPopupManager::Shutdown();
316 #endif
317 DOMStorageObserver::Shutdown();
318 txMozillaXSLTProcessor::Shutdown();
319 Attr::Shutdown();
320 EventListenerManager::Shutdown();
321 IMEStateManager::Shutdown();
322 nsCSSParser::Shutdown();
323 nsCSSRuleProcessor::Shutdown();
324 nsTextFrameTextRunCache::Shutdown();
325 nsHTMLDNSPrefetch::Shutdown();
326 nsCSSRendering::Shutdown();
327 #ifdef DEBUG
328 nsFrame::DisplayReflowShutdown();
329 #endif
330 nsCellMap::Shutdown();
331 ActiveLayerTracker::Shutdown();
333 // Release all of our atoms
334 nsColorNames::ReleaseTable();
335 nsCSSProps::ReleaseTable();
336 nsCSSKeywords::ReleaseTable();
337 nsRepeatService::Shutdown();
338 nsStackLayout::Shutdown();
339 nsBox::Shutdown();
341 #ifdef MOZ_XUL
342 nsXULContentUtils::Finish();
343 nsXULPrototypeCache::ReleaseGlobals();
344 nsSprocketLayout::Shutdown();
345 #endif
347 SVGElementFactory::Shutdown();
348 nsMathMLOperators::ReleaseTable();
350 nsFloatManager::Shutdown();
351 nsImageFrame::ReleaseGlobals();
353 mozilla::css::ErrorReporter::ReleaseGlobals();
355 nsTextFragment::Shutdown();
357 nsAttrValue::Shutdown();
358 nsContentUtils::Shutdown();
359 nsLayoutStylesheetCache::Shutdown();
361 ShutdownJSEnvironment();
362 nsGlobalWindow::ShutDown();
363 nsDOMClassInfo::ShutDown();
364 nsListControlFrame::Shutdown();
365 nsXBLService::Shutdown();
366 nsAutoCopyListener::Shutdown();
367 FrameLayerBuilder::Shutdown();
369 #ifdef MOZ_ANDROID_OMX
370 AndroidMediaPluginHost::Shutdown();
371 #endif
373 #ifdef MOZ_GSTREAMER
374 GStreamerFormatHelper::Shutdown();
375 #endif
377 #ifdef MOZ_FFMPEG
378 FFmpegRuntimeLinker::Unlink();
379 #endif
381 CubebUtils::ShutdownLibrary();
382 AsyncLatencyLogger::ShutdownLogger();
383 WebAudioUtils::Shutdown();
385 #ifdef MOZ_WMF
386 WMFDecoder::UnloadDLLs();
387 #endif
389 #ifdef MOZ_WIDGET_GONK
390 nsVolumeService::Shutdown();
391 SpeakerManagerService::Shutdown();
392 #endif
394 #ifdef MOZ_WEBSPEECH
395 nsSynthVoiceRegistry::Shutdown();
396 #endif
398 nsCORSListenerProxy::Shutdown();
400 nsIPresShell::ReleaseStatics();
402 nsTreeSanitizer::ReleaseStatics();
404 nsHtml5Module::ReleaseStatics();
406 mozilla::dom::FallbackEncoding::Shutdown();
408 nsRegion::ShutdownStatic();
410 mozilla::EventDispatcher::Shutdown();
412 HTMLInputElement::DestroyUploadLastDir();
414 nsLayoutUtils::Shutdown();
416 nsHyphenationManager::Shutdown();
417 nsDOMMutationObserver::Shutdown();
419 AudioChannelService::Shutdown();
421 DataStoreService::Shutdown();
423 ContentParent::ShutDown();
425 nsRefreshDriver::Shutdown();
427 DisplayItemClip::Shutdown();
429 nsDocument::XPCOMShutdown();
431 CacheObserver::Shutdown();
433 CameraPreferences::Shutdown();