layout/build/nsLayoutStatics.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/build/nsLayoutStatics.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,423 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#include "base/basictypes.h"
     1.9 +
    1.10 +#include "nsLayoutStatics.h"
    1.11 +#include "nscore.h"
    1.12 +
    1.13 +#include "nsAttrValue.h"
    1.14 +#include "nsAutoCopyListener.h"
    1.15 +#include "nsColorNames.h"
    1.16 +#include "nsComputedDOMStyle.h"
    1.17 +#include "nsContentDLF.h"
    1.18 +#include "nsContentUtils.h"
    1.19 +#include "nsCSSAnonBoxes.h"
    1.20 +#include "mozilla/css/ErrorReporter.h"
    1.21 +#include "nsCSSKeywords.h"
    1.22 +#include "nsCSSParser.h"
    1.23 +#include "nsCSSProps.h"
    1.24 +#include "nsCSSPseudoClasses.h"
    1.25 +#include "nsCSSPseudoElements.h"
    1.26 +#include "nsCSSRendering.h"
    1.27 +#include "mozilla/dom/Attr.h"
    1.28 +#include "nsDOMClassInfo.h"
    1.29 +#include "nsEditorEventListener.h"
    1.30 +#include "mozilla/EventListenerManager.h"
    1.31 +#include "nsFrame.h"
    1.32 +#include "nsGlobalWindow.h"
    1.33 +#include "nsGkAtoms.h"
    1.34 +#include "nsImageFrame.h"
    1.35 +#include "nsLayoutStylesheetCache.h"
    1.36 +#include "nsNodeInfo.h"
    1.37 +#include "nsRange.h"
    1.38 +#include "nsRegion.h"
    1.39 +#include "nsRepeatService.h"
    1.40 +#include "nsFloatManager.h"
    1.41 +#include "nsSprocketLayout.h"
    1.42 +#include "nsStackLayout.h"
    1.43 +#include "nsStyleSet.h"
    1.44 +#include "nsTextControlFrame.h"
    1.45 +#include "nsXBLService.h"
    1.46 +#include "txMozillaXSLTProcessor.h"
    1.47 +#include "nsTreeSanitizer.h"
    1.48 +#include "nsCellMap.h"
    1.49 +#include "nsTextFrame.h"
    1.50 +#include "nsCCUncollectableMarker.h"
    1.51 +#include "nsTextFragment.h"
    1.52 +#include "nsCSSRuleProcessor.h"
    1.53 +#include "nsCrossSiteListenerProxy.h"
    1.54 +#include "nsHTMLDNSPrefetch.h"
    1.55 +#include "nsHtml5Module.h"
    1.56 +#include "mozilla/dom/FallbackEncoding.h"
    1.57 +#include "nsFocusManager.h"
    1.58 +#include "nsListControlFrame.h"
    1.59 +#include "mozilla/dom/HTMLInputElement.h"
    1.60 +#include "SVGElementFactory.h"
    1.61 +#include "nsSVGUtils.h"
    1.62 +#include "nsMathMLAtoms.h"
    1.63 +#include "nsMathMLOperators.h"
    1.64 +#include "Navigator.h"
    1.65 +#include "DOMStorageObserver.h"
    1.66 +#include "CacheObserver.h"
    1.67 +#include "DisplayItemClip.h"
    1.68 +#include "ActiveLayerTracker.h"
    1.69 +
    1.70 +#include "AudioChannelService.h"
    1.71 +
    1.72 +#ifdef MOZ_XUL
    1.73 +#include "nsXULPopupManager.h"
    1.74 +#include "nsXULContentUtils.h"
    1.75 +#include "nsXULPrototypeCache.h"
    1.76 +#include "nsXULTooltipListener.h"
    1.77 +
    1.78 +#include "inDOMView.h"
    1.79 +
    1.80 +#include "nsMenuBarListener.h"
    1.81 +#endif
    1.82 +
    1.83 +#include "nsHTMLEditor.h"
    1.84 +#include "nsTextServicesDocument.h"
    1.85 +
    1.86 +#ifdef MOZ_WEBSPEECH
    1.87 +#include "nsSynthVoiceRegistry.h"
    1.88 +#endif
    1.89 +
    1.90 +#ifdef MOZ_MEDIA_PLUGINS
    1.91 +#include "MediaPluginHost.h"
    1.92 +#endif
    1.93 +
    1.94 +#ifdef MOZ_WMF
    1.95 +#include "WMFDecoder.h"
    1.96 +#endif
    1.97 +
    1.98 +#ifdef MOZ_GSTREAMER
    1.99 +#include "GStreamerFormatHelper.h"
   1.100 +#endif
   1.101 +
   1.102 +#ifdef MOZ_FFMPEG
   1.103 +#include "FFmpegRuntimeLinker.h"
   1.104 +#endif
   1.105 +
   1.106 +#include "AudioStream.h"
   1.107 +#include "Latency.h"
   1.108 +#include "WebAudioUtils.h"
   1.109 +
   1.110 +#ifdef MOZ_WIDGET_GONK
   1.111 +#include "nsVolumeService.h"
   1.112 +#include "SpeakerManagerService.h"
   1.113 +using namespace mozilla::system;
   1.114 +#endif
   1.115 +
   1.116 +#include "nsError.h"
   1.117 +
   1.118 +#include "nsJSEnvironment.h"
   1.119 +#include "nsContentSink.h"
   1.120 +#include "nsFrameMessageManager.h"
   1.121 +#include "nsRefreshDriver.h"
   1.122 +#include "nsDOMMutationObserver.h"
   1.123 +#include "nsHyphenationManager.h"
   1.124 +#include "nsEditorSpellCheck.h"
   1.125 +#include "nsWindowMemoryReporter.h"
   1.126 +#include "mozilla/dom/ContentParent.h"
   1.127 +#include "mozilla/ProcessPriorityManager.h"
   1.128 +#include "nsPermissionManager.h"
   1.129 +#include "nsCookieService.h"
   1.130 +#include "nsApplicationCacheService.h"
   1.131 +#include "mozilla/dom/time/DateCacheCleaner.h"
   1.132 +#include "mozilla/EventDispatcher.h"
   1.133 +#include "mozilla/IMEStateManager.h"
   1.134 +#include "nsDocument.h"
   1.135 +#include "mozilla/dom/HTMLVideoElement.h"
   1.136 +
   1.137 +using namespace mozilla;
   1.138 +using namespace mozilla::net;
   1.139 +using namespace mozilla::dom;
   1.140 +using namespace mozilla::dom::ipc;
   1.141 +
   1.142 +nsrefcnt nsLayoutStatics::sLayoutStaticRefcnt = 0;
   1.143 +
   1.144 +nsresult
   1.145 +nsLayoutStatics::Initialize()
   1.146 +{
   1.147 +  NS_ASSERTION(sLayoutStaticRefcnt == 0,
   1.148 +               "nsLayoutStatics isn't zero!");
   1.149 +
   1.150 +  sLayoutStaticRefcnt = 1;
   1.151 +  NS_LOG_ADDREF(&sLayoutStaticRefcnt, sLayoutStaticRefcnt,
   1.152 +                "nsLayoutStatics", 1);
   1.153 +
   1.154 +  nsresult rv;
   1.155 +
   1.156 +  ContentParent::StartUp();
   1.157 +
   1.158 +  // Register all of our atoms once
   1.159 +  nsCSSAnonBoxes::AddRefAtoms();
   1.160 +  nsCSSPseudoClasses::AddRefAtoms();
   1.161 +  nsCSSPseudoElements::AddRefAtoms();
   1.162 +  nsCSSKeywords::AddRefTable();
   1.163 +  nsCSSProps::AddRefTable();
   1.164 +  nsColorNames::AddRefTable();
   1.165 +  nsGkAtoms::AddRefAtoms();
   1.166 +
   1.167 +  StartupJSEnvironment();
   1.168 +  rv = nsRegion::InitStatic();
   1.169 +  if (NS_FAILED(rv)) {
   1.170 +    NS_ERROR("Could not initialize nsRegion");
   1.171 +    return rv;
   1.172 +  }
   1.173 +
   1.174 +  nsGlobalWindow::Init();
   1.175 +  Navigator::Init();
   1.176 +  nsXBLService::Init();
   1.177 +
   1.178 +  rv = nsContentUtils::Init();
   1.179 +  if (NS_FAILED(rv)) {
   1.180 +    NS_ERROR("Could not initialize nsContentUtils");
   1.181 +    return rv;
   1.182 +  }
   1.183 +
   1.184 +  rv = nsAttrValue::Init();
   1.185 +  if (NS_FAILED(rv)) {
   1.186 +    NS_ERROR("Could not initialize nsAttrValue");
   1.187 +    return rv;
   1.188 +  }
   1.189 +
   1.190 +  rv = nsTextFragment::Init();
   1.191 +  if (NS_FAILED(rv)) {
   1.192 +    NS_ERROR("Could not initialize nsTextFragment");
   1.193 +    return rv;
   1.194 +  }
   1.195 +
   1.196 +  nsCellMap::Init();
   1.197 +
   1.198 +  nsCSSRendering::Init();
   1.199 +
   1.200 +  nsTextFrameTextRunCache::Init();
   1.201 +
   1.202 +  rv = nsHTMLDNSPrefetch::Initialize();
   1.203 +  if (NS_FAILED(rv)) {
   1.204 +    NS_ERROR("Could not initialize HTML DNS prefetch");
   1.205 +    return rv;
   1.206 +  }
   1.207 +
   1.208 +#ifdef MOZ_XUL
   1.209 +  rv = nsXULContentUtils::Init();
   1.210 +  if (NS_FAILED(rv)) {
   1.211 +    NS_ERROR("Could not initialize nsXULContentUtils");
   1.212 +    return rv;
   1.213 +  }
   1.214 +
   1.215 +#endif
   1.216 +
   1.217 +  nsMathMLOperators::AddRefTable();
   1.218 +
   1.219 +  nsEditProperty::RegisterAtoms();
   1.220 +  nsTextServicesDocument::RegisterAtoms();
   1.221 +
   1.222 +#ifdef DEBUG
   1.223 +  nsFrame::DisplayReflowStartup();
   1.224 +#endif
   1.225 +  Attr::Initialize();
   1.226 +
   1.227 +  rv = txMozillaXSLTProcessor::Startup();
   1.228 +  if (NS_FAILED(rv)) {
   1.229 +    NS_ERROR("Could not initialize txMozillaXSLTProcessor");
   1.230 +    return rv;
   1.231 +  }
   1.232 +
   1.233 +  rv = DOMStorageObserver::Init();
   1.234 +  if (NS_FAILED(rv)) {
   1.235 +    NS_ERROR("Could not initialize DOMStorageObserver");
   1.236 +    return rv;
   1.237 +  }
   1.238 +
   1.239 +  rv = nsCCUncollectableMarker::Init();
   1.240 +  if (NS_FAILED(rv)) {
   1.241 +    NS_ERROR("Could not initialize nsCCUncollectableMarker");
   1.242 +    return rv;
   1.243 +  }
   1.244 +
   1.245 +  rv = nsCSSRuleProcessor::Startup();
   1.246 +  if (NS_FAILED(rv)) {
   1.247 +    NS_ERROR("Could not initialize nsCSSRuleProcessor");
   1.248 +    return rv;
   1.249 +  }
   1.250 +
   1.251 +#ifdef MOZ_XUL
   1.252 +  rv = nsXULPopupManager::Init();
   1.253 +  if (NS_FAILED(rv)) {
   1.254 +    NS_ERROR("Could not initialize nsXULPopupManager");
   1.255 +    return rv;
   1.256 +  }
   1.257 +#endif
   1.258 +
   1.259 +  rv = nsFocusManager::Init();
   1.260 +  if (NS_FAILED(rv)) {
   1.261 +    NS_ERROR("Could not initialize nsFocusManager");
   1.262 +    return rv;
   1.263 +  }
   1.264 +
   1.265 +  AsyncLatencyLogger::InitializeStatics();
   1.266 +  AudioStream::InitLibrary();
   1.267 +
   1.268 +  nsContentSink::InitializeStatics();
   1.269 +  nsHtml5Module::InitializeStatics();
   1.270 +  mozilla::dom::FallbackEncoding::Initialize();
   1.271 +  nsLayoutUtils::Initialize();
   1.272 +  nsIPresShell::InitializeStatics();
   1.273 +  nsRefreshDriver::InitializeStatics();
   1.274 +
   1.275 +  nsCORSListenerProxy::Startup();
   1.276 +
   1.277 +  NS_SealStaticAtomTable();
   1.278 +
   1.279 +  nsWindowMemoryReporter::Init();
   1.280 +
   1.281 +  SVGElementFactory::Init();
   1.282 +  nsSVGUtils::Init();
   1.283 +
   1.284 +  ProcessPriorityManager::Init();
   1.285 +
   1.286 +  nsPermissionManager::AppClearDataObserverInit();
   1.287 +  nsCookieService::AppClearDataObserverInit();
   1.288 +  nsApplicationCacheService::AppClearDataObserverInit();
   1.289 +
   1.290 +  HTMLVideoElement::Init();
   1.291 +
   1.292 +#ifdef MOZ_XUL
   1.293 +  nsMenuBarListener::InitializeStatics();
   1.294 +#endif
   1.295 +
   1.296 +  CacheObserver::Init();
   1.297 +
   1.298 +  return NS_OK;
   1.299 +}
   1.300 +
   1.301 +void
   1.302 +nsLayoutStatics::Shutdown()
   1.303 +{
   1.304 +  // Don't need to shutdown nsWindowMemoryReporter, that will be done by the
   1.305 +  // memory reporter manager.
   1.306 +
   1.307 +  nsFrameScriptExecutor::Shutdown();
   1.308 +  nsFocusManager::Shutdown();
   1.309 +#ifdef MOZ_XUL
   1.310 +  nsXULPopupManager::Shutdown();
   1.311 +#endif
   1.312 +  DOMStorageObserver::Shutdown();
   1.313 +  txMozillaXSLTProcessor::Shutdown();
   1.314 +  Attr::Shutdown();
   1.315 +  EventListenerManager::Shutdown();
   1.316 +  IMEStateManager::Shutdown();
   1.317 +  nsComputedDOMStyle::Shutdown();
   1.318 +  nsCSSParser::Shutdown();
   1.319 +  nsCSSRuleProcessor::Shutdown();
   1.320 +  nsTextFrameTextRunCache::Shutdown();
   1.321 +  nsHTMLDNSPrefetch::Shutdown();
   1.322 +  nsCSSRendering::Shutdown();
   1.323 +#ifdef DEBUG
   1.324 +  nsFrame::DisplayReflowShutdown();
   1.325 +#endif
   1.326 +  nsCellMap::Shutdown();
   1.327 +  ActiveLayerTracker::Shutdown();
   1.328 +
   1.329 +  // Release all of our atoms
   1.330 +  nsColorNames::ReleaseTable();
   1.331 +  nsCSSProps::ReleaseTable();
   1.332 +  nsCSSKeywords::ReleaseTable();
   1.333 +  nsRepeatService::Shutdown();
   1.334 +  nsStackLayout::Shutdown();
   1.335 +  nsBox::Shutdown();
   1.336 +
   1.337 +#ifdef MOZ_XUL
   1.338 +  nsXULContentUtils::Finish();
   1.339 +  nsXULPrototypeCache::ReleaseGlobals();
   1.340 +  nsSprocketLayout::Shutdown();
   1.341 +#endif
   1.342 +
   1.343 +  SVGElementFactory::Shutdown();
   1.344 +  nsMathMLOperators::ReleaseTable();
   1.345 +
   1.346 +  nsFloatManager::Shutdown();
   1.347 +  nsImageFrame::ReleaseGlobals();
   1.348 +
   1.349 +  mozilla::css::ErrorReporter::ReleaseGlobals();
   1.350 +
   1.351 +  nsTextFragment::Shutdown();
   1.352 +
   1.353 +  nsAttrValue::Shutdown();
   1.354 +  nsContentUtils::Shutdown();
   1.355 +  nsLayoutStylesheetCache::Shutdown();
   1.356 +
   1.357 +  ShutdownJSEnvironment();
   1.358 +  nsGlobalWindow::ShutDown();
   1.359 +  nsDOMClassInfo::ShutDown();
   1.360 +  nsListControlFrame::Shutdown();
   1.361 +  nsXBLService::Shutdown();
   1.362 +  nsAutoCopyListener::Shutdown();
   1.363 +  FrameLayerBuilder::Shutdown();
   1.364 +
   1.365 +#ifdef MOZ_MEDIA_PLUGINS
   1.366 +  MediaPluginHost::Shutdown();
   1.367 +#endif
   1.368 +
   1.369 +#ifdef MOZ_GSTREAMER
   1.370 +  GStreamerFormatHelper::Shutdown();
   1.371 +#endif
   1.372 +
   1.373 +#ifdef MOZ_FFMPEG
   1.374 +  FFmpegRuntimeLinker::Unlink();
   1.375 +#endif
   1.376 +
   1.377 +  AudioStream::ShutdownLibrary();
   1.378 +  AsyncLatencyLogger::ShutdownLogger();
   1.379 +  WebAudioUtils::Shutdown();
   1.380 +
   1.381 +#ifdef MOZ_WMF
   1.382 +  WMFDecoder::UnloadDLLs();
   1.383 +#endif
   1.384 +
   1.385 +#ifdef MOZ_WIDGET_GONK
   1.386 +  nsVolumeService::Shutdown();
   1.387 +  SpeakerManagerService::Shutdown();
   1.388 +#endif
   1.389 +
   1.390 +#ifdef MOZ_WEBSPEECH
   1.391 +  nsSynthVoiceRegistry::Shutdown();
   1.392 +#endif
   1.393 +
   1.394 +  nsCORSListenerProxy::Shutdown();
   1.395 +
   1.396 +  nsIPresShell::ReleaseStatics();
   1.397 +
   1.398 +  nsTreeSanitizer::ReleaseStatics();
   1.399 +
   1.400 +  nsHtml5Module::ReleaseStatics();
   1.401 +
   1.402 +  mozilla::dom::FallbackEncoding::Shutdown();
   1.403 +
   1.404 +  nsRegion::ShutdownStatic();
   1.405 +
   1.406 +  mozilla::EventDispatcher::Shutdown();
   1.407 +
   1.408 +  HTMLInputElement::DestroyUploadLastDir();
   1.409 +
   1.410 +  nsLayoutUtils::Shutdown();
   1.411 +
   1.412 +  nsHyphenationManager::Shutdown();
   1.413 +  nsDOMMutationObserver::Shutdown();
   1.414 +
   1.415 +  AudioChannelService::Shutdown();
   1.416 +
   1.417 +  ContentParent::ShutDown();
   1.418 +
   1.419 +  nsRefreshDriver::Shutdown();
   1.420 +
   1.421 +  DisplayItemClip::Shutdown();
   1.422 +
   1.423 +  nsDocument::XPCOMShutdown();
   1.424 +
   1.425 +  CacheObserver::Shutdown();
   1.426 +}

mercurial