Skip to content

Commit

Permalink
Bug 1491595 - Remove the XPCOM registration for the bidi keyboard; r=…
Browse files Browse the repository at this point in the history
…mstange

Differential Revision: https://phabricator.services.mozilla.com/D5962
  • Loading branch information
ehsan committed Sep 16, 2018
1 parent 7c90f6f commit ffa5ec3
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 40 deletions.
11 changes: 5 additions & 6 deletions dom/base/nsContentUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -272,7 +273,7 @@ nsIContentPolicy *nsContentUtils::sContentPolicyService;
bool nsContentUtils::sTriedToGetContentPolicy = false;
RefPtr<mozilla::intl::LineBreaker> nsContentUtils::sLineBreaker;
RefPtr<mozilla::intl::WordBreaker> nsContentUtils::sWordBreaker;
nsIBidiKeyboard *nsContentUtils::sBidiKeyboard = nullptr;
StaticRefPtr<nsIBidiKeyboard> nsContentUtils::sBidiKeyboard;
uint32_t nsContentUtils::sScriptBlockerCount = 0;
uint32_t nsContentUtils::sDOMNodeRemovedSuppressCount = 0;
AutoTArray<nsCOMPtr<nsIRunnable>, 8>* nsContentUtils::sBlockedScriptRunners = nullptr;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -1986,7 +1985,7 @@ nsContentUtils::Shutdown()
NS_IF_RELEASE(sUUIDGenerator);
sLineBreaker = nullptr;
sWordBreaker = nullptr;
NS_IF_RELEASE(sBidiKeyboard);
sBidiKeyboard = nullptr;

delete sAtomEventTable;
sAtomEventTable = nullptr;
Expand Down
3 changes: 2 additions & 1 deletion dom/base/nsContentUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -3449,7 +3450,7 @@ class nsContentUtils
static RefPtr<mozilla::intl::LineBreaker> sLineBreaker;
static RefPtr<mozilla::intl::WordBreaker> sWordBreaker;

static nsIBidiKeyboard* sBidiKeyboard;
static mozilla::StaticRefPtr<nsIBidiKeyboard> sBidiKeyboard;

static bool sInitialized;
static uint32_t sScriptBlockerCount;
Expand Down
8 changes: 8 additions & 0 deletions widget/PuppetBidiKeyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -49,3 +50,10 @@ PuppetBidiKeyboard::GetHaveBidiKeyboards(bool* aResult)
*aResult = mHaveBidiKeyboards;
return NS_OK;
}

// static
already_AddRefed<nsIBidiKeyboard>
nsIWidget::CreateBidiKeyboardContentProcess()
{
return do_AddRef(new PuppetBidiKeyboard());
}
8 changes: 8 additions & 0 deletions widget/cocoa/nsBidiKeyboard.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -40,3 +41,10 @@
// not implemented yet
return NS_ERROR_NOT_IMPLEMENTED;
}

// static
already_AddRefed<nsIBidiKeyboard>
nsIWidget::CreateBidiKeyboardInner()
{
return do_AddRef(new nsBidiKeyboard());
}
8 changes: 0 additions & 8 deletions widget/cocoa/nsWidgetFactory.mm
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@
#include "nsMenuBarX.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(nsNativeMenuServiceX)

#include "nsBidiKeyboard.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard)

#include "nsMacDockSupport.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMacDockSupport)

Expand Down Expand Up @@ -117,7 +114,6 @@
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);
Expand Down Expand Up @@ -148,8 +144,6 @@
{ &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 },
Expand Down Expand Up @@ -183,8 +177,6 @@
{ "@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 },
Expand Down
8 changes: 8 additions & 0 deletions widget/gtk/nsBidiKeyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "prlink.h"

#include "nsBidiKeyboard.h"
#include "nsIWidget.h"
#include <gtk/gtk.h>

NS_IMPL_ISUPPORTS(nsBidiKeyboard, nsIBidiKeyboard)
Expand Down Expand Up @@ -53,3 +54,10 @@ NS_IMETHODIMP nsBidiKeyboard::GetHaveBidiKeyboards(bool* aResult)
// not implemented yet
return NS_ERROR_NOT_IMPLEMENTED;
}

// static
already_AddRefed<nsIBidiKeyboard>
nsIWidget::CreateBidiKeyboardInner()
{
return do_AddRef(new nsBidiKeyboard());
}
6 changes: 0 additions & 6 deletions widget/gtk/nsWidgetFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include "nsColorPicker.h"
#include "nsFilePicker.h"
#include "nsSound.h"
#include "nsBidiKeyboard.h"
#include "nsGTKToolkit.h"
#include "WakeLockListener.h"

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions widget/nsBaseWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2482,6 +2482,25 @@ nsIWidget::GetEditCommands(nsIWidget::NativeKeyBindingsType aType,
MOZ_ASSERT(aCommands.IsEmpty());
}

already_AddRefed<nsIBidiKeyboard>
nsIWidget::CreateBidiKeyboard()
{
if (XRE_IsContentProcess()) {
return CreateBidiKeyboardContentProcess();
} else {
return CreateBidiKeyboardInner();
}
}

#ifdef ANDROID
already_AddRefed<nsIBidiKeyboard>
nsIWidget::CreateBidiKeyboardInner()
{
// no bidi keyboard implementation
return nullptr;
}
#endif

namespace mozilla {
namespace widget {

Expand Down
7 changes: 0 additions & 7 deletions widget/nsContentProcessWidgetFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -23,15 +22,13 @@ 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);
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[] = {
Expand All @@ -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 }
Expand All @@ -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 }
};

Expand Down
6 changes: 6 additions & 0 deletions widget/nsIWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "Units.h"

// forward declarations
class nsIBidiKeyboard;
class nsIRollupListener;
class imgIContainer;
class nsIContent;
Expand Down Expand Up @@ -1746,6 +1747,9 @@ class nsIWidget : public nsISupports

static void OnLongTapTimerCallback(nsITimer* aTimer, void* aClosure);

static already_AddRefed<nsIBidiKeyboard> CreateBidiKeyboardContentProcess();
static already_AddRefed<nsIBidiKeyboard> CreateBidiKeyboardInner();

mozilla::UniquePtr<LongTapInfo> mLongTapTouchPoint;
nsCOMPtr<nsITimer> mLongTapTimer;
static int32_t sPointerIdCounter;
Expand Down Expand Up @@ -2133,6 +2137,8 @@ class nsIWidget : public nsISupports
virtual void RecvScreenPixels(mozilla::ipc::Shmem&& aMem, const ScreenIntSize& aSize) = 0;
#endif

static already_AddRefed<nsIBidiKeyboard> CreateBidiKeyboard();

protected:
/**
* Like GetDefaultScale, but taking into account only the system settings
Expand Down
7 changes: 0 additions & 7 deletions widget/nsWidgetsCID.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 } }

Expand Down
8 changes: 8 additions & 0 deletions widget/windows/nsBidiKeyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <stdio.h>
#include "nsBidiKeyboard.h"
#include "WidgetUtils.h"
#include "nsIWidget.h"
#include <tchar.h>

NS_IMPL_ISUPPORTS(nsBidiKeyboard, nsIBidiKeyboard)
Expand Down Expand Up @@ -184,3 +185,10 @@ nsBidiKeyboard::OnLayoutChange()
{
mozilla::widget::WidgetUtils::SendBidiKeyboardInfoToContent();
}

// static
already_AddRefed<nsIBidiKeyboard>
nsIWidget::CreateBidiKeyboardInner()
{
return do_AddRef(new nsBidiKeyboard());
}
5 changes: 0 additions & 5 deletions widget/windows/nsWidgetFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 },
Expand Down Expand Up @@ -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 },
Expand Down

0 comments on commit ffa5ec3

Please sign in to comment.