1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
5
* The contents of this file are subject to the Netscape Public License
6
* Version 1.1 (the "License"); you may not use this file except in
7
* compliance with the License. You may obtain a copy of the License at
8
* http://www.mozilla.org/NPL/
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 mozilla.org code.
17
* The Initial Developer of the Original Code is
18
* Netscape Communications Corporation.
19
* Portions created by the Initial Developer are Copyright (C) 2000
20
* the Initial Developer. All Rights Reserved.
23
* Johnny Stenback <jst@netscape.com> (original author)
26
* Alternatively, the contents of this file may be used under the terms of
27
* either the GNU General Public License Version 2 or later (the "GPL"), or
28
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29
* in which case the provisions of the GPL or the LGPL are applicable instead
30
* of those above. If you wish to allow use of your version of this file only
31
* under the terms of either the GPL or the LGPL, and not to allow others to
32
* use your version of this file under the terms of the NPL, indicate your
33
* decision by deleting the provisions above and replace them with the notice
34
* and other provisions required by the GPL or the LGPL. If you do not delete
35
* the provisions above, a recipient may use your version of this file under
36
* the terms of any one of the NPL, the GPL or the LGPL.
38
* ***** END LICENSE BLOCK ***** */
40
#ifndef nsIDOMClassInfo_h___
41
#define nsIDOMClassInfo_h___
43
#include "nsIClassInfo.h"
44
#include "nsVoidArray.h"
46
enum nsDOMClassInfoID {
48
eDOMClassInfo_Window_id,
49
eDOMClassInfo_Location_id,
50
eDOMClassInfo_Navigator_id,
51
eDOMClassInfo_Plugin_id,
52
eDOMClassInfo_PluginArray_id,
53
eDOMClassInfo_MimeType_id,
54
eDOMClassInfo_MimeTypeArray_id,
55
eDOMClassInfo_BarProp_id,
56
eDOMClassInfo_History_id,
57
eDOMClassInfo_Screen_id,
60
eDOMClassInfo_XMLDocument_id,
61
eDOMClassInfo_DocumentType_id,
62
eDOMClassInfo_DOMImplementation_id,
63
eDOMClassInfo_DOMException_id,
64
eDOMClassInfo_DocumentFragment_id,
65
eDOMClassInfo_Element_id,
66
eDOMClassInfo_Attr_id,
67
eDOMClassInfo_Text_id,
68
eDOMClassInfo_Comment_id,
69
eDOMClassInfo_CDATASection_id,
70
eDOMClassInfo_ProcessingInstruction_id,
71
eDOMClassInfo_Entity_id,
72
eDOMClassInfo_EntityReference_id,
73
eDOMClassInfo_Notation_id,
74
eDOMClassInfo_NodeList_id,
75
eDOMClassInfo_NamedNodeMap_id,
78
eDOMClassInfo_DocumentStyleSheetList_id,
81
eDOMClassInfo_Event_id,
82
eDOMClassInfo_MutationEvent_id,
85
eDOMClassInfo_HTMLDocument_id,
86
eDOMClassInfo_HTMLCollection_id,
87
eDOMClassInfo_HTMLOptionsCollection_id,
88
eDOMClassInfo_HTMLFormControlCollection_id,
89
eDOMClassInfo_HTMLGenericCollection_id,
91
// HTML element classes
92
eDOMClassInfo_HTMLAnchorElement_id,
93
eDOMClassInfo_HTMLAppletElement_id,
94
eDOMClassInfo_HTMLAreaElement_id,
95
eDOMClassInfo_HTMLBRElement_id,
96
eDOMClassInfo_HTMLBaseElement_id,
97
eDOMClassInfo_HTMLBaseFontElement_id,
98
eDOMClassInfo_HTMLBodyElement_id,
99
eDOMClassInfo_HTMLButtonElement_id,
100
eDOMClassInfo_HTMLDListElement_id,
101
eDOMClassInfo_HTMLDelElement_id,
102
eDOMClassInfo_HTMLDirectoryElement_id,
103
eDOMClassInfo_HTMLDivElement_id,
104
eDOMClassInfo_HTMLEmbedElement_id,
105
eDOMClassInfo_HTMLFieldSetElement_id,
106
eDOMClassInfo_HTMLFontElement_id,
107
eDOMClassInfo_HTMLFormElement_id,
108
eDOMClassInfo_HTMLFrameElement_id,
109
eDOMClassInfo_HTMLFrameSetElement_id,
110
eDOMClassInfo_HTMLHRElement_id,
111
eDOMClassInfo_HTMLHeadElement_id,
112
eDOMClassInfo_HTMLHeadingElement_id,
113
eDOMClassInfo_HTMLHtmlElement_id,
114
eDOMClassInfo_HTMLIFrameElement_id,
115
eDOMClassInfo_HTMLImageElement_id,
116
eDOMClassInfo_HTMLInputElement_id,
117
eDOMClassInfo_HTMLInsElement_id,
118
eDOMClassInfo_HTMLIsIndexElement_id,
119
eDOMClassInfo_HTMLLIElement_id,
120
eDOMClassInfo_HTMLLabelElement_id,
121
eDOMClassInfo_HTMLLegendElement_id,
122
eDOMClassInfo_HTMLLinkElement_id,
123
eDOMClassInfo_HTMLMapElement_id,
124
eDOMClassInfo_HTMLMenuElement_id,
125
eDOMClassInfo_HTMLMetaElement_id,
126
eDOMClassInfo_HTMLModElement_id,
127
eDOMClassInfo_HTMLOListElement_id,
128
eDOMClassInfo_HTMLObjectElement_id,
129
eDOMClassInfo_HTMLOptGroupElement_id,
130
eDOMClassInfo_HTMLOptionElement_id,
131
eDOMClassInfo_HTMLParagraphElement_id,
132
eDOMClassInfo_HTMLParamElement_id,
133
eDOMClassInfo_HTMLPreElement_id,
134
eDOMClassInfo_HTMLQuoteElement_id,
135
eDOMClassInfo_HTMLScriptElement_id,
136
eDOMClassInfo_HTMLSelectElement_id,
137
eDOMClassInfo_HTMLSpacerElement_id,
138
eDOMClassInfo_HTMLSpanElement_id,
139
eDOMClassInfo_HTMLStyleElement_id,
140
eDOMClassInfo_HTMLTableCaptionElement_id,
141
eDOMClassInfo_HTMLTableCellElement_id,
142
eDOMClassInfo_HTMLTableColElement_id,
143
eDOMClassInfo_HTMLTableColGroupElement_id,
144
eDOMClassInfo_HTMLTableElement_id,
145
eDOMClassInfo_HTMLTableRowElement_id,
146
eDOMClassInfo_HTMLTableSectionElement_id,
147
eDOMClassInfo_HTMLTextAreaElement_id,
148
eDOMClassInfo_HTMLTitleElement_id,
149
eDOMClassInfo_HTMLUListElement_id,
150
eDOMClassInfo_HTMLUnknownElement_id,
151
eDOMClassInfo_HTMLWBRElement_id,
154
eDOMClassInfo_CSSStyleRule_id,
155
eDOMClassInfo_CSSCharsetRule_id,
156
eDOMClassInfo_CSSImportRule_id,
157
eDOMClassInfo_CSSMediaRule_id,
158
eDOMClassInfo_CSSNameSpaceRule_id,
159
eDOMClassInfo_CSSRuleList_id,
160
eDOMClassInfo_CSSGroupRuleRuleList_id,
161
eDOMClassInfo_MediaList_id,
162
eDOMClassInfo_StyleSheetList_id,
163
eDOMClassInfo_CSSStyleSheet_id,
164
eDOMClassInfo_CSSStyleDeclaration_id,
165
eDOMClassInfo_ComputedCSSStyleDeclaration_id,
166
eDOMClassInfo_ROCSSPrimitiveValue_id,
167
eDOMClassInfo_CSSSelectorQuery_id,
170
eDOMClassInfo_Range_id,
171
eDOMClassInfo_Selection_id,
175
eDOMClassInfo_XULDocument_id,
176
eDOMClassInfo_XULElement_id,
177
eDOMClassInfo_XULCommandDispatcher_id,
178
eDOMClassInfo_XULNodeList_id,
179
eDOMClassInfo_XULNamedNodeMap_id,
180
eDOMClassInfo_XULAttr_id,
182
eDOMClassInfo_XULControllers_id,
184
eDOMClassInfo_BoxObject_id,
185
eDOMClassInfo_TreeSelection_id,
186
eDOMClassInfo_TreeContentView_id,
190
eDOMClassInfo_Crypto_id,
191
eDOMClassInfo_CRMFObject_id,
192
eDOMClassInfo_Pkcs11_id,
194
// DOM Traversal classes
195
eDOMClassInfo_TreeWalker_id,
197
// We are now trying to preserve binary compat in classinfo. No
198
// more putting things in those categories up there. New entries
199
// are to be added right before eDOMClassInfoIDCount
201
// Rect object used by getComputedStyle
202
eDOMClassInfo_CSSRect_id,
204
// DOM Chrome Window class, almost identical to Window
205
eDOMClassInfo_ChromeWindow_id,
207
// RGBColor object used by getComputedStyle
208
eDOMClassInfo_CSSRGBColor_id,
210
eDOMClassInfo_RangeException_id,
212
// CSSValueList object that represents an nsIDOMCSSValueList, used
214
eDOMClassInfo_CSSValueList_id,
216
// ContentList object used for various live NodeLists
217
eDOMClassInfo_ContentList_id,
219
// Processing-instruction with target "xml-stylesheet"
220
eDOMClassInfo_XMLStylesheetProcessingInstruction_id,
222
eDOMClassInfo_ImageDocument_id,
225
eDOMClassInfo_XULTreeBuilder_id,
228
// DOMStringList object
229
eDOMClassInfo_DOMStringList_id,
231
// NameList object used by the DOM
232
eDOMClassInfo_NameList_id,
236
eDOMClassInfo_SVGDocument_id,
238
// SVG element classes
239
eDOMClassInfo_SVGSVGElement_id,
240
eDOMClassInfo_SVGPolygonElement_id,
241
eDOMClassInfo_SVGPolylineElement_id,
242
eDOMClassInfo_SVGCircleElement_id,
243
eDOMClassInfo_SVGEllipseElement_id,
244
eDOMClassInfo_SVGLineElement_id,
245
eDOMClassInfo_SVGRectElement_id,
246
eDOMClassInfo_SVGGElement_id,
247
eDOMClassInfo_SVGForeignObjectElement_id,
248
eDOMClassInfo_SVGPathElement_id,
251
eDOMClassInfo_SVGAnimatedLength_id,
252
eDOMClassInfo_SVGLength_id,
253
eDOMClassInfo_SVGAnimatedPoints_id,
254
eDOMClassInfo_SVGPointList_id,
255
eDOMClassInfo_SVGPoint_id,
256
eDOMClassInfo_SVGAnimatedTransformList_id,
257
eDOMClassInfo_SVGTransformList_id,
258
eDOMClassInfo_SVGTransform_id,
259
eDOMClassInfo_SVGMatrix_id,
260
eDOMClassInfo_SVGPathSegList_id,
261
eDOMClassInfo_SVGPathSegClosePath_id,
262
eDOMClassInfo_SVGPathSegMovetoAbs_id,
263
eDOMClassInfo_SVGPathSegMovetoRel_id,
264
eDOMClassInfo_SVGPathSegLinetoAbs_id,
265
eDOMClassInfo_SVGPathSegLinetoRel_id,
266
eDOMClassInfo_SVGPathSegCurvetoCubicAbs_id,
267
eDOMClassInfo_SVGPathSegCurvetoCubicRel_id,
268
eDOMClassInfo_SVGPathSegCurvetoQuadraticAbs_id,
269
eDOMClassInfo_SVGPathSegCurvetoQuadraticRel_id,
270
eDOMClassInfo_SVGPathSegArcAbs_id,
271
eDOMClassInfo_SVGPathSegArcRel_id,
272
eDOMClassInfo_SVGPathSegLinetoHorizontalAbs_id,
273
eDOMClassInfo_SVGPathSegLinetoHorizontalRel_id,
274
eDOMClassInfo_SVGPathSegLinetoVerticalAbs_id,
275
eDOMClassInfo_SVGPathSegLinetoVerticalRel_id,
276
eDOMClassInfo_SVGPathSegCurvetoCubicSmoothAbs_id,
277
eDOMClassInfo_SVGPathSegCurvetoCubicSmoothRel_id,
278
eDOMClassInfo_SVGPathSegCurvetoQuadraticSmoothAbs_id,
279
eDOMClassInfo_SVGPathSegCurvetoQuadraticSmoothRel_id,
280
eDOMClassInfo_SVGRect_id,
281
eDOMClassInfo_SVGAnimatedRect_id,
282
eDOMClassInfo_SVGAnimatedLengthList_id,
283
eDOMClassInfo_SVGLengthList_id,
284
eDOMClassInfo_SVGNumber_id,
285
eDOMClassInfo_SVGTextElement_id,
286
eDOMClassInfo_SVGTSpanElement_id,
287
eDOMClassInfo_SVGAnimatedString_id,
288
eDOMClassInfo_SVGImageElement_id,
291
// This one better be the last one in this list
295
#include "nsIXPCScriptable.h"
297
#define DEFAULT_SCRIPTABLE_FLAGS \
298
(nsIXPCScriptable::USE_JSSTUB_FOR_ADDPROPERTY | \
299
nsIXPCScriptable::USE_JSSTUB_FOR_DELPROPERTY | \
300
nsIXPCScriptable::USE_JSSTUB_FOR_SETPROPERTY | \
301
nsIXPCScriptable::ALLOW_PROP_MODS_DURING_RESOLVE | \
302
nsIXPCScriptable::ALLOW_PROP_MODS_TO_PROTOTYPE | \
303
nsIXPCScriptable::DONT_ASK_INSTANCE_FOR_SCRIPTABLE | \
304
nsIXPCScriptable::DONT_REFLECT_INTERFACE_NAMES | \
305
nsIXPCScriptable::WANT_NEWRESOLVE | \
306
nsIXPCScriptable::WANT_CHECKACCESS | \
307
nsIXPCScriptable::WANT_POSTCREATE)
309
#define DOM_DEFAULT_SCRIPTABLE_FLAGS \
310
(DEFAULT_SCRIPTABLE_FLAGS | \
311
nsIXPCScriptable::DONT_ENUM_QUERY_INTERFACE | \
312
nsIXPCScriptable::CLASSINFO_INTERFACES_ONLY)
315
typedef nsIClassInfo* (*nsDOMClassInfoExternalConstructorFnc)
320
* nsIClassInfo helper macros
323
#define NS_CLASSINFO_MAP_BEGIN(_class)
325
#define NS_CLASSINFO_MAP_BEGIN_EXPORTED(_class)
327
#define NS_CLASSINFO_MAP_ENTRY(_interface)
329
#define NS_CLASSINFO_MAP_ENTRY_FUNCTION(_function)
331
#define NS_CLASSINFO_MAP_END
334
#include "nsIServiceManager.h"
335
#include "nsIDOMScriptObjectFactory.h"
336
#include "nsDOMCID.h"
338
#define NS_INTERFACE_MAP_ENTRY_DOM_CLASSINFO(_class) \
339
if (aIID.Equals(NS_GET_IID(nsIClassInfo))) { \
340
static NS_DEFINE_CID(kDOMSOF_CID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID); \
343
nsCOMPtr<nsIDOMScriptObjectFactory> sof(do_GetService(kDOMSOF_CID, \
345
if (NS_FAILED(rv)) { \
346
*aInstancePtr = nsnull; \
351
sof->GetClassInfoInstance(eDOMClassInfo_##_class##_id); \
354
// Looks up the nsIClassInfo for a class name registered with the
355
// nsScriptNamespaceManager. Remember to release NS_CLASSINFO_NAME(_class)
356
// (eg. when your module unloads).
357
#define NS_INTERFACE_MAP_ENTRY_EXTERNAL_DOM_CLASSINFO(_class) \
358
if (aIID.Equals(NS_GET_IID(nsIClassInfo))) { \
359
extern nsISupports *NS_CLASSINFO_NAME(_class); \
360
if (NS_CLASSINFO_NAME(_class)) { \
361
foundInterface = NS_CLASSINFO_NAME(_class); \
363
static NS_DEFINE_CID(kDOMSOF_CID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID); \
366
nsCOMPtr<nsIDOMScriptObjectFactory> sof(do_GetService(kDOMSOF_CID, \
368
if (NS_FAILED(rv)) { \
369
*aInstancePtr = nsnull; \
374
sof->GetExternalClassInfoInstance(NS_LITERAL_STRING(#_class)); \
376
if (foundInterface) { \
377
NS_CLASSINFO_NAME(_class) = foundInterface; \
378
NS_CLASSINFO_NAME(_class)->AddRef(); \
384
#define NS_DECL_DOM_CLASSINFO(_class) \
385
nsISupports *NS_CLASSINFO_NAME(_class) = nsnull;
387
// {891a7b01-1b61-11d6-a7f2-f690b638899c}
388
#define NS_IDOMCI_EXTENSION_IID \
389
{ 0x891a7b01, 0x1b61, 0x11d6, \
390
{ 0xa7, 0xf2, 0xf6, 0x90, 0xb6, 0x38, 0x89, 0x9c } }
392
class nsIDOMScriptObjectFactory;
394
class nsIDOMCIExtension : public nsISupports {
396
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDOMCI_EXTENSION_IID)
398
NS_IMETHOD RegisterDOMCI(const char* aName,
399
nsIDOMScriptObjectFactory* aDOMSOFactory) = 0;
403
#define NS_DOMCI_EXTENSION_NAME(_module) ns##_module##DOMCIExtension
404
#define NS_DOMCI_EXTENSION_CONSTRUCTOR(_module) \
405
ns##_module##DOMCIExtensionConstructor
406
#define NS_DOMCI_EXTENSION_CONSTRUCTOR_IMP(_extension) \
407
NS_GENERIC_FACTORY_CONSTRUCTOR(_extension)
409
#define NS_DOMCI_EXTENSION(_module) \
410
class NS_DOMCI_EXTENSION_NAME(_module) : public nsIDOMCIExtension \
413
NS_DOMCI_EXTENSION_NAME(_module)(); \
414
virtual ~NS_DOMCI_EXTENSION_NAME(_module)(); \
418
NS_IMETHOD RegisterDOMCI(const char* aName, \
419
nsIDOMScriptObjectFactory* aDOMSOFactory); \
422
NS_DOMCI_EXTENSION_CONSTRUCTOR_IMP(NS_DOMCI_EXTENSION_NAME(_module)) \
424
NS_DOMCI_EXTENSION_NAME(_module)::NS_DOMCI_EXTENSION_NAME(_module)() \
428
NS_DOMCI_EXTENSION_NAME(_module)::~NS_DOMCI_EXTENSION_NAME(_module)() \
432
NS_IMPL_ISUPPORTS1(NS_DOMCI_EXTENSION_NAME(_module), nsIDOMCIExtension) \
435
NS_DOMCI_EXTENSION_NAME(_module)::RegisterDOMCI(const char* aName, \
436
nsIDOMScriptObjectFactory* aDOMSOFactory) \
439
#define NS_DOMCI_EXTENSION_ENTRY_BEGIN(_class) \
440
if (nsCRT::strcmp(aName, #_class) == 0) { \
441
static const nsIID* interfaces[] = {
443
#define NS_DOMCI_EXTENSION_ENTRY_INTERFACE(_interface) \
444
&NS_GET_IID(_interface),
446
// Don't forget to register the primary interface (_proto) in the
447
// JAVASCRIPT_DOM_INTERFACE category, or prototypes for this class
448
// won't work (except if the interface name starts with nsIDOM).
449
#define NS_DOMCI_EXTENSION_ENTRY_END_HELPER(_class, _proto, _hasclassif, \
453
aDOMSOFactory->RegisterDOMClassInfo(#_class, nsnull, _proto, \
455
DOM_DEFAULT_SCRIPTABLE_FLAGS, \
456
_hasclassif, _constructorcid); \
460
#define NS_DOMCI_EXTENSION_ENTRY_END(_class, _proto, _hasclassif, \
462
NS_DOMCI_EXTENSION_ENTRY_END_HELPER(_class, &NS_GET_IID(_proto), \
463
_hasclassif, _constructorcid)
465
#define NS_DOMCI_EXTENSION_ENTRY_END_NO_PRIMARY_IF(_class, _hasclassif, \
467
NS_DOMCI_EXTENSION_ENTRY_END_HELPER(_class, nsnull, _hasclassif, \
470
#define NS_DOMCI_EXTENSION_END \
471
return NS_ERROR_FAILURE; \
475
#endif /* nsIDOMClassInfo_h___ */