Back out a5a5d2c176f7 (bug 882865) because of Android test failures on a CLOSED TREE
[gecko.git] / gfx / src / nsThebesGfxFactory.cpp
blob839f90424cdcd4683e513fc9a2278d0556049d6d
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "mozilla/ModuleUtils.h"
7 #include "mozilla/Attributes.h"
8 #include "nsCOMPtr.h"
9 #include "nsGfxCIID.h"
11 #include "nsThebesFontEnumerator.h"
12 #include "nsScriptableRegion.h"
14 #include "gfxPlatform.h"
16 // This class doesn't do anything; its only purpose is to give
17 // gfxPlatform::Init a way to force this component to be registered,
18 // so that gfxPlatform::Shutdown will be called at an appropriate
19 // time. (Component teardown is the only shutdown hook that runs
20 // late enough; see bug 651498.)
22 namespace {
23 class GfxInitialization MOZ_FINAL : public nsISupports {
24 NS_DECL_ISUPPORTS
27 NS_IMPL_ISUPPORTS0(GfxInitialization)
30 NS_GENERIC_FACTORY_CONSTRUCTOR(nsThebesFontEnumerator)
32 static nsresult
33 nsScriptableRegionConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult)
35 if (!aResult) {
36 return NS_ERROR_NULL_POINTER;
38 *aResult = nullptr;
39 if (aOuter) {
40 return NS_ERROR_NO_AGGREGATION;
43 nsCOMPtr<nsIScriptableRegion> scriptableRgn = new nsScriptableRegion();
44 return scriptableRgn->QueryInterface(aIID, aResult);
47 NS_GENERIC_FACTORY_CONSTRUCTOR(GfxInitialization)
49 NS_DEFINE_NAMED_CID(NS_FONT_ENUMERATOR_CID);
50 NS_DEFINE_NAMED_CID(NS_SCRIPTABLE_REGION_CID);
51 NS_DEFINE_NAMED_CID(NS_GFX_INITIALIZATION_CID);
53 static const mozilla::Module::CIDEntry kThebesCIDs[] = {
54 { &kNS_FONT_ENUMERATOR_CID, false, NULL, nsThebesFontEnumeratorConstructor },
55 { &kNS_SCRIPTABLE_REGION_CID, false, NULL, nsScriptableRegionConstructor },
56 { &kNS_GFX_INITIALIZATION_CID, false, NULL, GfxInitializationConstructor },
57 { NULL }
60 static const mozilla::Module::ContractIDEntry kThebesContracts[] = {
61 { "@mozilla.org/gfx/fontenumerator;1", &kNS_FONT_ENUMERATOR_CID },
62 { "@mozilla.org/gfx/region;1", &kNS_SCRIPTABLE_REGION_CID },
63 { "@mozilla.org/gfx/init;1", &kNS_GFX_INITIALIZATION_CID },
64 { NULL }
67 static void
68 nsThebesGfxModuleDtor()
70 gfxPlatform::Shutdown();
73 static const mozilla::Module kThebesModule = {
74 mozilla::Module::kVersion,
75 kThebesCIDs,
76 kThebesContracts,
77 NULL,
78 NULL,
79 NULL,
80 nsThebesGfxModuleDtor
83 NSMODULE_DEFN(nsGfxModule) = &kThebesModule;