|
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/. */ |
|
4 |
|
5 #include "base/basictypes.h" |
|
6 |
|
7 #include "nsLayoutStatics.h" |
|
8 #include "nscore.h" |
|
9 |
|
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 "nsNodeInfo.h" |
|
34 #include "nsRange.h" |
|
35 #include "nsRegion.h" |
|
36 #include "nsRepeatService.h" |
|
37 #include "nsFloatManager.h" |
|
38 #include "nsSprocketLayout.h" |
|
39 #include "nsStackLayout.h" |
|
40 #include "nsStyleSet.h" |
|
41 #include "nsTextControlFrame.h" |
|
42 #include "nsXBLService.h" |
|
43 #include "txMozillaXSLTProcessor.h" |
|
44 #include "nsTreeSanitizer.h" |
|
45 #include "nsCellMap.h" |
|
46 #include "nsTextFrame.h" |
|
47 #include "nsCCUncollectableMarker.h" |
|
48 #include "nsTextFragment.h" |
|
49 #include "nsCSSRuleProcessor.h" |
|
50 #include "nsCrossSiteListenerProxy.h" |
|
51 #include "nsHTMLDNSPrefetch.h" |
|
52 #include "nsHtml5Module.h" |
|
53 #include "mozilla/dom/FallbackEncoding.h" |
|
54 #include "nsFocusManager.h" |
|
55 #include "nsListControlFrame.h" |
|
56 #include "mozilla/dom/HTMLInputElement.h" |
|
57 #include "SVGElementFactory.h" |
|
58 #include "nsSVGUtils.h" |
|
59 #include "nsMathMLAtoms.h" |
|
60 #include "nsMathMLOperators.h" |
|
61 #include "Navigator.h" |
|
62 #include "DOMStorageObserver.h" |
|
63 #include "CacheObserver.h" |
|
64 #include "DisplayItemClip.h" |
|
65 #include "ActiveLayerTracker.h" |
|
66 |
|
67 #include "AudioChannelService.h" |
|
68 |
|
69 #ifdef MOZ_XUL |
|
70 #include "nsXULPopupManager.h" |
|
71 #include "nsXULContentUtils.h" |
|
72 #include "nsXULPrototypeCache.h" |
|
73 #include "nsXULTooltipListener.h" |
|
74 |
|
75 #include "inDOMView.h" |
|
76 |
|
77 #include "nsMenuBarListener.h" |
|
78 #endif |
|
79 |
|
80 #include "nsHTMLEditor.h" |
|
81 #include "nsTextServicesDocument.h" |
|
82 |
|
83 #ifdef MOZ_WEBSPEECH |
|
84 #include "nsSynthVoiceRegistry.h" |
|
85 #endif |
|
86 |
|
87 #ifdef MOZ_MEDIA_PLUGINS |
|
88 #include "MediaPluginHost.h" |
|
89 #endif |
|
90 |
|
91 #ifdef MOZ_WMF |
|
92 #include "WMFDecoder.h" |
|
93 #endif |
|
94 |
|
95 #ifdef MOZ_GSTREAMER |
|
96 #include "GStreamerFormatHelper.h" |
|
97 #endif |
|
98 |
|
99 #ifdef MOZ_FFMPEG |
|
100 #include "FFmpegRuntimeLinker.h" |
|
101 #endif |
|
102 |
|
103 #include "AudioStream.h" |
|
104 #include "Latency.h" |
|
105 #include "WebAudioUtils.h" |
|
106 |
|
107 #ifdef MOZ_WIDGET_GONK |
|
108 #include "nsVolumeService.h" |
|
109 #include "SpeakerManagerService.h" |
|
110 using namespace mozilla::system; |
|
111 #endif |
|
112 |
|
113 #include "nsError.h" |
|
114 |
|
115 #include "nsJSEnvironment.h" |
|
116 #include "nsContentSink.h" |
|
117 #include "nsFrameMessageManager.h" |
|
118 #include "nsRefreshDriver.h" |
|
119 #include "nsDOMMutationObserver.h" |
|
120 #include "nsHyphenationManager.h" |
|
121 #include "nsEditorSpellCheck.h" |
|
122 #include "nsWindowMemoryReporter.h" |
|
123 #include "mozilla/dom/ContentParent.h" |
|
124 #include "mozilla/ProcessPriorityManager.h" |
|
125 #include "nsPermissionManager.h" |
|
126 #include "nsCookieService.h" |
|
127 #include "nsApplicationCacheService.h" |
|
128 #include "mozilla/dom/time/DateCacheCleaner.h" |
|
129 #include "mozilla/EventDispatcher.h" |
|
130 #include "mozilla/IMEStateManager.h" |
|
131 #include "nsDocument.h" |
|
132 #include "mozilla/dom/HTMLVideoElement.h" |
|
133 |
|
134 using namespace mozilla; |
|
135 using namespace mozilla::net; |
|
136 using namespace mozilla::dom; |
|
137 using namespace mozilla::dom::ipc; |
|
138 |
|
139 nsrefcnt nsLayoutStatics::sLayoutStaticRefcnt = 0; |
|
140 |
|
141 nsresult |
|
142 nsLayoutStatics::Initialize() |
|
143 { |
|
144 NS_ASSERTION(sLayoutStaticRefcnt == 0, |
|
145 "nsLayoutStatics isn't zero!"); |
|
146 |
|
147 sLayoutStaticRefcnt = 1; |
|
148 NS_LOG_ADDREF(&sLayoutStaticRefcnt, sLayoutStaticRefcnt, |
|
149 "nsLayoutStatics", 1); |
|
150 |
|
151 nsresult rv; |
|
152 |
|
153 ContentParent::StartUp(); |
|
154 |
|
155 // Register all of our atoms once |
|
156 nsCSSAnonBoxes::AddRefAtoms(); |
|
157 nsCSSPseudoClasses::AddRefAtoms(); |
|
158 nsCSSPseudoElements::AddRefAtoms(); |
|
159 nsCSSKeywords::AddRefTable(); |
|
160 nsCSSProps::AddRefTable(); |
|
161 nsColorNames::AddRefTable(); |
|
162 nsGkAtoms::AddRefAtoms(); |
|
163 |
|
164 StartupJSEnvironment(); |
|
165 rv = nsRegion::InitStatic(); |
|
166 if (NS_FAILED(rv)) { |
|
167 NS_ERROR("Could not initialize nsRegion"); |
|
168 return rv; |
|
169 } |
|
170 |
|
171 nsGlobalWindow::Init(); |
|
172 Navigator::Init(); |
|
173 nsXBLService::Init(); |
|
174 |
|
175 rv = nsContentUtils::Init(); |
|
176 if (NS_FAILED(rv)) { |
|
177 NS_ERROR("Could not initialize nsContentUtils"); |
|
178 return rv; |
|
179 } |
|
180 |
|
181 rv = nsAttrValue::Init(); |
|
182 if (NS_FAILED(rv)) { |
|
183 NS_ERROR("Could not initialize nsAttrValue"); |
|
184 return rv; |
|
185 } |
|
186 |
|
187 rv = nsTextFragment::Init(); |
|
188 if (NS_FAILED(rv)) { |
|
189 NS_ERROR("Could not initialize nsTextFragment"); |
|
190 return rv; |
|
191 } |
|
192 |
|
193 nsCellMap::Init(); |
|
194 |
|
195 nsCSSRendering::Init(); |
|
196 |
|
197 nsTextFrameTextRunCache::Init(); |
|
198 |
|
199 rv = nsHTMLDNSPrefetch::Initialize(); |
|
200 if (NS_FAILED(rv)) { |
|
201 NS_ERROR("Could not initialize HTML DNS prefetch"); |
|
202 return rv; |
|
203 } |
|
204 |
|
205 #ifdef MOZ_XUL |
|
206 rv = nsXULContentUtils::Init(); |
|
207 if (NS_FAILED(rv)) { |
|
208 NS_ERROR("Could not initialize nsXULContentUtils"); |
|
209 return rv; |
|
210 } |
|
211 |
|
212 #endif |
|
213 |
|
214 nsMathMLOperators::AddRefTable(); |
|
215 |
|
216 nsEditProperty::RegisterAtoms(); |
|
217 nsTextServicesDocument::RegisterAtoms(); |
|
218 |
|
219 #ifdef DEBUG |
|
220 nsFrame::DisplayReflowStartup(); |
|
221 #endif |
|
222 Attr::Initialize(); |
|
223 |
|
224 rv = txMozillaXSLTProcessor::Startup(); |
|
225 if (NS_FAILED(rv)) { |
|
226 NS_ERROR("Could not initialize txMozillaXSLTProcessor"); |
|
227 return rv; |
|
228 } |
|
229 |
|
230 rv = DOMStorageObserver::Init(); |
|
231 if (NS_FAILED(rv)) { |
|
232 NS_ERROR("Could not initialize DOMStorageObserver"); |
|
233 return rv; |
|
234 } |
|
235 |
|
236 rv = nsCCUncollectableMarker::Init(); |
|
237 if (NS_FAILED(rv)) { |
|
238 NS_ERROR("Could not initialize nsCCUncollectableMarker"); |
|
239 return rv; |
|
240 } |
|
241 |
|
242 rv = nsCSSRuleProcessor::Startup(); |
|
243 if (NS_FAILED(rv)) { |
|
244 NS_ERROR("Could not initialize nsCSSRuleProcessor"); |
|
245 return rv; |
|
246 } |
|
247 |
|
248 #ifdef MOZ_XUL |
|
249 rv = nsXULPopupManager::Init(); |
|
250 if (NS_FAILED(rv)) { |
|
251 NS_ERROR("Could not initialize nsXULPopupManager"); |
|
252 return rv; |
|
253 } |
|
254 #endif |
|
255 |
|
256 rv = nsFocusManager::Init(); |
|
257 if (NS_FAILED(rv)) { |
|
258 NS_ERROR("Could not initialize nsFocusManager"); |
|
259 return rv; |
|
260 } |
|
261 |
|
262 AsyncLatencyLogger::InitializeStatics(); |
|
263 AudioStream::InitLibrary(); |
|
264 |
|
265 nsContentSink::InitializeStatics(); |
|
266 nsHtml5Module::InitializeStatics(); |
|
267 mozilla::dom::FallbackEncoding::Initialize(); |
|
268 nsLayoutUtils::Initialize(); |
|
269 nsIPresShell::InitializeStatics(); |
|
270 nsRefreshDriver::InitializeStatics(); |
|
271 |
|
272 nsCORSListenerProxy::Startup(); |
|
273 |
|
274 NS_SealStaticAtomTable(); |
|
275 |
|
276 nsWindowMemoryReporter::Init(); |
|
277 |
|
278 SVGElementFactory::Init(); |
|
279 nsSVGUtils::Init(); |
|
280 |
|
281 ProcessPriorityManager::Init(); |
|
282 |
|
283 nsPermissionManager::AppClearDataObserverInit(); |
|
284 nsCookieService::AppClearDataObserverInit(); |
|
285 nsApplicationCacheService::AppClearDataObserverInit(); |
|
286 |
|
287 HTMLVideoElement::Init(); |
|
288 |
|
289 #ifdef MOZ_XUL |
|
290 nsMenuBarListener::InitializeStatics(); |
|
291 #endif |
|
292 |
|
293 CacheObserver::Init(); |
|
294 |
|
295 return NS_OK; |
|
296 } |
|
297 |
|
298 void |
|
299 nsLayoutStatics::Shutdown() |
|
300 { |
|
301 // Don't need to shutdown nsWindowMemoryReporter, that will be done by the |
|
302 // memory reporter manager. |
|
303 |
|
304 nsFrameScriptExecutor::Shutdown(); |
|
305 nsFocusManager::Shutdown(); |
|
306 #ifdef MOZ_XUL |
|
307 nsXULPopupManager::Shutdown(); |
|
308 #endif |
|
309 DOMStorageObserver::Shutdown(); |
|
310 txMozillaXSLTProcessor::Shutdown(); |
|
311 Attr::Shutdown(); |
|
312 EventListenerManager::Shutdown(); |
|
313 IMEStateManager::Shutdown(); |
|
314 nsComputedDOMStyle::Shutdown(); |
|
315 nsCSSParser::Shutdown(); |
|
316 nsCSSRuleProcessor::Shutdown(); |
|
317 nsTextFrameTextRunCache::Shutdown(); |
|
318 nsHTMLDNSPrefetch::Shutdown(); |
|
319 nsCSSRendering::Shutdown(); |
|
320 #ifdef DEBUG |
|
321 nsFrame::DisplayReflowShutdown(); |
|
322 #endif |
|
323 nsCellMap::Shutdown(); |
|
324 ActiveLayerTracker::Shutdown(); |
|
325 |
|
326 // Release all of our atoms |
|
327 nsColorNames::ReleaseTable(); |
|
328 nsCSSProps::ReleaseTable(); |
|
329 nsCSSKeywords::ReleaseTable(); |
|
330 nsRepeatService::Shutdown(); |
|
331 nsStackLayout::Shutdown(); |
|
332 nsBox::Shutdown(); |
|
333 |
|
334 #ifdef MOZ_XUL |
|
335 nsXULContentUtils::Finish(); |
|
336 nsXULPrototypeCache::ReleaseGlobals(); |
|
337 nsSprocketLayout::Shutdown(); |
|
338 #endif |
|
339 |
|
340 SVGElementFactory::Shutdown(); |
|
341 nsMathMLOperators::ReleaseTable(); |
|
342 |
|
343 nsFloatManager::Shutdown(); |
|
344 nsImageFrame::ReleaseGlobals(); |
|
345 |
|
346 mozilla::css::ErrorReporter::ReleaseGlobals(); |
|
347 |
|
348 nsTextFragment::Shutdown(); |
|
349 |
|
350 nsAttrValue::Shutdown(); |
|
351 nsContentUtils::Shutdown(); |
|
352 nsLayoutStylesheetCache::Shutdown(); |
|
353 |
|
354 ShutdownJSEnvironment(); |
|
355 nsGlobalWindow::ShutDown(); |
|
356 nsDOMClassInfo::ShutDown(); |
|
357 nsListControlFrame::Shutdown(); |
|
358 nsXBLService::Shutdown(); |
|
359 nsAutoCopyListener::Shutdown(); |
|
360 FrameLayerBuilder::Shutdown(); |
|
361 |
|
362 #ifdef MOZ_MEDIA_PLUGINS |
|
363 MediaPluginHost::Shutdown(); |
|
364 #endif |
|
365 |
|
366 #ifdef MOZ_GSTREAMER |
|
367 GStreamerFormatHelper::Shutdown(); |
|
368 #endif |
|
369 |
|
370 #ifdef MOZ_FFMPEG |
|
371 FFmpegRuntimeLinker::Unlink(); |
|
372 #endif |
|
373 |
|
374 AudioStream::ShutdownLibrary(); |
|
375 AsyncLatencyLogger::ShutdownLogger(); |
|
376 WebAudioUtils::Shutdown(); |
|
377 |
|
378 #ifdef MOZ_WMF |
|
379 WMFDecoder::UnloadDLLs(); |
|
380 #endif |
|
381 |
|
382 #ifdef MOZ_WIDGET_GONK |
|
383 nsVolumeService::Shutdown(); |
|
384 SpeakerManagerService::Shutdown(); |
|
385 #endif |
|
386 |
|
387 #ifdef MOZ_WEBSPEECH |
|
388 nsSynthVoiceRegistry::Shutdown(); |
|
389 #endif |
|
390 |
|
391 nsCORSListenerProxy::Shutdown(); |
|
392 |
|
393 nsIPresShell::ReleaseStatics(); |
|
394 |
|
395 nsTreeSanitizer::ReleaseStatics(); |
|
396 |
|
397 nsHtml5Module::ReleaseStatics(); |
|
398 |
|
399 mozilla::dom::FallbackEncoding::Shutdown(); |
|
400 |
|
401 nsRegion::ShutdownStatic(); |
|
402 |
|
403 mozilla::EventDispatcher::Shutdown(); |
|
404 |
|
405 HTMLInputElement::DestroyUploadLastDir(); |
|
406 |
|
407 nsLayoutUtils::Shutdown(); |
|
408 |
|
409 nsHyphenationManager::Shutdown(); |
|
410 nsDOMMutationObserver::Shutdown(); |
|
411 |
|
412 AudioChannelService::Shutdown(); |
|
413 |
|
414 ContentParent::ShutDown(); |
|
415 |
|
416 nsRefreshDriver::Shutdown(); |
|
417 |
|
418 DisplayItemClip::Shutdown(); |
|
419 |
|
420 nsDocument::XPCOMShutdown(); |
|
421 |
|
422 CacheObserver::Shutdown(); |
|
423 } |