2017-10-27 20:33:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2006-05-19 13:31:57 +04:00
|
|
|
|
2019-02-23 09:40:57 +03:00
|
|
|
#include "nsLayoutModule.h"
|
|
|
|
|
2010-05-13 21:44:51 +04:00
|
|
|
#include "base/basictypes.h"
|
|
|
|
|
2011-10-14 21:52:47 +04:00
|
|
|
#include "XPCModule.h"
|
2019-01-24 02:45:56 +03:00
|
|
|
#include "mozilla/Components.h"
|
2010-06-10 22:11:11 +04:00
|
|
|
#include "mozilla/ModuleUtils.h"
|
2014-04-09 02:51:34 +04:00
|
|
|
#include "nsImageModule.h"
|
2006-05-19 13:31:57 +04:00
|
|
|
#include "nsLayoutStatics.h"
|
2003-01-14 10:08:59 +03:00
|
|
|
#include "nsContentCID.h"
|
|
|
|
#include "nsContentDLF.h"
|
|
|
|
#include "nsContentPolicyUtils.h"
|
2005-04-11 04:29:36 +04:00
|
|
|
#include "nsDataDocumentContentPolicy.h"
|
2006-06-26 21:57:44 +04:00
|
|
|
#include "nsNoDataProtocolContentPolicy.h"
|
2003-01-14 10:08:59 +03:00
|
|
|
#include "nsDOMCID.h"
|
2018-02-14 19:35:39 +03:00
|
|
|
#include "nsFrameMessageManager.h"
|
2003-01-14 10:08:59 +03:00
|
|
|
#include "nsHTMLContentSerializer.h"
|
2004-07-16 10:32:16 +04:00
|
|
|
#include "nsHTMLParts.h"
|
2003-01-14 10:08:59 +03:00
|
|
|
#include "nsIContentSerializer.h"
|
2011-10-15 11:33:26 +04:00
|
|
|
#include "nsIContentViewer.h"
|
2003-01-14 10:08:59 +03:00
|
|
|
#include "nsPlainTextSerializer.h"
|
|
|
|
#include "nsXMLContentSerializer.h"
|
2009-04-25 13:00:14 +04:00
|
|
|
#include "nsXHTMLContentSerializer.h"
|
2012-10-15 22:35:50 +04:00
|
|
|
#include "nsIFrameTraversal.h"
|
2003-03-15 04:04:32 +03:00
|
|
|
#include "nsLayoutCID.h"
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
#include "nsFocusManager.h"
|
2010-10-19 20:37:03 +04:00
|
|
|
#include "ThirdPartyUtil.h"
|
2015-10-23 00:02:14 +03:00
|
|
|
#include "gfxPlatform.h"
|
2016-08-04 21:33:42 +03:00
|
|
|
#include "mozilla/gfx/gfxVars.h"
|
2019-01-24 02:45:56 +03:00
|
|
|
#include "mozilla/dom/quota/QuotaManagerService.h"
|
2003-03-15 04:04:32 +03:00
|
|
|
|
2009-10-16 12:57:32 +04:00
|
|
|
#include "nsIEventListenerService.h"
|
2010-06-10 13:26:19 +04:00
|
|
|
|
2003-03-15 04:04:32 +03:00
|
|
|
// view stuff
|
2004-06-25 16:26:02 +04:00
|
|
|
#include "nsContentCreatorFunctions.h"
|
2003-01-14 10:08:59 +03:00
|
|
|
|
2018-11-29 23:47:20 +03:00
|
|
|
#include "mozilla/dom/LocalStorageCommon.h"
|
2017-05-17 08:01:14 +03:00
|
|
|
#include "mozilla/dom/LocalStorageManager.h"
|
2018-11-29 23:47:20 +03:00
|
|
|
#include "mozilla/dom/LocalStorageManager2.h"
|
2019-11-12 18:40:02 +03:00
|
|
|
#include "mozilla/dom/SessionStorageManager.h"
|
2019-01-24 02:45:56 +03:00
|
|
|
|
2015-05-21 14:40:00 +03:00
|
|
|
#ifdef MOZ_WEBSPEECH
|
2013-04-04 02:13:16 +04:00
|
|
|
# include "mozilla/dom/nsSynthVoiceRegistry.h"
|
2019-10-21 23:58:57 +03:00
|
|
|
# include "mozilla/dom/OnlineSpeechRecognitionService.h"
|
2013-03-28 01:08:21 +04:00
|
|
|
#endif
|
|
|
|
|
2016-01-14 08:19:51 +03:00
|
|
|
#include "mozilla/dom/PushNotifier.h"
|
|
|
|
using mozilla::dom::PushNotifier;
|
|
|
|
#define PUSHNOTIFIER_CID \
|
|
|
|
{ \
|
|
|
|
0x2fc2d3e3, 0x020f, 0x404e, { \
|
|
|
|
0xb0, 0x6a, 0x6e, 0xcf, 0x3e, 0xa2, 0x33, 0x4a \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
2010-04-11 17:55:24 +04:00
|
|
|
#include "nsScriptSecurityManager.h"
|
|
|
|
#include "nsNetCID.h"
|
2013-08-26 03:56:53 +04:00
|
|
|
#if defined(MOZ_WIDGET_ANDROID)
|
2010-11-22 19:38:02 +03:00
|
|
|
# include "nsHapticFeedback.h"
|
|
|
|
#endif
|
2012-02-27 15:57:48 +04:00
|
|
|
#include "nsParserUtils.h"
|
2010-04-11 17:55:24 +04:00
|
|
|
|
2003-01-14 10:08:59 +03:00
|
|
|
class nsIDocumentLoaderFactory;
|
|
|
|
|
|
|
|
#define PRODUCT_NAME "Gecko"
|
|
|
|
|
2006-05-19 22:59:39 +04:00
|
|
|
#include "inDeepTreeWalker.h"
|
2007-07-18 09:41:40 +04:00
|
|
|
|
2004-04-30 03:17:54 +04:00
|
|
|
static void Shutdown();
|
2003-10-30 05:53:08 +03:00
|
|
|
|
2015-09-18 19:27:15 +03:00
|
|
|
#include "mozilla/dom/nsContentSecurityManager.h"
|
2015-01-28 09:27:32 +03:00
|
|
|
|
2012-09-20 11:55:36 +04:00
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::dom;
|
2018-05-30 22:21:17 +03:00
|
|
|
using namespace mozilla::net;
|
2016-09-01 21:17:03 +03:00
|
|
|
|
2004-04-30 03:17:54 +04:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool gInitialized = false;
|
2000-03-21 13:34:56 +03:00
|
|
|
|
2003-01-14 10:08:59 +03:00
|
|
|
// Perform our one-time intialization for this module
|
2003-10-30 05:53:08 +03:00
|
|
|
|
2018-10-24 19:10:29 +03:00
|
|
|
void nsLayoutModuleInitialize() {
|
2003-10-30 05:53:08 +03:00
|
|
|
if (gInitialized) {
|
2016-12-03 00:46:53 +03:00
|
|
|
MOZ_CRASH("Recursive layout module initialization");
|
2016-08-25 08:06:33 +03:00
|
|
|
}
|
1999-09-28 04:44:47 +04:00
|
|
|
|
2013-07-18 21:59:53 +04:00
|
|
|
static_assert(sizeof(uintptr_t) == sizeof(void*),
|
|
|
|
"Eeek! You'll need to adjust the size of uintptr_t to the "
|
|
|
|
"size of a pointer on your platform.");
|
2006-02-07 17:34:10 +03:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
gInitialized = true;
|
2004-06-09 22:36:25 +04:00
|
|
|
|
2018-10-24 19:10:29 +03:00
|
|
|
if (NS_FAILED(xpcModuleCtor())) {
|
|
|
|
MOZ_CRASH("xpcModuleCtor failed");
|
2003-10-30 05:53:08 +03:00
|
|
|
}
|
2005-11-02 22:03:06 +03:00
|
|
|
|
2018-10-24 19:10:29 +03:00
|
|
|
if (NS_FAILED(nsLayoutStatics::Initialize())) {
|
|
|
|
Shutdown();
|
|
|
|
MOZ_CRASH("nsLayoutStatics::Initialize failed");
|
|
|
|
}
|
1999-09-28 04:44:47 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Shutdown this module, releasing all of the module resources
|
2003-10-30 05:53:08 +03:00
|
|
|
|
|
|
|
// static
|
2004-04-30 03:17:54 +04:00
|
|
|
void Shutdown() {
|
2018-04-28 22:50:58 +03:00
|
|
|
MOZ_ASSERT(gInitialized, "module not initialized");
|
2003-10-30 05:53:08 +03:00
|
|
|
if (!gInitialized) return;
|
2001-08-07 06:55:54 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
gInitialized = false;
|
2000-11-08 06:22:03 +03:00
|
|
|
|
2006-05-19 13:31:57 +04:00
|
|
|
nsLayoutStatics::Release();
|
1999-09-28 04:44:47 +04:00
|
|
|
}
|
|
|
|
|
2012-10-15 22:35:50 +04:00
|
|
|
nsresult NS_CreateFrameTraversal(nsIFrameTraversal** aResult);
|
|
|
|
|
2014-02-09 12:04:40 +04:00
|
|
|
already_AddRefed<nsIContentViewer> NS_NewContentViewer();
|
2003-03-05 18:08:41 +03:00
|
|
|
nsresult NS_NewContentDocumentLoaderFactory(nsIDocumentLoaderFactory** aResult);
|
|
|
|
nsresult NS_NewContentPolicy(nsIContentPolicy** aResult);
|
2003-01-14 10:08:59 +03:00
|
|
|
|
2009-10-16 12:57:32 +04:00
|
|
|
nsresult NS_NewEventListenerService(nsIEventListenerService** aResult);
|
2018-02-14 19:35:39 +03:00
|
|
|
nsresult NS_NewGlobalMessageManager(nsISupports** aResult);
|
|
|
|
nsresult NS_NewParentProcessMessageManager(nsISupports** aResult);
|
2018-02-16 12:34:21 +03:00
|
|
|
nsresult NS_NewChildProcessMessageManager(nsISupports** aResult);
|
2009-10-16 12:57:32 +04:00
|
|
|
|
2019-01-24 02:45:56 +03:00
|
|
|
#define MAKE_CTOR(ctor_, iface_, func_) \
|
|
|
|
nsresult ctor_(nsISupports* aOuter, REFNSIID aIID, void** aResult) { \
|
|
|
|
*aResult = nullptr; \
|
|
|
|
if (aOuter) return NS_ERROR_NO_AGGREGATION; \
|
|
|
|
iface_* inst; \
|
|
|
|
nsresult rv = func_(&inst); \
|
|
|
|
if (NS_SUCCEEDED(rv)) { \
|
|
|
|
rv = inst->QueryInterface(aIID, aResult); \
|
|
|
|
NS_RELEASE(inst); \
|
|
|
|
} \
|
|
|
|
return rv; \
|
1999-09-28 04:44:47 +04:00
|
|
|
}
|
2003-01-14 10:08:59 +03:00
|
|
|
|
2019-01-24 02:45:56 +03:00
|
|
|
#define MAKE_GENERIC_CTOR(iface_, func_) \
|
|
|
|
NS_IMPL_COMPONENT_FACTORY(iface_) { \
|
|
|
|
nsCOMPtr<iface_> inst; \
|
|
|
|
if (NS_SUCCEEDED(func_(getter_AddRefs(inst)))) { \
|
|
|
|
return inst.forget(); \
|
|
|
|
} \
|
|
|
|
return nullptr; \
|
2012-06-04 21:42:00 +04:00
|
|
|
}
|
|
|
|
|
2019-01-24 02:45:56 +03:00
|
|
|
#define MAKE_GENERIC_CTOR2(iface_, func_) \
|
|
|
|
NS_IMPL_COMPONENT_FACTORY(iface_) { return func_(); }
|
|
|
|
|
|
|
|
MAKE_GENERIC_CTOR(nsIFrameTraversal, NS_CreateFrameTraversal)
|
2006-05-19 22:59:39 +04:00
|
|
|
|
2019-01-24 02:45:56 +03:00
|
|
|
MAKE_GENERIC_CTOR2(nsIContentViewer, NS_NewContentViewer)
|
2006-05-19 22:59:39 +04:00
|
|
|
|
2003-01-14 10:08:59 +03:00
|
|
|
MAKE_CTOR(CreateXMLContentSerializer, nsIContentSerializer,
|
|
|
|
NS_NewXMLContentSerializer)
|
|
|
|
MAKE_CTOR(CreateHTMLContentSerializer, nsIContentSerializer,
|
|
|
|
NS_NewHTMLContentSerializer)
|
2009-04-25 13:00:14 +04:00
|
|
|
MAKE_CTOR(CreateXHTMLContentSerializer, nsIContentSerializer,
|
|
|
|
NS_NewXHTMLContentSerializer)
|
2003-01-14 10:08:59 +03:00
|
|
|
MAKE_CTOR(CreatePlainTextSerializer, nsIContentSerializer,
|
|
|
|
NS_NewPlainTextSerializer)
|
|
|
|
MAKE_CTOR(CreateContentPolicy, nsIContentPolicy, NS_NewContentPolicy)
|
2019-01-24 02:45:56 +03:00
|
|
|
|
|
|
|
MAKE_GENERIC_CTOR(nsIDocumentLoaderFactory, NS_NewContentDocumentLoaderFactory)
|
|
|
|
MAKE_GENERIC_CTOR(nsIEventListenerService, NS_NewEventListenerService)
|
2018-02-14 19:35:39 +03:00
|
|
|
MAKE_CTOR(CreateGlobalMessageManager, nsISupports, NS_NewGlobalMessageManager)
|
|
|
|
MAKE_CTOR(CreateParentMessageManager, nsISupports,
|
|
|
|
NS_NewParentProcessMessageManager)
|
2018-02-16 12:34:21 +03:00
|
|
|
MAKE_CTOR(CreateChildMessageManager, nsISupports,
|
|
|
|
NS_NewChildProcessMessageManager)
|
2005-01-15 03:10:19 +03:00
|
|
|
|
2019-01-24 02:45:56 +03:00
|
|
|
MAKE_GENERIC_CTOR(nsIFocusManager, NS_NewFocusManager)
|
2008-11-19 01:54:36 +03:00
|
|
|
|
2003-03-15 04:04:32 +03:00
|
|
|
// views are not refcounted, so this is the same as
|
|
|
|
// NS_GENERIC_FACTORY_CONSTRUCTOR without the NS_ADDREF/NS_RELEASE
|
|
|
|
#define NS_GENERIC_FACTORY_CONSTRUCTOR_NOREFS(_InstanceClass) \
|
|
|
|
static nsresult _InstanceClass##Constructor(nsISupports* aOuter, \
|
|
|
|
REFNSIID aIID, void** aResult) { \
|
|
|
|
nsresult rv; \
|
|
|
|
\
|
2013-10-08 22:47:21 +04:00
|
|
|
*aResult = nullptr; \
|
|
|
|
if (nullptr != aOuter) { \
|
2003-03-15 04:04:32 +03:00
|
|
|
rv = NS_ERROR_NO_AGGREGATION; \
|
|
|
|
return rv; \
|
|
|
|
} \
|
|
|
|
\
|
2010-07-05 13:42:18 +04:00
|
|
|
_InstanceClass* inst = new _InstanceClass(); \
|
2013-10-08 22:47:21 +04:00
|
|
|
if (nullptr == inst) { \
|
2003-03-15 04:04:32 +03:00
|
|
|
rv = NS_ERROR_OUT_OF_MEMORY; \
|
|
|
|
return rv; \
|
|
|
|
} \
|
|
|
|
rv = inst->QueryInterface(aIID, aResult); \
|
|
|
|
\
|
|
|
|
return rv; \
|
|
|
|
}
|
|
|
|
|
2013-03-31 02:29:47 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
2016-08-08 18:35:56 +03:00
|
|
|
# include "xpcAccessibilityService.h"
|
2013-03-31 02:29:47 +04:00
|
|
|
|
2019-01-24 02:45:56 +03:00
|
|
|
MAKE_GENERIC_CTOR(nsIAccessibilityService, NS_GetAccessibilityService)
|
2013-03-31 02:29:47 +04:00
|
|
|
#endif
|
|
|
|
|
2019-01-24 02:45:56 +03:00
|
|
|
nsresult Construct_nsIScriptSecurityManager(nsISupports* aOuter, REFNSIID aIID,
|
|
|
|
void** aResult) {
|
2010-04-11 17:55:24 +04:00
|
|
|
if (!aResult) return NS_ERROR_NULL_POINTER;
|
2012-07-30 18:20:58 +04:00
|
|
|
*aResult = nullptr;
|
2010-04-11 17:55:24 +04:00
|
|
|
if (aOuter) return NS_ERROR_NO_AGGREGATION;
|
|
|
|
nsScriptSecurityManager* obj =
|
|
|
|
nsScriptSecurityManager::GetScriptSecurityManager();
|
|
|
|
if (!obj) return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
if (NS_FAILED(obj->QueryInterface(aIID, aResult))) return NS_ERROR_FAILURE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2019-01-24 02:45:56 +03:00
|
|
|
nsresult LocalStorageManagerConstructor(nsISupports* aOuter, REFNSIID aIID,
|
|
|
|
void** aResult) {
|
2018-11-29 23:47:20 +03:00
|
|
|
if (NextGenLocalStorageEnabled()) {
|
|
|
|
RefPtr<LocalStorageManager2> manager = new LocalStorageManager2();
|
|
|
|
return manager->QueryInterface(aIID, aResult);
|
|
|
|
}
|
|
|
|
|
|
|
|
RefPtr<LocalStorageManager> manager = new LocalStorageManager();
|
|
|
|
return manager->QueryInterface(aIID, aResult);
|
|
|
|
}
|
|
|
|
|
2019-11-12 18:40:02 +03:00
|
|
|
nsresult SessionStorageManagerConstructor(nsISupports* aOuter, REFNSIID aIID,
|
|
|
|
void** aResult) {
|
2019-12-10 15:12:32 +03:00
|
|
|
RefPtr<SessionStorageManager> manager = new SessionStorageManager(nullptr);
|
2019-11-12 18:40:02 +03:00
|
|
|
return manager->QueryInterface(aIID, aResult);
|
|
|
|
}
|
|
|
|
|
2019-01-29 11:03:06 +03:00
|
|
|
static const mozilla::Module::CategoryEntry kLayoutCategories[] = {
|
2019-01-24 02:45:56 +03:00
|
|
|
// clang-format off
|
|
|
|
{nullptr}
|
2018-10-12 23:48:24 +03:00
|
|
|
// clang-format on
|
2010-04-11 17:55:24 +04:00
|
|
|
};
|
|
|
|
|
2019-01-24 02:45:56 +03:00
|
|
|
void nsLayoutModuleDtor() {
|
|
|
|
if (XRE_GetProcessType() == GeckoProcessType_GPU ||
|
|
|
|
XRE_GetProcessType() == GeckoProcessType_VR ||
|
|
|
|
XRE_GetProcessType() == GeckoProcessType_RDD) {
|
|
|
|
return;
|
|
|
|
}
|
2018-10-24 19:10:29 +03:00
|
|
|
|
2014-04-09 02:51:33 +04:00
|
|
|
Shutdown();
|
|
|
|
nsContentUtils::XPCOMShutdown();
|
2014-04-09 02:51:33 +04:00
|
|
|
|
2014-04-09 02:51:34 +04:00
|
|
|
// Layout depends heavily on gfx and imagelib, so we want to make sure that
|
|
|
|
// these modules are shut down after all the layout cleanup runs.
|
|
|
|
mozilla::image::ShutdownModule();
|
2014-04-09 02:51:33 +04:00
|
|
|
gfxPlatform::Shutdown();
|
2016-08-04 21:33:42 +03:00
|
|
|
gfx::gfxVars::Shutdown();
|
2014-04-13 21:15:29 +04:00
|
|
|
|
|
|
|
nsScriptSecurityManager::Shutdown();
|
|
|
|
xpcModuleDtor();
|
2010-04-11 17:55:24 +04:00
|
|
|
}
|
|
|
|
|
2019-04-05 05:30:56 +03:00
|
|
|
extern const mozilla::Module kLayoutModule = {mozilla::Module::kVersion,
|
2019-01-24 02:45:56 +03:00
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
kLayoutCategories,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
nullptr};
|