From fe9734c5db5f7d862e585d557e3a7e57e8deea15 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Thu, 23 Jun 2022 23:05:36 +0000 Subject: [PATCH] Bug 1773770: Part 9 - Migrate widget component content proxies to static registration. r=mccr8 Several widget contracts use different implementations in the parent and content processes. Since the static registration system builds its hashtable at compile time rather than runtime, it doesn't support different contract IDs per process. It could make the decision at lookup time, but given how rarely it's needed, I don't think it would be worth the complexity. This patch updates the widget components that need different implementations in the parent and content process to register separate contracts for each implementation, and a third stub contract which forwards to the appropriate implementation depending on which process it's used in. The implementation entries restrict their usage to the process they are meant to be used in. Differential Revision: https://phabricator.services.mozilla.com/D149436 --- .../geckoview/ColorPickerDelegate.jsm | 3 - .../components/geckoview/components.conf | 8 +- .../tests/browser/browser_xpcom_graph_wait.js | 2 +- widget/android/components.conf | 10 +- widget/cocoa/components.conf | 26 +++-- widget/components.conf | 98 +++++++++++++++++++ widget/gtk/components.conf | 26 +++-- widget/moz.build | 5 +- widget/nsContentProcessWidgetFactory.cpp | 65 ------------ widget/nsContentProcessWidgetFactory.h | 48 +++++++++ widget/windows/components.conf | 26 +++-- xpcom/components/nsComponentManager.cpp | 7 +- 12 files changed, 197 insertions(+), 127 deletions(-) create mode 100644 widget/components.conf delete mode 100644 widget/nsContentProcessWidgetFactory.cpp create mode 100644 widget/nsContentProcessWidgetFactory.h diff --git a/mobile/android/components/geckoview/ColorPickerDelegate.jsm b/mobile/android/components/geckoview/ColorPickerDelegate.jsm index c0543dd53c1d8..ad757df2afbbf 100644 --- a/mobile/android/components/geckoview/ColorPickerDelegate.jsm +++ b/mobile/android/components/geckoview/ColorPickerDelegate.jsm @@ -40,9 +40,6 @@ class ColorPickerDelegate { } } -ColorPickerDelegate.prototype.classID = Components.ID( - "{aa0dd6fc-73dd-4621-8385-c0b377e02cee}" -); ColorPickerDelegate.prototype.QueryInterface = ChromeUtils.generateQI([ "nsIColorPicker", ]); diff --git a/mobile/android/components/geckoview/components.conf b/mobile/android/components/geckoview/components.conf index 65119010473d0..3e54e4c8403a4 100644 --- a/mobile/android/components/geckoview/components.conf +++ b/mobile/android/components/geckoview/components.conf @@ -41,15 +41,15 @@ Classes = [ 'constructor': 'PushService', }, { - 'cid': '{aa0dd6fc-73dd-4621-8385-c0b377e02cee}', - 'contract_ids': ['@mozilla.org/colorpicker;1'], + 'cid': '{fc4bec74-ddd0-4ea8-9a66-9a5081258e32}', + 'contract_ids': ['@mozilla.org/parent/colorpicker;1'], 'jsm': 'resource://gre/modules/ColorPickerDelegate.jsm', 'constructor': 'ColorPickerDelegate', 'processes': ProcessSelector.MAIN_PROCESS_ONLY, }, { - 'cid': '{e4565e36-f101-4bf5-950b-4be0887785a9}', - 'contract_ids': ['@mozilla.org/filepicker;1'], + 'cid': '{25fdbae6-f684-4bf0-b773-ff2b7a6273c8}', + 'contract_ids': ['@mozilla.org/parent/filepicker;1'], 'jsm': 'resource://gre/modules/FilePickerDelegate.jsm', 'constructor': 'FilePickerDelegate', 'processes': ProcessSelector.MAIN_PROCESS_ONLY, diff --git a/toolkit/components/backgroundtasks/tests/browser/browser_xpcom_graph_wait.js b/toolkit/components/backgroundtasks/tests/browser/browser_xpcom_graph_wait.js index 1c01dfdc78de5..5297f2009b731 100644 --- a/toolkit/components/backgroundtasks/tests/browser/browser_xpcom_graph_wait.js +++ b/toolkit/components/backgroundtasks/tests/browser/browser_xpcom_graph_wait.js @@ -109,7 +109,7 @@ const backgroundtaskPhases = { condition: WIN, }, { - name: "@mozilla.org/gfx/screenmanager;1", + name: "@mozilla.org/gfx/parent/screenmanager;1", condition: WIN, }, ], diff --git a/widget/android/components.conf b/widget/android/components.conf index 15b0e6d1d9826..3b926771f371d 100644 --- a/widget/android/components.conf +++ b/widget/android/components.conf @@ -20,8 +20,8 @@ Classes = [ 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_AND_UTILITY_PROCESS, }, { - 'cid': '{c401eb80-f9ea-11d3-bb6f-e732b73ebe7c}', - 'contract_ids': ['@mozilla.org/gfx/screenmanager;1'], + 'cid': '{d594094c-28b6-466b-97d7-66c039c3dea9}', + 'contract_ids': ['@mozilla.org/gfx/parent/screenmanager;1'], 'singleton': True, 'type': 'mozilla::widget::ScreenManager', 'headers': ['mozilla/widget/ScreenManager.h'], @@ -43,14 +43,12 @@ Classes = [ 'headers': ['/widget/nsTransferable.h'], }, { - 'js_name': 'clipboard', - 'cid': '{8b5314ba-db01-11d2-96ce-0060b0fb9956}', - 'contract_ids': ['@mozilla.org/widget/clipboard;1'], + 'cid': '{9d5adbb9-1da4-4162-acba-b373fe3ae837}', + 'contract_ids': ['@mozilla.org/widget/parent/clipboard;1'], 'interfaces': ['nsIClipboard'], 'type': 'nsClipboard', 'headers': ['/widget/android/nsClipboard.h'], 'processes': ProcessSelector.MAIN_PROCESS_ONLY, - 'overridable': True, }, { 'cid': '{77221d5a-1dd2-11b2-8c69-c710f15d2ed5}', diff --git a/widget/cocoa/components.conf b/widget/cocoa/components.conf index 2f126c7e89979..199e5cf255086 100644 --- a/widget/cocoa/components.conf +++ b/widget/cocoa/components.conf @@ -11,13 +11,11 @@ UnloadFunc = 'nsWidgetCocoaModuleDtor' Classes = [ { - 'js_name': 'clipboard', - 'cid': '{8b5314ba-db01-11d2-96ce-0060b0fb9956}', - 'contract_ids': ['@mozilla.org/widget/clipboard;1'], + 'cid': '{49f428e8-baf9-4ba3-b1b0-7d2fd3abbcea}', + 'contract_ids': ['@mozilla.org/widget/parent/clipboard;1'], 'interfaces': ['nsIClipboard'], 'type': 'nsIClipboard', 'processes': ProcessSelector.MAIN_PROCESS_ONLY, - 'overridable': True, }, { 'name': 'GfxInfo', @@ -28,14 +26,14 @@ Classes = [ 'init_method': 'Init', }, { - 'cid': '{bd57cee8-1dd1-11b2-9fe7-95cf4709aea3}', - 'contract_ids': ['@mozilla.org/filepicker;1'], + 'cid': '{e5170091-c16b-492d-bf00-f45d72470553}', + 'contract_ids': ['@mozilla.org/parent/filepicker;1'], 'type': 'nsFilePicker', 'processes': ProcessSelector.MAIN_PROCESS_ONLY, }, { - 'cid': '{0f872c8c-3ee6-46bd-92a2-69652c6b474e}', - 'contract_ids': ['@mozilla.org/colorpicker;1'], + 'cid': '{b90f5fdd-c23e-4ad6-a10e-1da8ffe07799}', + 'contract_ids': ['@mozilla.org/parent/colorpicker;1'], 'type': 'nsColorPicker', 'processes': ProcessSelector.MAIN_PROCESS_ONLY, }, @@ -46,8 +44,8 @@ Classes = [ 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_AND_UTILITY_PROCESS, }, { - 'cid': '{b148eed2-236d-11d3-b35c-00a0cc3c1cde}', - 'contract_ids': ['@mozilla.org/sound;1'], + 'cid': '{15cc80a9-5329-4fcb-9a0b-c6cf1440ae51}', + 'contract_ids': ['@mozilla.org/parent/sound;1'], 'type': 'nsSound', 'processes': ProcessSelector.MAIN_PROCESS_ONLY, }, @@ -70,14 +68,14 @@ Classes = [ 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_AND_UTILITY_PROCESS, }, { - 'cid': '{8b5314bb-db01-11d2-96ce-0060b0fb9956}', - 'contract_ids': ['@mozilla.org/widget/dragservice;1'], + 'cid': '{9a155bb2-2b67-45de-83e3-13a9dacf8336}', + 'contract_ids': ['@mozilla.org/widget/parent/dragservice;1'], 'type': 'nsDragService', 'processes': ProcessSelector.MAIN_PROCESS_ONLY, }, { - 'cid': '{c401eb80-f9ea-11d3-bb6f-e732b73ebe7c}', - 'contract_ids': ['@mozilla.org/gfx/screenmanager;1'], + 'cid': '{f0ddedd7-e8d5-4f95-a5b4-0f48f1741b36}', + 'contract_ids': ['@mozilla.org/gfx/parent/screenmanager;1'], 'type': 'mozilla::widget::ScreenManager', 'processes': ProcessSelector.MAIN_PROCESS_ONLY, 'singleton': True, diff --git a/widget/components.conf b/widget/components.conf new file mode 100644 index 0000000000000..4fa7da3bc9cfc --- /dev/null +++ b/widget/components.conf @@ -0,0 +1,98 @@ +# -*- 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 = [ + { + 'js_name': 'clipboard', + 'cid': '{8b5314ba-db01-11d2-96ce-0060b0fb9956}', + 'contract_ids': ['@mozilla.org/widget/clipboard;1'], + 'constructor': 'nsClipboardSelector', + 'headers': ['/widget/nsContentProcessWidgetFactory.h'], + 'interfaces': ['nsIClipboard'], + 'overridable': True, + }, + { + 'cid': '{c0ed2a75-96f8-4166-91d4-2fe8774448dc}', + 'type': 'nsClipboardProxy', + 'headers': ['/widget/nsClipboardProxy.h'], + 'contract_ids': ['@mozilla.org/widget/content/clipboard;1'], + 'processes': ProcessSelector.CONTENT_PROCESS_ONLY, + }, + + { + 'cid': '{0f872c8c-3ee6-46bd-92a2-69652c6b474e}', + 'contract_ids': ['@mozilla.org/colorpicker;1'], + 'constructor': 'nsColorPickerSelector', + 'headers': ['/widget/nsContentProcessWidgetFactory.h'], + }, + { + 'cid': '{11a77259-9d16-4386-8ac8-94338ee22f78}', + 'type': 'nsColorPickerProxy', + 'headers': ['/widget/nsColorPickerProxy.h'], + 'contract_ids': ['@mozilla.org/content/colorpicker;1'], + 'processes': ProcessSelector.CONTENT_PROCESS_ONLY, + }, + + { + 'cid': '{8b5314bb-db01-11d2-96ce-0060b0fb9956}', + 'contract_ids': ['@mozilla.org/widget/dragservice;1'], + 'constructor': 'nsDragServiceSelector', + 'headers': ['/widget/nsContentProcessWidgetFactory.h'], + }, + { + 'cid': '{28be18ae-73ee-494f-8c6d-5d14b7c998c7}', + 'type': 'nsDragServiceProxy', + 'headers': ['/widget/nsDragServiceProxy.h'], + 'contract_ids': ['@mozilla.org/widget/content/dragservice;1'], + 'processes': ProcessSelector.CONTENT_PROCESS_ONLY, + }, + + { + 'cid': '{bd57cee8-1dd1-11b2-9fe7-95cf4709aea3}', + 'contract_ids': ['@mozilla.org/filepicker;1'], + 'constructor': 'nsFilePickerSelector', + 'headers': ['/widget/nsContentProcessWidgetFactory.h'], + }, + { + 'cid': '{40fd47f2-463a-4e4a-a33f-27eb148bfee4}', + 'type': 'nsFilePickerProxy', + 'headers': ['/widget/nsFilePickerProxy.h'], + 'contract_ids': ['@mozilla.org/content/filepicker;1'], + 'processes': ProcessSelector.CONTENT_PROCESS_ONLY, + }, + + { + 'cid': '{b148eed2-236d-11d3-b35c-00a0cc3c1cde}', + 'contract_ids': ['@mozilla.org/sound;1'], + 'singleton': True, + 'constructor': 'nsSoundSelector', + 'headers': ['/widget/nsContentProcessWidgetFactory.h'], + }, + { + 'cid': '{b02c2470-6e5a-4865-a202-8b5ebae52632}', + 'type': 'nsSoundProxy', + 'headers': ['/widget/nsSoundProxy.h'], + 'contract_ids': ['@mozilla.org/content/sound;1'], + 'processes': ProcessSelector.CONTENT_PROCESS_ONLY, + }, + + { + 'cid': '{c401eb80-f9ea-11d3-bb6f-e732b73ebe7c}', + 'contract_ids': ['@mozilla.org/gfx/screenmanager;1'], + 'singleton': True, + 'constructor': 'nsScreenManagerSelector', + 'headers': ['/widget/nsContentProcessWidgetFactory.h'], + }, + { + 'cid': '{b2cdd51c-4277-417b-a931-08306c7814c3}', + 'type': 'mozilla::widget::ScreenManager', + 'constructor': 'mozilla::widget::ScreenManager::GetAddRefedSingleton', + 'headers': ['mozilla/widget/ScreenManager.h'], + 'contract_ids': ['@mozilla.org/gfx/content/screenmanager;1'], + 'singleton': True, + 'processes': ProcessSelector.CONTENT_PROCESS_ONLY, + }, +] diff --git a/widget/gtk/components.conf b/widget/gtk/components.conf index 61714d8b8190c..a2759a3c45cc0 100644 --- a/widget/gtk/components.conf +++ b/widget/gtk/components.conf @@ -20,8 +20,8 @@ Classes = [ 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_AND_UTILITY_PROCESS, }, { - 'cid': '{c401eb80-f9ea-11d3-bb6f-e732b73ebe7c}', - 'contract_ids': ['@mozilla.org/gfx/screenmanager;1'], + 'cid': '{e9537f8f-c07e-4435-8ab3-83f1ad6e3bbf}', + 'contract_ids': ['@mozilla.org/gfx/parent/screenmanager;1'], 'singleton': True, 'type': 'mozilla::widget::ScreenManager', 'headers': ['mozilla/StaticPtr.h', 'mozilla/widget/ScreenManager.h'], @@ -35,15 +35,15 @@ Classes = [ 'headers': ['/widget/gtk/TaskbarProgress.h'], }, { - 'cid': '{0f872c8c-3ee6-46bd-92a2-69652c6b474e}', - 'contract_ids': ['@mozilla.org/colorpicker;1'], + 'cid': '{4364de1a-798e-419c-a6f5-ca28866b6d5f}', + 'contract_ids': ['@mozilla.org/parent/colorpicker;1'], 'type': 'nsColorPicker', 'headers': ['/widget/gtk/nsColorPicker.h'], 'processes': ProcessSelector.MAIN_PROCESS_ONLY, }, { - 'cid': '{bd57cee8-1dd1-11b2-9fe7-95cf4709aea3}', - 'contract_ids': ['@mozilla.org/filepicker;1'], + 'cid': '{1940fed5-7d02-4122-8acf-7abaac698983}', + 'contract_ids': ['@mozilla.org/parent/filepicker;1'], 'type': 'nsFilePicker', 'headers': ['/widget/gtk/nsFilePicker.h'], 'processes': ProcessSelector.MAIN_PROCESS_ONLY, @@ -55,8 +55,8 @@ Classes = [ 'headers': ['/widget/nsHTMLFormatConverter.h'], }, { - 'cid': '{b148eed2-236d-11d3-b35c-00a0cc3c1cde}', - 'contract_ids': ['@mozilla.org/sound;1'], + 'cid': '{e711c28b-c1f1-4b87-8448-e1e0da0a7b7d}', + 'contract_ids': ['@mozilla.org/parent/sound;1'], 'singleton': True, 'type': 'nsISound', 'constructor': 'nsSound::GetInstance', @@ -77,13 +77,11 @@ Classes = [ 'processes': ProcessSelector.MAIN_PROCESS_ONLY, }, { - 'js_name': 'clipboard', - 'cid': '{8b5314ba-db01-11d2-96ce-0060b0fb9956}', - 'contract_ids': ['@mozilla.org/widget/clipboard;1'], + 'cid': '{f55f5d31-dbb7-4d0d-9f6f-a4f4cd8e8ef1}', + 'contract_ids': ['@mozilla.org/widget/parent/clipboard;1'], 'interfaces': ['nsIClipboard'], 'type': 'nsIClipboard', 'processes': ProcessSelector.MAIN_PROCESS_ONLY, - 'overridable': True, }, { 'cid': '{77221d5a-1dd2-11b2-8c69-c710f15d2ed5}', @@ -92,8 +90,8 @@ Classes = [ 'headers': ['/widget/nsClipboardHelper.h'], }, { - 'cid': '{8b5314bb-db01-11d2-96ce-0060b0fb9956}', - 'contract_ids': ['@mozilla.org/widget/dragservice;1'], + 'cid': '{0ba77e04-2adb-422f-af01-5a57b8013100}', + 'contract_ids': ['@mozilla.org/widget/parent/dragservice;1'], 'singleton': True, 'type': 'nsDragService', 'headers': ['/widget/gtk/nsDragService.h'], diff --git a/widget/moz.build b/widget/moz.build index 21df2695eaadb..70cdddd5918c1 100644 --- a/widget/moz.build +++ b/widget/moz.build @@ -51,6 +51,10 @@ with Files("*NativeKeyBindings*"): toolkit = CONFIG["MOZ_WIDGET_TOOLKIT"] +XPCOM_MANIFESTS += [ + "components.conf", +] + if toolkit in ("android", "cocoa", "gtk", "uikit", "windows"): DIRS += [toolkit] @@ -221,7 +225,6 @@ UNIFIED_SOURCES += [ "nsClipboardHelper.cpp", "nsClipboardProxy.cpp", "nsColorPickerProxy.cpp", - "nsContentProcessWidgetFactory.cpp", "nsDragServiceProxy.cpp", "nsFilePickerProxy.cpp", "nsHTMLFormatConverter.cpp", diff --git a/widget/nsContentProcessWidgetFactory.cpp b/widget/nsContentProcessWidgetFactory.cpp deleted file mode 100644 index 70d91f1f1d355..0000000000000 --- a/widget/nsContentProcessWidgetFactory.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- 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/. */ - -#include "mozilla/ModuleUtils.h" -#include "nsWidgetsCID.h" -#include "nsClipboardProxy.h" -#include "nsColorPickerProxy.h" -#include "nsDragServiceProxy.h" -#include "nsFilePickerProxy.h" -#include "nsSoundProxy.h" -#include "mozilla/widget/ScreenManager.h" - -using namespace mozilla; -using namespace mozilla::widget; - -NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardProxy) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsColorPickerProxy) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragServiceProxy) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsFilePickerProxy) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsSoundProxy) -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(ScreenManager, - ScreenManager::GetAddRefedSingleton) - -NS_DEFINE_NAMED_CID(NS_CLIPBOARD_CID); -NS_DEFINE_NAMED_CID(NS_COLORPICKER_CID); -NS_DEFINE_NAMED_CID(NS_DRAGSERVICE_CID); -NS_DEFINE_NAMED_CID(NS_FILEPICKER_CID); -NS_DEFINE_NAMED_CID(NS_SOUND_CID); -NS_DEFINE_NAMED_CID(NS_SCREENMANAGER_CID); - -static const mozilla::Module::CIDEntry kWidgetCIDs[] = { - {&kNS_CLIPBOARD_CID, false, nullptr, nsClipboardProxyConstructor, - Module::CONTENT_PROCESS_ONLY}, - {&kNS_COLORPICKER_CID, false, nullptr, nsColorPickerProxyConstructor, - Module::CONTENT_PROCESS_ONLY}, - {&kNS_DRAGSERVICE_CID, false, nullptr, nsDragServiceProxyConstructor, - Module::CONTENT_PROCESS_ONLY}, - {&kNS_FILEPICKER_CID, false, nullptr, nsFilePickerProxyConstructor, - Module::CONTENT_PROCESS_ONLY}, - {&kNS_SOUND_CID, false, nullptr, nsSoundProxyConstructor, - Module::CONTENT_PROCESS_ONLY}, - {&kNS_SCREENMANAGER_CID, false, nullptr, ScreenManagerConstructor, - Module::CONTENT_PROCESS_ONLY}, - {nullptr}}; - -static const mozilla::Module::ContractIDEntry kWidgetContracts[] = { - {"@mozilla.org/widget/clipboard;1", &kNS_CLIPBOARD_CID, - Module::CONTENT_PROCESS_ONLY}, - {"@mozilla.org/colorpicker;1", &kNS_COLORPICKER_CID, - Module::CONTENT_PROCESS_ONLY}, - {"@mozilla.org/filepicker;1", &kNS_FILEPICKER_CID, - Module::CONTENT_PROCESS_ONLY}, - {"@mozilla.org/gfx/screenmanager;1", &kNS_SCREENMANAGER_CID, - Module::CONTENT_PROCESS_ONLY}, - {"@mozilla.org/sound;1", &kNS_SOUND_CID, Module::CONTENT_PROCESS_ONLY}, - {"@mozilla.org/widget/dragservice;1", &kNS_DRAGSERVICE_CID, - Module::CONTENT_PROCESS_ONLY}, - {nullptr}}; - -extern const mozilla::Module kContentProcessWidgetModule = { - mozilla::Module::kVersion, kWidgetCIDs, kWidgetContracts}; diff --git a/widget/nsContentProcessWidgetFactory.h b/widget/nsContentProcessWidgetFactory.h new file mode 100644 index 0000000000000..f9aedf606dff4 --- /dev/null +++ b/widget/nsContentProcessWidgetFactory.h @@ -0,0 +1,48 @@ +/* -*- 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 nsContentProcessWidgetFactory_h +#define nsContentProcessWidgetFactory_h + +#include "nsISupports.h" +#include "nsComponentManagerUtils.h" +#include "nsServiceManagerUtils.h" +#include "nsXULAppAPI.h" + +#define MAKE_COMPONENT_CHOOSER(name_, parent_, content_, constructor_) \ + static already_AddRefed name_() { \ + nsCOMPtr inst; \ + if (XRE_IsContentProcess()) { \ + inst = constructor_(content_); \ + } else { \ + inst = constructor_(parent_); \ + } \ + return inst.forget(); \ + } + +MAKE_COMPONENT_CHOOSER(nsClipboardSelector, + "@mozilla.org/widget/parent/clipboard;1", + "@mozilla.org/widget/content/clipboard;1", do_GetService) +MAKE_COMPONENT_CHOOSER(nsColorPickerSelector, + "@mozilla.org/parent/colorpicker;1", + "@mozilla.org/content/colorpicker;1", do_CreateInstance) +MAKE_COMPONENT_CHOOSER(nsFilePickerSelector, "@mozilla.org/parent/filepicker;1", + "@mozilla.org/content/filepicker;1", do_CreateInstance) +MAKE_COMPONENT_CHOOSER(nsScreenManagerSelector, + "@mozilla.org/gfx/parent/screenmanager;1", + "@mozilla.org/gfx/content/screenmanager;1", + do_GetService) +MAKE_COMPONENT_CHOOSER(nsSoundSelector, "@mozilla.org/parent/sound;1", + "@mozilla.org/content/sound;1", do_GetService) +MAKE_COMPONENT_CHOOSER(nsDragServiceSelector, + "@mozilla.org/widget/parent/dragservice;1", + "@mozilla.org/widget/content/dragservice;1", + do_GetService) + +#undef MAKE_COMPONENT_CHOOSER + +#endif // defined nsContentProcessWidgetFactory_h diff --git a/widget/windows/components.conf b/widget/windows/components.conf index bdba775d6e81a..0ccaae359826c 100644 --- a/widget/windows/components.conf +++ b/widget/windows/components.conf @@ -13,8 +13,8 @@ UnloadFunc = 'nsWidgetWindowsModuleDtor' Classes = [ { - 'cid': '{c401eb80-f9ea-11d3-bb6f-e732b73ebe7c}', - 'contract_ids': ['@mozilla.org/gfx/screenmanager;1'], + 'cid': '{4c9dee4a-b083-4261-8bbe-c6883d2a6bc9}', + 'contract_ids': ['@mozilla.org/gfx/parent/screenmanager;1'], 'singleton': True, 'type': 'mozilla::widget::ScreenManager', 'constructor': 'mozilla::widget::ScreenManager::GetAddRefedSingleton', @@ -37,8 +37,8 @@ Classes = [ 'headers': ['/widget/windows/nsUserIdleServiceWin.h', 'nsUserIdleService.h'], }, { - 'cid': '{b148eed2-236d-11d3-b35c-00a0cc3c1cde}', - 'contract_ids': ['@mozilla.org/sound;1'], + 'cid': '{919f1217-073a-4a14-b034-67d461eccacc}', + 'contract_ids': ['@mozilla.org/parent/sound;1'], 'singleton': True, 'type': 'nsISound', 'constructor': 'nsSound::GetInstance', @@ -106,8 +106,8 @@ Classes = [ 'headers': ['/widget/nsHTMLFormatConverter.h'], }, { - 'cid': '{8b5314bb-db01-11d2-96ce-0060b0fb9956}', - 'contract_ids': ['@mozilla.org/widget/dragservice;1'], + 'cid': '{f92e733e-33a3-4752-90e5-25801ddeaf7b}', + 'contract_ids': ['@mozilla.org/widget/parent/dragservice;1'], 'type': 'nsDragService', 'headers': ['/widget/windows/nsDragService.h'], 'processes': ProcessSelector.MAIN_PROCESS_ONLY, @@ -128,15 +128,15 @@ Classes = [ 'processes': ProcessSelector.ALLOW_IN_GPU_RDD_SOCKET_AND_UTILITY_PROCESS, }, { - 'cid': '{bd57cee8-1dd1-11b2-9fe7-95cf4709aea3}', - 'contract_ids': ['@mozilla.org/filepicker;1'], + 'cid': '{e2fc3e45-c893-4b34-8f6d-b87faf65a897}', + 'contract_ids': ['@mozilla.org/parent/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'], + 'cid': '{035d92f3-3802-4cf5-87cb-1758bfc5d4da}', + 'contract_ids': ['@mozilla.org/parent/colorpicker;1'], 'type': 'nsColorPicker', 'headers': ['/widget/windows/nsColorPicker.h'], 'processes': ProcessSelector.MAIN_PROCESS_ONLY, @@ -149,13 +149,11 @@ Classes = [ 'processes': ProcessSelector.MAIN_PROCESS_ONLY, }, { - 'js_name': 'clipboard', - 'cid': '{8b5314ba-db01-11d2-96ce-0060b0fb9956}', - 'contract_ids': ['@mozilla.org/widget/clipboard;1'], + 'cid': '{25b4efa0-7054-4787-9cd6-630efb3fe6fa}', + 'contract_ids': ['@mozilla.org/widget/parent/clipboard;1'], 'interfaces': ['nsIClipboard'], 'type': 'nsIClipboard', 'processes': ProcessSelector.MAIN_PROCESS_ONLY, - 'overridable': True, }, { 'cid': '{b6e1a890-b2b8-4883-a65f-9476f6185313}', diff --git a/xpcom/components/nsComponentManager.cpp b/xpcom/components/nsComponentManager.cpp index 6668f440c9b97..30dbae56345ae 100644 --- a/xpcom/components/nsComponentManager.cpp +++ b/xpcom/components/nsComponentManager.cpp @@ -263,7 +263,7 @@ nsresult nsComponentManagerImpl::Create(REFNSIID aIID, void** aResult) { return gComponentManager->QueryInterface(aIID, aResult); } -static const int CONTRACTID_HASHTABLE_INITIAL_LENGTH = 16; +static const int CONTRACTID_HASHTABLE_INITIAL_LENGTH = 8; nsComponentManagerImpl::nsComponentManagerImpl() : mFactories(CONTRACTID_HASHTABLE_INITIAL_LENGTH), @@ -271,8 +271,6 @@ nsComponentManagerImpl::nsComponentManagerImpl() mLock("nsComponentManagerImpl.mLock"), mStatus(NOT_INITIALIZED) {} -extern const mozilla::Module kContentProcessWidgetModule; - static nsTArray* sExtraStaticModules; /* static */ @@ -356,8 +354,6 @@ nsresult nsComponentManagerImpl::Init() { nsCategoryManager::GetSingleton()->SuppressNotifications(true); - RegisterModule(&kContentProcessWidgetModule); - for (uint32_t i = 0; i < sExtraStaticModules->Length(); ++i) { RegisterModule((*sExtraStaticModules)[i]); } @@ -465,6 +461,7 @@ nsresult nsComponentManagerImpl::Init() { mStatus = NORMAL; MOZ_ASSERT(!XRE_IsContentProcess() || + CONTRACTID_HASHTABLE_INITIAL_LENGTH <= 8 || mFactories.Count() > CONTRACTID_HASHTABLE_INITIAL_LENGTH / 3, "Initial component hashtable size is too large");