1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is thebes gfx
17 * The Initial Developer of the Original Code is
19 * Portions created by the Initial Developer are Copyright (C) 2005
20 * the Initial Developer. All Rights Reserved.
23 * Vladimir Vukicevic <vladimir@pobox.com>
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 #include "mozilla/ModuleUtils.h"
41 #include "nsGfxCIID.h"
43 #include "nsScriptableRegion.h"
45 #include "nsThebesDeviceContext.h"
46 #include "nsThebesRenderingContext.h"
47 #include "nsThebesRegion.h"
48 #include "nsThebesFontMetrics.h"
49 #include "nsThebesFontEnumerator.h"
50 #include "gfxPlatform.h"
52 NS_GENERIC_FACTORY_CONSTRUCTOR(nsThebesFontMetrics
)
53 NS_GENERIC_FACTORY_CONSTRUCTOR(nsThebesDeviceContext
)
54 NS_GENERIC_FACTORY_CONSTRUCTOR(nsThebesRenderingContext
)
55 NS_GENERIC_FACTORY_CONSTRUCTOR(nsThebesRegion
)
56 NS_GENERIC_FACTORY_CONSTRUCTOR(nsThebesFontEnumerator
)
59 nsScriptableRegionConstructor(nsISupports
*aOuter
, REFNSIID aIID
, void **aResult
)
63 nsIScriptableRegion
*inst
= nsnull
;
67 rv
= NS_ERROR_NULL_POINTER
;
73 rv
= NS_ERROR_NO_AGGREGATION
;
77 nsCOMPtr
<nsIRegion
> rgn
= new nsThebesRegion();
78 nsCOMPtr
<nsIScriptableRegion
> scriptableRgn
;
81 scriptableRgn
= new nsScriptableRegion(rgn
);
86 rv
= NS_ERROR_OUT_OF_MEMORY
;
90 // release our variable above now that we have created our owning
91 // reference - we don't want this to go out of scope early!
92 scriptableRgn
= nsnull
;
93 rv
= inst
->QueryInterface(aIID
, aResult
);
99 NS_DEFINE_NAMED_CID(NS_FONT_METRICS_CID
);
100 NS_DEFINE_NAMED_CID(NS_FONT_ENUMERATOR_CID
);
101 NS_DEFINE_NAMED_CID(NS_DEVICE_CONTEXT_CID
);
102 NS_DEFINE_NAMED_CID(NS_RENDERING_CONTEXT_CID
);
103 NS_DEFINE_NAMED_CID(NS_REGION_CID
);
104 NS_DEFINE_NAMED_CID(NS_SCRIPTABLE_REGION_CID
);
106 static const mozilla::Module::CIDEntry kThebesCIDs
[] = {
107 { &kNS_FONT_METRICS_CID
, false, NULL
, nsThebesFontMetricsConstructor
},
108 { &kNS_FONT_ENUMERATOR_CID
, false, NULL
, nsThebesFontEnumeratorConstructor
},
109 { &kNS_DEVICE_CONTEXT_CID
, false, NULL
, nsThebesDeviceContextConstructor
},
110 { &kNS_RENDERING_CONTEXT_CID
, false, NULL
, nsThebesRenderingContextConstructor
},
111 { &kNS_REGION_CID
, false, NULL
, nsThebesRegionConstructor
},
112 { &kNS_SCRIPTABLE_REGION_CID
, false, NULL
, nsScriptableRegionConstructor
},
116 static const mozilla::Module::ContractIDEntry kThebesContracts
[] = {
117 { "@mozilla.org/gfx/fontmetrics;1", &kNS_FONT_METRICS_CID
},
118 { "@mozilla.org/gfx/fontenumerator;1", &kNS_FONT_ENUMERATOR_CID
},
119 { "@mozilla.org/gfx/devicecontext;1", &kNS_DEVICE_CONTEXT_CID
},
120 { "@mozilla.org/gfx/renderingcontext;1", &kNS_RENDERING_CONTEXT_CID
},
121 { "@mozilla.org/gfx/region/nsThebes;1", &kNS_REGION_CID
},
122 { "@mozilla.org/gfx/region;1", &kNS_SCRIPTABLE_REGION_CID
},
127 nsThebesGfxModuleCtor()
129 return gfxPlatform::Init();
133 nsThebesGfxModuleDtor()
135 nsThebesDeviceContext::Shutdown();
136 gfxPlatform::Shutdown();
139 static const mozilla::Module kThebesModule
= {
140 mozilla::Module::kVersion
,
145 nsThebesGfxModuleCtor
,
146 nsThebesGfxModuleDtor
149 NSMODULE_DEFN(nsGfxModule
) = &kThebesModule
;