diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /layout/build | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'layout/build')
-rw-r--r-- | layout/build/moz.build | 101 | ||||
-rw-r--r-- | layout/build/nsContentDLF.cpp | 425 | ||||
-rw-r--r-- | layout/build/nsContentDLF.h | 93 | ||||
-rw-r--r-- | layout/build/nsLayoutCID.h | 88 | ||||
-rw-r--r-- | layout/build/nsLayoutModule.cpp | 1275 | ||||
-rw-r--r-- | layout/build/nsLayoutStatics.cpp | 438 | ||||
-rw-r--r-- | layout/build/nsLayoutStatics.h | 71 |
7 files changed, 2491 insertions, 0 deletions
diff --git a/layout/build/moz.build b/layout/build/moz.build new file mode 100644 index 000000000..a628f3ee2 --- /dev/null +++ b/layout/build/moz.build @@ -0,0 +1,101 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# 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/. + +EXPORTS += [ + 'nsContentDLF.h', + 'nsLayoutCID.h', + 'nsLayoutStatics.h', +] + +UNIFIED_SOURCES += [ + 'nsContentDLF.cpp', + 'nsLayoutModule.cpp', + 'nsLayoutStatics.cpp', +] + +include('/ipc/chromium/chromium-config.mozbuild') + +LOCAL_INCLUDES += [ + '../base', + '../forms', + '../generic', + '../inspector', + '../mathml', + '../style', + '../tables', + '../xul', + '/caps', + '/docshell/base', + '/dom/audiochannel', + '/dom/base', + '/dom/canvas', + '/dom/filesystem', + '/dom/geolocation', + '/dom/html', + '/dom/json', + '/dom/jsurl', + '/dom/media', + '/dom/offline', + '/dom/speakermanager', + '/dom/storage', + '/dom/svg', + '/dom/xbl', + '/dom/xslt/base', + '/dom/xslt/xml', + '/dom/xslt/xpath', + '/dom/xslt/xslt', + '/dom/xul', + '/dom/xul/templates', + '/editor/composer', + '/editor/txmgr', + '/editor/txtsvc', + '/extensions/cookie', + '/js/xpconnect/loader', + '/js/xpconnect/src', + '/netwerk/base', + '/netwerk/cookie', + '/view', +] + +if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': + LOCAL_INCLUDES += [ + '/dom/system/windows', + ] +elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': + LOCAL_INCLUDES += [ + '/dom/system/mac', + ] +elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android': + LOCAL_INCLUDES += [ + '/dom/system', + '/dom/system/android', + ] +elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk': + LOCAL_INCLUDES += [ + '/dom/system/gonk', + ] + +if CONFIG['MOZ_WEBSPEECH']: + LOCAL_INCLUDES += [ + '/dom/media/webspeech/recognition', + '/dom/media/webspeech/synth', + ] + +if CONFIG['MOZ_WEBSPEECH_POCKETSPHINX']: + LOCAL_INCLUDES += [ + '/media/pocketsphinx', + '/media/sphinxbase', + ] + +if CONFIG['MOZ_SECUREELEMENT']: + LOCAL_INCLUDES += [ + '/dom/secureelement', + ] + +FINAL_LIBRARY = 'xul' + +if CONFIG['GNU_CXX']: + CXXFLAGS += ['-Wno-error=shadow'] diff --git a/layout/build/nsContentDLF.cpp b/layout/build/nsContentDLF.cpp new file mode 100644 index 000000000..5c4cef210 --- /dev/null +++ b/layout/build/nsContentDLF.cpp @@ -0,0 +1,425 @@ +/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 sw=2 et tw=78: */ +/* 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 "nsCOMPtr.h" +#include "nsContentDLF.h" +#include "nsDocShell.h" +#include "nsGenericHTMLElement.h" +#include "nsGkAtoms.h" +#include "nsIComponentManager.h" +#include "nsIComponentRegistrar.h" +#include "nsIContentViewer.h" +#include "nsICategoryManager.h" +#include "nsIDocumentLoaderFactory.h" +#include "nsIDocument.h" +#include "nsIURL.h" +#include "nsNodeInfoManager.h" +#include "nsIScriptSecurityManager.h" +#include "nsString.h" +#include "nsContentCID.h" +#include "prprf.h" +#include "nsNetUtil.h" +#include "nsCRT.h" +#include "nsIViewSourceChannel.h" +#include "nsContentUtils.h" +#include "imgLoader.h" +#include "nsCharsetSource.h" +#include "nsMimeTypes.h" +#include "DecoderTraits.h" + + +// plugins +#include "nsIPluginHost.h" +#include "nsPluginHost.h" +static NS_DEFINE_CID(kPluginDocumentCID, NS_PLUGINDOCUMENT_CID); + +// Factory code for creating variations on html documents + +#undef NOISY_REGISTRY + +static NS_DEFINE_IID(kHTMLDocumentCID, NS_HTMLDOCUMENT_CID); +static NS_DEFINE_IID(kXMLDocumentCID, NS_XMLDOCUMENT_CID); +static NS_DEFINE_IID(kSVGDocumentCID, NS_SVGDOCUMENT_CID); +static NS_DEFINE_IID(kVideoDocumentCID, NS_VIDEODOCUMENT_CID); +static NS_DEFINE_IID(kImageDocumentCID, NS_IMAGEDOCUMENT_CID); +static NS_DEFINE_IID(kXULDocumentCID, NS_XULDOCUMENT_CID); + +already_AddRefed<nsIContentViewer> NS_NewContentViewer(); + +static const char* const gHTMLTypes[] = { + TEXT_HTML, + VIEWSOURCE_CONTENT_TYPE, + APPLICATION_XHTML_XML, + APPLICATION_WAPXHTML_XML, + 0 +}; + +static const char* const gXMLTypes[] = { + TEXT_XML, + APPLICATION_XML, + APPLICATION_MATHML_XML, + APPLICATION_RDF_XML, + TEXT_RDF, + 0 +}; + +static const char* const gSVGTypes[] = { + IMAGE_SVG_XML, + 0 +}; + +static const char* const gXULTypes[] = { + TEXT_XUL, + APPLICATION_CACHED_XUL, + 0 +}; + +static bool +IsTypeInList(const nsACString& aType, const char* const aList[]) +{ + int32_t typeIndex; + for (typeIndex = 0; aList[typeIndex]; ++typeIndex) { + if (aType.Equals(aList[typeIndex])) { + return true; + } + } + + return false; +} + +nsresult +NS_NewContentDocumentLoaderFactory(nsIDocumentLoaderFactory** aResult) +{ + NS_PRECONDITION(aResult, "null OUT ptr"); + if (!aResult) { + return NS_ERROR_NULL_POINTER; + } + nsContentDLF* it = new nsContentDLF(); + if (!it) { + return NS_ERROR_OUT_OF_MEMORY; + } + + return CallQueryInterface(it, aResult); +} + +nsContentDLF::nsContentDLF() +{ +} + +nsContentDLF::~nsContentDLF() +{ +} + +NS_IMPL_ISUPPORTS(nsContentDLF, + nsIDocumentLoaderFactory) + +bool +MayUseXULXBL(nsIChannel* aChannel) +{ + nsIScriptSecurityManager *securityManager = + nsContentUtils::GetSecurityManager(); + if (!securityManager) { + return false; + } + + nsCOMPtr<nsIPrincipal> principal; + securityManager->GetChannelResultPrincipal(aChannel, getter_AddRefs(principal)); + NS_ENSURE_TRUE(principal, false); + + return nsContentUtils::AllowXULXBLForPrincipal(principal); +} + +NS_IMETHODIMP +nsContentDLF::CreateInstance(const char* aCommand, + nsIChannel* aChannel, + nsILoadGroup* aLoadGroup, + const nsACString& aContentType, + nsIDocShell* aContainer, + nsISupports* aExtraInfo, + nsIStreamListener** aDocListener, + nsIContentViewer** aDocViewer) +{ + // Make a copy of aContentType, because we're possibly going to change it. + nsAutoCString contentType(aContentType); + + // Are we viewing source? + nsCOMPtr<nsIViewSourceChannel> viewSourceChannel = do_QueryInterface(aChannel); + if (viewSourceChannel) + { + aCommand = "view-source"; + + // The parser freaks out when it sees the content-type that a + // view-source channel normally returns. Get the actual content + // type of the data. If it's known, use it; otherwise use + // text/plain. + nsAutoCString type; + viewSourceChannel->GetOriginalContentType(type); + bool knownType = + (!type.EqualsLiteral(VIEWSOURCE_CONTENT_TYPE) && + IsTypeInList(type, gHTMLTypes)) || + nsContentUtils::IsPlainTextType(type) || + IsTypeInList(type, gXMLTypes) || + IsTypeInList(type, gSVGTypes) || + IsTypeInList(type, gXMLTypes); + + if (knownType) { + viewSourceChannel->SetContentType(type); + } else if (IsImageContentType(type.get())) { + // If it's an image, we want to display it the same way we normally would. + // Also note the lifetime of "type" allows us to safely use "get()" here. + contentType = type; + } else { + viewSourceChannel->SetContentType(NS_LITERAL_CSTRING(TEXT_PLAIN)); + } + } else if (aContentType.EqualsLiteral(VIEWSOURCE_CONTENT_TYPE)) { + aChannel->SetContentType(NS_LITERAL_CSTRING(TEXT_PLAIN)); + contentType = TEXT_PLAIN; + } + + // Try html or plaintext; both use the same document CID + if (IsTypeInList(contentType, gHTMLTypes) || + nsContentUtils::IsPlainTextType(contentType)) { + return CreateDocument(aCommand, + aChannel, aLoadGroup, + aContainer, kHTMLDocumentCID, + aDocListener, aDocViewer); + } + + // Try XML + if (IsTypeInList(contentType, gXMLTypes)) { + return CreateDocument(aCommand, + aChannel, aLoadGroup, + aContainer, kXMLDocumentCID, + aDocListener, aDocViewer); + } + + // Try SVG + if (IsTypeInList(contentType, gSVGTypes)) { + return CreateDocument(aCommand, + aChannel, aLoadGroup, + aContainer, kSVGDocumentCID, + aDocListener, aDocViewer); + } + + // Try XUL + if (IsTypeInList(contentType, gXULTypes)) { + if (!MayUseXULXBL(aChannel)) { + return NS_ERROR_REMOTE_XUL; + } + + return CreateXULDocument(aCommand, aChannel, aLoadGroup, aContainer, + aExtraInfo, aDocListener, aDocViewer); + } + + if (mozilla::DecoderTraits::ShouldHandleMediaType(contentType.get(), + /* DecoderDoctorDiagnostics* */ nullptr)) { + return CreateDocument(aCommand, + aChannel, aLoadGroup, + aContainer, kVideoDocumentCID, + aDocListener, aDocViewer); + } + + // Try image types + if (IsImageContentType(contentType.get())) { + return CreateDocument(aCommand, + aChannel, aLoadGroup, + aContainer, kImageDocumentCID, + aDocListener, aDocViewer); + } + + RefPtr<nsPluginHost> pluginHost = nsPluginHost::GetInst(); + // Don't exclude disabled plugins, which will still trigger the "this plugin + // is disabled" placeholder. + if (pluginHost && pluginHost->HavePluginForType(contentType, + nsPluginHost::eExcludeNone)) { + return CreateDocument(aCommand, + aChannel, aLoadGroup, + aContainer, kPluginDocumentCID, + aDocListener, aDocViewer); + } + + // If we get here, then we weren't able to create anything. Sorry! + return NS_ERROR_FAILURE; +} + + +NS_IMETHODIMP +nsContentDLF::CreateInstanceForDocument(nsISupports* aContainer, + nsIDocument* aDocument, + const char *aCommand, + nsIContentViewer** aContentViewer) +{ + MOZ_ASSERT(aDocument); + + nsCOMPtr<nsIContentViewer> contentViewer = NS_NewContentViewer(); + + // Bind the document to the Content Viewer + contentViewer->LoadStart(aDocument); + contentViewer.forget(aContentViewer); + return NS_OK; +} + +NS_IMETHODIMP +nsContentDLF::CreateBlankDocument(nsILoadGroup *aLoadGroup, + nsIPrincipal* aPrincipal, + nsIDocument **aDocument) +{ + *aDocument = nullptr; + + nsresult rv = NS_ERROR_FAILURE; + + // create a new blank HTML document + nsCOMPtr<nsIDocument> blankDoc(do_CreateInstance(kHTMLDocumentCID)); + + if (blankDoc) { + // initialize + nsCOMPtr<nsIURI> uri; + NS_NewURI(getter_AddRefs(uri), NS_LITERAL_CSTRING("about:blank")); + if (uri) { + blankDoc->ResetToURI(uri, aLoadGroup, aPrincipal); + rv = NS_OK; + } + } + + // add some simple content structure + if (NS_SUCCEEDED(rv)) { + rv = NS_ERROR_FAILURE; + + nsNodeInfoManager *nim = blankDoc->NodeInfoManager(); + + RefPtr<mozilla::dom::NodeInfo> htmlNodeInfo; + + // generate an html html element + htmlNodeInfo = nim->GetNodeInfo(nsGkAtoms::html, 0, kNameSpaceID_XHTML, + nsIDOMNode::ELEMENT_NODE); + nsCOMPtr<nsIContent> htmlElement = + NS_NewHTMLHtmlElement(htmlNodeInfo.forget()); + + // generate an html head element + htmlNodeInfo = nim->GetNodeInfo(nsGkAtoms::head, 0, kNameSpaceID_XHTML, + nsIDOMNode::ELEMENT_NODE); + nsCOMPtr<nsIContent> headElement = + NS_NewHTMLHeadElement(htmlNodeInfo.forget()); + + // generate an html body elemment + htmlNodeInfo = nim->GetNodeInfo(nsGkAtoms::body, 0, kNameSpaceID_XHTML, + nsIDOMNode::ELEMENT_NODE); + nsCOMPtr<nsIContent> bodyElement = + NS_NewHTMLBodyElement(htmlNodeInfo.forget()); + + // blat in the structure + if (htmlElement && headElement && bodyElement) { + NS_ASSERTION(blankDoc->GetChildCount() == 0, + "Shouldn't have children"); + rv = blankDoc->AppendChildTo(htmlElement, false); + if (NS_SUCCEEDED(rv)) { + rv = htmlElement->AppendChildTo(headElement, false); + + if (NS_SUCCEEDED(rv)) { + // XXXbz Why not notifying here? + htmlElement->AppendChildTo(bodyElement, false); + } + } + } + } + + // add a nice bow + if (NS_SUCCEEDED(rv)) { + blankDoc->SetDocumentCharacterSetSource(kCharsetFromDocTypeDefault); + blankDoc->SetDocumentCharacterSet(NS_LITERAL_CSTRING("UTF-8")); + + blankDoc.forget(aDocument); + } + return rv; +} + + +nsresult +nsContentDLF::CreateDocument(const char* aCommand, + nsIChannel* aChannel, + nsILoadGroup* aLoadGroup, + nsIDocShell* aContainer, + const nsCID& aDocumentCID, + nsIStreamListener** aDocListener, + nsIContentViewer** aContentViewer) +{ + nsresult rv = NS_ERROR_FAILURE; + + nsCOMPtr<nsIURI> aURL; + rv = aChannel->GetURI(getter_AddRefs(aURL)); + if (NS_FAILED(rv)) return rv; + +#ifdef NOISY_CREATE_DOC + if (nullptr != aURL) { + nsAutoString tmp; + aURL->ToString(tmp); + fputs(NS_LossyConvertUTF16toASCII(tmp).get(), stdout); + printf(": creating document\n"); + } +#endif + + // Create the document + nsCOMPtr<nsIDocument> doc = do_CreateInstance(aDocumentCID, &rv); + NS_ENSURE_SUCCESS(rv, rv); + + // Create the content viewer XXX: could reuse content viewer here! + nsCOMPtr<nsIContentViewer> contentViewer = NS_NewContentViewer(); + + doc->SetContainer(static_cast<nsDocShell*>(aContainer)); + + // Initialize the document to begin loading the data. An + // nsIStreamListener connected to the parser is returned in + // aDocListener. + rv = doc->StartDocumentLoad(aCommand, aChannel, aLoadGroup, aContainer, aDocListener, true); + NS_ENSURE_SUCCESS(rv, rv); + + // Bind the document to the Content Viewer + contentViewer->LoadStart(doc); + contentViewer.forget(aContentViewer); + return NS_OK; +} + +nsresult +nsContentDLF::CreateXULDocument(const char* aCommand, + nsIChannel* aChannel, + nsILoadGroup* aLoadGroup, + nsIDocShell* aContainer, + nsISupports* aExtraInfo, + nsIStreamListener** aDocListener, + nsIContentViewer** aContentViewer) +{ + nsresult rv; + nsCOMPtr<nsIDocument> doc = do_CreateInstance(kXULDocumentCID, &rv); + if (NS_FAILED(rv)) return rv; + + nsCOMPtr<nsIContentViewer> contentViewer = NS_NewContentViewer(); + + nsCOMPtr<nsIURI> aURL; + rv = aChannel->GetURI(getter_AddRefs(aURL)); + if (NS_FAILED(rv)) return rv; + + /* + * Initialize the document to begin loading the data... + * + * An nsIStreamListener connected to the parser is returned in + * aDocListener. + */ + + doc->SetContainer(static_cast<nsDocShell*>(aContainer)); + + rv = doc->StartDocumentLoad(aCommand, aChannel, aLoadGroup, aContainer, aDocListener, true); + if (NS_FAILED(rv)) return rv; + + /* + * Bind the document to the Content Viewer... + */ + contentViewer->LoadStart(doc); + contentViewer.forget(aContentViewer); + return NS_OK; +} + +bool nsContentDLF::IsImageContentType(const char* aContentType) { + return imgLoader::SupportImageWithMimeType(aContentType); +} diff --git a/layout/build/nsContentDLF.h b/layout/build/nsContentDLF.h new file mode 100644 index 000000000..28673a694 --- /dev/null +++ b/layout/build/nsContentDLF.h @@ -0,0 +1,93 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * 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/. */ + +#ifndef nsContentDLF_h__ +#define nsContentDLF_h__ + +#include "nsIDocumentLoaderFactory.h" +#include "nsMimeTypes.h" + +class nsIChannel; +class nsIContentViewer; +class nsILoadGroup; +class nsIStreamListener; + +#define CONTENT_DLF_CONTRACTID "@mozilla.org/content/document-loader-factory;1" +#define PLUGIN_DLF_CONTRACTID "@mozilla.org/content/plugin/document-loader-factory;1" + +class nsContentDLF : public nsIDocumentLoaderFactory +{ +protected: + virtual ~nsContentDLF(); + +public: + nsContentDLF(); + + NS_DECL_ISUPPORTS + NS_DECL_NSIDOCUMENTLOADERFACTORY + + nsresult InitUAStyleSheet(); + + nsresult CreateDocument(const char* aCommand, + nsIChannel* aChannel, + nsILoadGroup* aLoadGroup, + nsIDocShell* aContainer, + const nsCID& aDocumentCID, + nsIStreamListener** aDocListener, + nsIContentViewer** aContentViewer); + + nsresult CreateXULDocument(const char* aCommand, + nsIChannel* aChannel, + nsILoadGroup* aLoadGroup, + nsIDocShell* aContainer, + nsISupports* aExtraInfo, + nsIStreamListener** aDocListener, + nsIContentViewer** aContentViewer); + +private: + static nsresult EnsureUAStyleSheet(); + static bool IsImageContentType(const char* aContentType); +}; + +nsresult +NS_NewContentDocumentLoaderFactory(nsIDocumentLoaderFactory** aResult); + +#ifdef MOZ_WEBM +#define CONTENTDLF_WEBM_CATEGORIES \ + { "Gecko-Content-Viewers", VIDEO_WEBM, "@mozilla.org/content/document-loader-factory;1" }, \ + { "Gecko-Content-Viewers", AUDIO_WEBM, "@mozilla.org/content/document-loader-factory;1" }, +#else +#define CONTENTDLF_WEBM_CATEGORIES +#endif + +#define CONTENTDLF_CATEGORIES \ + { "Gecko-Content-Viewers", TEXT_HTML, "@mozilla.org/content/document-loader-factory;1" }, \ + { "Gecko-Content-Viewers", TEXT_PLAIN, "@mozilla.org/content/document-loader-factory;1" }, \ + { "Gecko-Content-Viewers", TEXT_CACHE_MANIFEST, "@mozilla.org/content/document-loader-factory;1" }, \ + { "Gecko-Content-Viewers", TEXT_CSS, "@mozilla.org/content/document-loader-factory;1" }, \ + { "Gecko-Content-Viewers", TEXT_JAVASCRIPT, "@mozilla.org/content/document-loader-factory;1" }, \ + { "Gecko-Content-Viewers", TEXT_ECMASCRIPT, "@mozilla.org/content/document-loader-factory;1" }, \ + { "Gecko-Content-Viewers", APPLICATION_JAVASCRIPT, "@mozilla.org/content/document-loader-factory;1" }, \ + { "Gecko-Content-Viewers", APPLICATION_ECMASCRIPT, "@mozilla.org/content/document-loader-factory;1" }, \ + { "Gecko-Content-Viewers", APPLICATION_XJAVASCRIPT, "@mozilla.org/content/document-loader-factory;1" }, \ + { "Gecko-Content-Viewers", APPLICATION_JSON, "@mozilla.org/content/document-loader-factory;1" }, \ + { "Gecko-Content-Viewers", TEXT_JSON, "@mozilla.org/content/document-loader-factory;1" }, \ + { "Gecko-Content-Viewers", APPLICATION_XHTML_XML, "@mozilla.org/content/document-loader-factory;1" }, \ + { "Gecko-Content-Viewers", TEXT_XML, "@mozilla.org/content/document-loader-factory;1" }, \ + { "Gecko-Content-Viewers", APPLICATION_XML, "@mozilla.org/content/document-loader-factory;1" }, \ + { "Gecko-Content-Viewers", APPLICATION_RDF_XML, "@mozilla.org/content/document-loader-factory;1" }, \ + { "Gecko-Content-Viewers", TEXT_RDF, "@mozilla.org/content/document-loader-factory;1" }, \ + { "Gecko-Content-Viewers", TEXT_XUL, "@mozilla.org/content/document-loader-factory;1" }, \ + { "Gecko-Content-Viewers", APPLICATION_CACHED_XUL, "@mozilla.org/content/document-loader-factory;1" }, \ + { "Gecko-Content-Viewers", VIEWSOURCE_CONTENT_TYPE, "@mozilla.org/content/document-loader-factory;1" }, \ + { "Gecko-Content-Viewers", IMAGE_SVG_XML, "@mozilla.org/content/document-loader-factory;1" }, \ + { "Gecko-Content-Viewers", APPLICATION_MATHML_XML, "@mozilla.org/content/document-loader-factory;1" }, \ + { "Gecko-Content-Viewers", TEXT_VTT, "@mozilla.org/content/document-loader-factory;1" }, \ + { "Gecko-Content-Viewers", APPLICATION_WAPXHTML_XML, "@mozilla.org/content/document-loader-factory;1" }, \ + CONTENTDLF_WEBM_CATEGORIES + + +#endif + diff --git a/layout/build/nsLayoutCID.h b/layout/build/nsLayoutCID.h new file mode 100644 index 000000000..47a90d7d8 --- /dev/null +++ b/layout/build/nsLayoutCID.h @@ -0,0 +1,88 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. */ + +#ifndef nsLayoutCID_h__ +#define nsLayoutCID_h__ + +// {1691E1F4-EE41-11d4-9885-00C04FA0CF4B} +#define NS_FRAMETRAVERSAL_CID \ +{ 0x1691e1f4, 0xee41, 0x11d4, { 0x98, 0x85, 0x0, 0xc0, 0x4f, 0xa0, 0xcf, 0x4b } } + +/* a6cf90f9-15b3-11d2-932e-00805f8add32 */ +#define NS_LAYOUT_DEBUGGER_CID \ + { 0xa6cf90f9, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}} + +/* a6cf90d7-15b3-11d2-932e-00805f8add32 */ +#define NS_FRAME_UTIL_CID \ + { 0xa6cf90d5, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}} + +#define NS_DOMSELECTION_CID \ +{/* {C87A37FC-8109-4ce2-A322-8CDEC925379F}*/ \ + 0xc87a37fc, 0x8109, 0x4ce2, { 0xa3, 0x22, 0x8c, 0xde, 0xc9, 0x25, 0x37, 0x9f } } + +// {D750A964-2D14-484c-B3AA-8ED7823B5C7B} +#define NS_BOXOBJECT_CID \ +{ 0xd750a964, 0x2d14, 0x484c, { 0xb3, 0xaa, 0x8e, 0xd7, 0x82, 0x3b, 0x5c, 0x7b } } + +// {C2710D40-6F4D-4b7f-9778-76AE5166648C} +#define NS_LISTBOXOBJECT_CID \ +{ 0xc2710d40, 0x6f4d, 0x4b7f, { 0x97, 0x78, 0x76, 0xae, 0x51, 0x66, 0x64, 0x8c } } + +// {56E2ADA8-4631-11d4-BA11-001083023C1E} +#define NS_SCROLLBOXOBJECT_CID \ +{ 0x56e2ada8, 0x4631, 0x11d4, { 0xba, 0x11, 0x0, 0x10, 0x83, 0x2, 0x3c, 0x1e } } + +// {AA40253B-4C42-4056-8132-37BCD07862FD} +#define NS_MENUBOXOBJECT_CID \ +{ 0xaa40253b, 0x4c42, 0x4056, { 0x81, 0x32, 0x37, 0xbc, 0xd0, 0x78, 0x62, 0xfd } } + +// {6C392C62-1AB1-4de7-BFC6-ED4F9FC7749A} +#define NS_POPUPBOXOBJECT_CID \ +{ 0x6c392c62, 0x1ab1, 0x4de7, { 0xbf, 0xc6, 0xed, 0x4f, 0x9f, 0xc7, 0x74, 0x9a } } + +// {dca9d7c3-7b6a-4490-ad6d-2699a8d683cd} +#define NS_CONTAINERBOXOBJECT_CID \ +{ 0xdca9d7c3, 0x7b6a, 0x4490, { 0xad, 0x6d, 0x26, 0x99, 0xa8, 0xd6, 0x83, 0xcd } } + +// {3B581FD4-3497-426c-8F61-3658B971CB80} +#define NS_TREEBOXOBJECT_CID \ +{ 0x3b581fd4, 0x3497, 0x426c, { 0x8f, 0x61, 0x36, 0x58, 0xb9, 0x71, 0xcb, 0x80 } } + +// {2fe88332-31c6-4829-b247-a07d8a73e80f} +#define NS_CANVASRENDERINGCONTEXTWEBGL_CID \ +{ 0x2fe88332, 0x31c6, 0x4829, { 0xb2, 0x47, 0xa0, 0x7d, 0x8a, 0x7e, 0xe8, 0x0fe } } + +// {A746DECD-AE74-4d86-8E75-4FDA81A9BE90} +#define NS_DOMSESSIONSTORAGEMANAGER_CID \ +{ 0xa746decd, 0xae74, 0x4d86, { 0x8e, 0x75, 0x4f, 0xda, 0x81, 0xa9, 0xbe, 0x90 } } + +// {656DB07C-AA80-49e4-BCE8-E431BAAE697D} +#define NS_DOMLOCALSTORAGEMANAGER_CID \ +{ 0x656db07c, 0xaa80, 0x49e4, { 0xbc, 0xe8, 0xe4, 0x31, 0xba, 0xae, 0x69, 0x7d } } + +// {93ad72a6-02cd-4716-9626-d47d5ec275ec} +#define NS_DOMJSON_CID \ +{ 0x93ad72a6, 0x02cd, 0x4716, { 0x96, 0x26, 0xd4, 0x7d, 0x5e, 0xc2, 0x75, 0xec } } + +// {CF7FD51F-ABA2-44C1-9FF0-11F7508EFCD4} +#define NS_FOCUSMANAGER_CID \ +{ 0xcf7fd51f, 0xaba2, 0x44c1, { 0x9f, 0xf0, 0x11, 0xf7, 0x50, 0x8e, 0xfc, 0xd4 } } + +// {3160e271-138d-4cc7-9d63-6429f16957c7} +#define DOMREQUEST_SERVICE_CID \ +{ 0x3160e271, 0x138d, 0x4cc7, { 0x9d, 0x63, 0x64, 0x29, 0xf1, 0x69, 0x57, 0xc7 } } + +// {5a75c25a-5e7e-4d90-8f7c-07eb15cc0aa8} +#define QUOTAMANAGER_SERVICE_CID \ +{ 0x5a75c25a, 0x5e7e, 0x4d90, { 0x8f, 0x7c, 0x07, 0xeb, 0x15, 0xcc, 0x0a, 0xa8 } } + +// {c74bde32-bcc7-4840-8430-c733351b212a} +#define SERVICEWORKERMANAGER_CID \ +{ 0xc74bde32, 0xbcc7, 0x4840, { 0x84, 0x30, 0xc7, 0x33, 0x35, 0x1b, 0x21, 0x2a } } + +#define NOTIFICATIONTELEMETRYSERVICE_CID \ +{ 0x5995b782, 0x6a0e, 0x4066, { 0xaa, 0xc5, 0x27, 0x6f, 0x0a, 0x9a, 0xd8, 0xcf } } + +#endif /* nsLayoutCID_h__ */ diff --git a/layout/build/nsLayoutModule.cpp b/layout/build/nsLayoutModule.cpp new file mode 100644 index 000000000..ab301a627 --- /dev/null +++ b/layout/build/nsLayoutModule.cpp @@ -0,0 +1,1275 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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 "XPCModule.h" +#include "mozilla/ModuleUtils.h" +#include "nsImageModule.h" +#include "nsLayoutStatics.h" +#include "nsContentCID.h" +#include "nsContentDLF.h" +#include "nsContentPolicyUtils.h" +#include "nsDataDocumentContentPolicy.h" +#include "nsNoDataProtocolContentPolicy.h" +#include "nsDOMCID.h" +#include "nsHTMLContentSerializer.h" +#include "nsHTMLParts.h" +#include "nsIComponentManager.h" +#include "nsIContentIterator.h" +#include "nsIContentSerializer.h" +#include "nsIContentViewer.h" +#include "nsIController.h" +#include "nsIControllers.h" +#include "nsIDOMDOMImplementation.h" +#include "nsIDocument.h" +#include "nsIDocumentEncoder.h" +#include "nsIFactory.h" +#include "nsIFrameUtil.h" +#include "nsIIdleService.h" +#include "nsHTMLStyleSheet.h" +#include "nsILayoutDebugger.h" +#include "nsNameSpaceManager.h" +#include "nsIObserver.h" +#include "nsIObserverService.h" +#include "nsIScriptNameSpaceManager.h" +#include "nsISelection.h" +#include "nsCaret.h" +#include "nsPlainTextSerializer.h" +#include "nsXMLContentSerializer.h" +#include "nsXHTMLContentSerializer.h" +#include "nsRuleNode.h" +#include "nsContentAreaDragDrop.h" +#include "nsContentList.h" +#include "nsBox.h" +#include "nsIFrameTraversal.h" +#include "nsLayoutCID.h" +#include "nsStyleSheetService.h" +#include "nsFocusManager.h" +#include "ThirdPartyUtil.h" +#include "nsStructuredCloneContainer.h" +#include "gfxPlatform.h" +#include "mozilla/gfx/gfxVars.h" + +#include "nsIEventListenerService.h" +#include "nsIMessageManager.h" + +// Transformiix stuff +#include "mozilla/dom/XPathEvaluator.h" +#include "txMozillaXSLTProcessor.h" +#include "txNodeSetAdaptor.h" + +#include "mozilla/dom/DOMParser.h" +#include "mozilla/dom/XMLHttpRequestMainThread.h" +#include "nsDOMSerializer.h" + +// view stuff +#include "nsContentCreatorFunctions.h" + +#include "mozilla/dom/FormData.h" +#include "nsHostObjectURI.h" +#include "nsGlobalWindowCommands.h" +#include "nsIControllerCommandTable.h" +#include "nsJSProtocolHandler.h" +#include "nsScriptNameSpaceManager.h" +#include "nsIControllerContext.h" +#include "DOMStorageManager.h" +#include "nsJSON.h" +#include "nsZipArchive.h" +#include "mozIApplicationClearPrivateDataParams.h" +#include "mozilla/Attributes.h" +#include "mozilla/dom/DOMException.h" +#include "mozilla/dom/DOMRequest.h" +#include "mozilla/dom/network/UDPSocketChild.h" +#include "mozilla/dom/quota/QuotaManagerService.h" +#include "mozilla/dom/workers/ServiceWorkerManager.h" +#include "mozilla/dom/workers/WorkerDebuggerManager.h" +#include "mozilla/dom/Notification.h" +#include "mozilla/OSFileConstants.h" +#include "mozilla/Services.h" + +#ifdef MOZ_WEBSPEECH_TEST_BACKEND +#include "mozilla/dom/FakeSpeechRecognitionService.h" +#endif +#ifdef MOZ_WEBSPEECH_POCKETSPHINX +#include "mozilla/dom/PocketSphinxSpeechRecognitionService.h" +#endif +#ifdef MOZ_WEBSPEECH +#include "mozilla/dom/nsSynthVoiceRegistry.h" +#endif + +#ifdef MOZ_WIDGET_GONK +#include "SystemWorkerManager.h" +using mozilla::dom::gonk::SystemWorkerManager; +#define SYSTEMWORKERMANAGER_CID \ + {0xd53b6524, 0x6ac3, 0x42b0, {0xae, 0xca, 0x62, 0xb3, 0xc4, 0xe5, 0x2b, 0x04}} +#endif + +#ifdef MOZ_WIDGET_GONK +#include "AudioManager.h" +using mozilla::dom::gonk::AudioManager; +#include "nsVolumeService.h" +using mozilla::system::nsVolumeService; +#endif + +#include "mozilla/dom/PushNotifier.h" +using mozilla::dom::PushNotifier; +#define PUSHNOTIFIER_CID \ +{ 0x2fc2d3e3, 0x020f, 0x404e, { 0xb0, 0x6a, 0x6e, 0xcf, 0x3e, 0xa2, 0x33, 0x4a } } + +#include "AudioChannelAgent.h" +using mozilla::dom::AudioChannelAgent; + +// Editor stuff +#include "nsEditorCID.h" +#include "mozilla/EditorController.h" //CID +#include "mozilla/HTMLEditor.h" + +#include "nsTextServicesDocument.h" +#include "nsTextServicesCID.h" + +#include "nsScriptSecurityManager.h" +#include "nsPrincipal.h" +#include "nsSystemPrincipal.h" +#include "nsNullPrincipal.h" +#include "nsNetCID.h" +#ifndef MOZ_WIDGET_GONK +#if defined(MOZ_WIDGET_ANDROID) +#include "nsHapticFeedback.h" +#endif +#endif +#include "nsParserUtils.h" + +#include "nsHTMLCanvasFrame.h" + +#include "nsIDOMWebGLRenderingContext.h" + +class nsIDocumentLoaderFactory; + +#define PRODUCT_NAME "Gecko" + +/* 0ddf4df8-4dbb-4133-8b79-9afb966514f5 */ +#define NS_PLUGINDOCLOADERFACTORY_CID \ +{ 0x0ddf4df8, 0x4dbb, 0x4133, { 0x8b, 0x79, 0x9a, 0xfb, 0x96, 0x65, 0x14, 0xf5 } } + +#define NS_WINDOWCOMMANDTABLE_CID \ + { /* 0DE2FBFA-6B7F-11D7-BBBA-0003938A9D96 */ \ + 0x0DE2FBFA, 0x6B7F, 0x11D7, {0xBB, 0xBA, 0x00, 0x03, 0x93, 0x8A, 0x9D, 0x96} } + +#include "nsIBoxObject.h" + +#ifdef MOZ_XUL +#include "inDOMView.h" +#endif /* MOZ_XUL */ + +#include "inDeepTreeWalker.h" +#include "inCSSValueSearch.h" +#include "inDOMUtils.h" + +#ifdef MOZ_XUL +#include "nsIXULDocument.h" +#include "nsIXULSortService.h" + +nsresult +NS_NewXULContentBuilder(nsISupports* aOuter, REFNSIID aIID, void** aResult); + +nsresult +NS_NewXULTreeBuilder(nsISupports* aOuter, REFNSIID aIID, void** aResult); +#endif + +static void Shutdown(); + +#include "nsGeolocation.h" +#include "nsDeviceSensors.h" +#include "mozilla/dom/nsContentSecurityManager.h" +#include "mozilla/dom/nsCSPService.h" +#include "mozilla/dom/nsCSPContext.h" +#include "nsIPowerManagerService.h" +#include "nsIMediaManager.h" +#include "mozilla/dom/nsMixedContentBlocker.h" + +#include "AudioChannelService.h" +#include "mozilla/net/WebSocketEventService.h" + +#include "mozilla/dom/FlyWebService.h" + +#include "mozilla/dom/power/PowerManagerService.h" +#include "mozilla/dom/time/TimeService.h" +#include "StreamingProtocolService.h" + +#include "nsIPresentationService.h" + +#ifdef MOZ_WIDGET_GONK +#include "GonkGPSGeolocationProvider.h" +#endif +#include "MediaManager.h" + +#include "GMPService.h" + +#include "mozilla/dom/PresentationDeviceManager.h" +#include "mozilla/dom/PresentationTCPSessionTransport.h" + +#include "mozilla/TextInputProcessor.h" + +#ifdef MOZ_B2G +#include "nsIHardwareKeyHandler.h" +#include "mozilla/HardwareKeyHandler.h" +#endif + +using namespace mozilla; +using namespace mozilla::dom; +using mozilla::dom::power::PowerManagerService; +using mozilla::dom::quota::QuotaManagerService; +using mozilla::dom::workers::ServiceWorkerManager; +using mozilla::dom::workers::WorkerDebuggerManager; +using mozilla::dom::UDPSocketChild; +using mozilla::dom::time::TimeService; +using mozilla::net::StreamingProtocolControllerService; +using mozilla::gmp::GeckoMediaPluginService; +using mozilla::dom::NotificationTelemetryService; + +#define NS_EDITORCOMMANDTABLE_CID \ +{ 0x4f5e62b8, 0xd659, 0x4156, \ + { 0x84, 0xfc, 0x2f, 0x60, 0x99, 0x40, 0x03, 0x69 } } + +#define NS_EDITINGCOMMANDTABLE_CID \ +{ 0xcb38a746, 0xbeb8, 0x43f3, \ + { 0x94, 0x29, 0x77, 0x96, 0xe1, 0xa9, 0x3f, 0xb4 } } + +#define NS_HAPTICFEEDBACK_CID \ +{ 0x1f15dbc8, 0xbfaa, 0x45de, \ + { 0x8a, 0x46, 0x08, 0xe2, 0xe2, 0x63, 0x26, 0xb0 } } + +NS_GENERIC_FACTORY_CONSTRUCTOR(TextEditor) + +NS_GENERIC_FACTORY_CONSTRUCTOR(nsParserUtils) + +NS_GENERIC_FACTORY_CONSTRUCTOR(nsTextServicesDocument) + +NS_GENERIC_FACTORY_CONSTRUCTOR(HTMLEditor) + +// Transformiix +/* 5d5d92cd-6bf8-11d9-bf4a-000a95dc234c */ +#define TRANSFORMIIX_NODESET_CID \ +{ 0x5d5d92cd, 0x6bf8, 0x11d9, { 0xbf, 0x4a, 0x0, 0x0a, 0x95, 0xdc, 0x23, 0x4c } } + +#define TRANSFORMIIX_NODESET_CONTRACTID \ +"@mozilla.org/transformiix-nodeset;1" + +// PresentationDeviceManager +/* e1e79dec-4085-4994-ac5b-744b016697e6 */ +#define PRESENTATION_DEVICE_MANAGER_CID \ +{ 0xe1e79dec, 0x4085, 0x4994, { 0xac, 0x5b, 0x74, 0x4b, 0x01, 0x66, 0x97, 0xe6 } } + +#define PRESENTATION_TCP_SESSION_TRANSPORT_CID \ +{ 0xc9d023f4, 0x6228, 0x4c07, { 0x8b, 0x1d, 0x9c, 0x19, 0x57, 0x3f, 0xaa, 0x27 } } + +already_AddRefed<nsIPresentationService> NS_CreatePresentationService(); + +// Factory Constructor +NS_GENERIC_FACTORY_CONSTRUCTOR(txMozillaXSLTProcessor) +NS_GENERIC_FACTORY_CONSTRUCTOR(XPathEvaluator) +NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(txNodeSetAdaptor, Init) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsDOMSerializer) +NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(XMLHttpRequestMainThread, Init) +NS_GENERIC_FACTORY_CONSTRUCTOR(FormData) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsHostObjectURI) +NS_GENERIC_FACTORY_CONSTRUCTOR(DOMParser) +NS_GENERIC_FACTORY_CONSTRUCTOR(Exception) +NS_GENERIC_FACTORY_CONSTRUCTOR(DOMSessionStorageManager) +NS_GENERIC_FACTORY_CONSTRUCTOR(DOMLocalStorageManager) +NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(DOMRequestService, + DOMRequestService::FactoryCreate) +NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(QuotaManagerService, + QuotaManagerService::FactoryCreate) +NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(ServiceWorkerManager, + ServiceWorkerManager::GetInstance) +NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(WorkerDebuggerManager, + WorkerDebuggerManager::GetInstance) + +#ifdef MOZ_WIDGET_GONK +NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(SystemWorkerManager, + SystemWorkerManager::FactoryCreate) +#endif + +#ifdef MOZ_WEBSPEECH +NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsSynthVoiceRegistry, + nsSynthVoiceRegistry::GetInstanceForService) +#endif + +#ifdef MOZ_WIDGET_GONK +NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(AudioManager, + AudioManager::GetInstance) +#endif + +NS_GENERIC_FACTORY_CONSTRUCTOR(AudioChannelAgent) + +NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceSensors) + +#ifndef MOZ_WIDGET_GONK +#if defined(ANDROID) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsHapticFeedback) +#endif +#endif +NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(ThirdPartyUtil, Init) +NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIPowerManagerService, + PowerManagerService::GetInstance) +NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsITimeService, + TimeService::GetInstance) +NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIStreamingProtocolControllerService, + StreamingProtocolControllerService::GetInstance) + +#ifdef MOZ_WIDGET_GONK +#ifndef DISABLE_MOZ_RIL_GEOLOC +NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIGeolocationProvider, + GonkGPSGeolocationProvider::GetSingleton) +#endif +// Since the nsVolumeService constructor calls into nsIPowerManagerService, +// we need it to be constructed sometime after nsIPowerManagerService. +NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsVolumeService, + nsVolumeService::GetSingleton) +#endif +NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIMediaManagerService, + MediaManager::GetInstance) +NS_GENERIC_FACTORY_CONSTRUCTOR(PresentationDeviceManager) +NS_GENERIC_FACTORY_CONSTRUCTOR(TextInputProcessor) +NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIPresentationService, + NS_CreatePresentationService) +NS_GENERIC_FACTORY_CONSTRUCTOR(PresentationTCPSessionTransport) +NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(NotificationTelemetryService, Init) +NS_GENERIC_FACTORY_CONSTRUCTOR(PushNotifier) + +//----------------------------------------------------------------------------- + +static bool gInitialized = false; + +// Perform our one-time intialization for this module + +// static +nsresult +Initialize() +{ + if (gInitialized) { + NS_RUNTIMEABORT("Recursive layout module initialization"); + return NS_ERROR_FAILURE; + } + if (XRE_GetProcessType() == GeckoProcessType_GPU) { + // We mark the layout module as being available in the GPU process so that + // XPCOM's component manager initializes the power manager service, which + // is needed for nsAppShell. However, we don't actually need anything in + // the layout module itself. + return NS_OK; + } + + 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."); + + gInitialized = true; + + nsresult rv; + rv = xpcModuleCtor(); + if (NS_FAILED(rv)) + return rv; + + rv = nsLayoutStatics::Initialize(); + if (NS_FAILED(rv)) { + Shutdown(); + return rv; + } + +#ifdef DEBUG + nsStyleContext::AssertStyleStructMaxDifferenceValid(); +#endif + + return NS_OK; +} + +// Shutdown this module, releasing all of the module resources + +// static +void +Shutdown() +{ + NS_PRECONDITION(gInitialized, "module not initialized"); + if (!gInitialized) + return; + + gInitialized = false; + + nsLayoutStatics::Release(); +} + +#ifdef DEBUG +nsresult NS_NewFrameUtil(nsIFrameUtil** aResult); +nsresult NS_NewLayoutDebugger(nsILayoutDebugger** aResult); +#endif + +nsresult NS_NewBoxObject(nsIBoxObject** aResult); + +#ifdef MOZ_XUL +nsresult NS_NewListBoxObject(nsIBoxObject** aResult); +nsresult NS_NewScrollBoxObject(nsIBoxObject** aResult); +nsresult NS_NewMenuBoxObject(nsIBoxObject** aResult); +nsresult NS_NewPopupBoxObject(nsIBoxObject** aResult); +nsresult NS_NewContainerBoxObject(nsIBoxObject** aResult); +nsresult NS_NewTreeBoxObject(nsIBoxObject** aResult); +#endif + +nsresult NS_NewCanvasRenderingContextWebGL(nsIDOMWebGLRenderingContext** aResult); + +nsresult NS_CreateFrameTraversal(nsIFrameTraversal** aResult); + +nsresult NS_NewDomSelection(nsISelection** aResult); +already_AddRefed<nsIContentViewer> NS_NewContentViewer(); +nsresult NS_NewGenRegularIterator(nsIContentIterator** aResult); +nsresult NS_NewGenSubtreeIterator(nsIContentIterator** aInstancePtrResult); +nsresult NS_NewContentDocumentLoaderFactory(nsIDocumentLoaderFactory** aResult); +nsresult NS_NewHTMLCopyTextEncoder(nsIDocumentEncoder** aResult); +nsresult NS_NewTextEncoder(nsIDocumentEncoder** aResult); +nsresult NS_NewContentPolicy(nsIContentPolicy** aResult); + +nsresult NS_NewEventListenerService(nsIEventListenerService** aResult); +nsresult NS_NewGlobalMessageManager(nsIMessageBroadcaster** aResult); +nsresult NS_NewParentProcessMessageManager(nsIMessageBroadcaster** aResult); +nsresult NS_NewChildProcessMessageManager(nsISyncMessageSender** aResult); + +nsresult NS_NewXULControllers(nsISupports* aOuter, REFNSIID aIID, void** aResult); + +#define MAKE_CTOR(ctor_, iface_, func_) \ +static 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; \ +} + +// As above, but expects +// already_AddRefed<nsIFoo> NS_NewFoo(); +// instead of +// nsresult NS_NewFoo(nsIFoo**); +#define MAKE_CTOR2(ctor_, iface_, func_) \ +static nsresult \ +ctor_(nsISupports* aOuter, REFNSIID aIID, void** aResult) \ +{ \ + *aResult = nullptr; \ + if (aOuter) { \ + return NS_ERROR_NO_AGGREGATION; \ + } \ + nsCOMPtr<iface_> inst = func_(); \ + inst.forget(aResult); \ + return NS_OK; \ +} + +#ifdef DEBUG +MAKE_CTOR(CreateNewFrameUtil, nsIFrameUtil, NS_NewFrameUtil) +MAKE_CTOR(CreateNewLayoutDebugger, nsILayoutDebugger, NS_NewLayoutDebugger) +#endif + +MAKE_CTOR(CreateNewFrameTraversal, nsIFrameTraversal, NS_CreateFrameTraversal) +MAKE_CTOR(CreateNewBoxObject, nsIBoxObject, NS_NewBoxObject) + +#ifdef MOZ_XUL +MAKE_CTOR(CreateNewListBoxObject, nsIBoxObject, NS_NewListBoxObject) +MAKE_CTOR(CreateNewMenuBoxObject, nsIBoxObject, NS_NewMenuBoxObject) +MAKE_CTOR(CreateNewPopupBoxObject, nsIBoxObject, NS_NewPopupBoxObject) +MAKE_CTOR(CreateNewScrollBoxObject, nsIBoxObject, NS_NewScrollBoxObject) +MAKE_CTOR(CreateNewTreeBoxObject, nsIBoxObject, NS_NewTreeBoxObject) +MAKE_CTOR(CreateNewContainerBoxObject, nsIBoxObject, NS_NewContainerBoxObject) +#endif // MOZ_XUL + +#ifdef MOZ_XUL +NS_GENERIC_FACTORY_CONSTRUCTOR(inDOMView) +#endif +NS_GENERIC_FACTORY_CONSTRUCTOR(inDeepTreeWalker) +NS_GENERIC_FACTORY_CONSTRUCTOR(inCSSValueSearch) +NS_GENERIC_FACTORY_CONSTRUCTOR(inDOMUtils) + +MAKE_CTOR2(CreateContentViewer, nsIContentViewer, NS_NewContentViewer) +MAKE_CTOR(CreateHTMLDocument, nsIDocument, NS_NewHTMLDocument) +MAKE_CTOR(CreateXMLDocument, nsIDocument, NS_NewXMLDocument) +MAKE_CTOR(CreateSVGDocument, nsIDocument, NS_NewSVGDocument) +MAKE_CTOR(CreateImageDocument, nsIDocument, NS_NewImageDocument) +MAKE_CTOR(CreateDOMSelection, nsISelection, NS_NewDomSelection) +MAKE_CTOR2(CreateContentIterator, nsIContentIterator, NS_NewContentIterator) +MAKE_CTOR2(CreatePreContentIterator, nsIContentIterator, NS_NewPreContentIterator) +MAKE_CTOR2(CreateSubtreeIterator, nsIContentIterator, NS_NewContentSubtreeIterator) +MAKE_CTOR(CreateTextEncoder, nsIDocumentEncoder, NS_NewTextEncoder) +MAKE_CTOR(CreateHTMLCopyTextEncoder, nsIDocumentEncoder, NS_NewHTMLCopyTextEncoder) +MAKE_CTOR(CreateXMLContentSerializer, nsIContentSerializer, NS_NewXMLContentSerializer) +MAKE_CTOR(CreateHTMLContentSerializer, nsIContentSerializer, NS_NewHTMLContentSerializer) +MAKE_CTOR(CreateXHTMLContentSerializer, nsIContentSerializer, NS_NewXHTMLContentSerializer) +MAKE_CTOR(CreatePlainTextSerializer, nsIContentSerializer, NS_NewPlainTextSerializer) +MAKE_CTOR(CreateContentPolicy, nsIContentPolicy, NS_NewContentPolicy) +#ifdef MOZ_XUL +MAKE_CTOR(CreateXULSortService, nsIXULSortService, NS_NewXULSortService) +// NS_NewXULContentBuilder +// NS_NewXULTreeBuilder +MAKE_CTOR(CreateXULDocument, nsIXULDocument, NS_NewXULDocument) +// NS_NewXULControllers +#endif +MAKE_CTOR(CreateContentDLF, nsIDocumentLoaderFactory, NS_NewContentDocumentLoaderFactory) +MAKE_CTOR(CreateEventListenerService, nsIEventListenerService, NS_NewEventListenerService) +MAKE_CTOR(CreateGlobalMessageManager, nsIMessageBroadcaster, NS_NewGlobalMessageManager) +MAKE_CTOR(CreateParentMessageManager, nsIMessageBroadcaster, NS_NewParentProcessMessageManager) +MAKE_CTOR(CreateChildMessageManager, nsISyncMessageSender, NS_NewChildProcessMessageManager) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsDataDocumentContentPolicy) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsNoDataProtocolContentPolicy) +MAKE_CTOR(CreatePluginDocument, nsIDocument, NS_NewPluginDocument) +MAKE_CTOR(CreateVideoDocument, nsIDocument, NS_NewVideoDocument) +MAKE_CTOR(CreateFocusManager, nsIFocusManager, NS_NewFocusManager) + +MAKE_CTOR(CreateCanvasRenderingContextWebGL, nsIDOMWebGLRenderingContext, NS_NewCanvasRenderingContextWebGL) + +NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsStyleSheetService, Init) + +NS_GENERIC_FACTORY_CONSTRUCTOR(nsJSURI) + +// 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; \ + \ + *aResult = nullptr; \ + if (nullptr != aOuter) { \ + rv = NS_ERROR_NO_AGGREGATION; \ + return rv; \ + } \ + \ + _InstanceClass * inst = new _InstanceClass(); \ + if (nullptr == inst) { \ + rv = NS_ERROR_OUT_OF_MEMORY; \ + return rv; \ + } \ + rv = inst->QueryInterface(aIID, aResult); \ + \ + return rv; \ +} \ + +#define NS_GEOLOCATION_CID \ + { 0x1E1C3FF, 0x94A, 0xD048, { 0x44, 0xB4, 0x62, 0xD2, 0x9C, 0x7B, 0x4F, 0x39 } } + +NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(Geolocation, Init) + +#define NS_GEOLOCATION_SERVICE_CID \ + { 0x404d02a, 0x1CA, 0xAAAB, { 0x47, 0x62, 0x94, 0x4b, 0x1b, 0xf2, 0xf7, 0xb5 } } + +#define NS_AUDIOCHANNEL_SERVICE_CID \ + { 0xf712e983, 0x048a, 0x443f, { 0x88, 0x02, 0xfc, 0xc3, 0xd9, 0x27, 0xce, 0xac }} + +#define NS_WEBSOCKETEVENT_SERVICE_CID \ + { 0x31689828, 0xda66, 0x49a6, { 0x87, 0x0c, 0xdf, 0x62, 0xb8, 0x3f, 0xe7, 0x89 }} + +#define NS_FLYWEB_SERVICE_CID \ + { 0x5de19ef0, 0x895e, 0x4c0c, { 0xa6, 0xe0, 0xea, 0xe0, 0x23, 0x2b, 0x84, 0x5a } } + +NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsGeolocationService, nsGeolocationService::GetGeolocationService) + +NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(AudioChannelService, AudioChannelService::GetOrCreate) + +NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(WebSocketEventService, WebSocketEventService::GetOrCreate) + +NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(FlyWebService, FlyWebService::GetOrCreateAddRefed) + +#ifdef MOZ_WEBSPEECH_TEST_BACKEND +NS_GENERIC_FACTORY_CONSTRUCTOR(FakeSpeechRecognitionService) +#endif +#ifdef MOZ_WEBSPEECH_POCKETSPHINX +NS_GENERIC_FACTORY_CONSTRUCTOR(PocketSphinxSpeechRecognitionService) +#endif + +NS_GENERIC_FACTORY_CONSTRUCTOR(nsContentSecurityManager) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsCSPContext) +NS_GENERIC_FACTORY_CONSTRUCTOR(CSPService) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsMixedContentBlocker) + +NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrincipal) +NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsSystemPrincipal, + nsScriptSecurityManager::SystemPrincipalSingletonConstructor) +NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsNullPrincipal, Init) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsStructuredCloneContainer) + +NS_GENERIC_FACTORY_CONSTRUCTOR(OSFileConstantsService) +NS_GENERIC_FACTORY_CONSTRUCTOR(UDPSocketChild) + +NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(GeckoMediaPluginService, GeckoMediaPluginService::GetGeckoMediaPluginService) + +#ifdef MOZ_B2G +NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIHardwareKeyHandler, + HardwareKeyHandler::GetInstance) +#endif + +#ifdef ACCESSIBILITY +#include "xpcAccessibilityService.h" + + MAKE_CTOR(CreateA11yService, nsIAccessibilityService, NS_GetAccessibilityService) +#endif + +static nsresult +Construct_nsIScriptSecurityManager(nsISupports *aOuter, REFNSIID aIID, + void **aResult) +{ + if (!aResult) + return NS_ERROR_NULL_POINTER; + *aResult = nullptr; + 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; +} + +#ifdef DEBUG +NS_DEFINE_NAMED_CID(NS_FRAME_UTIL_CID); +NS_DEFINE_NAMED_CID(NS_LAYOUT_DEBUGGER_CID); +#endif +NS_DEFINE_NAMED_CID(NS_FRAMETRAVERSAL_CID); +NS_DEFINE_NAMED_CID(NS_BOXOBJECT_CID); +#ifdef MOZ_XUL +NS_DEFINE_NAMED_CID(NS_LISTBOXOBJECT_CID); +NS_DEFINE_NAMED_CID(NS_MENUBOXOBJECT_CID); +NS_DEFINE_NAMED_CID(NS_POPUPBOXOBJECT_CID); +NS_DEFINE_NAMED_CID(NS_CONTAINERBOXOBJECT_CID); +NS_DEFINE_NAMED_CID(NS_SCROLLBOXOBJECT_CID); +NS_DEFINE_NAMED_CID(NS_TREEBOXOBJECT_CID); +#endif // MOZ_XUL +#ifdef MOZ_XUL +NS_DEFINE_NAMED_CID(IN_DOMVIEW_CID); +#endif +NS_DEFINE_NAMED_CID(IN_DEEPTREEWALKER_CID); +NS_DEFINE_NAMED_CID(IN_CSSVALUESEARCH_CID); +NS_DEFINE_NAMED_CID(IN_DOMUTILS_CID); +NS_DEFINE_NAMED_CID(NS_CONTENT_VIEWER_CID); +NS_DEFINE_NAMED_CID(NS_HTMLDOCUMENT_CID); +NS_DEFINE_NAMED_CID(NS_XMLDOCUMENT_CID); +NS_DEFINE_NAMED_CID(NS_SVGDOCUMENT_CID); +NS_DEFINE_NAMED_CID(NS_IMAGEDOCUMENT_CID); +NS_DEFINE_NAMED_CID(NS_DOMSELECTION_CID); +NS_DEFINE_NAMED_CID(NS_CONTENTITERATOR_CID); +NS_DEFINE_NAMED_CID(NS_PRECONTENTITERATOR_CID); +NS_DEFINE_NAMED_CID(NS_SUBTREEITERATOR_CID); +NS_DEFINE_NAMED_CID(NS_CANVASRENDERINGCONTEXTWEBGL_CID); +NS_DEFINE_NAMED_CID(NS_TEXT_ENCODER_CID); +NS_DEFINE_NAMED_CID(NS_HTMLCOPY_TEXT_ENCODER_CID); +NS_DEFINE_NAMED_CID(NS_XMLCONTENTSERIALIZER_CID); +NS_DEFINE_NAMED_CID(NS_XHTMLCONTENTSERIALIZER_CID); +NS_DEFINE_NAMED_CID(NS_HTMLCONTENTSERIALIZER_CID); +NS_DEFINE_NAMED_CID(NS_PLAINTEXTSERIALIZER_CID); +NS_DEFINE_NAMED_CID(NS_PARSERUTILS_CID); +NS_DEFINE_NAMED_CID(NS_SCRIPTABLEUNESCAPEHTML_CID); +NS_DEFINE_NAMED_CID(NS_CONTENTPOLICY_CID); +NS_DEFINE_NAMED_CID(NS_DATADOCUMENTCONTENTPOLICY_CID); +NS_DEFINE_NAMED_CID(NS_NODATAPROTOCOLCONTENTPOLICY_CID); +NS_DEFINE_NAMED_CID(NS_XULCONTROLLERS_CID); +#ifdef MOZ_XUL +NS_DEFINE_NAMED_CID(NS_XULSORTSERVICE_CID); +NS_DEFINE_NAMED_CID(NS_XULTEMPLATEBUILDER_CID); +NS_DEFINE_NAMED_CID(NS_XULTREEBUILDER_CID); +NS_DEFINE_NAMED_CID(NS_XULDOCUMENT_CID); +#endif +NS_DEFINE_NAMED_CID(NS_CONTENT_DOCUMENT_LOADER_FACTORY_CID); +NS_DEFINE_NAMED_CID(NS_JSPROTOCOLHANDLER_CID); +NS_DEFINE_NAMED_CID(NS_JSURI_CID); +NS_DEFINE_NAMED_CID(NS_WINDOWCOMMANDTABLE_CID); +NS_DEFINE_NAMED_CID(NS_WINDOWCONTROLLER_CID); +NS_DEFINE_NAMED_CID(NS_PLUGINDOCLOADERFACTORY_CID); +NS_DEFINE_NAMED_CID(NS_PLUGINDOCUMENT_CID); +NS_DEFINE_NAMED_CID(NS_VIDEODOCUMENT_CID); +NS_DEFINE_NAMED_CID(NS_STYLESHEETSERVICE_CID); +NS_DEFINE_NAMED_CID(TRANSFORMIIX_XSLT_PROCESSOR_CID); +NS_DEFINE_NAMED_CID(TRANSFORMIIX_XPATH_EVALUATOR_CID); +NS_DEFINE_NAMED_CID(TRANSFORMIIX_NODESET_CID); +NS_DEFINE_NAMED_CID(NS_XMLSERIALIZER_CID); +NS_DEFINE_NAMED_CID(NS_FORMDATA_CID); +NS_DEFINE_NAMED_CID(NS_HOSTOBJECTURI_CID); +NS_DEFINE_NAMED_CID(NS_XMLHTTPREQUEST_CID); +NS_DEFINE_NAMED_CID(NS_DOMPARSER_CID); +NS_DEFINE_NAMED_CID(NS_DOMSESSIONSTORAGEMANAGER_CID); +NS_DEFINE_NAMED_CID(NS_DOMLOCALSTORAGEMANAGER_CID); +NS_DEFINE_NAMED_CID(NS_DOMJSON_CID); +NS_DEFINE_NAMED_CID(NS_TEXTEDITOR_CID); +NS_DEFINE_NAMED_CID(DOMREQUEST_SERVICE_CID); +NS_DEFINE_NAMED_CID(QUOTAMANAGER_SERVICE_CID); +NS_DEFINE_NAMED_CID(SERVICEWORKERMANAGER_CID); +NS_DEFINE_NAMED_CID(NOTIFICATIONTELEMETRYSERVICE_CID); +NS_DEFINE_NAMED_CID(PUSHNOTIFIER_CID); + +NS_DEFINE_NAMED_CID(WORKERDEBUGGERMANAGER_CID); +#ifdef MOZ_WIDGET_GONK +NS_DEFINE_NAMED_CID(SYSTEMWORKERMANAGER_CID); +#endif +#ifdef MOZ_WIDGET_GONK +NS_DEFINE_NAMED_CID(NS_AUDIOMANAGER_CID); +NS_DEFINE_NAMED_CID(NS_VOLUMESERVICE_CID); +#endif + +NS_DEFINE_NAMED_CID(NS_AUDIOCHANNELAGENT_CID); + +NS_DEFINE_NAMED_CID(NS_HTMLEDITOR_CID); +NS_DEFINE_NAMED_CID(NS_EDITORCONTROLLER_CID); +NS_DEFINE_NAMED_CID(NS_EDITINGCONTROLLER_CID); +NS_DEFINE_NAMED_CID(NS_EDITORCOMMANDTABLE_CID); +NS_DEFINE_NAMED_CID(NS_EDITINGCOMMANDTABLE_CID); +NS_DEFINE_NAMED_CID(NS_TEXTSERVICESDOCUMENT_CID); +NS_DEFINE_NAMED_CID(NS_GEOLOCATION_SERVICE_CID); +NS_DEFINE_NAMED_CID(NS_GEOLOCATION_CID); +NS_DEFINE_NAMED_CID(NS_AUDIOCHANNEL_SERVICE_CID); +NS_DEFINE_NAMED_CID(NS_WEBSOCKETEVENT_SERVICE_CID); +NS_DEFINE_NAMED_CID(NS_FLYWEB_SERVICE_CID); +NS_DEFINE_NAMED_CID(NS_FOCUSMANAGER_CID); +NS_DEFINE_NAMED_CID(NS_CONTENTSECURITYMANAGER_CID); +NS_DEFINE_NAMED_CID(CSPSERVICE_CID); +NS_DEFINE_NAMED_CID(NS_CSPCONTEXT_CID); +NS_DEFINE_NAMED_CID(NS_MIXEDCONTENTBLOCKER_CID); +NS_DEFINE_NAMED_CID(NS_EVENTLISTENERSERVICE_CID); +NS_DEFINE_NAMED_CID(NS_GLOBALMESSAGEMANAGER_CID); +NS_DEFINE_NAMED_CID(NS_PARENTPROCESSMESSAGEMANAGER_CID); +NS_DEFINE_NAMED_CID(NS_CHILDPROCESSMESSAGEMANAGER_CID); +NS_DEFINE_NAMED_CID(NS_SCRIPTSECURITYMANAGER_CID); +NS_DEFINE_NAMED_CID(NS_PRINCIPAL_CID); +NS_DEFINE_NAMED_CID(NS_SYSTEMPRINCIPAL_CID); +NS_DEFINE_NAMED_CID(NS_NULLPRINCIPAL_CID); +NS_DEFINE_NAMED_CID(THIRDPARTYUTIL_CID); +NS_DEFINE_NAMED_CID(NS_STRUCTUREDCLONECONTAINER_CID); +NS_DEFINE_NAMED_CID(NS_DEVICE_SENSORS_CID); + +#ifndef MOZ_WIDGET_GONK +#if defined(ANDROID) +NS_DEFINE_NAMED_CID(NS_HAPTICFEEDBACK_CID); +#endif +#endif +#ifndef DISABLE_MOZ_RIL_GEOLOC +#ifdef MOZ_WIDGET_GONK +NS_DEFINE_NAMED_CID(GONK_GPS_GEOLOCATION_PROVIDER_CID); +#endif +#endif +NS_DEFINE_NAMED_CID(NS_POWERMANAGERSERVICE_CID); +NS_DEFINE_NAMED_CID(OSFILECONSTANTSSERVICE_CID); +NS_DEFINE_NAMED_CID(UDPSOCKETCHILD_CID); +NS_DEFINE_NAMED_CID(NS_TIMESERVICE_CID); +NS_DEFINE_NAMED_CID(NS_MEDIASTREAMCONTROLLERSERVICE_CID); +NS_DEFINE_NAMED_CID(NS_MEDIAMANAGERSERVICE_CID); +#ifdef MOZ_WEBSPEECH_TEST_BACKEND +NS_DEFINE_NAMED_CID(NS_FAKE_SPEECH_RECOGNITION_SERVICE_CID); +#endif +#ifdef MOZ_WEBSPEECH_POCKETSPHINX +NS_DEFINE_NAMED_CID(NS_POCKETSPHINX_SPEECH_RECOGNITION_SERVICE_CID); +#endif +#ifdef MOZ_WEBSPEECH +NS_DEFINE_NAMED_CID(NS_SYNTHVOICEREGISTRY_CID); +#endif + +#ifdef ACCESSIBILITY +NS_DEFINE_NAMED_CID(NS_ACCESSIBILITY_SERVICE_CID); +#endif + +NS_DEFINE_NAMED_CID(GECKO_MEDIA_PLUGIN_SERVICE_CID); + +NS_DEFINE_NAMED_CID(PRESENTATION_SERVICE_CID); +NS_DEFINE_NAMED_CID(PRESENTATION_DEVICE_MANAGER_CID); +NS_DEFINE_NAMED_CID(PRESENTATION_TCP_SESSION_TRANSPORT_CID); + +NS_DEFINE_NAMED_CID(TEXT_INPUT_PROCESSOR_CID); + +#ifdef MOZ_B2G +NS_DEFINE_NAMED_CID(NS_HARDWARE_KEY_HANDLER_CID); +#endif + +static nsresult +CreateWindowCommandTableConstructor(nsISupports *aOuter, + REFNSIID aIID, void **aResult) +{ + nsresult rv; + nsCOMPtr<nsIControllerCommandTable> commandTable = + do_CreateInstance(NS_CONTROLLERCOMMANDTABLE_CONTRACTID, &rv); + if (NS_FAILED(rv)) return rv; + + rv = nsWindowCommandRegistration::RegisterWindowCommands(commandTable); + if (NS_FAILED(rv)) return rv; + + return commandTable->QueryInterface(aIID, aResult); +} + +static nsresult +CreateWindowControllerWithSingletonCommandTable(nsISupports *aOuter, + REFNSIID aIID, void **aResult) +{ + nsresult rv; + nsCOMPtr<nsIController> controller = + do_CreateInstance("@mozilla.org/embedcomp/base-command-controller;1", &rv); + + if (NS_FAILED(rv)) return rv; + + nsCOMPtr<nsIControllerCommandTable> windowCommandTable = do_GetService(kNS_WINDOWCOMMANDTABLE_CID, &rv); + if (NS_FAILED(rv)) return rv; + + // this is a singleton; make it immutable + windowCommandTable->MakeImmutable(); + + nsCOMPtr<nsIControllerContext> controllerContext = do_QueryInterface(controller, &rv); + if (NS_FAILED(rv)) return rv; + + controllerContext->Init(windowCommandTable); + if (NS_FAILED(rv)) return rv; + + return controller->QueryInterface(aIID, aResult); +} + +// Constructor of a controller which is set up to use, internally, a +// singleton command-table pre-filled with editor commands. +static nsresult +EditorControllerConstructor(nsISupports* aOuter, REFNSIID aIID, void** aResult) +{ + nsresult rv; + nsCOMPtr<nsIController> controller = do_CreateInstance("@mozilla.org/embedcomp/base-command-controller;1", &rv); + if (NS_FAILED(rv)) return rv; + + nsCOMPtr<nsIControllerCommandTable> editorCommandTable = do_GetService(kNS_EDITORCOMMANDTABLE_CID, &rv); + if (NS_FAILED(rv)) return rv; + + // this guy is a singleton, so make it immutable + editorCommandTable->MakeImmutable(); + + nsCOMPtr<nsIControllerContext> controllerContext = do_QueryInterface(controller, &rv); + if (NS_FAILED(rv)) return rv; + + rv = controllerContext->Init(editorCommandTable); + if (NS_FAILED(rv)) return rv; + + return controller->QueryInterface(aIID, aResult); +} + +// Constructor of a controller which is set up to use, internally, a +// singleton command-table pre-filled with editing commands. +static nsresult +nsEditingControllerConstructor(nsISupports *aOuter, REFNSIID aIID, + void **aResult) +{ + nsresult rv; + nsCOMPtr<nsIController> controller = do_CreateInstance("@mozilla.org/embedcomp/base-command-controller;1", &rv); + if (NS_FAILED(rv)) return rv; + + nsCOMPtr<nsIControllerCommandTable> editingCommandTable = do_GetService(kNS_EDITINGCOMMANDTABLE_CID, &rv); + if (NS_FAILED(rv)) return rv; + + // this guy is a singleton, so make it immutable + editingCommandTable->MakeImmutable(); + + nsCOMPtr<nsIControllerContext> controllerContext = do_QueryInterface(controller, &rv); + if (NS_FAILED(rv)) return rv; + + rv = controllerContext->Init(editingCommandTable); + if (NS_FAILED(rv)) return rv; + + return controller->QueryInterface(aIID, aResult); +} + +// Constructor for a command-table pre-filled with editor commands +static nsresult +nsEditorCommandTableConstructor(nsISupports *aOuter, REFNSIID aIID, + void **aResult) +{ + nsresult rv; + nsCOMPtr<nsIControllerCommandTable> commandTable = + do_CreateInstance(NS_CONTROLLERCOMMANDTABLE_CONTRACTID, &rv); + if (NS_FAILED(rv)) return rv; + + rv = EditorController::RegisterEditorCommands(commandTable); + if (NS_FAILED(rv)) return rv; + + // we don't know here whether we're being created as an instance, + // or a service, so we can't become immutable + + return commandTable->QueryInterface(aIID, aResult); +} + +// Constructor for a command-table pre-filled with editing commands +static nsresult +nsEditingCommandTableConstructor(nsISupports *aOuter, REFNSIID aIID, + void **aResult) +{ + nsresult rv; + nsCOMPtr<nsIControllerCommandTable> commandTable = + do_CreateInstance(NS_CONTROLLERCOMMANDTABLE_CONTRACTID, &rv); + if (NS_FAILED(rv)) return rv; + + rv = EditorController::RegisterEditingCommands(commandTable); + if (NS_FAILED(rv)) return rv; + + // we don't know here whether we're being created as an instance, + // or a service, so we can't become immutable + + return commandTable->QueryInterface(aIID, aResult); +} + +static const mozilla::Module::CIDEntry kLayoutCIDs[] = { + XPCONNECT_CIDENTRIES +#ifdef DEBUG + { &kNS_FRAME_UTIL_CID, false, nullptr, CreateNewFrameUtil }, + { &kNS_LAYOUT_DEBUGGER_CID, false, nullptr, CreateNewLayoutDebugger }, +#endif + { &kNS_FRAMETRAVERSAL_CID, false, nullptr, CreateNewFrameTraversal }, + { &kNS_BOXOBJECT_CID, false, nullptr, CreateNewBoxObject }, +#ifdef MOZ_XUL + { &kNS_LISTBOXOBJECT_CID, false, nullptr, CreateNewListBoxObject }, + { &kNS_MENUBOXOBJECT_CID, false, nullptr, CreateNewMenuBoxObject }, + { &kNS_POPUPBOXOBJECT_CID, false, nullptr, CreateNewPopupBoxObject }, + { &kNS_CONTAINERBOXOBJECT_CID, false, nullptr, CreateNewContainerBoxObject }, + { &kNS_SCROLLBOXOBJECT_CID, false, nullptr, CreateNewScrollBoxObject }, + { &kNS_TREEBOXOBJECT_CID, false, nullptr, CreateNewTreeBoxObject }, +#endif // MOZ_XUL +#ifdef MOZ_XUL + { &kIN_DOMVIEW_CID, false, nullptr, inDOMViewConstructor }, +#endif + { &kIN_DEEPTREEWALKER_CID, false, nullptr, inDeepTreeWalkerConstructor }, + { &kIN_CSSVALUESEARCH_CID, false, nullptr, inCSSValueSearchConstructor }, + { &kIN_DOMUTILS_CID, false, nullptr, inDOMUtilsConstructor }, + { &kNS_CONTENT_VIEWER_CID, false, nullptr, CreateContentViewer }, + { &kNS_HTMLDOCUMENT_CID, false, nullptr, CreateHTMLDocument }, + { &kNS_XMLDOCUMENT_CID, false, nullptr, CreateXMLDocument }, + { &kNS_SVGDOCUMENT_CID, false, nullptr, CreateSVGDocument }, + { &kNS_IMAGEDOCUMENT_CID, false, nullptr, CreateImageDocument }, + { &kNS_DOMSELECTION_CID, false, nullptr, CreateDOMSelection }, + { &kNS_CONTENTITERATOR_CID, false, nullptr, CreateContentIterator }, + { &kNS_PRECONTENTITERATOR_CID, false, nullptr, CreatePreContentIterator }, + { &kNS_SUBTREEITERATOR_CID, false, nullptr, CreateSubtreeIterator }, + { &kNS_CANVASRENDERINGCONTEXTWEBGL_CID, false, nullptr, CreateCanvasRenderingContextWebGL }, + { &kNS_TEXT_ENCODER_CID, false, nullptr, CreateTextEncoder }, + { &kNS_HTMLCOPY_TEXT_ENCODER_CID, false, nullptr, CreateHTMLCopyTextEncoder }, + { &kNS_XMLCONTENTSERIALIZER_CID, false, nullptr, CreateXMLContentSerializer }, + { &kNS_HTMLCONTENTSERIALIZER_CID, false, nullptr, CreateHTMLContentSerializer }, + { &kNS_XHTMLCONTENTSERIALIZER_CID, false, nullptr, CreateXHTMLContentSerializer }, + { &kNS_PLAINTEXTSERIALIZER_CID, false, nullptr, CreatePlainTextSerializer }, + { &kNS_PARSERUTILS_CID, false, nullptr, nsParserUtilsConstructor }, + { &kNS_SCRIPTABLEUNESCAPEHTML_CID, false, nullptr, nsParserUtilsConstructor }, + { &kNS_CONTENTPOLICY_CID, false, nullptr, CreateContentPolicy }, + { &kNS_DATADOCUMENTCONTENTPOLICY_CID, false, nullptr, nsDataDocumentContentPolicyConstructor }, + { &kNS_NODATAPROTOCOLCONTENTPOLICY_CID, false, nullptr, nsNoDataProtocolContentPolicyConstructor }, + { &kNS_XULCONTROLLERS_CID, false, nullptr, NS_NewXULControllers }, +#ifdef MOZ_XUL + { &kNS_XULSORTSERVICE_CID, false, nullptr, CreateXULSortService }, + { &kNS_XULTEMPLATEBUILDER_CID, false, nullptr, NS_NewXULContentBuilder }, + { &kNS_XULTREEBUILDER_CID, false, nullptr, NS_NewXULTreeBuilder }, + { &kNS_XULDOCUMENT_CID, false, nullptr, CreateXULDocument }, +#endif + { &kNS_CONTENT_DOCUMENT_LOADER_FACTORY_CID, false, nullptr, CreateContentDLF }, + { &kNS_JSPROTOCOLHANDLER_CID, false, nullptr, nsJSProtocolHandler::Create }, + { &kNS_JSURI_CID, false, nullptr, nsJSURIConstructor }, + { &kNS_WINDOWCOMMANDTABLE_CID, false, nullptr, CreateWindowCommandTableConstructor }, + { &kNS_WINDOWCONTROLLER_CID, false, nullptr, CreateWindowControllerWithSingletonCommandTable }, + { &kNS_PLUGINDOCLOADERFACTORY_CID, false, nullptr, CreateContentDLF }, + { &kNS_PLUGINDOCUMENT_CID, false, nullptr, CreatePluginDocument }, + { &kNS_VIDEODOCUMENT_CID, false, nullptr, CreateVideoDocument }, + { &kNS_STYLESHEETSERVICE_CID, false, nullptr, nsStyleSheetServiceConstructor }, + { &kTRANSFORMIIX_XSLT_PROCESSOR_CID, false, nullptr, txMozillaXSLTProcessorConstructor }, + { &kTRANSFORMIIX_XPATH_EVALUATOR_CID, false, nullptr, XPathEvaluatorConstructor }, + { &kTRANSFORMIIX_NODESET_CID, false, nullptr, txNodeSetAdaptorConstructor }, + { &kNS_XMLSERIALIZER_CID, false, nullptr, nsDOMSerializerConstructor }, + { &kNS_FORMDATA_CID, false, nullptr, FormDataConstructor }, + { &kNS_HOSTOBJECTURI_CID, false, nullptr, nsHostObjectURIConstructor }, + { &kNS_XMLHTTPREQUEST_CID, false, nullptr, XMLHttpRequestMainThreadConstructor }, + { &kNS_DOMPARSER_CID, false, nullptr, DOMParserConstructor }, + { &kNS_XPCEXCEPTION_CID, false, nullptr, ExceptionConstructor }, + { &kNS_DOMSESSIONSTORAGEMANAGER_CID, false, nullptr, DOMSessionStorageManagerConstructor }, + { &kNS_DOMLOCALSTORAGEMANAGER_CID, false, nullptr, DOMLocalStorageManagerConstructor }, + { &kNS_DOMJSON_CID, false, nullptr, NS_NewJSON }, + { &kNS_TEXTEDITOR_CID, false, nullptr, TextEditorConstructor }, + { &kDOMREQUEST_SERVICE_CID, false, nullptr, DOMRequestServiceConstructor }, + { &kQUOTAMANAGER_SERVICE_CID, false, nullptr, QuotaManagerServiceConstructor }, + { &kSERVICEWORKERMANAGER_CID, false, nullptr, ServiceWorkerManagerConstructor }, + { &kNOTIFICATIONTELEMETRYSERVICE_CID, false, nullptr, NotificationTelemetryServiceConstructor }, + { &kPUSHNOTIFIER_CID, false, nullptr, PushNotifierConstructor }, + { &kWORKERDEBUGGERMANAGER_CID, true, nullptr, WorkerDebuggerManagerConstructor }, +#ifdef MOZ_WIDGET_GONK + { &kSYSTEMWORKERMANAGER_CID, true, nullptr, SystemWorkerManagerConstructor }, +#endif +#ifdef MOZ_WIDGET_GONK + { &kNS_AUDIOMANAGER_CID, true, nullptr, AudioManagerConstructor }, + { &kNS_VOLUMESERVICE_CID, true, nullptr, nsVolumeServiceConstructor }, +#endif + { &kNS_AUDIOCHANNELAGENT_CID, true, nullptr, AudioChannelAgentConstructor }, + { &kNS_HTMLEDITOR_CID, false, nullptr, HTMLEditorConstructor }, + { &kNS_EDITORCONTROLLER_CID, false, nullptr, EditorControllerConstructor }, + { &kNS_EDITINGCONTROLLER_CID, false, nullptr, nsEditingControllerConstructor }, + { &kNS_EDITORCOMMANDTABLE_CID, false, nullptr, nsEditorCommandTableConstructor }, + { &kNS_EDITINGCOMMANDTABLE_CID, false, nullptr, nsEditingCommandTableConstructor }, + { &kNS_TEXTSERVICESDOCUMENT_CID, false, nullptr, nsTextServicesDocumentConstructor }, + { &kNS_GEOLOCATION_SERVICE_CID, false, nullptr, nsGeolocationServiceConstructor }, + { &kNS_GEOLOCATION_CID, false, nullptr, GeolocationConstructor }, + { &kNS_AUDIOCHANNEL_SERVICE_CID, false, nullptr, AudioChannelServiceConstructor }, + { &kNS_WEBSOCKETEVENT_SERVICE_CID, false, nullptr, WebSocketEventServiceConstructor }, + { &kNS_FLYWEB_SERVICE_CID, false, nullptr, FlyWebServiceConstructor }, + { &kNS_FOCUSMANAGER_CID, false, nullptr, CreateFocusManager }, +#ifdef MOZ_WEBSPEECH_TEST_BACKEND + { &kNS_FAKE_SPEECH_RECOGNITION_SERVICE_CID, false, nullptr, FakeSpeechRecognitionServiceConstructor }, +#endif +#ifdef MOZ_WEBSPEECH_POCKETSPHINX + { &kNS_POCKETSPHINX_SPEECH_RECOGNITION_SERVICE_CID, false, nullptr, PocketSphinxSpeechRecognitionServiceConstructor }, +#endif +#ifdef MOZ_WEBSPEECH + { &kNS_SYNTHVOICEREGISTRY_CID, true, nullptr, nsSynthVoiceRegistryConstructor }, +#endif + { &kNS_CONTENTSECURITYMANAGER_CID, false, nullptr, nsContentSecurityManagerConstructor }, + { &kCSPSERVICE_CID, false, nullptr, CSPServiceConstructor }, + { &kNS_CSPCONTEXT_CID, false, nullptr, nsCSPContextConstructor }, + { &kNS_MIXEDCONTENTBLOCKER_CID, false, nullptr, nsMixedContentBlockerConstructor }, + { &kNS_EVENTLISTENERSERVICE_CID, false, nullptr, CreateEventListenerService }, + { &kNS_GLOBALMESSAGEMANAGER_CID, false, nullptr, CreateGlobalMessageManager }, + { &kNS_PARENTPROCESSMESSAGEMANAGER_CID, false, nullptr, CreateParentMessageManager }, + { &kNS_CHILDPROCESSMESSAGEMANAGER_CID, false, nullptr, CreateChildMessageManager }, + { &kNS_SCRIPTSECURITYMANAGER_CID, false, nullptr, Construct_nsIScriptSecurityManager }, + { &kNS_PRINCIPAL_CID, false, nullptr, nsPrincipalConstructor }, + { &kNS_SYSTEMPRINCIPAL_CID, false, nullptr, nsSystemPrincipalConstructor }, + { &kNS_NULLPRINCIPAL_CID, false, nullptr, nsNullPrincipalConstructor }, + { &kNS_DEVICE_SENSORS_CID, false, nullptr, nsDeviceSensorsConstructor }, +#ifndef MOZ_WIDGET_GONK +#if defined(ANDROID) + { &kNS_HAPTICFEEDBACK_CID, false, nullptr, nsHapticFeedbackConstructor }, +#endif +#endif + { &kTHIRDPARTYUTIL_CID, false, nullptr, ThirdPartyUtilConstructor }, + { &kNS_STRUCTUREDCLONECONTAINER_CID, false, nullptr, nsStructuredCloneContainerConstructor }, + { &kNS_POWERMANAGERSERVICE_CID, false, nullptr, nsIPowerManagerServiceConstructor, Module::ALLOW_IN_GPU_PROCESS }, + { &kOSFILECONSTANTSSERVICE_CID, true, nullptr, OSFileConstantsServiceConstructor }, + { &kUDPSOCKETCHILD_CID, false, nullptr, UDPSocketChildConstructor }, + { &kGECKO_MEDIA_PLUGIN_SERVICE_CID, true, nullptr, GeckoMediaPluginServiceConstructor }, + { &kNS_TIMESERVICE_CID, false, nullptr, nsITimeServiceConstructor }, + { &kNS_MEDIASTREAMCONTROLLERSERVICE_CID, false, nullptr, nsIStreamingProtocolControllerServiceConstructor }, +#if defined(MOZ_WIDGET_GONK) && !defined(DISABLE_MOZ_RIL_GEOLOC) + { &kGONK_GPS_GEOLOCATION_PROVIDER_CID, false, nullptr, nsIGeolocationProviderConstructor }, +#endif + { &kNS_MEDIAMANAGERSERVICE_CID, false, nullptr, nsIMediaManagerServiceConstructor }, +#ifdef ACCESSIBILITY + { &kNS_ACCESSIBILITY_SERVICE_CID, false, nullptr, CreateA11yService }, +#endif + { &kPRESENTATION_SERVICE_CID, false, nullptr, nsIPresentationServiceConstructor }, + { &kPRESENTATION_DEVICE_MANAGER_CID, false, nullptr, PresentationDeviceManagerConstructor }, + { &kPRESENTATION_TCP_SESSION_TRANSPORT_CID, false, nullptr, PresentationTCPSessionTransportConstructor }, + { &kTEXT_INPUT_PROCESSOR_CID, false, nullptr, TextInputProcessorConstructor }, +#ifdef MOZ_B2G + { &kNS_HARDWARE_KEY_HANDLER_CID, false, nullptr, nsIHardwareKeyHandlerConstructor }, +#endif + { nullptr } +}; + +static const mozilla::Module::ContractIDEntry kLayoutContracts[] = { + XPCONNECT_CONTRACTS + { "@mozilla.org/layout/xul-boxobject;1", &kNS_BOXOBJECT_CID }, +#ifdef MOZ_XUL + { "@mozilla.org/layout/xul-boxobject-listbox;1", &kNS_LISTBOXOBJECT_CID }, + { "@mozilla.org/layout/xul-boxobject-menu;1", &kNS_MENUBOXOBJECT_CID }, + { "@mozilla.org/layout/xul-boxobject-popup;1", &kNS_POPUPBOXOBJECT_CID }, + { "@mozilla.org/layout/xul-boxobject-container;1", &kNS_CONTAINERBOXOBJECT_CID }, + { "@mozilla.org/layout/xul-boxobject-scrollbox;1", &kNS_SCROLLBOXOBJECT_CID }, + { "@mozilla.org/layout/xul-boxobject-tree;1", &kNS_TREEBOXOBJECT_CID }, +#endif // MOZ_XUL +#ifdef MOZ_XUL + { "@mozilla.org/inspector/dom-view;1", &kIN_DOMVIEW_CID }, +#endif + { "@mozilla.org/inspector/deep-tree-walker;1", &kIN_DEEPTREEWALKER_CID }, + { "@mozilla.org/inspector/search;1?type=cssvalue", &kIN_CSSVALUESEARCH_CID }, + { IN_DOMUTILS_CONTRACTID, &kIN_DOMUTILS_CID }, + { "@mozilla.org/xml/xml-document;1", &kNS_XMLDOCUMENT_CID }, + { "@mozilla.org/svg/svg-document;1", &kNS_SVGDOCUMENT_CID }, + { "@mozilla.org/content/dom-selection;1", &kNS_DOMSELECTION_CID }, + { "@mozilla.org/content/post-content-iterator;1", &kNS_CONTENTITERATOR_CID }, + { "@mozilla.org/content/pre-content-iterator;1", &kNS_PRECONTENTITERATOR_CID }, + { "@mozilla.org/content/subtree-content-iterator;1", &kNS_SUBTREEITERATOR_CID }, + { "@mozilla.org/content/canvas-rendering-context;1?id=webgl", &kNS_CANVASRENDERINGCONTEXTWEBGL_CID }, + { NS_DOC_ENCODER_CONTRACTID_BASE "text/xml", &kNS_TEXT_ENCODER_CID }, + { NS_DOC_ENCODER_CONTRACTID_BASE "application/xml", &kNS_TEXT_ENCODER_CID }, + { NS_DOC_ENCODER_CONTRACTID_BASE "application/xhtml+xml", &kNS_TEXT_ENCODER_CID }, + { NS_DOC_ENCODER_CONTRACTID_BASE "image/svg+xml", &kNS_TEXT_ENCODER_CID }, + { NS_DOC_ENCODER_CONTRACTID_BASE "text/html", &kNS_TEXT_ENCODER_CID }, + { NS_DOC_ENCODER_CONTRACTID_BASE "text/plain", &kNS_TEXT_ENCODER_CID }, + { NS_HTMLCOPY_ENCODER_CONTRACTID, &kNS_HTMLCOPY_TEXT_ENCODER_CID }, + { NS_CONTENTSERIALIZER_CONTRACTID_PREFIX "text/xml", &kNS_XMLCONTENTSERIALIZER_CID }, + { NS_CONTENTSERIALIZER_CONTRACTID_PREFIX "application/xml", &kNS_XMLCONTENTSERIALIZER_CID }, + { NS_CONTENTSERIALIZER_CONTRACTID_PREFIX "application/xhtml+xml", &kNS_XHTMLCONTENTSERIALIZER_CID }, + { NS_CONTENTSERIALIZER_CONTRACTID_PREFIX "image/svg+xml", &kNS_XMLCONTENTSERIALIZER_CID }, + { NS_CONTENTSERIALIZER_CONTRACTID_PREFIX "text/html", &kNS_HTMLCONTENTSERIALIZER_CID }, + { NS_CONTENTSERIALIZER_CONTRACTID_PREFIX "application/vnd.mozilla.xul+xml", &kNS_XMLCONTENTSERIALIZER_CID }, + { NS_CONTENTSERIALIZER_CONTRACTID_PREFIX "text/plain", &kNS_PLAINTEXTSERIALIZER_CID }, + { NS_PARSERUTILS_CONTRACTID, &kNS_PARSERUTILS_CID }, + { NS_SCRIPTABLEUNESCAPEHTML_CONTRACTID, &kNS_SCRIPTABLEUNESCAPEHTML_CID }, + { NS_CONTENTPOLICY_CONTRACTID, &kNS_CONTENTPOLICY_CID }, + { NS_DATADOCUMENTCONTENTPOLICY_CONTRACTID, &kNS_DATADOCUMENTCONTENTPOLICY_CID }, + { NS_NODATAPROTOCOLCONTENTPOLICY_CONTRACTID, &kNS_NODATAPROTOCOLCONTENTPOLICY_CID }, + { "@mozilla.org/xul/xul-controllers;1", &kNS_XULCONTROLLERS_CID }, +#ifdef MOZ_XUL + { "@mozilla.org/xul/xul-sort-service;1", &kNS_XULSORTSERVICE_CID }, + { "@mozilla.org/xul/xul-template-builder;1", &kNS_XULTEMPLATEBUILDER_CID }, + { "@mozilla.org/xul/xul-tree-builder;1", &kNS_XULTREEBUILDER_CID }, + { "@mozilla.org/xul/xul-document;1", &kNS_XULDOCUMENT_CID }, +#endif + { CONTENT_DLF_CONTRACTID, &kNS_CONTENT_DOCUMENT_LOADER_FACTORY_CID }, + { NS_JSPROTOCOLHANDLER_CONTRACTID, &kNS_JSPROTOCOLHANDLER_CID }, + { NS_WINDOWCONTROLLER_CONTRACTID, &kNS_WINDOWCONTROLLER_CID }, + { PLUGIN_DLF_CONTRACTID, &kNS_PLUGINDOCLOADERFACTORY_CID }, + { NS_STYLESHEETSERVICE_CONTRACTID, &kNS_STYLESHEETSERVICE_CID }, + { TRANSFORMIIX_XSLT_PROCESSOR_CONTRACTID, &kTRANSFORMIIX_XSLT_PROCESSOR_CID }, + { NS_XPATH_EVALUATOR_CONTRACTID, &kTRANSFORMIIX_XPATH_EVALUATOR_CID }, + { TRANSFORMIIX_NODESET_CONTRACTID, &kTRANSFORMIIX_NODESET_CID }, + { NS_XMLSERIALIZER_CONTRACTID, &kNS_XMLSERIALIZER_CID }, + { NS_FORMDATA_CONTRACTID, &kNS_FORMDATA_CID }, + { NS_XMLHTTPREQUEST_CONTRACTID, &kNS_XMLHTTPREQUEST_CID }, + { NS_DOMPARSER_CONTRACTID, &kNS_DOMPARSER_CID }, + { XPC_EXCEPTION_CONTRACTID, &kNS_XPCEXCEPTION_CID }, + { "@mozilla.org/dom/localStorage-manager;1", &kNS_DOMLOCALSTORAGEMANAGER_CID }, + // Keeping the old ContractID for backward compatibility + { "@mozilla.org/dom/storagemanager;1", &kNS_DOMLOCALSTORAGEMANAGER_CID }, + { "@mozilla.org/dom/sessionStorage-manager;1", &kNS_DOMSESSIONSTORAGEMANAGER_CID }, + { "@mozilla.org/dom/json;1", &kNS_DOMJSON_CID }, + { "@mozilla.org/editor/texteditor;1", &kNS_TEXTEDITOR_CID }, + { DOMREQUEST_SERVICE_CONTRACTID, &kDOMREQUEST_SERVICE_CID }, + { QUOTAMANAGER_SERVICE_CONTRACTID, &kQUOTAMANAGER_SERVICE_CID }, + { SERVICEWORKERMANAGER_CONTRACTID, &kSERVICEWORKERMANAGER_CID }, + { NOTIFICATIONTELEMETRYSERVICE_CONTRACTID, &kNOTIFICATIONTELEMETRYSERVICE_CID }, + { PUSHNOTIFIER_CONTRACTID, &kPUSHNOTIFIER_CID }, + { WORKERDEBUGGERMANAGER_CONTRACTID, &kWORKERDEBUGGERMANAGER_CID }, +#ifdef MOZ_WIDGET_GONK + { SYSTEMWORKERMANAGER_CONTRACTID, &kSYSTEMWORKERMANAGER_CID }, +#endif +#ifdef MOZ_WIDGET_GONK + { NS_AUDIOMANAGER_CONTRACTID, &kNS_AUDIOMANAGER_CID }, + { NS_VOLUMESERVICE_CONTRACTID, &kNS_VOLUMESERVICE_CID }, +#endif + { NS_AUDIOCHANNELAGENT_CONTRACTID, &kNS_AUDIOCHANNELAGENT_CID }, + { "@mozilla.org/editor/htmleditor;1", &kNS_HTMLEDITOR_CID }, + { "@mozilla.org/editor/editorcontroller;1", &kNS_EDITORCONTROLLER_CID }, + { "@mozilla.org/editor/editingcontroller;1", &kNS_EDITINGCONTROLLER_CID }, + { "@mozilla.org/textservices/textservicesdocument;1", &kNS_TEXTSERVICESDOCUMENT_CID }, + { "@mozilla.org/geolocation/service;1", &kNS_GEOLOCATION_SERVICE_CID }, + { "@mozilla.org/geolocation;1", &kNS_GEOLOCATION_CID }, + { "@mozilla.org/audiochannel/service;1", &kNS_AUDIOCHANNEL_SERVICE_CID }, + { "@mozilla.org/websocketevent/service;1", &kNS_WEBSOCKETEVENT_SERVICE_CID }, + { "@mozilla.org/flyweb-service;1", &kNS_FLYWEB_SERVICE_CID }, + { NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "flyweb", &kNS_FLYWEB_SERVICE_CID }, + { "@mozilla.org/focus-manager;1", &kNS_FOCUSMANAGER_CID }, +#ifdef MOZ_WEBSPEECH_TEST_BACKEND + { NS_SPEECH_RECOGNITION_SERVICE_CONTRACTID_PREFIX "fake", &kNS_FAKE_SPEECH_RECOGNITION_SERVICE_CID }, +#endif +#ifdef MOZ_WEBSPEECH_POCKETSPHINX + { NS_SPEECH_RECOGNITION_SERVICE_CONTRACTID_PREFIX "pocketsphinx-en-US", &kNS_POCKETSPHINX_SPEECH_RECOGNITION_SERVICE_CID }, +#endif +#ifdef MOZ_WEBSPEECH + { NS_SYNTHVOICEREGISTRY_CONTRACTID, &kNS_SYNTHVOICEREGISTRY_CID }, +#endif + { NS_CONTENTSECURITYMANAGER_CONTRACTID, &kNS_CONTENTSECURITYMANAGER_CID }, + { CSPSERVICE_CONTRACTID, &kCSPSERVICE_CID }, + { NS_CSPCONTEXT_CONTRACTID, &kNS_CSPCONTEXT_CID }, + { NS_MIXEDCONTENTBLOCKER_CONTRACTID, &kNS_MIXEDCONTENTBLOCKER_CID }, + { NS_EVENTLISTENERSERVICE_CONTRACTID, &kNS_EVENTLISTENERSERVICE_CID }, + { NS_GLOBALMESSAGEMANAGER_CONTRACTID, &kNS_GLOBALMESSAGEMANAGER_CID }, + { NS_PARENTPROCESSMESSAGEMANAGER_CONTRACTID, &kNS_PARENTPROCESSMESSAGEMANAGER_CID }, + { NS_CHILDPROCESSMESSAGEMANAGER_CONTRACTID, &kNS_CHILDPROCESSMESSAGEMANAGER_CID }, + { NS_SCRIPTSECURITYMANAGER_CONTRACTID, &kNS_SCRIPTSECURITYMANAGER_CID }, + { NS_PRINCIPAL_CONTRACTID, &kNS_PRINCIPAL_CID }, + { NS_SYSTEMPRINCIPAL_CONTRACTID, &kNS_SYSTEMPRINCIPAL_CID }, + { NS_NULLPRINCIPAL_CONTRACTID, &kNS_NULLPRINCIPAL_CID }, + { NS_DEVICE_SENSORS_CONTRACTID, &kNS_DEVICE_SENSORS_CID }, +#ifndef MOZ_WIDGET_GONK +#if defined(ANDROID) + { "@mozilla.org/widget/hapticfeedback;1", &kNS_HAPTICFEEDBACK_CID }, +#endif +#endif + { THIRDPARTYUTIL_CONTRACTID, &kTHIRDPARTYUTIL_CID }, + { NS_STRUCTUREDCLONECONTAINER_CONTRACTID, &kNS_STRUCTUREDCLONECONTAINER_CID }, + { POWERMANAGERSERVICE_CONTRACTID, &kNS_POWERMANAGERSERVICE_CID, Module::ALLOW_IN_GPU_PROCESS }, + { OSFILECONSTANTSSERVICE_CONTRACTID, &kOSFILECONSTANTSSERVICE_CID }, + { "@mozilla.org/udp-socket-child;1", &kUDPSOCKETCHILD_CID }, + { TIMESERVICE_CONTRACTID, &kNS_TIMESERVICE_CID }, + { MEDIASTREAMCONTROLLERSERVICE_CONTRACTID, &kNS_MEDIASTREAMCONTROLLERSERVICE_CID }, +#if defined(MOZ_WIDGET_GONK) && !defined(DISABLE_MOZ_RIL_GEOLOC) + { GONK_GPS_GEOLOCATION_PROVIDER_CONTRACTID, &kGONK_GPS_GEOLOCATION_PROVIDER_CID }, +#endif + { MEDIAMANAGERSERVICE_CONTRACTID, &kNS_MEDIAMANAGERSERVICE_CID }, +#ifdef ACCESSIBILITY + { "@mozilla.org/accessibilityService;1", &kNS_ACCESSIBILITY_SERVICE_CID }, + { "@mozilla.org/accessibleRetrieval;1", &kNS_ACCESSIBILITY_SERVICE_CID }, +#endif + { "@mozilla.org/gecko-media-plugin-service;1", &kGECKO_MEDIA_PLUGIN_SERVICE_CID }, + { PRESENTATION_SERVICE_CONTRACTID, &kPRESENTATION_SERVICE_CID }, + { PRESENTATION_DEVICE_MANAGER_CONTRACTID, &kPRESENTATION_DEVICE_MANAGER_CID }, + { PRESENTATION_TCP_SESSION_TRANSPORT_CONTRACTID, &kPRESENTATION_TCP_SESSION_TRANSPORT_CID }, + { "@mozilla.org/text-input-processor;1", &kTEXT_INPUT_PROCESSOR_CID }, +#ifdef MOZ_B2G + { NS_HARDWARE_KEY_HANDLER_CONTRACTID, &kNS_HARDWARE_KEY_HANDLER_CID }, +#endif + { nullptr } +}; + +static const mozilla::Module::CategoryEntry kLayoutCategories[] = { + XPCONNECT_CATEGORIES + { "content-policy", NS_DATADOCUMENTCONTENTPOLICY_CONTRACTID, NS_DATADOCUMENTCONTENTPOLICY_CONTRACTID }, + { "content-policy", NS_NODATAPROTOCOLCONTENTPOLICY_CONTRACTID, NS_NODATAPROTOCOLCONTENTPOLICY_CONTRACTID }, + { "content-policy", "CSPService", CSPSERVICE_CONTRACTID }, + { "content-policy", NS_MIXEDCONTENTBLOCKER_CONTRACTID, NS_MIXEDCONTENTBLOCKER_CONTRACTID }, + { "net-channel-event-sinks", "CSPService", CSPSERVICE_CONTRACTID }, + { "net-channel-event-sinks", NS_MIXEDCONTENTBLOCKER_CONTRACTID, NS_MIXEDCONTENTBLOCKER_CONTRACTID }, + { "app-startup", "Script Security Manager", "service," NS_SCRIPTSECURITYMANAGER_CONTRACTID }, + { "app-startup", "Push Notifier", "service," PUSHNOTIFIER_CONTRACTID }, + { "clear-origin-attributes-data", "QuotaManagerService", "service," QUOTAMANAGER_SERVICE_CONTRACTID }, + { OBSERVER_TOPIC_IDLE_DAILY, "QuotaManagerService", QUOTAMANAGER_SERVICE_CONTRACTID }, +#ifdef MOZ_WIDGET_GONK + { "app-startup", "Volume Service", "service," NS_VOLUMESERVICE_CONTRACTID }, +#endif + CONTENTDLF_CATEGORIES +#ifdef MOZ_WIDGET_GONK + { "profile-after-change", "Gonk System Worker Manager", SYSTEMWORKERMANAGER_CONTRACTID }, +#endif + { "profile-after-change", "PresentationDeviceManager", PRESENTATION_DEVICE_MANAGER_CONTRACTID }, + { "profile-after-change", "PresentationService", PRESENTATION_SERVICE_CONTRACTID }, + { "profile-after-change", "Notification Telemetry Service", NOTIFICATIONTELEMETRYSERVICE_CONTRACTID }, + { nullptr } +}; + +static void +LayoutModuleDtor() +{ + if (XRE_GetProcessType() == GeckoProcessType_GPU) { + return; + } + + Shutdown(); + nsContentUtils::XPCOMShutdown(); + + // 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(); + gfxPlatform::Shutdown(); + gfx::gfxVars::Shutdown(); + + nsScriptSecurityManager::Shutdown(); + xpcModuleDtor(); +} + +static const mozilla::Module kLayoutModule = { + mozilla::Module::kVersion, + kLayoutCIDs, + kLayoutContracts, + kLayoutCategories, + nullptr, + Initialize, + LayoutModuleDtor, + Module::ALLOW_IN_GPU_PROCESS +}; + +NSMODULE_DEFN(nsLayoutModule) = &kLayoutModule; diff --git a/layout/build/nsLayoutStatics.cpp b/layout/build/nsLayoutStatics.cpp new file mode 100644 index 000000000..3f534c8d8 --- /dev/null +++ b/layout/build/nsLayoutStatics.cpp @@ -0,0 +1,438 @@ +/* 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 "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 "nsHtml5Atoms.h" +#include "nsHtml5Module.h" +#include "nsHTMLTags.h" +#include "nsIRDFContentSink.h" // for RDF atom initialization +#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 "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 "nsTextServicesDocument.h" + +#ifdef MOZ_WEBSPEECH +#include "nsSynthVoiceRegistry.h" +#endif + +#ifdef MOZ_ANDROID_OMX +#include "AndroidMediaPluginHost.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 "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/CustomElementRegistry.h" +#include "mozilla/dom/time/DateCacheCleaner.h" +#include "mozilla/EventDispatcher.h" +#include "mozilla/IMEStateManager.h" +#include "mozilla/dom/HTMLVideoElement.h" +#include "TouchManager.h" +#include "MediaDecoder.h" +#include "MediaPrefs.h" +#include "mozilla/ServoBindings.h" +#include "mozilla/StaticPresData.h" +#include "mozilla/dom/WebIDLGlobalNameHash.h" + +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::AddRefAtoms(); + nsCSSProps::AddRefTable(); + nsColorNames::AddRefTable(); + nsGkAtoms::AddRefAtoms(); + nsHtml5Atoms::AddRefAtoms(); + nsTextServicesDocument::RegisterAtoms(); + nsHTMLTags::RegisterAtoms(); + nsRDFAtoms::RegisterAtoms(); + + NS_SealStaticAtomTable(); + + 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(); + +#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(); + nsPrincipal::InitializeStatics(); + + nsCORSListenerProxy::Startup(); + + nsWindowMemoryReporter::Init(); + + SVGElementFactory::Init(); + nsSVGUtils::Init(); + + ProcessPriorityManager::Init(); + + nsPermissionManager::ClearOriginDataObserverInit(); + nsCookieService::AppClearDataObserverInit(); + nsApplicationCacheService::AppClearDataObserverInit(); + + HTMLVideoElement::Init(); + +#ifdef MOZ_XUL + nsMenuBarListener::InitializeStatics(); +#endif + + CacheObserver::Init(); + + CounterStyleManager::InitializeBuiltinCounterStyles(); + + IMEStateManager::Init(); + + ServiceWorkerRegistrar::Initialize(); + +#ifdef DEBUG + nsStyleContext::Initialize(); + mozilla::LayerAnimationInfo::Initialize(); +#endif + + MediaDecoder::InitStatics(); + + PromiseDebugging::Init(); + + mozilla::dom::WebCryptoThreadPool::Initialize(); + + // NB: We initialize servo in nsAppRunner.cpp, because we need to do it after + // creating the hidden DOM window to support some current stylo hacks. We + // should move initialization back here once those go away. + +#ifndef MOZ_WIDGET_ANDROID + // On Android, we instantiate it when constructing AndroidBridge. + MediaPrefs::GetSingleton(); +#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 + + 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(); + + DisplayItemClip::Shutdown(); + + CustomElementRegistry::XPCOMShutdown(); + + CacheObserver::Shutdown(); + + PromiseDebugging::Shutdown(); +} diff --git a/layout/build/nsLayoutStatics.h b/layout/build/nsLayoutStatics.h new file mode 100644 index 000000000..76663cff5 --- /dev/null +++ b/layout/build/nsLayoutStatics.h @@ -0,0 +1,71 @@ +/* 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/. */ + +#ifndef nsLayoutStatics_h__ +#define nsLayoutStatics_h__ + +#include "nscore.h" +#include "MainThreadUtils.h" +#include "nsISupportsImpl.h" +#include "nsDebug.h" + +// This isn't really a class, it's a namespace for static methods. +// Documents and other objects can hold a reference to the layout static +// objects so that they last past the xpcom-shutdown notification. + +class nsLayoutStatics +{ +public: + // Called by the layout module constructor. This call performs an AddRef() + // internally. + static nsresult Initialize(); + + static void AddRef() + { + NS_ASSERTION(NS_IsMainThread(), + "nsLayoutStatics reference counting must be on main thread"); + + NS_ASSERTION(sLayoutStaticRefcnt, + "nsLayoutStatics already dropped to zero!"); + + ++sLayoutStaticRefcnt; + NS_LOG_ADDREF(&sLayoutStaticRefcnt, sLayoutStaticRefcnt, + "nsLayoutStatics", 1); + } + static void Release() + { + NS_ASSERTION(NS_IsMainThread(), + "nsLayoutStatics reference counting must be on main thread"); + + --sLayoutStaticRefcnt; + NS_LOG_RELEASE(&sLayoutStaticRefcnt, sLayoutStaticRefcnt, + "nsLayoutStatics"); + + if (!sLayoutStaticRefcnt) + Shutdown(); + } + +private: + // not to be called! + nsLayoutStatics(); + + static void Shutdown(); + + static nsrefcnt sLayoutStaticRefcnt; +}; + +class nsLayoutStaticsRef +{ +public: + nsLayoutStaticsRef() + { + nsLayoutStatics::AddRef(); + } + ~nsLayoutStaticsRef() + { + nsLayoutStatics::Release(); + } +}; + +#endif // nsLayoutStatics_h__ |