widget/gonk/nsWidgetFactory.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/widget/gonk/nsWidgetFactory.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,124 @@
     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 "nsScreenManagerGonk.h"
    1.32 +#include "nsIdleServiceGonk.h"
    1.33 +#include "nsTransferable.h"
    1.34 +#include "nsClipboard.h"
    1.35 +#include "nsClipboardHelper.h"
    1.36 +
    1.37 +#include "nsHTMLFormatConverter.h"
    1.38 +#include "nsXULAppAPI.h"
    1.39 +
    1.40 +#include "PuppetWidget.h"
    1.41 +
    1.42 +using namespace mozilla::widget;
    1.43 +
    1.44 +// taken from android/nsWidgetFactory.cpp. GfxInfo is a legacy kludge, unfortunately
    1.45 +// for the time being we still have to implement it on all platforms.
    1.46 +#include "GfxInfo.h"
    1.47 +namespace mozilla {
    1.48 +namespace widget {
    1.49 +// This constructor should really be shared with all platforms.
    1.50 +NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(GfxInfo, Init)
    1.51 +}
    1.52 +}
    1.53 +
    1.54 +NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindow)
    1.55 +NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerGonk)
    1.56 +NS_GENERIC_FACTORY_CONSTRUCTOR(PuppetScreenManager)
    1.57 +NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter)
    1.58 +NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIdleServiceGonk, nsIdleServiceGonk::GetInstance)
    1.59 +NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable)
    1.60 +NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard)
    1.61 +NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper)
    1.62 +
    1.63 +NS_DEFINE_NAMED_CID(NS_APPSHELL_CID);
    1.64 +NS_DEFINE_NAMED_CID(NS_WINDOW_CID);
    1.65 +NS_DEFINE_NAMED_CID(NS_CHILD_CID);
    1.66 +NS_DEFINE_NAMED_CID(NS_SCREENMANAGER_CID);
    1.67 +NS_DEFINE_NAMED_CID(NS_HTMLFORMATCONVERTER_CID);
    1.68 +NS_DEFINE_NAMED_CID(NS_IDLE_SERVICE_CID);
    1.69 +NS_DEFINE_NAMED_CID(NS_TRANSFERABLE_CID);
    1.70 +NS_DEFINE_NAMED_CID(NS_GFXINFO_CID);
    1.71 +NS_DEFINE_NAMED_CID(NS_CLIPBOARD_CID);
    1.72 +NS_DEFINE_NAMED_CID(NS_CLIPBOARDHELPER_CID);
    1.73 +
    1.74 +static nsresult
    1.75 +ScreenManagerConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult)
    1.76 +{
    1.77 +    return (XRE_GetProcessType() == GeckoProcessType_Default) ?
    1.78 +        nsScreenManagerGonkConstructor(aOuter, aIID, aResult) :
    1.79 +        PuppetScreenManagerConstructor(aOuter, aIID, aResult);
    1.80 +}
    1.81 +
    1.82 +static const mozilla::Module::CIDEntry kWidgetCIDs[] = {
    1.83 +    { &kNS_WINDOW_CID, false, nullptr, nsWindowConstructor },
    1.84 +    { &kNS_CHILD_CID, false, nullptr, nsWindowConstructor },
    1.85 +    { &kNS_APPSHELL_CID, false, nullptr, nsAppShellConstructor },
    1.86 +    { &kNS_SCREENMANAGER_CID, false, nullptr, ScreenManagerConstructor },
    1.87 +    { &kNS_HTMLFORMATCONVERTER_CID, false, nullptr, nsHTMLFormatConverterConstructor },
    1.88 +    { &kNS_IDLE_SERVICE_CID, false, nullptr, nsIdleServiceGonkConstructor },
    1.89 +    { &kNS_TRANSFERABLE_CID, false, nullptr, nsTransferableConstructor },
    1.90 +    { &kNS_GFXINFO_CID, false, nullptr, mozilla::widget::GfxInfoConstructor },
    1.91 +    { &kNS_CLIPBOARD_CID, false, nullptr, nsClipboardConstructor },
    1.92 +    { &kNS_CLIPBOARDHELPER_CID, false, nullptr, nsClipboardHelperConstructor },
    1.93 +    { nullptr }
    1.94 +};
    1.95 +
    1.96 +static const mozilla::Module::ContractIDEntry kWidgetContracts[] = {
    1.97 +    { "@mozilla.org/widgets/window/gonk;1", &kNS_WINDOW_CID },
    1.98 +    { "@mozilla.org/widgets/child_window/gonk;1", &kNS_CHILD_CID },
    1.99 +    { "@mozilla.org/widget/appshell/gonk;1", &kNS_APPSHELL_CID },
   1.100 +    { "@mozilla.org/gfx/screenmanager;1", &kNS_SCREENMANAGER_CID },
   1.101 +    { "@mozilla.org/widget/htmlformatconverter;1", &kNS_HTMLFORMATCONVERTER_CID },
   1.102 +    { "@mozilla.org/widget/idleservice;1", &kNS_IDLE_SERVICE_CID },
   1.103 +    { "@mozilla.org/widget/transferable;1", &kNS_TRANSFERABLE_CID },
   1.104 +    { "@mozilla.org/gfx/info;1", &kNS_GFXINFO_CID },
   1.105 +    { "@mozilla.org/widget/clipboard;1", &kNS_CLIPBOARD_CID },
   1.106 +    { "@mozilla.org/widget/clipboardhelper;1", &kNS_CLIPBOARDHELPER_CID },
   1.107 +    { nullptr }
   1.108 +};
   1.109 +
   1.110 +static void
   1.111 +nsWidgetGonkModuleDtor()
   1.112 +{
   1.113 +    nsLookAndFeel::Shutdown();
   1.114 +    nsAppShellShutdown();
   1.115 +}
   1.116 +
   1.117 +static const mozilla::Module kWidgetModule = {
   1.118 +    mozilla::Module::kVersion,
   1.119 +    kWidgetCIDs,
   1.120 +    kWidgetContracts,
   1.121 +    nullptr,
   1.122 +    nullptr,
   1.123 +    nsAppShellInit,
   1.124 +    nsWidgetGonkModuleDtor
   1.125 +};
   1.126 +
   1.127 +NSMODULE_DEFN(nsWidgetGonkModule) = &kWidgetModule;

mercurial