Files
palemoon27/layout/build/nsLayoutStatics.cpp
roytam1 f632bc6ab3 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1267186 - Split lookup of WebIDL DOM class names from lookup of DOMCI DOM class names. r=bz. (1cb4c3698e)
- Bug 1206637: P1. Add MediaPrefs convenience class. r=cpearce (d352b9ca0b)
- Bug 1254378 - Make new 'speech-synth-started' component service category. r=smaug (ece851540b)
- Bug 1206637: P2. Replace all cached preferences with MediaPrefs ones. r=cpearce (1492083f62)
- Bug 1216407 - Use mozilla/Endian.h for NfcService. r=yoshi (b2a508186d)
- Bug 1237493 - [NFC] Separate Gecko and Gonk layers for accessing Androids properties. r=yoshi (062e468bed)
- Bug 1272135, part 1 - Fix leading tab usage in ipc/chromium. r=billm (cf29df6977)
- Bug 1272135, part 2 - Delete two weird modelines in ipc/chromium. r=billm (da4cdafc7c)
- Bug 1272135, part 3 - Fix mode lines in ipc/chromium/. r=billm (040b11738e)
- Bug 1273307 - Remove copy constructor/assignment operator for Message/Pickle (r=froydnj) (b53e6d3470)
- Bug 1262671 - Remove unused TrimWriteData (r=froydnj) (8fbcefde63)
- Bug 1267438 - Group ScrollMetadata's optional clip rect and mask layer index into a LayerClip structure. r=mstange (dcd01e3bce)
- Bug 1267438 - Use IntersectMaybeRects() in Layer::GetCombinedClipRect(). r=mstange (5ec2d68aac)
- Bug 1262937 - part 1 - don't include the protocol name in Clone error messages; r=jld (3e23610fb1)
- Bug 1191452 - Limit IPDL-generated Move()s to Recv methods. r=billm (991cc733b6)
- Bug 1262937 - part 2 - don't include the message name when complaining about handler failure; r=jld (b8abbc5c8b)
- Bug 1262937 - part 3 - move quoting out of checkedRead; r=jld (16d36ae02a)
- Bug 1262937 - part 4 - publically inherit from MessageListener in IProtocol; r=jld (b89aaa7347)
- Bug 1262937 - part 5 - factor out actor reading code to a common base class; r=jld (702388bce7)
- Bug 1262937 - part 7 - factor out union type deserialization errors; r=jld (dcdf428efc)
- Bug 1262937 - part 6 - enable custom error message for ipdl.py's checkedRead; r=jld (5cf11d5d24)
- Bug 1262937 - part 8 - factor out array length deserialization errors; r=jld (d1149cc120)
- Bug 1271601: If a child process fails to duplicate a TransportDescriptor pipe handle then send it anyway and get the target to duplicate. r=gabor (d578cd0c85)
- Bug 1270247 - Crash in ParamTraits<mozilla::net::NetAddr>::Write if the family is unknown. r=hurley (3ed49495c0)
- Bug 1267474 - cache-control: immutable tests 3/3 r=mayhemer (ba0bc6e71a)
- bug 1188100 - fold PSM's test_client_cert.js into necko's test_tls_server.js r=mcmanus (a2b93abbbb)
- Bug 669259 - Expose original header received from a peer. r=mcmanus (cf53cad7ac)
- Bug 386743 - Set default event bubbling/cancelable flags in the WidgetEvent constructor. r=smaug (1c68cfffd2)
- Bug 1259661 part.1 Rename WidgetMouseEvent::reasonType to WidgetMouseEvent::Reason r=smaug (0edd107b56)
- Bug 1259661 part.2 Rename WidgetMouseEvent::context to WidgetMouseEvent::ContextMenuTrigger r=smaug (0049757099)
- Bug 1259661 part.3 Rename WidgetMouseEvent::exitType to WidgetMouseEvent::ExitFrom r=smaug (5ffd3f41b1)
- Bug 1259661 part.4 Rename WidgetMouseEvent::reason to WidgetMouseEvent::mReason r=smaug (5605ce8fd0)
- Bug 1259661 part.5 Rename WidgetMouseEvent::context to WidgetMouseEvent::mContextMenuTrigger r=smaug (4dd92f0066)
- Bug 1259661 part.6 Rename WidgetMouseEvent::exit to WidgetMouseEvent::mExitFrom r=smaug (c46f5fe1bc)
- Bug 1259661 part.7 Get rid of WidgetMouseEvent::acceptActivation because of unused r=smaug (4867aaf1a7)
- Bug 1259661 part.8 Rename WidgetMouseEvent::ignoreRootScrollFrame to WidgetMouseEvent::mIgnoreRootScrollFrame r=smaug (c829c446fd)
- Bug 1259661 part.9 Rename WidgetMouseEvent::clickCount to WidgetMouseEvent::mClickCount r=smaug (2fa015c006)
- Bug 1259661 part.10 Clean up some nits of WidgetMouseEvent definition r=smaug (58d3a0cb2c)
- Bug 1179346 - Add strings and accesskeys for Microsoft Edge. r=mak (b97f5e7ab4)
- Bug 931445 part 1 - Remove unused code from pointerlock_utils.js. r=smaug (e1b9c15569)
- Bug 931445 part 2 - Use util code from fullscreen tests to improve robustness of pointerlock tests. r=smaug (3c7b47751e)
- Bug 931445 part 3 - Reset synth centering pointer when unlocking pointer. r=smaug (e272fec9c7)
- Bug 1263389 NativeKey should initialize WidgetKeyboardEvent::mKeyValue of WM_KEYDOWN of VK_PACKET with following char message r=m_kato (e56a31bd4b)
- Bug 1261880 NativeKey should decide printable KeyboardEvent.key value of keydown and keypress events with following WM_CHAR message of WM_KEYDOWN r=m_kato (7208001852)
- Bug 1254755 part.1 Rename WidgetKeyboardEvent::keyCode to WidgetKeyboardEvent::mKeyCode r=smaug (97ebefa314)
- put back some XP/2003 code, as well as crash/debug (73b3147e58)
- Bug 1259679 - Space key shouldn't work as a space key if it's assigned to a function key. r=masayuki (db422c248b)
- Bug 1101975, handle access keys in content process before menus, r=masayuki (760213b62e)
- Bug 1254755 part.2 Rename WidgetKeyboardEvent::charCode to WidgetKeyboardEvent::mCharCode r=smaug (6cef6114a5)
- Bug 1254755 part.3 Rename WidgetKeyboardEvent::alternativeCharCodes to WidgetKeyboardEvent::mAlternativeCharCodes r=smaug (9d23a113fd)
- Bug 1254755 part.4 Rename WidgetKeyboardEvent::location to WidgetKeyboardEvent::mLocation r=smaug (f44e0212a6)
- Bug 1254755 part.5 Rename WidgetKeyboardEvent::isChar to WidgetKeyboardEvent::mIsChar r=smaug (a713d9903c)
- Bug 1254755 part.6 Reorder the members of WidgetKeyboardEvent for reducing its instance size r=smaug (39a14a7d4f)
- Bug 1262671 - void** -> PickleIterator (r=froydnj) (716a88b499)
2024-10-08 21:42:19 +08:00

466 lines
10 KiB
C++

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "base/basictypes.h"
#include "nsLayoutStatics.h"
#include "nscore.h"
#include "nsAttrValue.h"
#include "nsAutoCopyListener.h"
#include "nsColorNames.h"
#include "nsComputedDOMStyle.h"
#include "nsContentDLF.h"
#include "nsContentUtils.h"
#include "nsCSSAnonBoxes.h"
#include "mozilla/css/ErrorReporter.h"
#include "nsCSSKeywords.h"
#include "nsCSSParser.h"
#include "nsCSSProps.h"
#include "nsCSSPseudoClasses.h"
#include "nsCSSPseudoElements.h"
#include "nsCSSRendering.h"
#include "mozilla/dom/Attr.h"
#include "nsDOMClassInfo.h"
#include "nsEditorEventListener.h"
#include "mozilla/EventListenerManager.h"
#include "nsFrame.h"
#include "nsGlobalWindow.h"
#include "nsGkAtoms.h"
#include "nsImageFrame.h"
#include "nsLayoutStylesheetCache.h"
#include "mozilla/RuleProcessorCache.h"
#include "nsPrincipal.h"
#include "nsRange.h"
#include "nsRegion.h"
#include "nsRepeatService.h"
#include "nsFloatManager.h"
#include "nsSprocketLayout.h"
#include "nsStackLayout.h"
#include "nsStyleSet.h"
#include "nsTextControlFrame.h"
#include "nsXBLService.h"
#include "txMozillaXSLTProcessor.h"
#include "nsTreeSanitizer.h"
#include "nsCellMap.h"
#include "nsTextFrame.h"
#include "nsCCUncollectableMarker.h"
#include "nsTextFragment.h"
#include "nsCSSRuleProcessor.h"
#include "nsCORSListenerProxy.h"
#include "nsHTMLDNSPrefetch.h"
#include "nsHtml5Module.h"
#include "mozilla/dom/FallbackEncoding.h"
#include "nsFocusManager.h"
#include "nsListControlFrame.h"
#include "mozilla/dom/HTMLInputElement.h"
#include "SVGElementFactory.h"
#include "nsSVGUtils.h"
#include "nsMathMLAtoms.h"
#include "nsMathMLOperators.h"
#include "Navigator.h"
#include "DOMStorageObserver.h"
#include "CacheObserver.h"
#include "DisplayItemClip.h"
#include "ActiveLayerTracker.h"
#include "CounterStyleManager.h"
#include "FrameLayerBuilder.h"
#include "mozilla/dom/RequestSyncWifiService.h"
#include "AnimationCommon.h"
#include "LayerAnimationInfo.h"
#include "AudioChannelService.h"
#include "mozilla/dom/PromiseDebugging.h"
#include "mozilla/dom/WebCryptoThreadPool.h"
#ifdef MOZ_XUL
#include "nsXULPopupManager.h"
#include "nsXULContentUtils.h"
#include "nsXULPrototypeCache.h"
#include "nsXULTooltipListener.h"
#include "inDOMView.h"
#include "nsMenuBarListener.h"
#endif
#include "nsHTMLEditor.h"
#include "nsTextServicesDocument.h"
#ifdef MOZ_WEBSPEECH
#include "nsSynthVoiceRegistry.h"
#endif
#ifdef MOZ_ANDROID_OMX
#include "AndroidMediaPluginHost.h"
#endif
#ifdef MOZ_FFMPEG
#include "FFmpegRuntimeLinker.h"
#endif
#include "CubebUtils.h"
#include "Latency.h"
#include "WebAudioUtils.h"
#ifdef MOZ_WIDGET_GONK
#include "nsVolumeService.h"
using namespace mozilla::system;
#endif
#include "nsError.h"
#include "nsJSEnvironment.h"
#include "nsContentSink.h"
#include "nsFrameMessageManager.h"
#include "nsRefreshDriver.h"
#include "nsDOMMutationObserver.h"
#include "nsHyphenationManager.h"
#include "nsEditorSpellCheck.h"
#include "nsWindowMemoryReporter.h"
#include "mozilla/dom/ContentParent.h"
#include "mozilla/ProcessPriorityManager.h"
#include "nsPermissionManager.h"
#include "nsCookieService.h"
#include "nsApplicationCacheService.h"
#include "mozilla/dom/time/DateCacheCleaner.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/IMEStateManager.h"
#include "nsDocument.h"
#include "mozilla/dom/HTMLVideoElement.h"
#include "CameraPreferences.h"
#include "TouchManager.h"
#include "MediaDecoder.h"
#include "MediaPrefs.h"
#include "mozilla/layers/CompositorLRU.h"
#include "mozilla/dom/devicestorage/DeviceStorageStatics.h"
#include "mozilla/ServoBindings.h"
#include "mozilla/StaticPresData.h"
#include "mozilla/dom/WebIDLGlobalNameHash.h"
#ifdef MOZ_B2G_BT
#include "mozilla/dom/BluetoothUUID.h"
#endif
using namespace mozilla;
using namespace mozilla::net;
using namespace mozilla::dom;
using namespace mozilla::dom::ipc;
nsrefcnt nsLayoutStatics::sLayoutStaticRefcnt = 0;
nsresult
nsLayoutStatics::Initialize()
{
NS_ASSERTION(sLayoutStaticRefcnt == 0,
"nsLayoutStatics isn't zero!");
sLayoutStaticRefcnt = 1;
NS_LOG_ADDREF(&sLayoutStaticRefcnt, sLayoutStaticRefcnt,
"nsLayoutStatics", 1);
nsresult rv;
ContentParent::StartUp();
// Register all of our atoms once
nsCSSAnonBoxes::AddRefAtoms();
nsCSSPseudoClasses::AddRefAtoms();
nsCSSPseudoElements::AddRefAtoms();
nsCSSKeywords::AddRefTable();
nsCSSProps::AddRefTable();
nsColorNames::AddRefTable();
nsGkAtoms::AddRefAtoms();
StartupJSEnvironment();
rv = nsRegion::InitStatic();
if (NS_FAILED(rv)) {
NS_ERROR("Could not initialize nsRegion");
return rv;
}
nsGlobalWindow::Init();
Navigator::Init();
nsXBLService::Init();
rv = nsContentUtils::Init();
if (NS_FAILED(rv)) {
NS_ERROR("Could not initialize nsContentUtils");
return rv;
}
rv = nsAttrValue::Init();
if (NS_FAILED(rv)) {
NS_ERROR("Could not initialize nsAttrValue");
return rv;
}
rv = nsTextFragment::Init();
if (NS_FAILED(rv)) {
NS_ERROR("Could not initialize nsTextFragment");
return rv;
}
nsCellMap::Init();
StaticPresData::Init();
nsCSSRendering::Init();
rv = nsHTMLDNSPrefetch::Initialize();
if (NS_FAILED(rv)) {
NS_ERROR("Could not initialize HTML DNS prefetch");
return rv;
}
#ifdef MOZ_XUL
rv = nsXULContentUtils::Init();
if (NS_FAILED(rv)) {
NS_ERROR("Could not initialize nsXULContentUtils");
return rv;
}
#endif
nsMathMLOperators::AddRefTable();
nsTextServicesDocument::RegisterAtoms();
#ifdef DEBUG
nsFrame::DisplayReflowStartup();
#endif
Attr::Initialize();
rv = txMozillaXSLTProcessor::Startup();
if (NS_FAILED(rv)) {
NS_ERROR("Could not initialize txMozillaXSLTProcessor");
return rv;
}
rv = DOMStorageObserver::Init();
if (NS_FAILED(rv)) {
NS_ERROR("Could not initialize DOMStorageObserver");
return rv;
}
rv = nsCCUncollectableMarker::Init();
if (NS_FAILED(rv)) {
NS_ERROR("Could not initialize nsCCUncollectableMarker");
return rv;
}
nsCSSParser::Startup();
nsCSSRuleProcessor::Startup();
#ifdef MOZ_XUL
rv = nsXULPopupManager::Init();
if (NS_FAILED(rv)) {
NS_ERROR("Could not initialize nsXULPopupManager");
return rv;
}
#endif
rv = nsFocusManager::Init();
if (NS_FAILED(rv)) {
NS_ERROR("Could not initialize nsFocusManager");
return rv;
}
AsyncLatencyLogger::InitializeStatics();
MediaManager::StartupInit();
CubebUtils::InitLibrary();
nsContentSink::InitializeStatics();
nsHtml5Module::InitializeStatics();
mozilla::dom::FallbackEncoding::Initialize();
nsLayoutUtils::Initialize();
nsIPresShell::InitializeStatics();
TouchManager::InitializeStatics();
nsRefreshDriver::InitializeStatics();
nsPrincipal::InitializeStatics();
nsCORSListenerProxy::Startup();
NS_SealStaticAtomTable();
nsWindowMemoryReporter::Init();
SVGElementFactory::Init();
nsSVGUtils::Init();
ProcessPriorityManager::Init();
nsPermissionManager::AppClearDataObserverInit();
nsCookieService::AppClearDataObserverInit();
nsApplicationCacheService::AppClearDataObserverInit();
HTMLVideoElement::Init();
#ifdef MOZ_XUL
nsMenuBarListener::InitializeStatics();
#endif
CacheObserver::Init();
CounterStyleManager::InitializeBuiltinCounterStyles();
CameraPreferences::Initialize();
IMEStateManager::Init();
ServiceWorkerRegistrar::Initialize();
#ifdef MOZ_B2G
RequestSyncWifiService::Init();
#endif
#ifdef DEBUG
nsStyleContext::Initialize();
mozilla::LayerAnimationInfo::Initialize();
#endif
MediaDecoder::InitStatics();
MediaPrefs::GetSingleton();
PromiseDebugging::Init();
layers::CompositorLRU::Init();
mozilla::dom::devicestorage::DeviceStorageStatics::Initialize();
mozilla::dom::WebCryptoThreadPool::Initialize();
#ifdef MOZ_STYLO
Servo_Initialize();
#endif
return NS_OK;
}
void
nsLayoutStatics::Shutdown()
{
// Don't need to shutdown nsWindowMemoryReporter, that will be done by the
// memory reporter manager.
nsMessageManagerScriptExecutor::Shutdown();
nsFocusManager::Shutdown();
#ifdef MOZ_XUL
nsXULPopupManager::Shutdown();
#endif
DOMStorageObserver::Shutdown();
txMozillaXSLTProcessor::Shutdown();
Attr::Shutdown();
EventListenerManager::Shutdown();
IMEStateManager::Shutdown();
nsCSSParser::Shutdown();
nsCSSRuleProcessor::Shutdown();
nsHTMLDNSPrefetch::Shutdown();
nsCSSRendering::Shutdown();
StaticPresData::Shutdown();
#ifdef DEBUG
nsFrame::DisplayReflowShutdown();
#endif
nsCellMap::Shutdown();
ActiveLayerTracker::Shutdown();
// Release all of our atoms
nsColorNames::ReleaseTable();
nsCSSProps::ReleaseTable();
nsCSSKeywords::ReleaseTable();
nsRepeatService::Shutdown();
nsStackLayout::Shutdown();
nsBox::Shutdown();
#ifdef MOZ_XUL
nsXULContentUtils::Finish();
nsXULPrototypeCache::ReleaseGlobals();
nsSprocketLayout::Shutdown();
#endif
SVGElementFactory::Shutdown();
nsMathMLOperators::ReleaseTable();
nsFloatManager::Shutdown();
nsImageFrame::ReleaseGlobals();
mozilla::css::ErrorReporter::ReleaseGlobals();
nsTextFragment::Shutdown();
nsAttrValue::Shutdown();
nsContentUtils::Shutdown();
nsLayoutStylesheetCache::Shutdown();
RuleProcessorCache::Shutdown();
ShutdownJSEnvironment();
nsGlobalWindow::ShutDown();
nsDOMClassInfo::ShutDown();
WebIDLGlobalNameHash::Shutdown();
nsListControlFrame::Shutdown();
nsXBLService::Shutdown();
nsAutoCopyListener::Shutdown();
FrameLayerBuilder::Shutdown();
#ifdef MOZ_ANDROID_OMX
AndroidMediaPluginHost::Shutdown();
#endif
#ifdef MOZ_FFMPEG
FFmpegRuntimeLinker::Unlink();
#endif
CubebUtils::ShutdownLibrary();
AsyncLatencyLogger::ShutdownLogger();
WebAudioUtils::Shutdown();
#ifdef MOZ_WIDGET_GONK
nsVolumeService::Shutdown();
#endif
#ifdef MOZ_WEBSPEECH
nsSynthVoiceRegistry::Shutdown();
#endif
nsCORSListenerProxy::Shutdown();
nsIPresShell::ReleaseStatics();
TouchManager::ReleaseStatics();
nsTreeSanitizer::ReleaseStatics();
nsHtml5Module::ReleaseStatics();
mozilla::dom::FallbackEncoding::Shutdown();
nsRegion::ShutdownStatic();
mozilla::EventDispatcher::Shutdown();
HTMLInputElement::DestroyUploadLastDir();
nsLayoutUtils::Shutdown();
nsHyphenationManager::Shutdown();
nsDOMMutationObserver::Shutdown();
ContentParent::ShutDown();
nsRefreshDriver::Shutdown();
DisplayItemClip::Shutdown();
nsDocument::XPCOMShutdown();
CacheObserver::Shutdown();
CameraPreferences::Shutdown();
PromiseDebugging::Shutdown();
#ifdef MOZ_B2G_BT
BluetoothUUID::HandleShutdown();
#endif
}