Bug 1524687: Part 10 - Convert Windows widget module to static registration. r=erahm
☠☠ backed out by 3b1b94e39795 ☠ ☠
authorKris Maglione <maglione.k@gmail.com>
Fri, 25 Jan 2019 15:20:36 -0800
changeset 458970 614be688767f
parent 458969 9c24919ac5c2
child 458971 46e13c453538
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)
reviewerserahm
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 10 - Convert Windows widget module to static registration. r=erahm
testing/xpcshell/head.js
widget/moz.build
widget/windows/components.conf
widget/windows/moz.build
widget/windows/nsWidgetFactory.cpp
widget/windows/nsWidgetFactory.h
--- a/testing/xpcshell/head.js
+++ b/testing/xpcshell/head.js
@@ -226,16 +226,21 @@ function _do_main() {
   tm.spinEventLoopUntilEmpty();
 }
 
 function _do_quit() {
   _testLogger.info("exiting test");
   _quit = true;
 }
 
+// This is useless, except to the extent that it has the side-effect of
+// initializing the widget module, which some tests unfortunately
+// accidentally rely on.
+void Cc["@mozilla.org/widget/transferable;1"].createInstance();
+
 /**
  * Overrides idleService with a mock.  Idle is commonly used for maintenance
  * tasks, thus if a test uses a service that requires the idle service, it will
  * start handling them.
  * This behaviour would cause random failures and slowdown tests execution,
  * for example by running database vacuum or cleanups for each test.
  *
  * @note Idle service is overridden by default.  If a test requires it, it will
@@ -247,22 +252,16 @@ var _fakeIdleService = {
     return this.registrar =
       Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
   },
   contractID: "@mozilla.org/widget/idleservice;1",
   CID: Components.ID("{9163a4ae-70c2-446c-9ac1-bbe4ab93004e}"),
 
   activate: function FIS_activate() {
     if (!this.originalCID) {
-      // This is useless, except to the extent that it has the
-      // side-effect of initializing the widget module, which some
-      // callers unfortunately accidentally rely on.
-      void Components.manager.getClassObject(Cc[this.contractID],
-                                             Ci.nsIFactory);
-
       this.originalCID = this.registrar.contractIDToCID(this.contractID);
       // Replace with the mock.
       this.registrar.registerFactory(this.CID, "Fake Idle Service",
                                      this.contractID, this.factory
       );
     }
   },
 
--- a/widget/moz.build
+++ b/widget/moz.build
@@ -122,16 +122,17 @@ XPIDL_SOURCES += [
 
 XPIDL_MODULE = 'widget'
 
 EXPORTS += [
     'GfxDriverInfo.h',
     'GfxInfoBase.h',
     'GfxInfoCollector.h',
     'InputData.h',
+    'nsBaseAppShell.h',
     'nsBaseDragService.h',
     'nsBaseFilePicker.h',
     'nsBaseScreen.h',
     'nsBaseWidget.h',
     'nsIDeviceContextSpec.h',
     'nsIdleService.h',
     'nsIKeyEventInPluginCallback.h',
     'nsIPluginWidget.h',
new file mode 100644
--- /dev/null
+++ b/widget/windows/components.conf
@@ -0,0 +1,199 @@
+# -*- 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 = [
+    '/widget/windows/nsWidgetFactory.h',
+]
+
+InitFunc = 'nsWidgetWindowsModuleCtor'
+UnloadFunc = 'nsWidgetWindowsModuleDtor'
+
+Classes = [
+    {
+        'cid': '{c401eb80-f9ea-11d3-bb6f-e732b73ebe7c}',
+        'contract_ids': ['@mozilla.org/gfx/screenmanager;1'],
+        'singleton': True,
+        'type': 'mozilla::widget::ScreenManager',
+        'constructor': 'mozilla::widget::ScreenManager::GetAddRefedSingleton',
+        'headers': ['/widget/ScreenManager.h'],
+        'processes': ProcessSelector.MAIN_PROCESS_ONLY,
+    },
+    {
+        'cid': '{2d96b3df-c051-11d1-a827-0040959a28c9}',
+        'contract_ids': ['@mozilla.org/widget/appshell/win;1'],
+        'headers': ['/widget/windows/nsWidgetFactory.h'],
+        'legacy_constructor': 'nsAppShellConstructor',
+        'processes': ProcessSelector.ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS,
+    },
+    {
+        'cid': '{6987230e-0098-4e78-bc5f-1493ee7519fa}',
+        'contract_ids': ['@mozilla.org/widget/idleservice;1'],
+        'singleton': True,
+        'type': 'nsIdleServiceWin',
+        'constructor': 'nsIdleServiceWin::GetInstance',
+        'headers': ['/widget/windows/nsIdleServiceWin.h', 'nsIdleService.h'],
+    },
+    {
+        'cid': '{b148eed2-236d-11d3-b35c-00a0cc3c1cde}',
+        'contract_ids': ['@mozilla.org/sound;1'],
+        'singleton': True,
+        'type': 'nsISound',
+        'constructor': 'nsSound::GetInstance',
+        'headers': ['/widget/windows/nsSound.h'],
+        'processes': ProcessSelector.MAIN_PROCESS_ONLY,
+    },
+    {
+        'cid': '{77221d5a-1dd2-11b2-8c69-c710f15d2ed5}',
+        'contract_ids': ['@mozilla.org/widget/clipboardhelper;1'],
+        'type': 'nsClipboardHelper',
+        'headers': ['/widget/nsClipboardHelper.h'],
+    },
+    {
+        'cid': '{b8e5bc54-a22f-4eb2-b061-24cb6d19c15f}',
+        'contract_ids': ['@mozilla.org/windows-taskbar;1'],
+        'type': 'mozilla::widget::WinTaskbar',
+        'headers': ['/widget/windows/WinTaskbar.h'],
+    },
+    {
+        'cid': '{73a5946f-608d-454f-9d33-0b8f8c7294b6}',
+        'contract_ids': ['@mozilla.org/windows-jumplistbuilder;1'],
+        'type': 'mozilla::widget::JumpListBuilder',
+        'headers': ['/widget/windows/JumpListBuilder.h'],
+    },
+    {
+        'cid': '{2b9a1f2c-27ce-45b6-8d4e-755d0e34f8db}',
+        'contract_ids': ['@mozilla.org/windows-jumplistitem;1'],
+        'type': 'mozilla::widget::JumpListItem',
+        'headers': ['/widget/windows/JumpListItem.h'],
+    },
+    {
+        'cid': '{21f1f13b-f75a-42ad-867a-d91ad694447e}',
+        'contract_ids': ['@mozilla.org/windows-jumplistseparator;1'],
+        'type': 'mozilla::widget::JumpListSeparator',
+        'headers': ['/widget/windows/JumpListItem.h'],
+    },
+    {
+        'cid': '{f72c5dc4-5a12-47be-be28-ab105f33b08f}',
+        'contract_ids': ['@mozilla.org/windows-jumplistlink;1'],
+        'type': 'mozilla::widget::JumpListLink',
+        'headers': ['/widget/windows/JumpListItem.h'],
+    },
+    {
+        'cid': '{b16656b2-5187-498f-abf4-56346126bfdb}',
+        'contract_ids': ['@mozilla.org/windows-jumplistshortcut;1'],
+        'type': 'mozilla::widget::JumpListShortcut',
+        'headers': ['/widget/windows/JumpListItem.h'],
+    },
+    {
+        'cid': '{e04a55e8-fee3-4ea2-a98b-41d2621adc3c}',
+        'contract_ids': ['@mozilla.org/windows-ui-utils;1'],
+        'type': 'WindowsUIUtils',
+        'headers': ['/widget/windows/WindowsUIUtils.h'],
+    },
+    {
+        'cid': '{8b5314bc-db01-11d2-96ce-0060b0fb9956}',
+        'contract_ids': ['@mozilla.org/widget/transferable;1'],
+        'type': 'nsTransferable',
+        'headers': ['/widget/nsTransferable.h'],
+    },
+    {
+        'cid': '{948a0023-e3a7-11d2-96cf-0060b0fb9956}',
+        'contract_ids': ['@mozilla.org/widget/htmlformatconverter;1'],
+        'type': 'nsHTMLFormatConverter',
+        'headers': ['/widget/nsHTMLFormatConverter.h'],
+    },
+    {
+        'cid': '{8b5314bb-db01-11d2-96ce-0060b0fb9956}',
+        'contract_ids': ['@mozilla.org/widget/dragservice;1'],
+        'type': 'nsDragService',
+        'headers': ['/widget/windows/nsDragService.h'],
+        'processes': ProcessSelector.MAIN_PROCESS_ONLY,
+    },
+    {
+        'cid': '{9a0cb62b-d638-4faf-9588-ae96f5e29093}',
+        'contract_ids': ['@mozilla.org/widget/taskbar-preview-callback;1'],
+        'type': 'mozilla::widget::TaskbarPreviewCallback',
+        'headers': ['/widget/windows/TaskbarPreview.h'],
+    },
+    {
+        'cid': '{d755a760-9f27-11df-0800-200c9a664242}',
+        'contract_ids': ['@mozilla.org/gfx/info;1'],
+        'type': 'mozilla::widget::GfxInfo',
+        'headers': ['/widget/windows/GfxInfo.h'],
+        'init_method': 'Init',
+        'processes': ProcessSelector.ALLOW_IN_GPU_AND_SOCKET_PROCESS,
+    },
+    {
+        'cid': '{bd57cee8-1dd1-11b2-9fe7-95cf4709aea3}',
+        'contract_ids': ['@mozilla.org/filepicker;1'],
+        'type': 'nsFilePicker',
+        'headers': ['/widget/windows/nsFilePicker.h'],
+        'processes': ProcessSelector.MAIN_PROCESS_ONLY,
+    },
+    {
+        'cid': '{0f872c8c-3ee6-46bd-92a2-69652c6b474e}',
+        'contract_ids': ['@mozilla.org/colorpicker;1'],
+        'type': 'nsColorPicker',
+        'headers': ['/widget/windows/nsColorPicker.h'],
+        'processes': ProcessSelector.MAIN_PROCESS_ONLY,
+    },
+    {
+        'cid': '{8b5314ba-db01-11d2-96ce-0060b0fb9956}',
+        'contract_ids': ['@mozilla.org/widget/clipboard;1'],
+        'type': 'nsIClipboard',
+        'processes': ProcessSelector.MAIN_PROCESS_ONLY,
+    },
+]
+
+if buildconfig.substs['CC_TYPE'] in ('msvc', 'clang-cl'):
+    Classes += [
+        {
+            'cid': '{84e11f80-ca55-11dd-ad8b-0800200c9a66}',
+            'contract_ids': ['@mozilla.org/system-alerts-service;1'],
+            'type': 'mozilla::widget::ToastNotification',
+            'headers': ['/widget/windows/ToastNotification.h'],
+            'init_method': 'Init',
+            'processes': ProcessSelector.MAIN_PROCESS_ONLY,
+        },
+    ]
+
+if defined('NS_PRINTING'):
+    Classes += [
+        {
+            'cid': '{d3f69889-e13a-4321-980c-a39332e21f34}',
+            'contract_ids': ['@mozilla.org/gfx/devicecontextspec;1'],
+            'type': 'nsDeviceContextSpecWin',
+            'headers': ['/widget/windows/nsDeviceContextSpecWin.h'],
+        },
+        {
+            'cid': '{06beec76-a183-4d9f-85dd-085f26da565a}',
+            'contract_ids': ['@mozilla.org/widget/printdialog-service;1'],
+            'type': 'nsPrintDialogServiceWin',
+            'headers': ['/widget/windows/nsPrintDialogWin.h'],
+            'init_method': 'Init',
+            'processes': ProcessSelector.MAIN_PROCESS_ONLY,
+        },
+        {
+            'cid': '{841387c8-72e6-484b-9296-bf6eea80d58a}',
+            'contract_ids': ['@mozilla.org/gfx/printsettings-service;1'],
+            'type': 'nsPrintSettingsServiceWin',
+            'headers': ['/widget/windows/nsPrintSettingsServiceWin.h'],
+            'init_method': 'Init',
+        },
+        {
+            'cid': '{a6cf9129-15b3-11d2-932e-00805f8add32}',
+            'contract_ids': ['@mozilla.org/gfx/printerenumerator;1'],
+            'type': 'nsPrinterEnumeratorWin',
+            'headers': ['/widget/windows/nsDeviceContextSpecWin.h'],
+        },
+        {
+            'cid': '{2f977d53-5485-11d4-87e2-0010a4e75ef2}',
+            'contract_ids': ['@mozilla.org/gfx/printsession;1'],
+            'type': 'nsPrintSession',
+            'headers': ['/widget/nsPrintSession.h'],
+            'init_method': 'Init',
+        },
+    ]
--- a/widget/windows/moz.build
+++ b/widget/windows/moz.build
@@ -111,16 +111,20 @@ if CONFIG['MOZ_ENABLE_SKIA_PDF']:
         'WindowsEMF.cpp',
     ]
 
 if CONFIG['NS_ENABLE_TSF']:
     SOURCES += [
         'TSFTextStore.cpp',
     ]
 
+XPCOM_MANIFESTS += [
+    'components.conf',
+]
+
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'
 
 if CONFIG['MOZ_ENABLE_SKIA_PDF']:
   LOCAL_INCLUDES += CONFIG['SKIA_INCLUDES']
   LOCAL_INCLUDES += [
     '/gfx/skia/skia/include/config',
--- a/widget/windows/nsWidgetFactory.cpp
+++ b/widget/windows/nsWidgetFactory.cpp
@@ -1,277 +1,64 @@
 /* -*- Mode: C++; tab-width: 4; 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 "nsWidgetFactory.h"
+
+#include "mozilla/Components.h"
 #include "nsIFactory.h"
 #include "nsISupports.h"
 #include "nsdefs.h"
 #include "nsWidgetsCID.h"
 #include "nsAppShell.h"
 #include "nsAppShellSingleton.h"
-#include "mozilla/ModuleUtils.h"
 #include "mozilla/WidgetUtils.h"
 #include "mozilla/widget/ScreenManager.h"
 #include "nsIServiceManager.h"
-#include "nsIdleServiceWin.h"
 #include "nsLookAndFeel.h"
-#include "nsSound.h"
 #include "WinMouseScrollHandler.h"
 #include "KeyboardLayout.h"
-#include "GfxInfo.h"
 #include "nsToolkit.h"
 
 // Modules that switch out based on the environment
 #include "nsXULAppAPI.h"
 // Desktop
 #include "nsFilePicker.h"  // needs to be included before other shobjidl.h includes
 #include "nsColorPicker.h"
 // Content processes
 #include "nsFilePickerProxy.h"
 
-// Drag & Drop, Clipboard
+// Clipboard
 #include "nsClipboardHelper.h"
 #include "nsClipboard.h"
 #include "HeadlessClipboard.h"
-#include "nsDragService.h"
-#include "nsTransferable.h"
-#include "nsHTMLFormatConverter.h"
-
-#include "WinTaskbar.h"
-#include "JumpListBuilder.h"
-#include "JumpListItem.h"
-#include "TaskbarPreview.h"
-// Toast notification support
-#ifndef __MINGW32__
-#  include "ToastNotification.h"
-#  include "nsToolkitCompsCID.h"
-#endif
 
 #include "WindowsUIUtils.h"
 
-#ifdef NS_PRINTING
-#  include "nsDeviceContextSpecWin.h"
-#  include "nsPrintDialogWin.h"
-#  include "nsPrintSettingsServiceWin.h"
-#  include "nsPrintSession.h"
-#endif
-
 using namespace mozilla;
 using namespace mozilla::widget;
 
-static nsresult FilePickerConstructor(nsISupports *aOuter, REFNSIID aIID,
-                                      void **aResult) {
-  *aResult = nullptr;
-  if (aOuter != nullptr) {
-    return NS_ERROR_NO_AGGREGATION;
-  }
-  nsCOMPtr<nsIFilePicker> picker = new nsFilePicker;
-  return picker->QueryInterface(aIID, aResult);
-}
-
-static nsresult ColorPickerConstructor(nsISupports *aOuter, REFNSIID aIID,
-                                       void **aResult) {
-  *aResult = nullptr;
-  if (aOuter != nullptr) {
-    return NS_ERROR_NO_AGGREGATION;
-  }
-  nsCOMPtr<nsIColorPicker> picker = new nsColorPicker;
-  return picker->QueryInterface(aIID, aResult);
-}
-
-static nsresult nsClipboardConstructor(nsISupports *aOuter, REFNSIID aIID,
-                                       void **aResult) {
-  *aResult = nullptr;
-  if (aOuter != nullptr) {
-    return NS_ERROR_NO_AGGREGATION;
-  }
+NS_IMPL_COMPONENT_FACTORY(nsIClipboard) {
   nsCOMPtr<nsIClipboard> inst;
   if (gfxPlatform::IsHeadless()) {
     inst = new HeadlessClipboard();
   } else {
     inst = new nsClipboard();
   }
-  return inst->QueryInterface(aIID, aResult);
+  return inst.forget().downcast<nsISupports>();
 }
 
-NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(ScreenManager,
-                                         ScreenManager::GetAddRefedSingleton)
-NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIdleServiceWin,
-                                         nsIdleServiceWin::GetInstance)
-NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsISound, nsSound::GetInstance)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper)
-NS_GENERIC_FACTORY_CONSTRUCTOR(WinTaskbar)
-NS_GENERIC_FACTORY_CONSTRUCTOR(JumpListBuilder)
-NS_GENERIC_FACTORY_CONSTRUCTOR(JumpListItem)
-NS_GENERIC_FACTORY_CONSTRUCTOR(JumpListSeparator)
-NS_GENERIC_FACTORY_CONSTRUCTOR(JumpListLink)
-NS_GENERIC_FACTORY_CONSTRUCTOR(JumpListShortcut)
-NS_GENERIC_FACTORY_CONSTRUCTOR(WindowsUIUtils)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService)
-#ifndef __MINGW32__
-NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(ToastNotification, Init)
-#endif
-NS_GENERIC_FACTORY_CONSTRUCTOR(TaskbarPreviewCallback)
-#ifdef NS_PRINTING
-NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintDialogServiceWin, Init)
-NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSettingsServiceWin, Init)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrinterEnumeratorWin)
-NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecWin)
-#endif
-
-namespace mozilla {
-namespace widget {
-// This constructor should really be shared with all platforms.
-NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(GfxInfo, Init)
-}  // namespace widget
-}  // namespace mozilla
-
-NS_DEFINE_NAMED_CID(NS_FILEPICKER_CID);
-NS_DEFINE_NAMED_CID(NS_COLORPICKER_CID);
-NS_DEFINE_NAMED_CID(NS_APPSHELL_CID);
-NS_DEFINE_NAMED_CID(NS_SCREENMANAGER_CID);
-NS_DEFINE_NAMED_CID(NS_GFXINFO_CID);
-NS_DEFINE_NAMED_CID(NS_IDLE_SERVICE_CID);
-NS_DEFINE_NAMED_CID(NS_CLIPBOARD_CID);
-NS_DEFINE_NAMED_CID(NS_CLIPBOARDHELPER_CID);
-NS_DEFINE_NAMED_CID(NS_SOUND_CID);
-NS_DEFINE_NAMED_CID(NS_TRANSFERABLE_CID);
-NS_DEFINE_NAMED_CID(NS_HTMLFORMATCONVERTER_CID);
-NS_DEFINE_NAMED_CID(NS_WIN_TASKBAR_CID);
-NS_DEFINE_NAMED_CID(NS_WIN_JUMPLISTBUILDER_CID);
-NS_DEFINE_NAMED_CID(NS_WIN_JUMPLISTITEM_CID);
-NS_DEFINE_NAMED_CID(NS_WIN_JUMPLISTSEPARATOR_CID);
-NS_DEFINE_NAMED_CID(NS_WIN_JUMPLISTLINK_CID);
-NS_DEFINE_NAMED_CID(NS_WIN_JUMPLISTSHORTCUT_CID);
-NS_DEFINE_NAMED_CID(NS_WINDOWS_UIUTILS_CID);
-NS_DEFINE_NAMED_CID(NS_DRAGSERVICE_CID);
-#ifndef __MINGW32__
-NS_DEFINE_NAMED_CID(NS_SYSTEMALERTSSERVICE_CID);
-#endif
-NS_DEFINE_NAMED_CID(NS_TASKBARPREVIEWCALLBACK_CID);
-#ifdef NS_PRINTING
-NS_DEFINE_NAMED_CID(NS_PRINTDIALOGSERVICE_CID);
-NS_DEFINE_NAMED_CID(NS_PRINTSETTINGSSERVICE_CID);
-NS_DEFINE_NAMED_CID(NS_PRINTER_ENUMERATOR_CID);
-NS_DEFINE_NAMED_CID(NS_PRINTSESSION_CID);
-NS_DEFINE_NAMED_CID(NS_DEVICE_CONTEXT_SPEC_CID);
-#endif
+nsresult nsWidgetWindowsModuleCtor() {
+  return nsAppShellInit();
+}
 
-static const mozilla::Module::CIDEntry kWidgetCIDs[] = {
-    {&kNS_FILEPICKER_CID, false, nullptr, FilePickerConstructor,
-     Module::MAIN_PROCESS_ONLY},
-    {&kNS_COLORPICKER_CID, false, nullptr, ColorPickerConstructor,
-     Module::MAIN_PROCESS_ONLY},
-    {&kNS_APPSHELL_CID, false, nullptr, nsAppShellConstructor,
-     Module::ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS},
-    {&kNS_SCREENMANAGER_CID, false, nullptr, ScreenManagerConstructor,
-     Module::MAIN_PROCESS_ONLY},
-    {&kNS_GFXINFO_CID, false, nullptr, GfxInfoConstructor,
-     Module::ALLOW_IN_GPU_AND_SOCKET_PROCESS},
-    {&kNS_IDLE_SERVICE_CID, false, nullptr, nsIdleServiceWinConstructor},
-    {&kNS_CLIPBOARD_CID, false, nullptr, nsClipboardConstructor,
-     Module::MAIN_PROCESS_ONLY},
-    {&kNS_CLIPBOARDHELPER_CID, false, nullptr, nsClipboardHelperConstructor},
-    {&kNS_SOUND_CID, false, nullptr, nsISoundConstructor,
-     Module::MAIN_PROCESS_ONLY},
-    {&kNS_TRANSFERABLE_CID, false, nullptr, nsTransferableConstructor},
-    {&kNS_HTMLFORMATCONVERTER_CID, false, nullptr,
-     nsHTMLFormatConverterConstructor},
-    {&kNS_WIN_TASKBAR_CID, false, nullptr, WinTaskbarConstructor},
-    {&kNS_WIN_JUMPLISTBUILDER_CID, false, nullptr, JumpListBuilderConstructor},
-    {&kNS_WIN_JUMPLISTITEM_CID, false, nullptr, JumpListItemConstructor},
-    {&kNS_WIN_JUMPLISTSEPARATOR_CID, false, nullptr,
-     JumpListSeparatorConstructor},
-    {&kNS_WIN_JUMPLISTLINK_CID, false, nullptr, JumpListLinkConstructor},
-    {&kNS_WIN_JUMPLISTSHORTCUT_CID, false, nullptr,
-     JumpListShortcutConstructor},
-    {&kNS_WINDOWS_UIUTILS_CID, false, nullptr, WindowsUIUtilsConstructor},
-    {&kNS_DRAGSERVICE_CID, false, nullptr, nsDragServiceConstructor,
-     Module::MAIN_PROCESS_ONLY},
-#ifndef __MINGW32__
-    {&kNS_SYSTEMALERTSSERVICE_CID, false, nullptr, ToastNotificationConstructor,
-     Module::MAIN_PROCESS_ONLY},
-#endif
-    {&kNS_TASKBARPREVIEWCALLBACK_CID, false, nullptr,
-     TaskbarPreviewCallbackConstructor},
-#ifdef NS_PRINTING
-    {&kNS_PRINTDIALOGSERVICE_CID, false, nullptr,
-     nsPrintDialogServiceWinConstructor, Module::MAIN_PROCESS_ONLY},
-    {&kNS_PRINTSETTINGSSERVICE_CID, false, nullptr,
-     nsPrintSettingsServiceWinConstructor},
-    {&kNS_PRINTER_ENUMERATOR_CID, false, nullptr,
-     nsPrinterEnumeratorWinConstructor},
-    {&kNS_PRINTSESSION_CID, false, nullptr, nsPrintSessionConstructor},
-    {&kNS_DEVICE_CONTEXT_SPEC_CID, false, nullptr,
-     nsDeviceContextSpecWinConstructor},
-#endif
-    {nullptr}};
-
-static const mozilla::Module::ContractIDEntry kWidgetContracts[] = {
-    {"@mozilla.org/filepicker;1", &kNS_FILEPICKER_CID,
-     Module::MAIN_PROCESS_ONLY},
-    {"@mozilla.org/colorpicker;1", &kNS_COLORPICKER_CID,
-     Module::MAIN_PROCESS_ONLY},
-    {"@mozilla.org/widget/appshell/win;1", &kNS_APPSHELL_CID,
-     Module::ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS},
-    {"@mozilla.org/gfx/screenmanager;1", &kNS_SCREENMANAGER_CID,
-     Module::MAIN_PROCESS_ONLY},
-    {"@mozilla.org/gfx/info;1", &kNS_GFXINFO_CID,
-     Module::ALLOW_IN_GPU_AND_SOCKET_PROCESS},
-    {"@mozilla.org/widget/idleservice;1", &kNS_IDLE_SERVICE_CID},
-    {"@mozilla.org/widget/clipboard;1", &kNS_CLIPBOARD_CID,
-     Module::MAIN_PROCESS_ONLY},
-    {"@mozilla.org/widget/clipboardhelper;1", &kNS_CLIPBOARDHELPER_CID},
-    {"@mozilla.org/sound;1", &kNS_SOUND_CID, Module::MAIN_PROCESS_ONLY},
-    {"@mozilla.org/widget/transferable;1", &kNS_TRANSFERABLE_CID},
-    {"@mozilla.org/widget/htmlformatconverter;1", &kNS_HTMLFORMATCONVERTER_CID},
-    {"@mozilla.org/windows-taskbar;1", &kNS_WIN_TASKBAR_CID},
-    {"@mozilla.org/windows-jumplistbuilder;1", &kNS_WIN_JUMPLISTBUILDER_CID},
-    {"@mozilla.org/windows-jumplistitem;1", &kNS_WIN_JUMPLISTITEM_CID},
-    {"@mozilla.org/windows-jumplistseparator;1",
-     &kNS_WIN_JUMPLISTSEPARATOR_CID},
-    {"@mozilla.org/windows-jumplistlink;1", &kNS_WIN_JUMPLISTLINK_CID},
-    {"@mozilla.org/windows-jumplistshortcut;1", &kNS_WIN_JUMPLISTSHORTCUT_CID},
-    {"@mozilla.org/windows-ui-utils;1", &kNS_WINDOWS_UIUTILS_CID},
-    {"@mozilla.org/widget/dragservice;1", &kNS_DRAGSERVICE_CID,
-     Module::MAIN_PROCESS_ONLY},
-#ifndef __MINGW32__
-    {NS_SYSTEMALERTSERVICE_CONTRACTID, &kNS_SYSTEMALERTSSERVICE_CID,
-     Module::MAIN_PROCESS_ONLY},
-#endif
-    {"@mozilla.org/widget/taskbar-preview-callback;1",
-     &kNS_TASKBARPREVIEWCALLBACK_CID},
-#ifdef NS_PRINTING
-    {NS_PRINTDIALOGSERVICE_CONTRACTID, &kNS_PRINTDIALOGSERVICE_CID},
-    {"@mozilla.org/gfx/printsettings-service;1", &kNS_PRINTSETTINGSSERVICE_CID},
-    {"@mozilla.org/gfx/printerenumerator;1", &kNS_PRINTER_ENUMERATOR_CID},
-    {"@mozilla.org/gfx/printsession;1", &kNS_PRINTSESSION_CID},
-    {"@mozilla.org/gfx/devicecontextspec;1", &kNS_DEVICE_CONTEXT_SPEC_CID},
-#endif
-    {nullptr}};
-
-static void nsWidgetWindowsModuleDtor() {
+void nsWidgetWindowsModuleDtor() {
   // Shutdown all XP level widget classes.
   WidgetUtils::Shutdown();
 
   KeyboardLayout::Shutdown();
   MouseScrollHandler::Shutdown();
   nsLookAndFeel::Shutdown();
   nsToolkit::Shutdown();
   nsAppShellShutdown();
 }
-
-static const mozilla::Module kWidgetModule = {
-    mozilla::Module::kVersion,
-    kWidgetCIDs,
-    kWidgetContracts,
-    nullptr,
-    nullptr,
-    nsAppShellInit,
-    nsWidgetWindowsModuleDtor,
-    Module::ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS};
-
-NSMODULE_DEFN(nsWidgetModule) = &kWidgetModule;
new file mode 100644
--- /dev/null
+++ b/widget/windows/nsWidgetFactory.h
@@ -0,0 +1,22 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=4:tabstop=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 widget_windows_nsWidgetFactory_h
+#define widget_windows_nsWidgetFactory_h
+
+#include "nscore.h"
+#include "nsID.h"
+
+class nsISupports;
+
+nsresult nsAppShellConstructor(nsISupports *outer, const nsIID &iid,
+                               void **result);
+
+nsresult nsWidgetWindowsModuleCtor();
+void nsWidgetWindowsModuleDtor();
+
+#endif  // defined widget_windows_nsWidgetFactory_h