widget/qt/nsWidgetFactory.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/widget/qt/nsWidgetFactory.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,164 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* Copyright 2012 Mozilla Foundation and Mozilla contributors
     1.6 + *
     1.7 + * Licensed under the Apache License, Version 2.0 (the "License");
     1.8 + * you may not use this file except in compliance with the License.
     1.9 + * You may obtain a copy of the License at
    1.10 + *
    1.11 + *     http://www.apache.org/licenses/LICENSE-2.0
    1.12 + *
    1.13 + * Unless required by applicable law or agreed to in writing, software
    1.14 + * distributed under the License is distributed on an "AS IS" BASIS,
    1.15 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    1.16 + * See the License for the specific language governing permissions and
    1.17 + * limitations under the License.
    1.18 + */
    1.19 +
    1.20 +#include "base/basictypes.h"
    1.21 +
    1.22 +#include "mozilla/ModuleUtils.h"
    1.23 +
    1.24 +#include "nsCOMPtr.h"
    1.25 +#include "nsWidgetsCID.h"
    1.26 +#include "nsAppShell.h"
    1.27 +
    1.28 +#include "nsWindow.h"
    1.29 +#include "nsLookAndFeel.h"
    1.30 +#include "nsAppShellSingleton.h"
    1.31 +#include "nsScreenManagerQt.h"
    1.32 +#include "nsIdleServiceQt.h"
    1.33 +#include "nsTransferable.h"
    1.34 +#include "nsBidiKeyboard.h"
    1.35 +
    1.36 +#include "nsHTMLFormatConverter.h"
    1.37 +#include "nsXULAppAPI.h"
    1.38 +
    1.39 +#ifdef NS_PRINTING
    1.40 +#include "nsDeviceContextSpecQt.h"
    1.41 +#include "nsPrintSession.h"
    1.42 +#include "nsPrintOptionsQt.h"
    1.43 +#include "nsPrintDialogQt.h"
    1.44 +#endif
    1.45 +
    1.46 +#include "nsClipboard.h"
    1.47 +#include "nsClipboardHelper.h"
    1.48 +
    1.49 +#if defined(MOZ_X11)
    1.50 +#include "GfxInfoX11.h"
    1.51 +#endif
    1.52 +
    1.53 +using namespace mozilla::widget;
    1.54 +
    1.55 +NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindow)
    1.56 +NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard)
    1.57 +NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerQt)
    1.58 +NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter)
    1.59 +NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIdleServiceQt, nsIdleServiceQt::GetInstance)
    1.60 +NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable)
    1.61 +NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard)
    1.62 +NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper)
    1.63 +#ifdef NS_PRINTING
    1.64 +NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecQt)
    1.65 +NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintOptionsQt, Init)
    1.66 +NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrinterEnumeratorQt)
    1.67 +NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init)
    1.68 +NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintDialogServiceQt, Init)
    1.69 +#endif
    1.70 +
    1.71 +#if defined(MOZ_X11)
    1.72 +namespace mozilla {
    1.73 +namespace widget {
    1.74 +// This constructor should really be shared with all platforms.
    1.75 +NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(GfxInfo, Init)
    1.76 +}
    1.77 +}
    1.78 +#endif
    1.79 +
    1.80 +
    1.81 +NS_DEFINE_NAMED_CID(NS_APPSHELL_CID);
    1.82 +NS_DEFINE_NAMED_CID(NS_BIDIKEYBOARD_CID);
    1.83 +NS_DEFINE_NAMED_CID(NS_WINDOW_CID);
    1.84 +NS_DEFINE_NAMED_CID(NS_CHILD_CID);
    1.85 +NS_DEFINE_NAMED_CID(NS_SCREENMANAGER_CID);
    1.86 +NS_DEFINE_NAMED_CID(NS_HTMLFORMATCONVERTER_CID);
    1.87 +NS_DEFINE_NAMED_CID(NS_IDLE_SERVICE_CID);
    1.88 +NS_DEFINE_NAMED_CID(NS_TRANSFERABLE_CID);
    1.89 +NS_DEFINE_NAMED_CID(NS_CLIPBOARD_CID);
    1.90 +NS_DEFINE_NAMED_CID(NS_CLIPBOARDHELPER_CID);
    1.91 +#if defined(MOZ_X11)
    1.92 +NS_DEFINE_NAMED_CID(NS_GFXINFO_CID);
    1.93 +#endif
    1.94 +#ifdef NS_PRINTING
    1.95 +NS_DEFINE_NAMED_CID(NS_PRINTSETTINGSSERVICE_CID);
    1.96 +NS_DEFINE_NAMED_CID(NS_PRINTER_ENUMERATOR_CID);
    1.97 +NS_DEFINE_NAMED_CID(NS_PRINTSESSION_CID);
    1.98 +NS_DEFINE_NAMED_CID(NS_DEVICE_CONTEXT_SPEC_CID);
    1.99 +NS_DEFINE_NAMED_CID(NS_PRINTDIALOGSERVICE_CID);
   1.100 +#endif
   1.101 +
   1.102 +static const mozilla::Module::CIDEntry kWidgetCIDs[] = {
   1.103 +    { &kNS_APPSHELL_CID, false, nullptr, nsAppShellConstructor },
   1.104 +    { &kNS_BIDIKEYBOARD_CID, false, nullptr, nsBidiKeyboardConstructor },
   1.105 +    { &kNS_CHILD_CID, false, nullptr, nsWindowConstructor },
   1.106 +    { &kNS_CLIPBOARD_CID, false, nullptr, nsClipboardConstructor },
   1.107 +    { &kNS_CLIPBOARDHELPER_CID, false, nullptr, nsClipboardHelperConstructor },
   1.108 +    { &kNS_HTMLFORMATCONVERTER_CID, false, nullptr, nsHTMLFormatConverterConstructor },
   1.109 +    { &kNS_IDLE_SERVICE_CID, false, nullptr, nsIdleServiceQtConstructor },
   1.110 +    { &kNS_SCREENMANAGER_CID, false, nullptr, nsScreenManagerQtConstructor },
   1.111 +    { &kNS_TRANSFERABLE_CID, false, nullptr, nsTransferableConstructor },
   1.112 +    { &kNS_WINDOW_CID, false, nullptr, nsWindowConstructor },
   1.113 +#if defined(MOZ_X11)
   1.114 +    { &kNS_GFXINFO_CID, false, nullptr, mozilla::widget::GfxInfoConstructor },
   1.115 +#endif
   1.116 +#ifdef NS_PRINTING
   1.117 +    { &kNS_DEVICE_CONTEXT_SPEC_CID, false, nullptr, nsDeviceContextSpecQtConstructor },
   1.118 +    { &kNS_PRINTDIALOGSERVICE_CID, false, nullptr, nsPrintDialogServiceQtConstructor },
   1.119 +    { &kNS_PRINTER_ENUMERATOR_CID, false, nullptr, nsPrinterEnumeratorQtConstructor },
   1.120 +    { &kNS_PRINTSESSION_CID, false, nullptr, nsPrintSessionConstructor },
   1.121 +    { &kNS_PRINTSETTINGSSERVICE_CID, false, nullptr, nsPrintOptionsQtConstructor },
   1.122 +#endif
   1.123 +    { nullptr }
   1.124 +};
   1.125 +
   1.126 +static const mozilla::Module::ContractIDEntry kWidgetContracts[] = {
   1.127 +    { "@mozilla.org/gfx/screenmanager;1", &kNS_SCREENMANAGER_CID },
   1.128 +    { "@mozilla.org/widget/appshell/qt;1", &kNS_APPSHELL_CID },
   1.129 +    { "@mozilla.org/widget/bidikeyboard;1", &kNS_BIDIKEYBOARD_CID },
   1.130 +    { "@mozilla.org/widget/clipboard;1", &kNS_CLIPBOARD_CID },
   1.131 +    { "@mozilla.org/widget/clipboardhelper;1", &kNS_CLIPBOARDHELPER_CID },
   1.132 +    { "@mozilla.org/widget/htmlformatconverter;1", &kNS_HTMLFORMATCONVERTER_CID },
   1.133 +    { "@mozilla.org/widget/idleservice;1", &kNS_IDLE_SERVICE_CID },
   1.134 +    { "@mozilla.org/widgets/child_window/qt;1", &kNS_CHILD_CID },
   1.135 +    { "@mozilla.org/widgets/window/qt;1", &kNS_WINDOW_CID },
   1.136 +    { "@mozilla.org/widget/transferable;1", &kNS_TRANSFERABLE_CID },
   1.137 +#if defined(MOZ_X11)
   1.138 +    { "@mozilla.org/gfx/info;1", &kNS_GFXINFO_CID },
   1.139 +#endif
   1.140 +#ifdef NS_PRINTING
   1.141 +    { "@mozilla.org/gfx/devicecontextspec;1", &kNS_DEVICE_CONTEXT_SPEC_CID },
   1.142 +    { "@mozilla.org/gfx/printerenumerator;1", &kNS_PRINTER_ENUMERATOR_CID },
   1.143 +    { "@mozilla.org/gfx/printsession;1", &kNS_PRINTSESSION_CID },
   1.144 +    { "@mozilla.org/gfx/printsettings-service;1", &kNS_PRINTSETTINGSSERVICE_CID },
   1.145 +    { NS_PRINTDIALOGSERVICE_CONTRACTID, &kNS_PRINTDIALOGSERVICE_CID },
   1.146 +#endif
   1.147 +    { nullptr }
   1.148 +};
   1.149 +
   1.150 +static void
   1.151 +nsWidgetQtModuleDtor()
   1.152 +{
   1.153 +    nsLookAndFeel::Shutdown();
   1.154 +    nsAppShellShutdown();
   1.155 +}
   1.156 +
   1.157 +static const mozilla::Module kWidgetModule = {
   1.158 +    mozilla::Module::kVersion,
   1.159 +    kWidgetCIDs,
   1.160 +    kWidgetContracts,
   1.161 +    nullptr,
   1.162 +    nullptr,
   1.163 +    nsAppShellInit,
   1.164 +    nsWidgetQtModuleDtor
   1.165 +};
   1.166 +
   1.167 +NSMODULE_DEFN(nsWidgetQtModule) = &kWidgetModule;

mercurial