From ffa5ec335e2d1c53db481cc3acc28770ed73488b Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Sat, 15 Sep 2018 14:38:44 -0400 Subject: [PATCH] Bug 1491595 - Remove the XPCOM registration for the bidi keyboard; r=mstange Differential Revision: https://phabricator.services.mozilla.com/D5962 --- dom/base/nsContentUtils.cpp | 11 +++++------ dom/base/nsContentUtils.h | 3 ++- widget/PuppetBidiKeyboard.cpp | 8 ++++++++ widget/cocoa/nsBidiKeyboard.mm | 8 ++++++++ widget/cocoa/nsWidgetFactory.mm | 8 -------- widget/gtk/nsBidiKeyboard.cpp | 8 ++++++++ widget/gtk/nsWidgetFactory.cpp | 6 ------ widget/nsBaseWidget.cpp | 19 +++++++++++++++++++ widget/nsContentProcessWidgetFactory.cpp | 7 ------- widget/nsIWidget.h | 6 ++++++ widget/nsWidgetsCID.h | 7 ------- widget/windows/nsBidiKeyboard.cpp | 8 ++++++++ widget/windows/nsWidgetFactory.cpp | 5 ----- 13 files changed, 64 insertions(+), 40 deletions(-) diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index 6f58a4c21d0b..a953fcd54cd3 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -183,6 +183,7 @@ #include "nsIURIWithSpecialOrigin.h" #include "nsIURL.h" #include "nsIWebNavigation.h" +#include "nsIWidget.h" #include "nsIWindowMediator.h" #include "nsIXPConnect.h" #include "nsJSUtils.h" @@ -272,7 +273,7 @@ nsIContentPolicy *nsContentUtils::sContentPolicyService; bool nsContentUtils::sTriedToGetContentPolicy = false; RefPtr nsContentUtils::sLineBreaker; RefPtr nsContentUtils::sWordBreaker; -nsIBidiKeyboard *nsContentUtils::sBidiKeyboard = nullptr; +StaticRefPtr nsContentUtils::sBidiKeyboard; uint32_t nsContentUtils::sScriptBlockerCount = 0; uint32_t nsContentUtils::sDOMNodeRemovedSuppressCount = 0; AutoTArray, 8>* nsContentUtils::sBlockedScriptRunners = nullptr; @@ -1633,10 +1634,8 @@ nsIBidiKeyboard* nsContentUtils::GetBidiKeyboard() { if (!sBidiKeyboard) { - nsresult rv = CallGetService("@mozilla.org/widget/bidikeyboard;1", &sBidiKeyboard); - if (NS_FAILED(rv)) { - sBidiKeyboard = nullptr; - } + sBidiKeyboard = nsIWidget::CreateBidiKeyboard(); + MOZ_ASSERT(sBidiKeyboard); } return sBidiKeyboard; } @@ -1986,7 +1985,7 @@ nsContentUtils::Shutdown() NS_IF_RELEASE(sUUIDGenerator); sLineBreaker = nullptr; sWordBreaker = nullptr; - NS_IF_RELEASE(sBidiKeyboard); + sBidiKeyboard = nullptr; delete sAtomEventTable; sAtomEventTable = nullptr; diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h index 299c61427bbc..7dfbb18e0d32 100644 --- a/dom/base/nsContentUtils.h +++ b/dom/base/nsContentUtils.h @@ -25,6 +25,7 @@ #include "mozilla/CORSMode.h" #include "mozilla/EventForwards.h" #include "mozilla/GuardObjects.h" +#include "mozilla/StaticPtr.h" #include "mozilla/TaskCategory.h" #include "mozilla/TimeStamp.h" #include "nsContentListDeclarations.h" @@ -3449,7 +3450,7 @@ private: static RefPtr sLineBreaker; static RefPtr sWordBreaker; - static nsIBidiKeyboard* sBidiKeyboard; + static mozilla::StaticRefPtr sBidiKeyboard; static bool sInitialized; static uint32_t sScriptBlockerCount; diff --git a/widget/PuppetBidiKeyboard.cpp b/widget/PuppetBidiKeyboard.cpp index 67f875d2bd85..c4e6150b8f81 100644 --- a/widget/PuppetBidiKeyboard.cpp +++ b/widget/PuppetBidiKeyboard.cpp @@ -6,6 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "PuppetBidiKeyboard.h" +#include "nsIWidget.h" using namespace mozilla::widget; @@ -49,3 +50,10 @@ PuppetBidiKeyboard::GetHaveBidiKeyboards(bool* aResult) *aResult = mHaveBidiKeyboards; return NS_OK; } + +// static +already_AddRefed +nsIWidget::CreateBidiKeyboardContentProcess() +{ + return do_AddRef(new PuppetBidiKeyboard()); +} diff --git a/widget/cocoa/nsBidiKeyboard.mm b/widget/cocoa/nsBidiKeyboard.mm index e0fc86aeb79d..e00cdb0543c4 100644 --- a/widget/cocoa/nsBidiKeyboard.mm +++ b/widget/cocoa/nsBidiKeyboard.mm @@ -7,6 +7,7 @@ #include "nsBidiKeyboard.h" #include "nsCocoaUtils.h" #include "TextInputHandler.h" +#include "nsIWidget.h" // This must be the last include: #include "nsObjCExceptions.h" @@ -40,3 +41,10 @@ NS_IMETHODIMP nsBidiKeyboard::GetHaveBidiKeyboards(bool* aResult) // not implemented yet return NS_ERROR_NOT_IMPLEMENTED; } + +// static +already_AddRefed +nsIWidget::CreateBidiKeyboardInner() +{ + return do_AddRef(new nsBidiKeyboard()); +} diff --git a/widget/cocoa/nsWidgetFactory.mm b/widget/cocoa/nsWidgetFactory.mm index c949d1adb666..35e7cd585273 100644 --- a/widget/cocoa/nsWidgetFactory.mm +++ b/widget/cocoa/nsWidgetFactory.mm @@ -82,9 +82,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(OSXNotificationCenter, Init) #include "nsMenuBarX.h" NS_GENERIC_FACTORY_CONSTRUCTOR(nsNativeMenuServiceX) -#include "nsBidiKeyboard.h" -NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard) - #include "nsMacDockSupport.h" NS_GENERIC_FACTORY_CONSTRUCTOR(nsMacDockSupport) @@ -117,7 +114,6 @@ NS_DEFINE_NAMED_CID(NS_HTMLFORMATCONVERTER_CID); NS_DEFINE_NAMED_CID(NS_CLIPBOARD_CID); NS_DEFINE_NAMED_CID(NS_CLIPBOARDHELPER_CID); NS_DEFINE_NAMED_CID(NS_DRAGSERVICE_CID); -NS_DEFINE_NAMED_CID(NS_BIDIKEYBOARD_CID); NS_DEFINE_NAMED_CID(NS_SCREENMANAGER_CID); NS_DEFINE_NAMED_CID(NS_DEVICE_CONTEXT_SPEC_CID); NS_DEFINE_NAMED_CID(NS_PRINTSESSION_CID); @@ -148,8 +144,6 @@ static const mozilla::Module::CIDEntry kWidgetCIDs[] = { { &kNS_CLIPBOARDHELPER_CID, false, NULL, nsClipboardHelperConstructor }, { &kNS_DRAGSERVICE_CID, false, NULL, nsDragServiceConstructor, mozilla::Module::MAIN_PROCESS_ONLY }, - { &kNS_BIDIKEYBOARD_CID, false, NULL, nsBidiKeyboardConstructor, - mozilla::Module::MAIN_PROCESS_ONLY }, { &kNS_SCREENMANAGER_CID, false, NULL, ScreenManagerConstructor, mozilla::Module::MAIN_PROCESS_ONLY }, { &kNS_DEVICE_CONTEXT_SPEC_CID, false, NULL, nsDeviceContextSpecXConstructor }, @@ -183,8 +177,6 @@ static const mozilla::Module::ContractIDEntry kWidgetContracts[] = { { "@mozilla.org/widget/clipboardhelper;1", &kNS_CLIPBOARDHELPER_CID }, { "@mozilla.org/widget/dragservice;1", &kNS_DRAGSERVICE_CID, mozilla::Module::MAIN_PROCESS_ONLY }, - { "@mozilla.org/widget/bidikeyboard;1", &kNS_BIDIKEYBOARD_CID, - mozilla::Module::MAIN_PROCESS_ONLY }, { "@mozilla.org/gfx/screenmanager;1", &kNS_SCREENMANAGER_CID, mozilla::Module::MAIN_PROCESS_ONLY }, { "@mozilla.org/gfx/devicecontextspec;1", &kNS_DEVICE_CONTEXT_SPEC_CID }, diff --git a/widget/gtk/nsBidiKeyboard.cpp b/widget/gtk/nsBidiKeyboard.cpp index 51102d945e8b..6055891c2f57 100644 --- a/widget/gtk/nsBidiKeyboard.cpp +++ b/widget/gtk/nsBidiKeyboard.cpp @@ -8,6 +8,7 @@ #include "prlink.h" #include "nsBidiKeyboard.h" +#include "nsIWidget.h" #include NS_IMPL_ISUPPORTS(nsBidiKeyboard, nsIBidiKeyboard) @@ -53,3 +54,10 @@ NS_IMETHODIMP nsBidiKeyboard::GetHaveBidiKeyboards(bool* aResult) // not implemented yet return NS_ERROR_NOT_IMPLEMENTED; } + +// static +already_AddRefed +nsIWidget::CreateBidiKeyboardInner() +{ + return do_AddRef(new nsBidiKeyboard()); +} diff --git a/widget/gtk/nsWidgetFactory.cpp b/widget/gtk/nsWidgetFactory.cpp index 5bbf185314ab..1973c2a73536 100644 --- a/widget/gtk/nsWidgetFactory.cpp +++ b/widget/gtk/nsWidgetFactory.cpp @@ -31,7 +31,6 @@ #include "nsColorPicker.h" #include "nsFilePicker.h" #include "nsSound.h" -#include "nsBidiKeyboard.h" #include "nsGTKToolkit.h" #include "WakeLockListener.h" @@ -59,7 +58,6 @@ using namespace mozilla; using namespace mozilla::widget; NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard) NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter) #ifdef MOZ_X11 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIdleServiceGTK, nsIdleServiceGTK::GetInstance) @@ -176,7 +174,6 @@ NS_DEFINE_NAMED_CID(NS_CLIPBOARDHELPER_CID); NS_DEFINE_NAMED_CID(NS_DRAGSERVICE_CID); #endif NS_DEFINE_NAMED_CID(NS_HTMLFORMATCONVERTER_CID); -NS_DEFINE_NAMED_CID(NS_BIDIKEYBOARD_CID); NS_DEFINE_NAMED_CID(NS_SCREENMANAGER_CID); #ifdef NS_PRINTING NS_DEFINE_NAMED_CID(NS_PRINTSETTINGSSERVICE_CID); @@ -208,7 +205,6 @@ static const mozilla::Module::CIDEntry kWidgetCIDs[] = { { &kNS_DRAGSERVICE_CID, false, nullptr, nsDragServiceConstructor, Module::MAIN_PROCESS_ONLY }, #endif { &kNS_HTMLFORMATCONVERTER_CID, false, nullptr, nsHTMLFormatConverterConstructor }, - { &kNS_BIDIKEYBOARD_CID, false, nullptr, nsBidiKeyboardConstructor }, { &kNS_SCREENMANAGER_CID, false, nullptr, ScreenManagerConstructor, Module::MAIN_PROCESS_ONLY }, #ifdef NS_PRINTING @@ -242,8 +238,6 @@ static const mozilla::Module::ContractIDEntry kWidgetContracts[] = { { "@mozilla.org/widget/dragservice;1", &kNS_DRAGSERVICE_CID, Module::MAIN_PROCESS_ONLY }, #endif { "@mozilla.org/widget/htmlformatconverter;1", &kNS_HTMLFORMATCONVERTER_CID }, - { "@mozilla.org/widget/bidikeyboard;1", &kNS_BIDIKEYBOARD_CID, - Module::MAIN_PROCESS_ONLY }, { "@mozilla.org/gfx/screenmanager;1", &kNS_SCREENMANAGER_CID, Module::MAIN_PROCESS_ONLY }, #ifdef NS_PRINTING diff --git a/widget/nsBaseWidget.cpp b/widget/nsBaseWidget.cpp index bece544045db..b8f810064caa 100644 --- a/widget/nsBaseWidget.cpp +++ b/widget/nsBaseWidget.cpp @@ -2482,6 +2482,25 @@ nsIWidget::GetEditCommands(nsIWidget::NativeKeyBindingsType aType, MOZ_ASSERT(aCommands.IsEmpty()); } +already_AddRefed +nsIWidget::CreateBidiKeyboard() +{ + if (XRE_IsContentProcess()) { + return CreateBidiKeyboardContentProcess(); + } else { + return CreateBidiKeyboardInner(); + } +} + +#ifdef ANDROID +already_AddRefed +nsIWidget::CreateBidiKeyboardInner() +{ + // no bidi keyboard implementation + return nullptr; +} +#endif + namespace mozilla { namespace widget { diff --git a/widget/nsContentProcessWidgetFactory.cpp b/widget/nsContentProcessWidgetFactory.cpp index 21d5b571babf..a10fe1f56817 100644 --- a/widget/nsContentProcessWidgetFactory.cpp +++ b/widget/nsContentProcessWidgetFactory.cpp @@ -12,7 +12,6 @@ #include "nsDragServiceProxy.h" #include "nsFilePickerProxy.h" #include "nsSoundProxy.h" -#include "mozilla/widget/PuppetBidiKeyboard.h" #include "mozilla/widget/ScreenManager.h" using namespace mozilla; @@ -23,7 +22,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsColorPickerProxy) NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragServiceProxy) NS_GENERIC_FACTORY_CONSTRUCTOR(nsFilePickerProxy) NS_GENERIC_FACTORY_CONSTRUCTOR(nsSoundProxy) -NS_GENERIC_FACTORY_CONSTRUCTOR(PuppetBidiKeyboard) NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(ScreenManager, ScreenManager::GetAddRefedSingleton) NS_DEFINE_NAMED_CID(NS_CLIPBOARD_CID); @@ -31,7 +29,6 @@ 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(PUPPETBIDIKEYBOARD_CID); NS_DEFINE_NAMED_CID(NS_SCREENMANAGER_CID); static const mozilla::Module::CIDEntry kWidgetCIDs[] = { @@ -45,8 +42,6 @@ static const mozilla::Module::CIDEntry kWidgetCIDs[] = { Module::CONTENT_PROCESS_ONLY }, { &kNS_SOUND_CID, false, nullptr, nsSoundProxyConstructor, Module::CONTENT_PROCESS_ONLY }, - { &kPUPPETBIDIKEYBOARD_CID, false, NULL, PuppetBidiKeyboardConstructor, - Module::CONTENT_PROCESS_ONLY }, { &kNS_SCREENMANAGER_CID, false, nullptr, ScreenManagerConstructor, Module::CONTENT_PROCESS_ONLY }, { nullptr } @@ -59,8 +54,6 @@ static const mozilla::Module::ContractIDEntry kWidgetContracts[] = { { "@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 }, - { "@mozilla.org/widget/bidikeyboard;1", &kPUPPETBIDIKEYBOARD_CID, - Module::CONTENT_PROCESS_ONLY }, { nullptr } }; diff --git a/widget/nsIWidget.h b/widget/nsIWidget.h index 9ee388e93539..2ae236124883 100644 --- a/widget/nsIWidget.h +++ b/widget/nsIWidget.h @@ -34,6 +34,7 @@ #include "Units.h" // forward declarations +class nsIBidiKeyboard; class nsIRollupListener; class imgIContainer; class nsIContent; @@ -1746,6 +1747,9 @@ private: static void OnLongTapTimerCallback(nsITimer* aTimer, void* aClosure); + static already_AddRefed CreateBidiKeyboardContentProcess(); + static already_AddRefed CreateBidiKeyboardInner(); + mozilla::UniquePtr mLongTapTouchPoint; nsCOMPtr mLongTapTimer; static int32_t sPointerIdCounter; @@ -2133,6 +2137,8 @@ public: virtual void RecvScreenPixels(mozilla::ipc::Shmem&& aMem, const ScreenIntSize& aSize) = 0; #endif + static already_AddRefed CreateBidiKeyboard(); + protected: /** * Like GetDefaultScale, but taking into account only the system settings diff --git a/widget/nsWidgetsCID.h b/widget/nsWidgetsCID.h index 751dfa423f4b..a5e08633511e 100644 --- a/widget/nsWidgetsCID.h +++ b/widget/nsWidgetsCID.h @@ -104,13 +104,6 @@ #define NS_SOUND_CID \ { 0xb148eed2, 0x236d, 0x11d3, { 0xb3, 0x5c, 0x0, 0xa0, 0xcc, 0x3c, 0x1c, 0xde } } -// {9f1800ab-f428-4207-b40c-e832e77b01fc} -#define NS_BIDIKEYBOARD_CID \ -{ 0x9f1800ab, 0xf428, 0x4207, { 0xb4, 0x0c, 0xe8, 0x32, 0xe7, 0x7b, 0x01, 0xfc } } - -#define PUPPETBIDIKEYBOARD_CID \ -{ 0x689e2586, 0x0344, 0x40b2, {0x83, 0x75, 0x13, 0x67, 0x2d, 0x3b, 0x71, 0x9a } } - #define NS_SCREENMANAGER_CID \ { 0xc401eb80, 0xf9ea, 0x11d3, { 0xbb, 0x6f, 0xe7, 0x32, 0xb7, 0x3e, 0xbe, 0x7c } } diff --git a/widget/windows/nsBidiKeyboard.cpp b/widget/windows/nsBidiKeyboard.cpp index 2dafcc0faa0b..9d884e711bf0 100644 --- a/widget/windows/nsBidiKeyboard.cpp +++ b/widget/windows/nsBidiKeyboard.cpp @@ -7,6 +7,7 @@ #include #include "nsBidiKeyboard.h" #include "WidgetUtils.h" +#include "nsIWidget.h" #include NS_IMPL_ISUPPORTS(nsBidiKeyboard, nsIBidiKeyboard) @@ -184,3 +185,10 @@ nsBidiKeyboard::OnLayoutChange() { mozilla::widget::WidgetUtils::SendBidiKeyboardInfoToContent(); } + +// static +already_AddRefed +nsIWidget::CreateBidiKeyboardInner() +{ + return do_AddRef(new nsBidiKeyboard()); +} diff --git a/widget/windows/nsWidgetFactory.cpp b/widget/windows/nsWidgetFactory.cpp index 9bcace7b2d6f..7a1757cd6b81 100644 --- a/widget/windows/nsWidgetFactory.cpp +++ b/widget/windows/nsWidgetFactory.cpp @@ -34,7 +34,6 @@ #include "nsClipboardHelper.h" #include "nsClipboard.h" #include "HeadlessClipboard.h" -#include "nsBidiKeyboard.h" #include "nsDragService.h" #include "nsTransferable.h" #include "nsHTMLFormatConverter.h" @@ -111,7 +110,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(WindowsUIUtils) NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable) NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter) NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard) NS_GENERIC_FACTORY_CONSTRUCTOR(TaskbarPreviewCallback) #ifdef NS_PRINTING NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintDialogServiceWin, Init) @@ -147,7 +145,6 @@ 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); -NS_DEFINE_NAMED_CID(NS_BIDIKEYBOARD_CID); NS_DEFINE_NAMED_CID(NS_TASKBARPREVIEWCALLBACK_CID); #ifdef NS_PRINTING NS_DEFINE_NAMED_CID(NS_PRINTDIALOGSERVICE_CID); @@ -179,7 +176,6 @@ static const mozilla::Module::CIDEntry kWidgetCIDs[] = { { &kNS_WIN_JUMPLISTSHORTCUT_CID, false, nullptr, JumpListShortcutConstructor }, { &kNS_WINDOWS_UIUTILS_CID, false, nullptr, WindowsUIUtilsConstructor }, { &kNS_DRAGSERVICE_CID, false, nullptr, nsDragServiceConstructor, Module::MAIN_PROCESS_ONLY }, - { &kNS_BIDIKEYBOARD_CID, false, nullptr, nsBidiKeyboardConstructor, Module::MAIN_PROCESS_ONLY }, { &kNS_TASKBARPREVIEWCALLBACK_CID, false, nullptr, TaskbarPreviewCallbackConstructor }, #ifdef NS_PRINTING { &kNS_PRINTDIALOGSERVICE_CID, false, nullptr, nsPrintDialogServiceWinConstructor, Module::MAIN_PROCESS_ONLY }, @@ -211,7 +207,6 @@ static const mozilla::Module::ContractIDEntry kWidgetContracts[] = { { "@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 }, - { "@mozilla.org/widget/bidikeyboard;1", &kNS_BIDIKEYBOARD_CID, Module::MAIN_PROCESS_ONLY }, { "@mozilla.org/widget/taskbar-preview-callback;1", &kNS_TASKBARPREVIEWCALLBACK_CID }, #ifdef NS_PRINTING { NS_PRINTDIALOGSERVICE_CONTRACTID, &kNS_PRINTDIALOGSERVICE_CID },