1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=2 sw=2 et tw=80: */
3 /* ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
16 * The Original Code is mozilla.org code.
18 * The Initial Developer of the Original Code is
19 * Netscape Communications Corporation.
20 * Portions created by the Initial Developer are Copyright (C) 2000
21 * the Initial Developer. All Rights Reserved.
24 * Johnny Stenback <jst@netscape.com> (original author)
26 * Alternatively, the contents of this file may be used under the terms of
27 * either of the GNU General Public License Version 2 or later (the "GPL"),
28 * or 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 MPL, 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 MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
40 #ifndef nsDOMClassInfo_h___
41 #define nsDOMClassInfo_h___
43 #include "nsIDOMClassInfo.h"
44 #include "nsIXPCScriptable.h"
46 #include "nsIScriptSecurityManager.h"
47 #include "nsIScriptContext.h"
48 #include "nsDOMJSUtils.h" // for GetScriptContextFromJSContext
49 #include "nsIScriptGlobalObject.h"
50 #include "nsContentUtils.h"
53 class nsIDOMNSHTMLOptionCollection
;
54 class nsIPluginInstance
;
58 class nsIHTMLDocument
;
61 struct nsDOMClassInfoData
;
63 typedef nsIClassInfo
* (*nsDOMClassInfoConstructorFnc
)
64 (nsDOMClassInfoData
* aData
);
66 typedef nsresult (*nsDOMConstructorFunc
)(nsISupports
** aNewObject
);
68 struct nsDOMClassInfoData
71 const PRUnichar
*mNameUTF16
;
73 nsDOMClassInfoConstructorFnc mConstructorFptr
;
74 nsDOMClassInfoExternalConstructorFnc mExternalConstructorFptr
;
77 nsIClassInfo
*mCachedClassInfo
; // low bit is set to 1 if external,
78 // so be sure to mask if necessary!
79 const nsIID
*mProtoChainInterface
;
80 const nsIID
**mInterfaces
;
81 PRUint32 mScriptableFlags
: 31; // flags must not use more than 31 bits!
82 PRUint32 mHasClassInterface
: 1;
83 PRUint32 mInterfacesBitmap
;
90 struct nsExternalDOMClassInfoData
: public nsDOMClassInfoData
92 const nsCID
*mConstructorCID
;
96 typedef PRUptrdiff PtrBits
;
98 // To be used with the nsDOMClassInfoData::mCachedClassInfo pointer.
99 // The low bit is set when we created a generic helper for an external
100 // (which holds on to the nsDOMClassInfoData).
101 #define GET_CLEAN_CI_PTR(_ptr) (nsIClassInfo*)(PtrBits(_ptr) & ~0x1)
102 #define MARK_EXTERNAL(_ptr) (nsIClassInfo*)(PtrBits(_ptr) | 0x1)
103 #define IS_EXTERNAL(_ptr) (PtrBits(_ptr) & 0x1)
106 class nsDOMClassInfo
: public nsXPCClassInfo
109 nsDOMClassInfo(nsDOMClassInfoData
* aData
);
110 virtual ~nsDOMClassInfo();
112 NS_DECL_NSIXPCSCRIPTABLE
118 // Helper method that returns a *non* refcounted pointer to a
119 // helper. So please note, don't release this pointer, if you do,
120 // you better make sure you've addreffed before release.
122 // Whaaaaa! I wanted to name this method GetClassInfo, but nooo,
123 // some of Microsoft devstudio's headers #defines GetClassInfo to
124 // GetClassInfoA so I can't, those $%#@^! bastards!!! What gives
125 // them the right to do that?
127 static nsIClassInfo
* GetClassInfoInstance(nsDOMClassInfoData
* aData
);
129 static void ShutDown();
131 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
133 return new nsDOMClassInfo(aData
);
136 static nsresult
WrapNative(JSContext
*cx
, JSObject
*scope
,
137 nsISupports
*native
, const nsIID
* aIID
,
138 PRBool aAllowWrapping
, jsval
*vp
,
139 // If non-null aHolder will keep the jsval alive
140 // while there's a ref to it
141 nsIXPConnectJSObjectHolder
** aHolder
= nsnull
)
143 return WrapNative(cx
, scope
, native
, nsnull
, aIID
, vp
, aHolder
,
147 // Used for cases where PreCreate needs to wrap the native parent, and the
148 // native parent is likely to have been wrapped already. |native| must
149 // implement nsWrapperCache, and nativeWrapperCache must be |native|'s
151 static inline nsresult
WrapNativeParent(JSContext
*cx
, JSObject
*scope
,
153 nsWrapperCache
*nativeWrapperCache
,
154 JSObject
**parentObj
);
156 // Same as the WrapNative above, but use these if aIID is nsISupports' IID.
157 static nsresult
WrapNative(JSContext
*cx
, JSObject
*scope
,
158 nsISupports
*native
, PRBool aAllowWrapping
,
160 // If non-null aHolder will keep the jsval alive
161 // while there's a ref to it
162 nsIXPConnectJSObjectHolder
** aHolder
= nsnull
)
164 return WrapNative(cx
, scope
, native
, nsnull
, nsnull
, vp
, aHolder
,
167 static nsresult
WrapNative(JSContext
*cx
, JSObject
*scope
,
168 nsISupports
*native
, nsWrapperCache
*cache
,
169 PRBool aAllowWrapping
, jsval
*vp
,
170 // If non-null aHolder will keep the jsval alive
171 // while there's a ref to it
172 nsIXPConnectJSObjectHolder
** aHolder
= nsnull
)
174 return WrapNative(cx
, scope
, native
, cache
, nsnull
, vp
, aHolder
,
178 static nsresult
ThrowJSException(JSContext
*cx
, nsresult aResult
);
181 * The following two functions exist because of the way that Xray wrappers
182 * work. In order to allow scriptable helpers to define non-IDL defined but
183 * still "safe" properties for Xray wrappers, we call into the scriptable
184 * helper with |obj| being the wrapper.
186 * Ideally, that would be the end of the story, however due to complications
187 * dealing with document.domain, it's possible to end up in a scriptable
188 * helper with a wrapper, even though we should be treating the lookup as a
191 static PRBool
ObjectIsNativeWrapper(JSContext
* cx
, JSObject
* obj
);
193 static nsISupports
*GetNative(nsIXPConnectWrappedNative
*wrapper
, JSObject
*obj
);
195 static nsIXPConnect
*XPConnect()
201 friend nsIClassInfo
* NS_GetDOMClassInfoInstance(nsDOMClassInfoID aID
);
203 const nsDOMClassInfoData
* mData
;
205 virtual void PreserveWrapper(nsISupports
*aNative
)
209 virtual PRUint32
GetInterfacesBitmap()
211 return mData
->mInterfacesBitmap
;
214 static nsresult
Init();
215 static nsresult
RegisterClassName(PRInt32 aDOMClassInfoID
);
216 static nsresult
RegisterClassProtos(PRInt32 aDOMClassInfoID
);
217 static nsresult
RegisterExternalClasses();
218 nsresult
ResolveConstructor(JSContext
*cx
, JSObject
*obj
,
221 // Checks if id is a number and returns the number, if aIsNumber is
222 // non-null it's set to true if the id is a number and false if it's
223 // not a number. If id is not a number this method returns -1
224 static PRInt32
GetArrayIndexFromId(JSContext
*cx
, jsid id
,
225 PRBool
*aIsNumber
= nsnull
);
227 static inline PRBool
IsReadonlyReplaceable(jsid id
)
229 return (id
== sTop_id
||
231 id
== sScrollbars_id
||
235 id
== sLocationbar_id
||
236 id
== sPersonalbar_id
||
237 id
== sStatusbar_id
||
238 id
== sControllers_id
||
241 id
== sScrollMaxX_id
||
242 id
== sScrollMaxY_id
||
249 static inline PRBool
IsWritableReplaceable(jsid id
)
251 return (id
== sInnerHeight_id
||
252 id
== sInnerWidth_id
||
254 id
== sOuterHeight_id
||
255 id
== sOuterWidth_id
||
262 inline static nsresult
WrapNative(JSContext
*cx
, JSObject
*scope
,
263 nsISupports
*native
, nsWrapperCache
*cache
,
264 const nsIID
* aIID
, jsval
*vp
,
265 nsIXPConnectJSObjectHolder
** aHolder
,
266 PRBool aAllowWrapping
);
268 static nsIXPConnect
*sXPConnect
;
269 static nsIScriptSecurityManager
*sSecMan
;
271 // nsIXPCScriptable code
272 static nsresult
DefineStaticJSVals(JSContext
*cx
);
274 static PRBool sIsInitialized
;
275 static PRBool sDisableDocumentAllSupport
;
276 static PRBool sDisableGlobalScopePollutionSupport
;
280 static jsid sParent_id
;
281 static jsid sScrollbars_id
;
282 static jsid sLocation_id
;
283 static jsid sConstructor_id
;
284 static jsid s_content_id
;
285 static jsid sContent_id
;
286 static jsid sMenubar_id
;
287 static jsid sToolbar_id
;
288 static jsid sLocationbar_id
;
289 static jsid sPersonalbar_id
;
290 static jsid sStatusbar_id
;
291 static jsid sDialogArguments_id
;
292 static jsid sControllers_id
;
293 static jsid sLength_id
;
294 static jsid sInnerHeight_id
;
295 static jsid sInnerWidth_id
;
296 static jsid sOuterHeight_id
;
297 static jsid sOuterWidth_id
;
298 static jsid sScreenX_id
;
299 static jsid sScreenY_id
;
300 static jsid sStatus_id
;
301 static jsid sName_id
;
302 static jsid sOnmousedown_id
;
303 static jsid sOnmouseup_id
;
304 static jsid sOnclick_id
;
305 static jsid sOndblclick_id
;
306 static jsid sOncontextmenu_id
;
307 static jsid sOnmouseover_id
;
308 static jsid sOnmouseout_id
;
309 static jsid sOnkeydown_id
;
310 static jsid sOnkeyup_id
;
311 static jsid sOnkeypress_id
;
312 static jsid sOnmousemove_id
;
313 static jsid sOnfocus_id
;
314 static jsid sOnblur_id
;
315 static jsid sOnsubmit_id
;
316 static jsid sOnreset_id
;
317 static jsid sOnchange_id
;
318 static jsid sOninput_id
;
319 static jsid sOninvalid_id
;
320 static jsid sOnselect_id
;
321 static jsid sOnload_id
;
322 static jsid sOnpopstate_id
;
323 static jsid sOnbeforeunload_id
;
324 static jsid sOnunload_id
;
325 static jsid sOnhashchange_id
;
326 static jsid sOnreadystatechange_id
;
327 static jsid sOnpageshow_id
;
328 static jsid sOnpagehide_id
;
329 static jsid sOnabort_id
;
330 static jsid sOnerror_id
;
331 static jsid sOnpaint_id
;
332 static jsid sOnresize_id
;
333 static jsid sOnscroll_id
;
334 static jsid sOndrag_id
;
335 static jsid sOndragend_id
;
336 static jsid sOndragenter_id
;
337 static jsid sOndragleave_id
;
338 static jsid sOndragover_id
;
339 static jsid sOndragstart_id
;
340 static jsid sOndrop_id
;
341 static jsid sScrollX_id
;
342 static jsid sScrollY_id
;
343 static jsid sScrollMaxX_id
;
344 static jsid sScrollMaxY_id
;
345 static jsid sOpen_id
;
346 static jsid sItem_id
;
347 static jsid sNamedItem_id
;
348 static jsid sEnumerate_id
;
349 static jsid sNavigator_id
;
350 static jsid sDocument_id
;
351 static jsid sFrames_id
;
352 static jsid sSelf_id
;
353 static jsid sOpener_id
;
355 static jsid sTags_id
;
356 static jsid sAddEventListener_id
;
357 static jsid sBaseURIObject_id
;
358 static jsid sNodePrincipal_id
;
359 static jsid sDocumentURIObject_id
;
360 static jsid sOncopy_id
;
361 static jsid sOncut_id
;
362 static jsid sOnpaste_id
;
363 static jsid sJava_id
;
364 static jsid sPackages_id
;
365 static jsid sOnloadstart_id
;
366 static jsid sOnprogress_id
;
367 static jsid sOnsuspend_id
;
368 static jsid sOnemptied_id
;
369 static jsid sOnstalled_id
;
370 static jsid sOnplay_id
;
371 static jsid sOnpause_id
;
372 static jsid sOnloadedmetadata_id
;
373 static jsid sOnloadeddata_id
;
374 static jsid sOnwaiting_id
;
375 static jsid sOnplaying_id
;
376 static jsid sOncanplay_id
;
377 static jsid sOncanplaythrough_id
;
378 static jsid sOnseeking_id
;
379 static jsid sOnseeked_id
;
380 static jsid sOntimeupdate_id
;
381 static jsid sOnended_id
;
382 static jsid sOnratechange_id
;
383 static jsid sOndurationchange_id
;
384 static jsid sOnvolumechange_id
;
385 static jsid sOnmessage_id
;
386 static jsid sOnbeforescriptexecute_id
;
387 static jsid sOnafterscriptexecute_id
;
388 static jsid sWrappedJSObject_id
;
390 static jsid sKeyPath_id
;
391 static jsid sAutoIncrement_id
;
392 static jsid sUnique_id
;
395 static JSPropertyOp sXPCNativeWrapperGetPropertyOp
;
396 static JSPropertyOp sXrayWrapperPropertyHolderGetPropertyOp
;
401 const nsQueryInterface
402 do_QueryWrappedNative(nsIXPConnectWrappedNative
*wrapper
, JSObject
*obj
)
404 return nsQueryInterface(nsDOMClassInfo::GetNative(wrapper
, obj
));
408 const nsQueryInterfaceWithError
409 do_QueryWrappedNative(nsIXPConnectWrappedNative
*wrapper
, JSObject
*obj
,
413 return nsQueryInterfaceWithError(nsDOMClassInfo::GetNative(wrapper
, obj
),
419 do_QueryWrapper(JSContext
*cx
, JSObject
*obj
)
421 nsISupports
*native
=
422 nsDOMClassInfo::XPConnect()->GetNativeOfWrapper(cx
, obj
);
423 return nsQueryInterface(native
);
427 nsQueryInterfaceWithError
428 do_QueryWrapper(JSContext
*cx
, JSObject
*obj
, nsresult
* error
)
430 nsISupports
*native
=
431 nsDOMClassInfo::XPConnect()->GetNativeOfWrapper(cx
, obj
);
432 return nsQueryInterfaceWithError(native
, error
);
436 typedef nsDOMClassInfo nsDOMGenericSH
;
438 // EventProp scriptable helper, this class should be the base class of
439 // all objects that should support things like
440 // obj.onclick=function{...}
442 class nsEventReceiverSH
: public nsDOMGenericSH
445 nsEventReceiverSH(nsDOMClassInfoData
* aData
) : nsDOMGenericSH(aData
)
449 virtual ~nsEventReceiverSH()
453 static PRBool
ReallyIsEventName(jsid id
, jschar aFirstChar
);
455 static inline PRBool
IsEventName(jsid id
)
457 NS_ASSERTION(JSID_IS_STRING(id
), "Don't pass non-string jsid's here!");
459 const jschar
*str
= ::JS_GetInternedStringChars(JSID_TO_STRING(id
));
461 if (str
[0] == 'o' && str
[1] == 'n') {
462 return ReallyIsEventName(id
, str
[2]);
468 nsresult
RegisterCompileHandler(nsIXPConnectWrappedNative
*wrapper
,
469 JSContext
*cx
, JSObject
*obj
, jsid id
,
470 PRBool compile
, PRBool remove
,
474 NS_IMETHOD
NewResolve(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
475 JSObject
*obj
, jsid id
, PRUint32 flags
,
476 JSObject
**objp
, PRBool
*_retval
);
477 NS_IMETHOD
SetProperty(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
478 JSObject
*obj
, jsid id
, jsval
*vp
,
480 NS_IMETHOD
AddProperty(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
481 JSObject
*obj
, jsid id
, jsval
*vp
, PRBool
*_retval
);
484 // Simpler than nsEventReceiverSH
485 // Makes sure that the wrapper is preserved if new properties are added.
486 class nsEventTargetSH
: public nsDOMGenericSH
489 nsEventTargetSH(nsDOMClassInfoData
* aData
) : nsDOMGenericSH(aData
)
493 virtual ~nsEventTargetSH()
497 NS_IMETHOD
PreCreate(nsISupports
*nativeObj
, JSContext
*cx
,
498 JSObject
*globalObj
, JSObject
**parentObj
);
499 NS_IMETHOD
AddProperty(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
500 JSObject
*obj
, jsid id
, jsval
*vp
, PRBool
*_retval
);
502 virtual void PreserveWrapper(nsISupports
*aNative
);
504 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
506 return new nsEventTargetSH(aData
);
510 // Window scriptable helper
512 class nsWindowSH
: public nsEventReceiverSH
515 nsWindowSH(nsDOMClassInfoData
*aData
) : nsEventReceiverSH(aData
)
519 virtual ~nsWindowSH()
523 static nsresult
GlobalResolve(nsGlobalWindow
*aWin
, JSContext
*cx
,
524 JSObject
*obj
, jsid id
, PRBool
*did_resolve
);
527 NS_IMETHOD
PreCreate(nsISupports
*nativeObj
, JSContext
*cx
,
528 JSObject
*globalObj
, JSObject
**parentObj
);
530 NS_IMETHOD
PostCreate(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
533 nsCOMPtr
<nsIScriptGlobalObject
> sgo(do_QueryWrappedNative(wrapper
));
535 NS_ASSERTION(!sgo
|| sgo
->GetGlobalJSObject() == nsnull
,
536 "Multiple wrappers created for global object!");
540 NS_IMETHOD
GetScriptableFlags(PRUint32
*aFlags
)
543 nsresult rv
= nsEventReceiverSH::GetScriptableFlags(&flags
);
544 if (NS_SUCCEEDED(rv
)) {
545 *aFlags
= flags
| nsIXPCScriptable::WANT_POSTCREATE
;
551 NS_IMETHOD
GetProperty(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
552 JSObject
*obj
, jsid id
, jsval
*vp
, PRBool
*_retval
);
553 NS_IMETHOD
SetProperty(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
554 JSObject
*obj
, jsid id
, jsval
*vp
, PRBool
*_retval
);
555 NS_IMETHOD
NewResolve(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
556 JSObject
*obj
, jsid id
, PRUint32 flags
,
557 JSObject
**objp
, PRBool
*_retval
);
558 NS_IMETHOD
Finalize(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
560 NS_IMETHOD
Equality(nsIXPConnectWrappedNative
*wrapper
, JSContext
* cx
,
561 JSObject
* obj
, const jsval
&val
, PRBool
*bp
);
562 NS_IMETHOD
OuterObject(nsIXPConnectWrappedNative
*wrapper
, JSContext
* cx
,
563 JSObject
* obj
, JSObject
* *_retval
);
565 static JSBool
GlobalScopePolluterNewResolve(JSContext
*cx
, JSObject
*obj
,
566 jsid id
, uintN flags
,
568 static JSBool
GlobalScopePolluterGetProperty(JSContext
*cx
, JSObject
*obj
,
570 static JSBool
SecurityCheckOnAddDelProp(JSContext
*cx
, JSObject
*obj
, jsid id
,
572 static JSBool
SecurityCheckOnSetProp(JSContext
*cx
, JSObject
*obj
, jsid id
,
573 JSBool strict
, jsval
*vp
);
574 static void InvalidateGlobalScopePolluter(JSContext
*cx
, JSObject
*obj
);
575 static nsresult
InstallGlobalScopePolluter(JSContext
*cx
, JSObject
*obj
,
576 nsIHTMLDocument
*doc
);
577 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
579 return new nsWindowSH(aData
);
583 // Location scriptable helper
585 class nsLocationSH
: public nsDOMGenericSH
588 nsLocationSH(nsDOMClassInfoData
* aData
) : nsDOMGenericSH(aData
)
592 virtual ~nsLocationSH()
597 NS_IMETHOD
CheckAccess(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
598 JSObject
*obj
, jsid id
, PRUint32 mode
,
599 jsval
*vp
, PRBool
*_retval
);
601 NS_IMETHOD
PreCreate(nsISupports
*nativeObj
, JSContext
*cx
,
602 JSObject
*globalObj
, JSObject
**parentObj
);
604 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
606 return new nsLocationSH(aData
);
611 // Navigator scriptable helper
613 class nsNavigatorSH
: public nsDOMGenericSH
616 nsNavigatorSH(nsDOMClassInfoData
* aData
) : nsDOMGenericSH(aData
)
620 virtual ~nsNavigatorSH()
625 NS_IMETHOD
PreCreate(nsISupports
*nativeObj
, JSContext
*cx
,
626 JSObject
*globalObj
, JSObject
**parentObj
);
628 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
630 return new nsNavigatorSH(aData
);
635 // DOM Node helper, this class deals with setting the parent for the
638 class nsNodeSH
: public nsEventReceiverSH
641 nsNodeSH(nsDOMClassInfoData
* aData
) : nsEventReceiverSH(aData
)
649 // Helper to check whether a capability is enabled
650 PRBool
IsCapabilityEnabled(const char* aCapability
);
652 inline PRBool
IsPrivilegedScript() {
653 return IsCapabilityEnabled("UniversalXPConnect");
656 // Helper to define a void property with JSPROP_SHARED; this can do all the
657 // work so it's safe to just return whatever it returns. |obj| is the object
658 // we're defining on, |id| is the name of the prop. This must be a string
659 // jsval. |objp| is the out param if we define successfully.
660 nsresult
DefineVoidProp(JSContext
* cx
, JSObject
* obj
, jsid id
,
664 NS_IMETHOD
PreCreate(nsISupports
*nativeObj
, JSContext
*cx
,
665 JSObject
*globalObj
, JSObject
**parentObj
);
666 NS_IMETHOD
AddProperty(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
667 JSObject
*obj
, jsid id
, jsval
*vp
, PRBool
*_retval
);
668 NS_IMETHOD
NewResolve(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
669 JSObject
*obj
, jsid id
, PRUint32 flags
,
670 JSObject
**objp
, PRBool
*_retval
);
671 NS_IMETHOD
GetProperty(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
672 JSObject
*obj
, jsid id
, jsval
*vp
, PRBool
*_retval
);
673 NS_IMETHOD
SetProperty(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
674 JSObject
*obj
, jsid id
, jsval
*vp
, PRBool
*_retval
);
675 NS_IMETHOD
GetFlags(PRUint32
*aFlags
);
677 virtual void PreserveWrapper(nsISupports
*aNative
);
679 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
681 return new nsNodeSH(aData
);
688 class nsElementSH
: public nsNodeSH
691 nsElementSH(nsDOMClassInfoData
* aData
) : nsNodeSH(aData
)
695 virtual ~nsElementSH()
700 NS_IMETHOD
PreCreate(nsISupports
*nativeObj
, JSContext
*cx
,
701 JSObject
*globalObj
, JSObject
**parentObj
);
702 NS_IMETHOD
PostCreate(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
704 NS_IMETHOD
Enumerate(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
705 JSObject
*obj
, PRBool
*_retval
);
707 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
709 return new nsElementSH(aData
);
714 // Generic array scriptable helper
716 class nsGenericArraySH
: public nsDOMClassInfo
719 nsGenericArraySH(nsDOMClassInfoData
* aData
) : nsDOMClassInfo(aData
)
723 virtual ~nsGenericArraySH()
728 NS_IMETHOD
NewResolve(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
729 JSObject
*obj
, jsid id
, PRUint32 flags
,
730 JSObject
**objp
, PRBool
*_retval
);
731 NS_IMETHOD
Enumerate(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
732 JSObject
*obj
, PRBool
*_retval
);
734 virtual nsresult
GetLength(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
735 JSObject
*obj
, PRUint32
*length
);
737 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
739 return new nsGenericArraySH(aData
);
744 // Array scriptable helper
746 class nsArraySH
: public nsGenericArraySH
749 nsArraySH(nsDOMClassInfoData
* aData
) : nsGenericArraySH(aData
)
757 // Subclasses need to override this, if the implementation can't fail it's
758 // allowed to not set *aResult.
759 virtual nsISupports
* GetItemAt(nsISupports
*aNative
, PRUint32 aIndex
,
760 nsWrapperCache
**aCache
, nsresult
*aResult
) = 0;
763 NS_IMETHOD
GetProperty(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
764 JSObject
*obj
, jsid id
, jsval
*vp
, PRBool
*_retval
);
767 // Not implemented, nothing should create an instance of this class.
768 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
);
772 // NodeList scriptable helper
774 class nsNodeListSH
: public nsArraySH
777 nsNodeListSH(nsDOMClassInfoData
* aData
) : nsArraySH(aData
)
782 NS_IMETHOD
PreCreate(nsISupports
*nativeObj
, JSContext
*cx
,
783 JSObject
*globalObj
, JSObject
**parentObj
);
785 virtual nsresult
GetLength(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
786 JSObject
*obj
, PRUint32
*length
);
787 virtual nsISupports
* GetItemAt(nsISupports
*aNative
, PRUint32 aIndex
,
788 nsWrapperCache
**aCache
, nsresult
*aResult
);
790 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
792 return new nsNodeListSH(aData
);
799 class nsNamedArraySH
: public nsArraySH
802 nsNamedArraySH(nsDOMClassInfoData
* aData
) : nsArraySH(aData
)
806 virtual ~nsNamedArraySH()
810 virtual nsISupports
* GetNamedItem(nsISupports
*aNative
,
811 const nsAString
& aName
,
812 nsWrapperCache
**cache
,
813 nsresult
*aResult
) = 0;
816 NS_IMETHOD
GetProperty(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
817 JSObject
*obj
, jsid id
, jsval
*vp
, PRBool
*_retval
);
820 // Not implemented, nothing should create an instance of this class.
821 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
);
825 // NamedNodeMap helper
827 class nsNamedNodeMapSH
: public nsNamedArraySH
830 nsNamedNodeMapSH(nsDOMClassInfoData
* aData
) : nsNamedArraySH(aData
)
834 virtual ~nsNamedNodeMapSH()
838 virtual nsISupports
* GetItemAt(nsISupports
*aNative
, PRUint32 aIndex
,
839 nsWrapperCache
**aCache
, nsresult
*aResult
);
841 // Override nsNamedArraySH::GetNamedItem()
842 virtual nsISupports
* GetNamedItem(nsISupports
*aNative
,
843 const nsAString
& aName
,
844 nsWrapperCache
**cache
,
848 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
850 return new nsNamedNodeMapSH(aData
);
855 // HTMLCollection helper
857 class nsHTMLCollectionSH
: public nsNamedArraySH
860 nsHTMLCollectionSH(nsDOMClassInfoData
* aData
) : nsNamedArraySH(aData
)
864 virtual ~nsHTMLCollectionSH()
868 virtual nsresult
GetLength(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
869 JSObject
*obj
, PRUint32
*length
);
870 virtual nsISupports
* GetItemAt(nsISupports
*aNative
, PRUint32 aIndex
,
871 nsWrapperCache
**aCache
, nsresult
*aResult
);
873 // Override nsNamedArraySH::GetNamedItem()
874 virtual nsISupports
* GetNamedItem(nsISupports
*aNative
,
875 const nsAString
& aName
,
876 nsWrapperCache
**cache
,
880 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
882 return new nsHTMLCollectionSH(aData
);
887 // ContentList helper
889 class nsContentListSH
: public nsNamedArraySH
892 nsContentListSH(nsDOMClassInfoData
* aData
) : nsNamedArraySH(aData
)
897 NS_IMETHOD
PreCreate(nsISupports
*nativeObj
, JSContext
*cx
,
898 JSObject
*globalObj
, JSObject
**parentObj
);
900 virtual nsresult
GetLength(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
901 JSObject
*obj
, PRUint32
*length
);
902 virtual nsISupports
* GetItemAt(nsISupports
*aNative
, PRUint32 aIndex
,
903 nsWrapperCache
**aCache
, nsresult
*aResult
);
904 virtual nsISupports
* GetNamedItem(nsISupports
*aNative
,
905 const nsAString
& aName
,
906 nsWrapperCache
**cache
,
909 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
911 return new nsContentListSH(aData
);
917 // Document helper, for document.location and document.on*
919 class nsDocumentSH
: public nsNodeSH
922 nsDocumentSH(nsDOMClassInfoData
* aData
) : nsNodeSH(aData
)
926 virtual ~nsDocumentSH()
931 NS_IMETHOD
NewResolve(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
932 JSObject
*obj
, jsid id
, PRUint32 flags
,
933 JSObject
**objp
, PRBool
*_retval
);
934 NS_IMETHOD
GetProperty(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
935 JSObject
*obj
, jsid id
, jsval
*vp
, PRBool
*_retval
);
936 NS_IMETHOD
SetProperty(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
937 JSObject
*obj
, jsid id
, jsval
*vp
, PRBool
*_retval
);
938 NS_IMETHOD
GetFlags(PRUint32
* aFlags
);
939 NS_IMETHOD
PostCreate(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
942 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
944 return new nsDocumentSH(aData
);
949 // HTMLDocument helper
951 class nsHTMLDocumentSH
: public nsDocumentSH
954 nsHTMLDocumentSH(nsDOMClassInfoData
* aData
) : nsDocumentSH(aData
)
958 virtual ~nsHTMLDocumentSH()
962 static JSBool
DocumentOpen(JSContext
*cx
, uintN argc
, jsval
*vp
);
963 static JSBool
GetDocumentAllNodeList(JSContext
*cx
, JSObject
*obj
,
965 nsContentList
**nodeList
);
968 static JSBool
DocumentAllGetProperty(JSContext
*cx
, JSObject
*obj
, jsid id
,
970 static JSBool
DocumentAllNewResolve(JSContext
*cx
, JSObject
*obj
, jsid id
,
971 uintN flags
, JSObject
**objp
);
972 static void ReleaseDocument(JSContext
*cx
, JSObject
*obj
);
973 static JSBool
CallToGetPropMapper(JSContext
*cx
, uintN argc
, jsval
*vp
);
974 static JSBool
DocumentAllHelperGetProperty(JSContext
*cx
, JSObject
*obj
,
976 static JSBool
DocumentAllHelperNewResolve(JSContext
*cx
, JSObject
*obj
,
977 jsid id
, uintN flags
,
979 static JSBool
DocumentAllTagsNewResolve(JSContext
*cx
, JSObject
*obj
,
980 jsid id
, uintN flags
,
983 NS_IMETHOD
NewResolve(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
984 JSObject
*obj
, jsid id
, PRUint32 flags
,
985 JSObject
**objp
, PRBool
*_retval
);
986 NS_IMETHOD
GetProperty(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
987 JSObject
*obj
, jsid id
, jsval
*vp
, PRBool
*_retval
);
989 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
991 return new nsHTMLDocumentSH(aData
);
996 // HTMLBodyElement helper
998 class nsHTMLBodyElementSH
: public nsElementSH
1001 nsHTMLBodyElementSH(nsDOMClassInfoData
* aData
) : nsElementSH(aData
)
1005 virtual ~nsHTMLBodyElementSH()
1010 NS_IMETHOD
NewResolve(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
1011 JSObject
*obj
, jsid id
, PRUint32 flags
,
1012 JSObject
**objp
, PRBool
*_retval
);
1014 NS_IMETHOD
GetProperty(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
1015 JSObject
*obj
, jsid id
, jsval
*vp
,
1018 NS_IMETHOD
SetProperty(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
1019 JSObject
*obj
, jsid id
, jsval
*vp
, PRBool
*_retval
);
1021 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
1023 return new nsHTMLBodyElementSH(aData
);
1028 // HTMLFormElement helper
1030 class nsHTMLFormElementSH
: public nsElementSH
1033 nsHTMLFormElementSH(nsDOMClassInfoData
* aData
) : nsElementSH(aData
)
1037 virtual ~nsHTMLFormElementSH()
1041 static nsresult
FindNamedItem(nsIForm
*aForm
, jsid id
,
1042 nsISupports
**aResult
, nsWrapperCache
**aCache
);
1045 NS_IMETHOD
NewResolve(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
1046 JSObject
*obj
, jsid id
, PRUint32 flags
,
1047 JSObject
**objp
, PRBool
*_retval
);
1048 NS_IMETHOD
GetProperty(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
1049 JSObject
*obj
, jsid id
, jsval
*vp
,
1052 NS_IMETHOD
NewEnumerate(nsIXPConnectWrappedNative
*wrapper
,
1053 JSContext
*cx
, JSObject
*obj
,
1054 PRUint32 enum_op
, jsval
*statep
,
1055 jsid
*idp
, PRBool
*_retval
);
1057 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
1059 return new nsHTMLFormElementSH(aData
);
1064 // HTMLSelectElement helper
1066 class nsHTMLSelectElementSH
: public nsElementSH
1069 nsHTMLSelectElementSH(nsDOMClassInfoData
* aData
) : nsElementSH(aData
)
1073 virtual ~nsHTMLSelectElementSH()
1078 NS_IMETHOD
GetProperty(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
1079 JSObject
*obj
, jsid id
, jsval
*vp
,
1081 NS_IMETHOD
SetProperty(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
1082 JSObject
*obj
, jsid id
, jsval
*vp
, PRBool
*_retval
);
1084 static nsresult
SetOption(JSContext
*cx
, jsval
*vp
, PRUint32 aIndex
,
1085 nsIDOMNSHTMLOptionCollection
*aOptCollection
);
1087 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
1089 return new nsHTMLSelectElementSH(aData
);
1094 // HTMLEmbed/Object/AppletElement helper
1096 class nsHTMLPluginObjElementSH
: public nsElementSH
1099 nsHTMLPluginObjElementSH(nsDOMClassInfoData
* aData
)
1100 : nsElementSH(aData
)
1104 virtual ~nsHTMLPluginObjElementSH()
1108 static nsresult
GetPluginInstanceIfSafe(nsIXPConnectWrappedNative
*aWrapper
,
1110 nsIPluginInstance
**aResult
);
1112 static nsresult
GetPluginJSObject(JSContext
*cx
, JSObject
*obj
,
1113 nsIPluginInstance
*plugin_inst
,
1114 JSObject
**plugin_obj
,
1115 JSObject
**plugin_proto
);
1118 NS_IMETHOD
NewResolve(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
1119 JSObject
*obj
, jsid id
, PRUint32 flags
,
1120 JSObject
**objp
, PRBool
*_retval
);
1121 NS_IMETHOD
PreCreate(nsISupports
*nativeObj
, JSContext
*cx
,
1122 JSObject
*globalObj
, JSObject
**parentObj
);
1123 NS_IMETHOD
PostCreate(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
1125 NS_IMETHOD
GetProperty(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
1126 JSObject
*obj
, jsid id
, jsval
*vp
, PRBool
*_retval
);
1127 NS_IMETHOD
SetProperty(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
1128 JSObject
*obj
, jsid id
, jsval
*vp
, PRBool
*_retval
);
1129 NS_IMETHOD
Call(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
1130 JSObject
*obj
, PRUint32 argc
, jsval
*argv
, jsval
*vp
,
1134 static nsresult
SetupProtoChain(nsIXPConnectWrappedNative
*wrapper
,
1135 JSContext
*cx
, JSObject
*obj
);
1137 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
1139 return new nsHTMLPluginObjElementSH(aData
);
1144 // HTMLOptionsCollection helper
1146 class nsHTMLOptionsCollectionSH
: public nsHTMLCollectionSH
1149 nsHTMLOptionsCollectionSH(nsDOMClassInfoData
* aData
)
1150 : nsHTMLCollectionSH(aData
)
1154 virtual ~nsHTMLOptionsCollectionSH()
1159 NS_IMETHOD
SetProperty(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
1160 JSObject
*obj
, jsid id
, jsval
*vp
, PRBool
*_retval
);
1162 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
1164 return new nsHTMLOptionsCollectionSH(aData
);
1171 class nsPluginSH
: public nsNamedArraySH
1174 nsPluginSH(nsDOMClassInfoData
* aData
) : nsNamedArraySH(aData
)
1178 virtual ~nsPluginSH()
1182 virtual nsISupports
* GetItemAt(nsISupports
*aNative
, PRUint32 aIndex
,
1183 nsWrapperCache
**aCache
, nsresult
*aResult
);
1185 // Override nsNamedArraySH::GetNamedItem()
1186 virtual nsISupports
* GetNamedItem(nsISupports
*aNative
,
1187 const nsAString
& aName
,
1188 nsWrapperCache
**cache
,
1192 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
1194 return new nsPluginSH(aData
);
1199 // PluginArray helper
1201 class nsPluginArraySH
: public nsNamedArraySH
1204 nsPluginArraySH(nsDOMClassInfoData
* aData
) : nsNamedArraySH(aData
)
1208 virtual ~nsPluginArraySH()
1212 virtual nsISupports
* GetItemAt(nsISupports
*aNative
, PRUint32 aIndex
,
1213 nsWrapperCache
**aCache
, nsresult
*aResult
);
1215 // Override nsNamedArraySH::GetNamedItem()
1216 virtual nsISupports
* GetNamedItem(nsISupports
*aNative
,
1217 const nsAString
& aName
,
1218 nsWrapperCache
**cache
,
1222 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
1224 return new nsPluginArraySH(aData
);
1229 // MimeTypeArray helper
1231 class nsMimeTypeArraySH
: public nsNamedArraySH
1234 nsMimeTypeArraySH(nsDOMClassInfoData
* aData
) : nsNamedArraySH(aData
)
1238 virtual ~nsMimeTypeArraySH()
1242 virtual nsISupports
* GetItemAt(nsISupports
*aNative
, PRUint32 aIndex
,
1243 nsWrapperCache
**aCache
, nsresult
*aResult
);
1245 // Override nsNamedArraySH::GetNamedItem()
1246 virtual nsISupports
* GetNamedItem(nsISupports
*aNative
,
1247 const nsAString
& aName
,
1248 nsWrapperCache
**cache
,
1252 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
1254 return new nsMimeTypeArraySH(aData
);
1259 // String array helper
1261 class nsStringArraySH
: public nsGenericArraySH
1264 nsStringArraySH(nsDOMClassInfoData
* aData
) : nsGenericArraySH(aData
)
1268 virtual ~nsStringArraySH()
1272 virtual nsresult
GetStringAt(nsISupports
*aNative
, PRInt32 aIndex
,
1273 nsAString
& aResult
) = 0;
1276 NS_IMETHOD
GetProperty(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
1277 JSObject
*obj
, jsid id
, jsval
*vp
, PRBool
*_retval
);
1283 class nsHistorySH
: public nsStringArraySH
1286 nsHistorySH(nsDOMClassInfoData
* aData
) : nsStringArraySH(aData
)
1290 virtual ~nsHistorySH()
1294 virtual nsresult
GetStringAt(nsISupports
*aNative
, PRInt32 aIndex
,
1295 nsAString
& aResult
);
1298 NS_IMETHOD
PreCreate(nsISupports
*nativeObj
, JSContext
*cx
,
1299 JSObject
*globalObj
, JSObject
**parentObj
);
1300 NS_IMETHOD
GetProperty(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
1301 JSObject
*obj
, jsid id
, jsval
*vp
, PRBool
*_retval
);
1303 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
1305 return new nsHistorySH(aData
);
1309 // StringList scriptable helper
1311 class nsStringListSH
: public nsStringArraySH
1314 nsStringListSH(nsDOMClassInfoData
* aData
) : nsStringArraySH(aData
)
1318 virtual ~nsStringListSH()
1322 virtual nsresult
GetStringAt(nsISupports
*aNative
, PRInt32 aIndex
,
1323 nsAString
& aResult
);
1326 // Inherit GetProperty, Enumerate from nsStringArraySH
1328 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
1330 return new nsStringListSH(aData
);
1335 // DOMTokenList scriptable helper
1337 class nsDOMTokenListSH
: public nsStringArraySH
1340 nsDOMTokenListSH(nsDOMClassInfoData
* aData
) : nsStringArraySH(aData
)
1344 virtual ~nsDOMTokenListSH()
1348 virtual nsresult
GetStringAt(nsISupports
*aNative
, PRInt32 aIndex
,
1349 nsAString
& aResult
);
1353 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
1355 return new nsDOMTokenListSH(aData
);
1362 class nsMediaListSH
: public nsStringArraySH
1365 nsMediaListSH(nsDOMClassInfoData
* aData
) : nsStringArraySH(aData
)
1369 virtual ~nsMediaListSH()
1373 virtual nsresult
GetStringAt(nsISupports
*aNative
, PRInt32 aIndex
,
1374 nsAString
& aResult
);
1377 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
1379 return new nsMediaListSH(aData
);
1384 // StyleSheetList helper
1386 class nsStyleSheetListSH
: public nsArraySH
1389 nsStyleSheetListSH(nsDOMClassInfoData
* aData
) : nsArraySH(aData
)
1393 virtual ~nsStyleSheetListSH()
1397 virtual nsISupports
* GetItemAt(nsISupports
*aNative
, PRUint32 aIndex
,
1398 nsWrapperCache
**aCache
, nsresult
*aResult
);
1401 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
1403 return new nsStyleSheetListSH(aData
);
1408 // CSSValueList helper
1410 class nsCSSValueListSH
: public nsArraySH
1413 nsCSSValueListSH(nsDOMClassInfoData
* aData
) : nsArraySH(aData
)
1417 virtual ~nsCSSValueListSH()
1421 virtual nsISupports
* GetItemAt(nsISupports
*aNative
, PRUint32 aIndex
,
1422 nsWrapperCache
**aCache
, nsresult
*aResult
);
1425 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
1427 return new nsCSSValueListSH(aData
);
1432 // CSSStyleDeclaration helper
1434 class nsCSSStyleDeclSH
: public nsStringArraySH
1437 nsCSSStyleDeclSH(nsDOMClassInfoData
* aData
) : nsStringArraySH(aData
)
1441 virtual ~nsCSSStyleDeclSH()
1445 virtual nsresult
GetStringAt(nsISupports
*aNative
, PRInt32 aIndex
,
1446 nsAString
& aResult
);
1449 NS_IMETHOD
PreCreate(nsISupports
*nativeObj
, JSContext
*cx
,
1450 JSObject
*globalObj
, JSObject
**parentObj
);
1452 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
1454 return new nsCSSStyleDeclSH(aData
);
1459 // CSSRuleList helper
1461 class nsCSSRuleListSH
: public nsArraySH
1464 nsCSSRuleListSH(nsDOMClassInfoData
* aData
) : nsArraySH(aData
)
1468 virtual ~nsCSSRuleListSH()
1472 virtual nsISupports
* GetItemAt(nsISupports
*aNative
, PRUint32 aIndex
,
1473 nsWrapperCache
**aCache
, nsresult
*aResult
);
1476 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
1478 return new nsCSSRuleListSH(aData
);
1482 // ClientRectList helper
1484 class nsClientRectListSH
: public nsArraySH
1487 nsClientRectListSH(nsDOMClassInfoData
* aData
) : nsArraySH(aData
)
1491 virtual ~nsClientRectListSH()
1495 virtual nsISupports
* GetItemAt(nsISupports
*aNative
, PRUint32 aIndex
,
1496 nsWrapperCache
**aCache
, nsresult
*aResult
);
1499 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
1501 return new nsClientRectListSH(aData
);
1506 // PaintRequestList helper
1508 class nsPaintRequestListSH
: public nsArraySH
1511 nsPaintRequestListSH(nsDOMClassInfoData
* aData
) : nsArraySH(aData
)
1515 virtual ~nsPaintRequestListSH()
1519 virtual nsISupports
* GetItemAt(nsISupports
*aNative
, PRUint32 aIndex
,
1520 nsWrapperCache
**aCache
, nsresult
*aResult
);
1523 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
1525 return new nsPaintRequestListSH(aData
);
1531 // TreeColumns helper
1533 class nsTreeColumnsSH
: public nsNamedArraySH
1536 nsTreeColumnsSH(nsDOMClassInfoData
* aData
) : nsNamedArraySH(aData
)
1540 virtual ~nsTreeColumnsSH()
1544 virtual nsISupports
* GetItemAt(nsISupports
*aNative
, PRUint32 aIndex
,
1545 nsWrapperCache
**aCache
, nsresult
*aResult
);
1547 // Override nsNamedArraySH::GetNamedItem()
1548 virtual nsISupports
* GetNamedItem(nsISupports
*aNative
,
1549 const nsAString
& aName
,
1550 nsWrapperCache
**cache
,
1554 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
1556 return new nsTreeColumnsSH(aData
);
1561 // WebApps Storage helpers
1563 class nsStorageSH
: public nsNamedArraySH
1566 nsStorageSH(nsDOMClassInfoData
* aData
) : nsNamedArraySH(aData
)
1570 virtual ~nsStorageSH()
1574 NS_IMETHOD
NewResolve(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
1575 JSObject
*obj
, jsid id
, PRUint32 flags
,
1576 JSObject
**objp
, PRBool
*_retval
);
1577 NS_IMETHOD
SetProperty(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
1578 JSObject
*obj
, jsid id
, jsval
*vp
, PRBool
*_retval
);
1579 NS_IMETHOD
DelProperty(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
1580 JSObject
*obj
, jsid id
, jsval
*vp
, PRBool
*_retval
);
1581 NS_IMETHOD
NewEnumerate(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
1582 JSObject
*obj
, PRUint32 enum_op
, jsval
*statep
,
1583 jsid
*idp
, PRBool
*_retval
);
1585 virtual nsISupports
* GetItemAt(nsISupports
*aNative
, PRUint32 aIndex
,
1586 nsWrapperCache
**aCache
, nsresult
*aResult
)
1590 // Override nsNamedArraySH::GetNamedItem()
1591 virtual nsISupports
* GetNamedItem(nsISupports
*aNative
,
1592 const nsAString
& aName
,
1593 nsWrapperCache
**cache
,
1597 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
1599 return new nsStorageSH(aData
);
1604 class nsStorage2SH
: public nsDOMGenericSH
1607 nsStorage2SH(nsDOMClassInfoData
* aData
) : nsDOMGenericSH(aData
)
1611 virtual ~nsStorage2SH()
1615 NS_IMETHOD
NewResolve(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
1616 JSObject
*obj
, jsid id
, PRUint32 flags
,
1617 JSObject
**objp
, PRBool
*_retval
);
1618 NS_IMETHOD
SetProperty(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
1619 JSObject
*obj
, jsid id
, jsval
*vp
, PRBool
*_retval
);
1620 NS_IMETHOD
GetProperty(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
1621 JSObject
*obj
, jsid id
, jsval
*vp
, PRBool
*_retval
);
1622 NS_IMETHOD
DelProperty(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
1623 JSObject
*obj
, jsid id
, jsval
*vp
, PRBool
*_retval
);
1624 NS_IMETHOD
NewEnumerate(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
1625 JSObject
*obj
, PRUint32 enum_op
, jsval
*statep
,
1626 jsid
*idp
, PRBool
*_retval
);
1629 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
1631 return new nsStorage2SH(aData
);
1635 class nsStorageListSH
: public nsNamedArraySH
1638 nsStorageListSH(nsDOMClassInfoData
* aData
) : nsNamedArraySH(aData
)
1642 virtual ~nsStorageListSH()
1646 virtual nsISupports
* GetItemAt(nsISupports
*aNative
, PRUint32 aIndex
,
1647 nsWrapperCache
**aCache
, nsresult
*aResult
)
1651 // Override nsNamedArraySH::GetNamedItem()
1652 virtual nsISupports
* GetNamedItem(nsISupports
*aNative
,
1653 const nsAString
& aName
,
1654 nsWrapperCache
**cache
,
1658 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
1660 return new nsStorageListSH(aData
);
1665 // Event handler 'this' translator class, this is called by XPConnect
1666 // when a "function interface" (nsIDOMEventListener) is called, this
1667 // class extracts 'this' fomr the first argument to the called
1668 // function (nsIDOMEventListener::HandleEvent(in nsIDOMEvent)), this
1669 // class will pass back nsIDOMEvent::currentTarget to be used as
1672 class nsEventListenerThisTranslator
: public nsIXPCFunctionThisTranslator
1675 nsEventListenerThisTranslator()
1679 virtual ~nsEventListenerThisTranslator()
1686 // nsIXPCFunctionThisTranslator
1687 NS_DECL_NSIXPCFUNCTIONTHISTRANSLATOR
1690 class nsDOMConstructorSH
: public nsDOMGenericSH
1693 nsDOMConstructorSH(nsDOMClassInfoData
* aData
) : nsDOMGenericSH(aData
)
1698 NS_IMETHOD
PreCreate(nsISupports
*nativeObj
, JSContext
*cx
,
1699 JSObject
*globalObj
, JSObject
**parentObj
);
1700 NS_IMETHOD
PostCreatePrototype(JSContext
* cx
, JSObject
* proto
)
1704 NS_IMETHOD
Call(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
1705 JSObject
*obj
, PRUint32 argc
, jsval
*argv
, jsval
*vp
,
1708 NS_IMETHOD
Construct(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
1709 JSObject
*obj
, PRUint32 argc
, jsval
*argv
,
1710 jsval
*vp
, PRBool
*_retval
);
1712 NS_IMETHOD
HasInstance(nsIXPConnectWrappedNative
*wrapper
, JSContext
*cx
,
1713 JSObject
*obj
, const jsval
&val
, PRBool
*bp
,
1716 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
1718 return new nsDOMConstructorSH(aData
);
1722 class nsNonDOMObjectSH
: public nsDOMGenericSH
1725 nsNonDOMObjectSH(nsDOMClassInfoData
* aData
) : nsDOMGenericSH(aData
)
1729 virtual ~nsNonDOMObjectSH()
1734 NS_IMETHOD
GetFlags(PRUint32
*aFlags
);
1736 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
1738 return new nsNonDOMObjectSH(aData
);
1742 // Need this to override GetFlags() on nsNodeSH
1743 class nsAttributeSH
: public nsNodeSH
1746 nsAttributeSH(nsDOMClassInfoData
* aData
) : nsNodeSH(aData
)
1750 virtual ~nsAttributeSH()
1755 NS_IMETHOD
GetFlags(PRUint32
*aFlags
);
1757 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
1759 return new nsAttributeSH(aData
);
1763 class nsOfflineResourceListSH
: public nsStringArraySH
1766 nsOfflineResourceListSH(nsDOMClassInfoData
* aData
) : nsStringArraySH(aData
)
1770 virtual ~nsOfflineResourceListSH()
1774 virtual nsresult
GetStringAt(nsISupports
*aNative
, PRInt32 aIndex
,
1775 nsAString
& aResult
);
1778 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
1780 return new nsOfflineResourceListSH(aData
);
1784 class nsFileListSH
: public nsArraySH
1787 nsFileListSH(nsDOMClassInfoData
*aData
) : nsArraySH(aData
)
1791 virtual ~nsFileListSH()
1795 virtual nsISupports
* GetItemAt(nsISupports
*aNative
, PRUint32 aIndex
,
1796 nsWrapperCache
**aCache
, nsresult
*aResult
);
1799 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
1801 return new nsFileListSH(aData
);
1805 class nsWebGLViewportHandlerSH
: public nsDOMGenericSH
1808 nsWebGLViewportHandlerSH(nsDOMClassInfoData
*aData
) : nsDOMGenericSH(aData
)
1812 virtual ~nsWebGLViewportHandlerSH()
1817 NS_IMETHOD
PostCreatePrototype(JSContext
* cx
, JSObject
* proto
) {
1818 nsresult rv
= nsDOMGenericSH::PostCreatePrototype(cx
, proto
);
1819 if (NS_SUCCEEDED(rv
)) {
1820 if (!::JS_DefineProperty(cx
, proto
, "VIEWPORT", INT_TO_JSVAL(0x0BA2),
1821 nsnull
, nsnull
, JSPROP_ENUMERATE
))
1823 return NS_ERROR_UNEXPECTED
;
1829 static nsIClassInfo
*doCreate(nsDOMClassInfoData
* aData
)
1831 return new nsWebGLViewportHandlerSH(aData
);
1835 #endif /* nsDOMClassInfo_h___ */