Bug 1524687: Part 3 - Convert nsImageModule to static registration. r=jwatt
☠☠ backed out by 3b1b94e39795 ☠ ☠
authorKris Maglione <maglione.k@gmail.com>
Thu, 24 Jan 2019 15:40:58 -0800
changeset 458963 df95a56dae04
parent 458962 10c69df4444d
child 458964 c58caf41bb94
push id111908
push usermaglione.k@gmail.com
push dateThu, 14 Feb 2019 02:29:45 +0000
treeherdermozilla-inbound@625f71135038 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwatt
bugs1524687
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1524687: Part 3 - Convert nsImageModule to static registration. r=jwatt Differential Revision: https://phabricator.services.mozilla.com/D18398
image/build/components.conf
image/build/moz.build
image/build/nsImageModule.cpp
image/decoders/icon/components.conf
image/decoders/icon/moz.build
image/decoders/icon/nsIconModule.cpp
layout/build/components.conf
new file mode 100644
--- /dev/null
+++ b/image/build/components.conf
@@ -0,0 +1,66 @@
+# -*- 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/.
+
+Headers = [
+    '/image/build/nsImageModule.h',
+]
+
+InitFunc = 'mozilla::image::EnsureModuleInitialized'
+# This is called by LayoutModuleDtor to ensure it happens at the right time
+# during shutdown.
+# UnloadFunc = 'mozilla::image::ShutdownModule'
+
+Classes = [
+    # XXX We would like to get rid of the imgLoader factory constructor.  See the
+    # comment documenting the imgLoader constructor.
+    {
+        'cid': '{c1354898-e3fe-4602-88a7-c4520c21cb4e}',
+        'contract_ids': [
+            '@mozilla.org/image/cache;1',
+            '@mozilla.org/image/loader;1',
+        ],
+        'type': 'imgLoader',
+        'headers': ['imgLoader.h'],
+        'init_method': 'Init',
+        'categories': {'content-sniffing-services': '@mozilla.org/image/loader;1'},
+    },
+    {
+        'cid': '{20557898-1dd2-11b2-8f65-9c462ee2bc95}',
+        'contract_ids': ['@mozilla.org/image/request;1'],
+        'type': 'imgRequestProxy',
+        'headers': ['imgRequestProxy.h'],
+    },
+    {
+        'cid': '{3d8fa16d-c9e1-4b50-bdef-2c7ae249967a}',
+        'contract_ids': ['@mozilla.org/image/tools;1'],
+        'type': 'mozilla::image::imgTools',
+        'headers': ['/image/imgTools.h'],
+    },
+    {
+        'cid': '{13a5320c-4c91-4fa4-bd16-b081a3ba8c0b}',
+        'contract_ids': ['@mozilla.org/image/encoder;2?type=image/bmp'],
+        'type': 'nsBMPEncoder',
+        'headers': ['/image/encoders/bmp/nsBMPEncoder.h'],
+    },
+    {
+        'cid': '{92ae3ab2-8968-41b1-8709-b6123bceaf21}',
+        'contract_ids': ['@mozilla.org/image/encoder;2?type=image/vnd.microsoft.icon'],
+        'type': 'nsICOEncoder',
+        'headers': ['/image/encoders/ico/nsICOEncoder.h'],
+    },
+    {
+        'cid': '{ac2bb8fe-eeeb-4572-b40f-be03932b56e0}',
+        'contract_ids': ['@mozilla.org/image/encoder;2?type=image/jpeg'],
+        'type': 'nsJPEGEncoder',
+        'headers': ['/image/encoders/jpeg/nsJPEGEncoder.h'],
+    },
+    {
+        'cid': '{38d1592e-b81e-432b-86f8-471878bbfe07}',
+        'contract_ids': ['@mozilla.org/image/encoder;2?type=image/png'],
+        'type': 'nsPNGEncoder',
+        'headers': ['/image/encoders/png/nsPNGEncoder.h'],
+    },
+]
--- a/image/build/moz.build
+++ b/image/build/moz.build
@@ -7,16 +7,20 @@
 EXPORTS += [
     'nsImageModule.h',
 ]
 
 SOURCES += [
     'nsImageModule.cpp',
 ]
 
+XPCOM_MANIFESTS += [
+    'components.conf',
+]
+
 FINAL_LIBRARY = 'xul'
 LOCAL_INCLUDES += [
     '/image',
     '/image/encoders/bmp',
     '/image/encoders/ico',
     '/image/encoders/jpeg',
     '/image/encoders/png',
 ]
--- a/image/build/nsImageModule.cpp
+++ b/image/build/nsImageModule.cpp
@@ -2,142 +2,27 @@
  *
  * 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 "nsImageModule.h"
 
 #include "mozilla/ModuleUtils.h"
-#include "nsMimeTypes.h"
 
 #include "DecodePool.h"
 #include "ImageFactory.h"
 #include "ShutdownTracker.h"
 #include "SurfaceCache.h"
-#include "SurfacePipe.h"
 
 #include "gfxPrefs.h"
 #include "imgLoader.h"
-#include "imgRequest.h"
-#include "imgRequestProxy.h"
-#include "imgTools.h"
 
-#include "nsICOEncoder.h"
-#include "nsPNGEncoder.h"
-#include "nsJPEGEncoder.h"
-#include "nsBMPEncoder.h"
-
-// objects that just require generic constructors
 using namespace mozilla::image;
 
-// XXX We would like to get rid of the imgLoader factory constructor.  See the
-// comment documenting the imgLoader constructor.
-NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(imgLoader, Init)
-NS_GENERIC_FACTORY_CONSTRUCTOR(imgRequestProxy)
-NS_GENERIC_FACTORY_CONSTRUCTOR(imgTools)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsICOEncoder)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsJPEGEncoder)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsPNGEncoder)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsBMPEncoder)
-NS_DEFINE_NAMED_CID(NS_IMGLOADER_CID);
-NS_DEFINE_NAMED_CID(NS_IMGREQUESTPROXY_CID);
-NS_DEFINE_NAMED_CID(NS_IMGTOOLS_CID);
-NS_DEFINE_NAMED_CID(NS_ICOENCODER_CID);
-NS_DEFINE_NAMED_CID(NS_JPEGENCODER_CID);
-NS_DEFINE_NAMED_CID(NS_PNGENCODER_CID);
-NS_DEFINE_NAMED_CID(NS_BMPENCODER_CID);
-
-static const mozilla::Module::CIDEntry kImageCIDs[] = {
-    {
-        &kNS_IMGLOADER_CID,
-        false,
-        nullptr,
-        imgLoaderConstructor,
-    },
-    {
-        &kNS_IMGREQUESTPROXY_CID,
-        false,
-        nullptr,
-        imgRequestProxyConstructor,
-    },
-    {
-        &kNS_IMGTOOLS_CID,
-        false,
-        nullptr,
-        imgToolsConstructor,
-    },
-    {
-        &kNS_ICOENCODER_CID,
-        false,
-        nullptr,
-        nsICOEncoderConstructor,
-    },
-    {
-        &kNS_JPEGENCODER_CID,
-        false,
-        nullptr,
-        nsJPEGEncoderConstructor,
-    },
-    {
-        &kNS_PNGENCODER_CID,
-        false,
-        nullptr,
-        nsPNGEncoderConstructor,
-    },
-    {
-        &kNS_BMPENCODER_CID,
-        false,
-        nullptr,
-        nsBMPEncoderConstructor,
-    },
-    {nullptr}};
-
-static const mozilla::Module::ContractIDEntry kImageContracts[] = {
-    {"@mozilla.org/image/cache;1", &kNS_IMGLOADER_CID},
-    {"@mozilla.org/image/loader;1", &kNS_IMGLOADER_CID},
-    {"@mozilla.org/image/request;1", &kNS_IMGREQUESTPROXY_CID},
-    {"@mozilla.org/image/tools;1", &kNS_IMGTOOLS_CID},
-    {"@mozilla.org/image/encoder;2?type=" IMAGE_ICO_MS, &kNS_ICOENCODER_CID},
-    {"@mozilla.org/image/encoder;2?type=" IMAGE_JPEG, &kNS_JPEGENCODER_CID},
-    {"@mozilla.org/image/encoder;2?type=" IMAGE_PNG, &kNS_PNGENCODER_CID},
-    {"@mozilla.org/image/encoder;2?type=" IMAGE_BMP, &kNS_BMPENCODER_CID},
-    {nullptr}};
-
-static const mozilla::Module::CategoryEntry kImageCategories[] = {
-    {"Gecko-Content-Viewers", IMAGE_GIF,
-     "@mozilla.org/content/document-loader-factory;1"},
-    {"Gecko-Content-Viewers", IMAGE_JPEG,
-     "@mozilla.org/content/document-loader-factory;1"},
-    {"Gecko-Content-Viewers", IMAGE_PJPEG,
-     "@mozilla.org/content/document-loader-factory;1"},
-    {"Gecko-Content-Viewers", IMAGE_JPG,
-     "@mozilla.org/content/document-loader-factory;1"},
-    {"Gecko-Content-Viewers", IMAGE_ICO,
-     "@mozilla.org/content/document-loader-factory;1"},
-    {"Gecko-Content-Viewers", IMAGE_ICO_MS,
-     "@mozilla.org/content/document-loader-factory;1"},
-    {"Gecko-Content-Viewers", IMAGE_BMP,
-     "@mozilla.org/content/document-loader-factory;1"},
-    {"Gecko-Content-Viewers", IMAGE_BMP_MS,
-     "@mozilla.org/content/document-loader-factory;1"},
-    {"Gecko-Content-Viewers", IMAGE_ICON_MS,
-     "@mozilla.org/content/document-loader-factory;1"},
-    {"Gecko-Content-Viewers", IMAGE_PNG,
-     "@mozilla.org/content/document-loader-factory;1"},
-    {"Gecko-Content-Viewers", IMAGE_APNG,
-     "@mozilla.org/content/document-loader-factory;1"},
-    {"Gecko-Content-Viewers", IMAGE_X_PNG,
-     "@mozilla.org/content/document-loader-factory;1"},
-    {"Gecko-Content-Viewers", IMAGE_WEBP,
-     "@mozilla.org/content/document-loader-factory;1"},
-    {"content-sniffing-services", "@mozilla.org/image/loader;1",
-     "@mozilla.org/image/loader;1"},
-    {nullptr}};
-
 static bool sInitialized = false;
 nsresult mozilla::image::EnsureModuleInitialized() {
   MOZ_ASSERT(NS_IsMainThread());
 
   if (sInitialized) {
     return NS_OK;
   }
 
@@ -156,19 +41,8 @@ nsresult mozilla::image::EnsureModuleIni
 void mozilla::image::ShutdownModule() {
   if (!sInitialized) {
     return;
   }
   imgLoader::Shutdown();
   mozilla::image::SurfaceCache::Shutdown();
   sInitialized = false;
 }
-
-static const mozilla::Module kImageModule = {
-    mozilla::Module::kVersion, kImageCIDs, kImageContracts, kImageCategories,
-    nullptr, mozilla::image::EnsureModuleInitialized,
-    // We need to be careful about shutdown ordering to avoid intermittent
-    // crashes when hashtable enumeration decides to destroy modules in an
-    // unfortunate order. So our shutdown is invoked explicitly during layout
-    // module shutdown.
-    nullptr};
-
-NSMODULE_DEFN(nsImageLib2Module) = &kImageModule;
new file mode 100644
--- /dev/null
+++ b/image/decoders/icon/components.conf
@@ -0,0 +1,19 @@
+# -*- 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/.
+
+Classes = [
+    {
+        'cid': '{d0f9db12-249c-11d5-9905-001083010e9b}',
+        'contract_ids': ['@mozilla.org/network/protocol;1?name=moz-icon'],
+        'type': 'nsIconProtocolHandler',
+        'headers': ['/image/decoders/icon/nsIconProtocolHandler.h'],
+    },
+    {
+        'cid': '{1460df3b-774c-4205-8349-838e507c3ef9}',
+        'type': 'nsMozIconURI::Mutator',
+        'headers': ['/image/decoders/icon/nsIconURI.h'],
+    },
+]
--- a/image/decoders/icon/moz.build
+++ b/image/decoders/icon/moz.build
@@ -1,20 +1,23 @@
 # -*- 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/.
 
 UNIFIED_SOURCES += [
-    'nsIconModule.cpp',
     'nsIconProtocolHandler.cpp',
     'nsIconURI.cpp',
 ]
 
+XPCOM_MANIFESTS += [
+    'components.conf',
+]
+
 FINAL_LIBRARY = 'xul'
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 platform = None
 
 if 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']:
     platform = 'gtk'
deleted file mode 100644
--- a/image/decoders/icon/nsIconModule.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/* -*- 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 "mozilla/ModuleUtils.h"
-#include "nsServiceManagerUtils.h"
-
-#include "nsIconProtocolHandler.h"
-#include "nsIconURI.h"
-#include "nsIconChannel.h"
-
-// objects that just require generic constructors
-//*****************************************************************************
-// Protocol CIDs
-
-#define NS_ICONPROTOCOL_CID                                                    \
-  {                                                                            \
-    0xd0f9db12, 0x249c, 0x11d5, { 0x99, 0x5, 0x0, 0x10, 0x83, 0x1, 0xe, 0x9b } \
-  }
-
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsIconProtocolHandler)
-typedef nsMozIconURI::Mutator nsMozIconURIMutator;
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsMozIconURIMutator)
-
-NS_DEFINE_NAMED_CID(NS_ICONPROTOCOL_CID);
-NS_DEFINE_NAMED_CID(NS_MOZICONURIMUTATOR_CID);
-
-static const mozilla::Module::CIDEntry kIconCIDs[] = {
-    {&kNS_ICONPROTOCOL_CID, false, nullptr, nsIconProtocolHandlerConstructor},
-    {&kNS_MOZICONURIMUTATOR_CID, false, nullptr,
-     nsMozIconURIMutatorConstructor},
-    {nullptr}};
-
-static const mozilla::Module::ContractIDEntry kIconContracts[] = {
-    {NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "moz-icon", &kNS_ICONPROTOCOL_CID},
-    {nullptr}};
-
-static const mozilla::Module::CategoryEntry kIconCategories[] = {{nullptr}};
-
-static void IconDecoderModuleDtor() {}
-
-static const mozilla::Module kIconModule = {
-    mozilla::Module::kVersion, kIconCIDs, kIconContracts,
-    kIconCategories,           nullptr,   nullptr,
-    IconDecoderModuleDtor};
-
-NSMODULE_DEFN(nsIconDecoderModule) = &kIconModule;
--- a/layout/build/components.conf
+++ b/layout/build/components.conf
@@ -32,16 +32,30 @@ content_types = [
     'text/ecmascript',
     'text/html',
     'text/javascript',
     'text/json',
     'text/plain',
     'text/rdf',
     'text/vtt',
     'text/xml',
+
+    'image/apng',
+    'image/bmp',
+    'image/gif',
+    'image/icon',
+    'image/jpeg',
+    'image/jpg',
+    'image/pjpeg',
+    'image/png',
+    'image/vnd.microsoft.icon',
+    'image/webp',
+    'image/x-icon',
+    'image/x-ms-bmp',
+    'image/x-png',
 ]
 
 if defined('MOZ_WEBM'):
     content_types += [
         "audio/webm",
         "video/webm",
     ]