Back to index

lightning-sunbird  0.9+nobinonly
nsDOMClassInfo.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* vim: set ts=2 sw=2 et tw=80: */
00003 /* ***** BEGIN LICENSE BLOCK *****
00004  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00005  *
00006  * The contents of this file are subject to the Mozilla Public License Version
00007  * 1.1 (the "License"); you may not use this file except in compliance with
00008  * the License. You may obtain a copy of the License at
00009  * http://www.mozilla.org/MPL/
00010  *
00011  * Software distributed under the License is distributed on an "AS IS" basis,
00012  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013  * for the specific language governing rights and limitations under the
00014  * License.
00015  *
00016  * The Original Code is mozilla.org code.
00017  *
00018  * The Initial Developer of the Original Code is
00019  * Netscape Communications Corporation.
00020  * Portions created by the Initial Developer are Copyright (C) 2000
00021  * the Initial Developer. All Rights Reserved.
00022  *
00023  * Contributor(s):
00024  *   Johnny Stenback <jst@netscape.com> (original author)
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * either of the GNU General Public License Version 2 or later (the "GPL"),
00028  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00029  * in which case the provisions of the GPL or the LGPL are applicable instead
00030  * of those above. If you wish to allow use of your version of this file only
00031  * under the terms of either the GPL or the LGPL, and not to allow others to
00032  * use your version of this file under the terms of the MPL, indicate your
00033  * decision by deleting the provisions above and replace them with the notice
00034  * and other provisions required by the GPL or the LGPL. If you do not delete
00035  * the provisions above, a recipient may use your version of this file under
00036  * the terms of any one of the MPL, the GPL or the LGPL.
00037  *
00038  * ***** END LICENSE BLOCK ***** */
00039 
00040 #ifndef nsDOMClassInfo_h___
00041 #define nsDOMClassInfo_h___
00042 
00043 #include "nsIDOMClassInfo.h"
00044 #include "nsIXPCScriptable.h"
00045 #include "jsapi.h"
00046 #include "nsIScriptSecurityManager.h"
00047 #include "nsIScriptContext.h"
00048 
00049 class nsIDOMWindow;
00050 class nsIDOMNSHTMLOptionCollection;
00051 class nsIPluginInstance;
00052 class nsIForm;
00053 class nsIDOMNode;
00054 class nsIDOMNodeList;
00055 class nsIDOMDocument;
00056 class nsIDOMGCParticipant;
00057 class nsIHTMLDocument;
00058 class nsGlobalWindow;
00059 
00060 struct nsDOMClassInfoData;
00061 
00062 typedef nsIClassInfo* (*nsDOMClassInfoConstructorFnc)
00063   (nsDOMClassInfoData* aData);
00064 
00065 
00066 struct nsDOMClassInfoData
00067 {
00068   const char *mName;
00069   union {
00070     nsDOMClassInfoConstructorFnc mConstructorFptr;
00071     nsDOMClassInfoExternalConstructorFnc mExternalConstructorFptr;
00072   } u;
00073 
00074   nsIClassInfo *mCachedClassInfo; // low bit is set to 1 if external,
00075                                   // so be sure to mask if necessary!
00076   const nsIID *mProtoChainInterface;
00077   const nsIID **mInterfaces;
00078   PRUint32 mScriptableFlags : 31; // flags must not use more than 31 bits!
00079   PRBool mHasClassInterface : 1;
00080 #ifdef NS_DEBUG
00081   PRUint32 mDebugID;
00082 #endif
00083 };
00084 
00085 struct nsExternalDOMClassInfoData : public nsDOMClassInfoData
00086 {
00087   const nsCID *mConstructorCID;
00088 };
00089 
00090 
00091 typedef unsigned long PtrBits;
00092 
00093 // To be used with the nsDOMClassInfoData::mCachedClassInfo pointer.
00094 // The low bit is set when we created a generic helper for an external
00095 // (which holds on to the nsDOMClassInfoData).
00096 #define GET_CLEAN_CI_PTR(_ptr) (nsIClassInfo*)(PtrBits(_ptr) & ~0x1)
00097 #define MARK_EXTERNAL(_ptr) (nsIClassInfo*)(PtrBits(_ptr) | 0x1)
00098 #define IS_EXTERNAL(_ptr) (PtrBits(_ptr) & 0x1)
00099 
00100 
00101 class nsDOMClassInfo : public nsIXPCScriptable,
00102                        public nsIClassInfo
00103 {
00104 public:
00105   nsDOMClassInfo(nsDOMClassInfoData* aData);
00106   virtual ~nsDOMClassInfo();
00107 
00108   NS_DECL_NSIXPCSCRIPTABLE
00109 
00110   NS_DECL_ISUPPORTS
00111 
00112   NS_DECL_NSICLASSINFO
00113 
00114   // Helper method that returns a *non* refcounted pointer to a
00115   // helper. So please note, don't release this pointer, if you do,
00116   // you better make sure you've addreffed before release.
00117   //
00118   // Whaaaaa! I wanted to name this method GetClassInfo, but nooo,
00119   // some of Microsoft devstudio's headers #defines GetClassInfo to
00120   // GetClassInfoA so I can't, those $%#@^! bastards!!! What gives
00121   // them the right to do that?
00122 
00123   static nsIClassInfo* GetClassInfoInstance(nsDOMClassInfoID aID);
00124   static nsIClassInfo* GetClassInfoInstance(nsDOMClassInfoData* aData);
00125 
00126   static void ShutDown();
00127 
00128   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
00129   {
00130     return new nsDOMClassInfo(aData);
00131   }
00132 
00133   static nsresult WrapNative(JSContext *cx, JSObject *scope,
00134                              nsISupports *native, const nsIID& aIID,
00135                              jsval *vp,
00136                              // aHolder keeps the jsval alive while
00137                              // there's a ref to it
00138                              nsIXPConnectJSObjectHolder** aHolder);
00139   static nsresult ThrowJSException(JSContext *cx, nsresult aResult);
00140 
00141   static nsresult InitDOMJSClass(JSContext *cx, JSObject *obj);
00142 
00143   static JSClass sDOMJSClass;
00144 
00148   static const JSClass* GetXPCNativeWrapperClass() {
00149     return sXPCNativeWrapperClass;
00150   }
00151   
00155   static void SetXPCNativeWrapperClass(JSClass* aClass) {
00156     NS_ASSERTION(!sXPCNativeWrapperClass,
00157                  "Double set of sXPCNativeWrapperClass");
00158     sXPCNativeWrapperClass = aClass;
00159   }
00160 
00161   static PRBool ObjectIsNativeWrapper(JSContext* cx, JSObject* obj)
00162   {
00163 #ifdef DEBUG
00164     {
00165       nsIScriptContext *scx = GetScriptContextFromJSContext(cx);
00166 
00167       NS_PRECONDITION(!scx || !scx->IsContextInitialized() ||
00168                       sXPCNativeWrapperClass,
00169                       "Must know what the XPCNativeWrapper class is!");
00170     }
00171 #endif
00172 
00173     return sXPCNativeWrapperClass &&
00174       ::JS_GetClass(cx, obj) == sXPCNativeWrapperClass;
00175   }
00176 
00192   static nsresult PreserveWrapper(void* aKey,
00193                                   nsIXPConnectJSObjectHolder* (*aKeyToWrapperFunc)(void* aKey),
00194                                   nsIDOMGCParticipant *aParticipant,
00195                                   PRBool aRootWhenExternallyReferenced);
00196 
00197 
00206   static nsresult PreserveNodeWrapper(nsIXPConnectWrappedNative *aWrapper,
00207                                       PRBool aRootWhenExternallyReferenced =
00208                                         PR_FALSE);
00209 
00214   static void ReleaseWrapper(void* aKey);
00215 
00219   static void MarkReachablePreservedWrappers(nsIDOMGCParticipant *aParticipant,
00220                                              JSContext *cx, void *arg);
00221 
00244   static nsresult SetExternallyReferenced(nsIDOMGCParticipant *aParticipant);
00245   static void UnsetExternallyReferenced(nsIDOMGCParticipant *aParticipant);
00246 
00251   static PRBool BeginGCMark(JSContext *cx);
00252 
00257   static void EndGCMark();
00258 
00259 protected:
00260   const nsDOMClassInfoData* mData;
00261 
00262   static nsresult Init();
00263   static nsresult RegisterClassName(PRInt32 aDOMClassInfoID);
00264   static nsresult RegisterClassProtos(PRInt32 aDOMClassInfoID);
00265   static nsresult RegisterExternalClasses();
00266   nsresult ResolveConstructor(JSContext *cx, JSObject *obj,
00267                               JSObject **objp);
00268 
00269   // Checks if id is a number and returns the number, if aIsNumber is
00270   // non-null it's set to true if the id is a number and false if it's
00271   // not a number. If id is not a number this method returns -1
00272   static PRInt32 GetArrayIndexFromId(JSContext *cx, jsval id,
00273                                      PRBool *aIsNumber = nsnull);
00274 
00275   static inline PRBool IsReadonlyReplaceable(jsval id)
00276   {
00277     return (id == sTop_id          ||
00278             id == sParent_id       ||
00279             id == sScrollbars_id   ||
00280             id == sContent_id      ||
00281             id == sMenubar_id      ||
00282             id == sToolbar_id      ||
00283             id == sLocationbar_id  ||
00284             id == sPersonalbar_id  ||
00285             id == sStatusbar_id    ||
00286             id == sDirectories_id  ||
00287             id == sControllers_id  ||
00288             id == sScrollX_id      ||
00289             id == sScrollY_id      ||
00290             id == sScrollMaxX_id   ||
00291             id == sScrollMaxY_id   ||
00292             id == sLength_id       ||
00293             id == sFrames_id       ||
00294             id == sSelf_id);
00295   }
00296 
00297   static inline PRBool IsWritableReplaceable(jsval id)
00298   {
00299     return (id == sInnerHeight_id  ||
00300             id == sInnerWidth_id   ||
00301             id == sOpener_id       ||
00302             id == sOuterHeight_id  ||
00303             id == sOuterWidth_id   ||
00304             id == sScreenX_id      ||
00305             id == sScreenY_id      ||
00306             id == sStatus_id       ||
00307             id == sName_id);
00308   }
00309 
00310   nsresult doCheckPropertyAccess(JSContext *cx, JSObject *obj, jsval id,
00311                                  nsIXPConnectWrappedNative *wrapper,
00312                                  PRUint32 accessMode, PRBool isWindow);
00313 
00314   static JSClass sDOMConstructorProtoClass;
00315   static JSFunctionSpec sDOMJSClass_methods[];
00316 
00317   static nsIXPConnect *sXPConnect;
00318   static nsIScriptSecurityManager *sSecMan;
00319 
00320   // nsIXPCScriptable code
00321   static nsresult DefineStaticJSVals(JSContext *cx);
00322 
00323   static PRBool sIsInitialized;
00324   static PRBool sDisableDocumentAllSupport;
00325   static PRBool sDisableGlobalScopePollutionSupport;
00326 
00327   static jsval sTop_id;
00328   static jsval sParent_id;
00329   static jsval sScrollbars_id;
00330   static jsval sLocation_id;
00331   static jsval sComponents_id;
00332   static jsval sConstructor_id;
00333   static jsval s_content_id;
00334   static jsval sContent_id;
00335   static jsval sMenubar_id;
00336   static jsval sToolbar_id;
00337   static jsval sLocationbar_id;
00338   static jsval sPersonalbar_id;
00339   static jsval sStatusbar_id;
00340   static jsval sDirectories_id;
00341   static jsval sControllers_id;
00342   static jsval sLength_id;
00343   static jsval sInnerHeight_id;
00344   static jsval sInnerWidth_id;
00345   static jsval sOuterHeight_id;
00346   static jsval sOuterWidth_id;
00347   static jsval sScreenX_id;
00348   static jsval sScreenY_id;
00349   static jsval sStatus_id;
00350   static jsval sName_id;
00351   static jsval sOnmousedown_id;
00352   static jsval sOnmouseup_id;
00353   static jsval sOnclick_id;
00354   static jsval sOndblclick_id;
00355   static jsval sOncontextmenu_id;
00356   static jsval sOnmouseover_id;
00357   static jsval sOnmouseout_id;
00358   static jsval sOnkeydown_id;
00359   static jsval sOnkeyup_id;
00360   static jsval sOnkeypress_id;
00361   static jsval sOnmousemove_id;
00362   static jsval sOnfocus_id;
00363   static jsval sOnblur_id;
00364   static jsval sOnsubmit_id;
00365   static jsval sOnreset_id;
00366   static jsval sOnchange_id;
00367   static jsval sOnselect_id;
00368   static jsval sOnload_id;
00369   static jsval sOnbeforeunload_id;
00370   static jsval sOnunload_id;
00371   static jsval sOnpageshow_id;
00372   static jsval sOnpagehide_id;
00373   static jsval sOnabort_id;
00374   static jsval sOnerror_id;
00375   static jsval sOnpaint_id;
00376   static jsval sOnresize_id;
00377   static jsval sOnscroll_id;
00378   static jsval sScrollIntoView_id;
00379   static jsval sScrollX_id;
00380   static jsval sScrollY_id;
00381   static jsval sScrollMaxX_id;
00382   static jsval sScrollMaxY_id;
00383   static jsval sOpen_id;
00384   static jsval sItem_id;
00385   static jsval sNamedItem_id;
00386   static jsval sEnumerate_id;
00387   static jsval sNavigator_id;
00388   static jsval sDocument_id;
00389   static jsval sWindow_id;
00390   static jsval sFrames_id;
00391   static jsval sSelf_id;
00392   static jsval sOpener_id;
00393   static jsval sAdd_id;
00394   static jsval sAll_id;
00395   static jsval sTags_id;
00396   static jsval sAddEventListener_id;
00397 
00398   static const JSClass *sObjectClass;
00399   static const JSClass *sXPCNativeWrapperClass;
00400 
00401 public:
00402   static PRBool sDoSecurityCheckInAddProperty;
00403 };
00404 
00405 typedef nsDOMClassInfo nsDOMGenericSH;
00406 
00407 // Scriptable helper for implementations of nsIDOMGCParticipant that
00408 // need a mark callback.
00409 class nsDOMGCParticipantSH : public nsDOMGenericSH
00410 {
00411 protected:
00412   nsDOMGCParticipantSH(nsDOMClassInfoData* aData) : nsDOMGenericSH(aData)
00413   {
00414   }
00415 
00416   virtual ~nsDOMGCParticipantSH()
00417   {
00418   }
00419 
00420 public:
00421   NS_IMETHOD Finalize(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
00422                       JSObject *obj);
00423   NS_IMETHOD Mark(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
00424                   JSObject *obj, void *arg, PRUint32 *_retval);
00425 
00426   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
00427   {
00428     return new nsDOMGCParticipantSH(aData);
00429   }
00430 };
00431 
00432 // EventProp scriptable helper, this class should be the base class of
00433 // all objects that should support things like
00434 // obj.onclick=function{...}
00435 
00436 class nsEventReceiverSH : public nsDOMGCParticipantSH
00437 {
00438 protected:
00439   nsEventReceiverSH(nsDOMClassInfoData* aData) : nsDOMGCParticipantSH(aData)
00440   {
00441   }
00442 
00443   virtual ~nsEventReceiverSH()
00444   {
00445   }
00446 
00447   static PRBool ReallyIsEventName(jsval id, jschar aFirstChar);
00448 
00449   static inline PRBool IsEventName(jsval id)
00450   {
00451     NS_ASSERTION(JSVAL_IS_STRING(id), "Don't pass non-string jsval's here!");
00452 
00453     jschar *str = ::JS_GetStringChars(JSVAL_TO_STRING(id));
00454 
00455     if (str[0] == 'o' && str[1] == 'n') {
00456       return ReallyIsEventName(id, str[2]);
00457     }
00458 
00459     return PR_FALSE;
00460   }
00461 
00462   static JSBool JS_DLL_CALLBACK AddEventListenerHelper(JSContext *cx,
00463                                                        JSObject *obj,
00464                                                        uintN argc, jsval *argv,
00465                                                        jsval *rval);
00466 
00467   nsresult RegisterCompileHandler(nsIXPConnectWrappedNative *wrapper,
00468                                   JSContext *cx, JSObject *obj, jsval id,
00469                                   PRBool compile, PRBool remove,
00470                                   PRBool *did_define);
00471 
00472 public:
00473   NS_IMETHOD NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
00474                         JSObject *obj, jsval id, PRUint32 flags,
00475                         JSObject **objp, PRBool *_retval);
00476   NS_IMETHOD SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
00477                          JSObject *obj, jsval id, jsval *vp,
00478                          PRBool *_retval);
00479   NS_IMETHOD AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
00480                          JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
00481 };
00482 
00483 
00484 // Window scriptable helper
00485 
00486 class nsWindowSH : public nsEventReceiverSH
00487 {
00488 protected:
00489   nsWindowSH(nsDOMClassInfoData* aData) : nsEventReceiverSH(aData)
00490   {
00491   }
00492 
00493   virtual ~nsWindowSH()
00494   {
00495   }
00496 
00497   static nsresult GlobalResolve(nsGlobalWindow *aWin, JSContext *cx,
00498                                 JSObject *obj, JSString *str, PRUint32 flags,
00499                                 PRBool *did_resolve);
00500 
00501 public:
00502   NS_IMETHOD PreCreate(nsISupports *nativeObj, JSContext *cx,
00503                        JSObject *globalObj, JSObject **parentObj);
00504   NS_IMETHOD GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
00505                          JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
00506   NS_IMETHOD SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
00507                          JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
00508   NS_IMETHOD AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
00509                          JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
00510   NS_IMETHOD DelProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
00511                          JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
00512   NS_IMETHOD NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
00513                         JSObject *obj, jsval id, PRUint32 flags,
00514                         JSObject **objp, PRBool *_retval);
00515   NS_IMETHOD NewEnumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
00516                           JSObject *obj, PRUint32 enum_op, jsval *statep,
00517                           jsid *idp, PRBool *_retval);
00518   NS_IMETHOD Finalize(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
00519                       JSObject *obj);
00520   NS_IMETHOD Equality(nsIXPConnectWrappedNative *wrapper, JSContext * cx,
00521                       JSObject * obj, jsval val, PRBool *bp);
00522   NS_IMETHOD OuterObject(nsIXPConnectWrappedNative *wrapper, JSContext * cx,
00523                          JSObject * obj, JSObject * *_retval);
00524   NS_IMETHOD InnerObject(nsIXPConnectWrappedNative *wrapper, JSContext * cx,
00525                          JSObject * obj, JSObject * *_retval);
00526 
00527   static JSBool JS_DLL_CALLBACK GlobalScopePolluterNewResolve(JSContext *cx,
00528                                                               JSObject *obj,
00529                                                               jsval id,
00530                                                               uintN flags,
00531                                                               JSObject **objp);
00532   static JSBool JS_DLL_CALLBACK GlobalScopePolluterGetProperty(JSContext *cx,
00533                                                                JSObject *obj,
00534                                                                jsval id,
00535                                                                jsval *vp);
00536   static JSBool JS_DLL_CALLBACK SecurityCheckOnSetProp(JSContext *cx,
00537                                                        JSObject *obj, jsval id,
00538                                                        jsval *vp);
00539   static void InvalidateGlobalScopePolluter(JSContext *cx, JSObject *obj);
00540   static nsresult InstallGlobalScopePolluter(JSContext *cx, JSObject *obj,
00541                                              nsIHTMLDocument *doc);
00542 
00543   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
00544   {
00545     return new nsWindowSH(aData);
00546   }
00547 };
00548 
00549 
00550 // Location scriptable helper
00551 
00552 class nsLocationSH : public nsDOMGenericSH
00553 {
00554 protected:
00555   nsLocationSH(nsDOMClassInfoData* aData) : nsDOMGenericSH(aData)
00556   {
00557   }
00558 
00559   virtual ~nsLocationSH()
00560   {
00561   }
00562 
00563 public:
00564   NS_IMETHOD CheckAccess(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
00565                          JSObject *obj, jsval id, PRUint32 mode,
00566                          jsval *vp, PRBool *_retval);
00567 
00568   NS_IMETHOD PreCreate(nsISupports *nativeObj, JSContext *cx,
00569                        JSObject *globalObj, JSObject **parentObj);
00570 
00571   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
00572   {
00573     return new nsLocationSH(aData);
00574   }
00575 };
00576 
00577 
00578 // Navigator scriptable helper
00579 
00580 class nsNavigatorSH : public nsDOMGenericSH
00581 {
00582 protected:
00583   nsNavigatorSH(nsDOMClassInfoData* aData) : nsDOMGenericSH(aData)
00584   {
00585   }
00586 
00587   virtual ~nsNavigatorSH()
00588   {
00589   }
00590 
00591 public:
00592   NS_IMETHOD PreCreate(nsISupports *nativeObj, JSContext *cx,
00593                        JSObject *globalObj, JSObject **parentObj);
00594 
00595   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
00596   {
00597     return new nsNavigatorSH(aData);
00598   }
00599 };
00600 
00601 
00602 // DOM Node helper, this class deals with setting the parent for the
00603 // wrappers
00604 
00605 class nsNodeSH : public nsEventReceiverSH
00606 {
00607 protected:
00608   nsNodeSH(nsDOMClassInfoData* aData) : nsEventReceiverSH(aData)
00609   {
00610   }
00611 
00612   virtual ~nsNodeSH()
00613   {
00614   }
00615 
00616 public:
00617   NS_IMETHOD PreCreate(nsISupports *nativeObj, JSContext *cx,
00618                        JSObject *globalObj, JSObject **parentObj);
00619   NS_IMETHOD AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
00620                          JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
00621   NS_IMETHOD GetFlags(PRUint32 *aFlags);
00622 
00623   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
00624   {
00625     return new nsNodeSH(aData);
00626   }
00627 };
00628 
00629 
00630 // Element helper
00631 
00632 class nsElementSH : public nsNodeSH
00633 {
00634 protected:
00635   nsElementSH(nsDOMClassInfoData* aData) : nsNodeSH(aData)
00636   {
00637   }
00638 
00639   virtual ~nsElementSH()
00640   {
00641   }
00642 
00643 public:
00644   NS_IMETHOD PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
00645                         JSObject *obj);
00646 
00647   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
00648   {
00649     return new nsElementSH(aData);
00650   }
00651 };
00652 
00653 
00654 // Generic array scriptable helper
00655 
00656 class nsGenericArraySH : public nsDOMClassInfo
00657 {
00658 protected:
00659   nsGenericArraySH(nsDOMClassInfoData* aData) : nsDOMClassInfo(aData)
00660   {
00661   }
00662 
00663   virtual ~nsGenericArraySH()
00664   {
00665   }
00666   
00667 public:
00668   NS_IMETHOD NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
00669                         JSObject *obj, jsval id, PRUint32 flags,
00670                         JSObject **objp, PRBool *_retval);
00671   NS_IMETHOD Enumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
00672                        JSObject *obj, PRBool *_retval);
00673   
00674   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
00675   {
00676     return new nsGenericArraySH(aData);
00677   }
00678 };
00679 
00680 
00681 // NodeList scriptable helper
00682 
00683 class nsArraySH : public nsGenericArraySH
00684 {
00685 protected:
00686   nsArraySH(nsDOMClassInfoData* aData) : nsGenericArraySH(aData)
00687   {
00688   }
00689 
00690   virtual ~nsArraySH()
00691   {
00692   }
00693 
00694   virtual nsresult GetItemAt(nsISupports *aNative, PRUint32 aIndex,
00695                              nsISupports **aResult);
00696 
00697 public:
00698   NS_IMETHOD GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
00699                          JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
00700 
00701   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
00702   {
00703     return new nsArraySH(aData);
00704   }
00705 };
00706 
00707 
00708 // NamedArray helper
00709 
00710 class nsNamedArraySH : public nsArraySH
00711 {
00712 protected:
00713   nsNamedArraySH(nsDOMClassInfoData* aData) : nsArraySH(aData)
00714   {
00715   }
00716 
00717   virtual ~nsNamedArraySH()
00718   {
00719   }
00720 
00721   virtual nsresult GetNamedItem(nsISupports *aNative, const nsAString& aName,
00722                                 nsISupports **aResult) = 0;
00723 
00724 public:
00725   NS_IMETHOD GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
00726                          JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
00727 };
00728 
00729 
00730 // NamedNodeMap helper
00731 
00732 class nsNamedNodeMapSH : public nsNamedArraySH
00733 {
00734 protected:
00735   nsNamedNodeMapSH(nsDOMClassInfoData* aData) : nsNamedArraySH(aData)
00736   {
00737   }
00738 
00739   virtual ~nsNamedNodeMapSH()
00740   {
00741   }
00742 
00743   // Override nsArraySH::GetItemAt() since our list isn't a
00744   // nsIDOMNodeList
00745   virtual nsresult GetItemAt(nsISupports *aNative, PRUint32 aIndex,
00746                              nsISupports **aResult);
00747 
00748   // Override nsNamedArraySH::GetNamedItem()
00749   virtual nsresult GetNamedItem(nsISupports *aNative, const nsAString& aName,
00750                                 nsISupports **aResult);
00751 
00752 public:
00753   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
00754   {
00755     return new nsNamedNodeMapSH(aData);
00756   }
00757 };
00758 
00759 
00760 // HTMLCollection helper
00761 
00762 class nsHTMLCollectionSH : public nsNamedArraySH
00763 {
00764 protected:
00765   nsHTMLCollectionSH(nsDOMClassInfoData* aData) : nsNamedArraySH(aData)
00766   {
00767   }
00768 
00769   virtual ~nsHTMLCollectionSH()
00770   {
00771   }
00772 
00773   // Override nsArraySH::GetItemAt() since our list isn't a
00774   // nsIDOMNodeList
00775   virtual nsresult GetItemAt(nsISupports *aNative, PRUint32 aIndex,
00776                              nsISupports **aResult);
00777 
00778   // Override nsNamedArraySH::GetNamedItem()
00779   virtual nsresult GetNamedItem(nsISupports *aNative, const nsAString& aName,
00780                                 nsISupports **aResult);
00781 
00782 public:
00783   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
00784   {
00785     return new nsHTMLCollectionSH(aData);
00786   }
00787 };
00788 
00789 
00790 // ContentList helper
00791 
00792 class nsContentListSH : public nsHTMLCollectionSH
00793 {
00794 protected:
00795   nsContentListSH(nsDOMClassInfoData* aData) : nsHTMLCollectionSH(aData)
00796   {
00797   }
00798 
00799   virtual ~nsContentListSH()
00800   {
00801   }
00802 
00803 public:
00804   NS_IMETHOD PreCreate(nsISupports *nativeObj, JSContext *cx,
00805                        JSObject *globalObj, JSObject **parentObj);
00806 
00807   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
00808   {
00809     return new nsContentListSH(aData);
00810   }
00811 };
00812 
00813 
00814 
00815 // FomrControlList helper
00816 
00817 class nsFormControlListSH : public nsHTMLCollectionSH
00818 {
00819 protected:
00820   nsFormControlListSH(nsDOMClassInfoData* aData) : nsHTMLCollectionSH(aData)
00821   {
00822   }
00823 
00824   virtual ~nsFormControlListSH()
00825   {
00826   }
00827 
00828   // Override nsNamedArraySH::GetNamedItem() since our NamedItem() can
00829   // return either a nsIDOMNode or a nsIHTMLCollection
00830   virtual nsresult GetNamedItem(nsISupports *aNative, const nsAString& aName,
00831                                 nsISupports **aResult);
00832 
00833 public:
00834   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
00835   {
00836     return new nsFormControlListSH(aData);
00837   }
00838 };
00839 
00840 
00841 // Document helper, for document.location and document.on*
00842 
00843 class nsDocumentSH : public nsNodeSH
00844 {
00845 public:
00846   nsDocumentSH(nsDOMClassInfoData* aData) : nsNodeSH(aData)
00847   {
00848   }
00849 
00850   virtual ~nsDocumentSH()
00851   {
00852   }
00853 
00854 public:
00855   NS_IMETHOD AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
00856                          JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
00857   NS_IMETHOD DelProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
00858                          JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
00859   NS_IMETHOD NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
00860                         JSObject *obj, jsval id, PRUint32 flags,
00861                         JSObject **objp, PRBool *_retval);
00862   NS_IMETHOD GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
00863                          JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
00864   NS_IMETHOD SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
00865                          JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
00866   NS_IMETHOD GetFlags(PRUint32* aFlags);
00867   NS_IMETHOD PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
00868                         JSObject *obj);
00869 
00870   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
00871   {
00872     return new nsDocumentSH(aData);
00873   }
00874 };
00875 
00876 
00877 // HTMLDocument helper
00878 
00879 class nsHTMLDocumentSH : public nsDocumentSH
00880 {
00881 protected:
00882   nsHTMLDocumentSH(nsDOMClassInfoData* aData) : nsDocumentSH(aData)
00883   {
00884   }
00885 
00886   virtual ~nsHTMLDocumentSH()
00887   {
00888   }
00889 
00890   static nsresult ResolveImpl(JSContext *cx,
00891                               nsIXPConnectWrappedNative *wrapper, jsval id,
00892                               nsISupports **result);
00893   static JSBool JS_DLL_CALLBACK DocumentOpen(JSContext *cx, JSObject *obj,
00894                                              uintN argc, jsval *argv,
00895                                              jsval *rval);
00896   static JSBool GetDocumentAllNodeList(JSContext *cx, JSObject *obj,
00897                                        nsIDOMDocument *doc,
00898                                        nsIDOMNodeList **nodeList);
00899 
00900 public:
00901   static JSBool JS_DLL_CALLBACK DocumentAllGetProperty(JSContext *cx,
00902                                                        JSObject *obj, jsval id,
00903                                                        jsval *vp);
00904   static JSBool JS_DLL_CALLBACK DocumentAllNewResolve(JSContext *cx,
00905                                                       JSObject *obj, jsval id,
00906                                                       uintN flags,
00907                                                       JSObject **objp);
00908   static void JS_DLL_CALLBACK ReleaseDocument(JSContext *cx, JSObject *obj);
00909   static JSBool JS_DLL_CALLBACK CallToGetPropMapper(JSContext *cx,
00910                                                     JSObject *obj, uintN argc,
00911                                                     jsval *argv, jsval *rval);
00912   static JSBool JS_DLL_CALLBACK DocumentAllHelperGetProperty(JSContext *cx,
00913                                                              JSObject *obj,
00914                                                              jsval id,
00915                                                              jsval *vp);
00916   static JSBool JS_DLL_CALLBACK DocumentAllHelperNewResolve(JSContext *cx,
00917                                                             JSObject *obj,
00918                                                             jsval id,
00919                                                             uintN flags,
00920                                                             JSObject **objp);
00921   static JSBool JS_DLL_CALLBACK DocumentAllTagsNewResolve(JSContext *cx,
00922                                                           JSObject *obj,
00923                                                           jsval id,
00924                                                           uintN flags,
00925                                                           JSObject **objp);
00926 
00927   NS_IMETHOD NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
00928                         JSObject *obj, jsval id, PRUint32 flags,
00929                         JSObject **objp, PRBool *_retval);
00930   NS_IMETHOD GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
00931                          JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
00932 
00933   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
00934   {
00935     return new nsHTMLDocumentSH(aData);
00936   }
00937 };
00938 
00939 
00940 // HTMLElement helper
00941 
00942 class nsHTMLElementSH : public nsElementSH
00943 {
00944 protected:
00945   nsHTMLElementSH(nsDOMClassInfoData* aData) : nsElementSH(aData)
00946   {
00947   }
00948 
00949   virtual ~nsHTMLElementSH()
00950   {
00951   }
00952 
00953   static JSBool JS_DLL_CALLBACK ScrollIntoView(JSContext *cx, JSObject *obj,
00954                                                uintN argc, jsval *argv,
00955                                                jsval *rval);
00956 
00957 public:
00958   NS_IMETHOD NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
00959                         JSObject *obj, jsval id, PRUint32 flags,
00960                         JSObject **objp, PRBool *_retval);
00961 
00962   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
00963   {
00964     return new nsHTMLElementSH(aData);
00965   }
00966 };
00967 
00968 
00969 // HTMLFormElement helper
00970 
00971 class nsHTMLFormElementSH : public nsHTMLElementSH
00972 {
00973 protected:
00974   nsHTMLFormElementSH(nsDOMClassInfoData* aData) : nsHTMLElementSH(aData)
00975   {
00976   }
00977 
00978   virtual ~nsHTMLFormElementSH()
00979   {
00980   }
00981 
00982   static nsresult FindNamedItem(nsIForm *aForm, JSString *str,
00983                                 nsISupports **aResult);
00984 
00985 public:
00986   NS_IMETHOD NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
00987                         JSObject *obj, jsval id, PRUint32 flags,
00988                         JSObject **objp, PRBool *_retval);
00989   NS_IMETHOD GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
00990                          JSObject *obj, jsval id, jsval *vp,
00991                          PRBool *_retval);
00992 
00993   NS_IMETHOD NewEnumerate(nsIXPConnectWrappedNative *wrapper,
00994                           JSContext *cx, JSObject *obj,
00995                           PRUint32 enum_op, jsval *statep,
00996                           jsid *idp, PRBool *_retval);
00997 
00998   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
00999   {
01000     return new nsHTMLFormElementSH(aData);
01001   }
01002 };
01003 
01004 
01005 // HTML[I]FrameElement helper
01006 
01007 class nsHTMLFrameElementSH : public nsHTMLElementSH
01008 {
01009 protected:
01010   nsHTMLFrameElementSH(nsDOMClassInfoData* aData) : nsHTMLElementSH(aData)
01011   {
01012   }
01013 
01014   virtual ~nsHTMLFrameElementSH()
01015   {
01016   }
01017 
01018 public:
01019   NS_IMETHOD GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
01020                          JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
01021   NS_IMETHOD SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
01022                          JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
01023   NS_IMETHOD AddProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
01024                          JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
01025   NS_IMETHOD DelProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
01026                          JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
01027   NS_IMETHOD NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
01028                         JSObject *obj, jsval id, PRUint32 flags,
01029                         JSObject **objp, PRBool *_retval);
01030 
01031   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
01032   {
01033     return new nsHTMLFrameElementSH(aData);
01034   }
01035 };
01036 
01037 
01038 // HTMLSelectElement helper
01039 
01040 class nsHTMLSelectElementSH : public nsHTMLElementSH
01041 {
01042 protected:
01043   nsHTMLSelectElementSH(nsDOMClassInfoData* aData) : nsHTMLElementSH(aData)
01044   {
01045   }
01046 
01047   virtual ~nsHTMLSelectElementSH()
01048   {
01049   }
01050 
01051 public:
01052   NS_IMETHOD GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
01053                          JSObject *obj, jsval id, jsval *vp,
01054                          PRBool *_retval);
01055   NS_IMETHOD SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
01056                          JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
01057 
01058   static nsresult SetOption(JSContext *cx, jsval *vp, PRUint32 aIndex,
01059                             nsIDOMNSHTMLOptionCollection *aOptCollection);
01060 
01061   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
01062   {
01063     return new nsHTMLSelectElementSH(aData);
01064   }
01065 };
01066 
01067 
01068 // Base helper for external HTML object (such as a plugin or an
01069 // applet)
01070 
01071 class nsHTMLExternalObjSH : public nsHTMLElementSH
01072 {
01073 protected:
01074   nsHTMLExternalObjSH(nsDOMClassInfoData* aData) : nsHTMLElementSH(aData)
01075   {
01076   }
01077 
01078   virtual ~nsHTMLExternalObjSH()
01079   {
01080   }
01081 
01082   nsresult GetPluginInstance(nsIXPConnectWrappedNative *aWrapper,
01083                              nsIPluginInstance **aResult);
01084 
01085   virtual nsresult GetPluginJSObject(JSContext *cx, JSObject *obj,
01086                                      nsIPluginInstance *plugin_inst,
01087                                      JSObject **plugin_obj,
01088                                      JSObject **plugin_proto) = 0;
01089 
01090 public:
01091   NS_IMETHOD PostCreate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
01092                         JSObject *obj);
01093   NS_IMETHOD GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
01094                          JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
01095   NS_IMETHOD SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
01096                          JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
01097   NS_IMETHOD Call(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
01098                   JSObject *obj, PRUint32 argc, jsval *argv, jsval *vp,
01099                   PRBool *_retval);
01100 };
01101 
01102 
01103 // HTMLAppletElement helper
01104 
01105 class nsHTMLAppletElementSH : public nsHTMLExternalObjSH
01106 {
01107 protected:
01108   nsHTMLAppletElementSH(nsDOMClassInfoData* aData) : nsHTMLExternalObjSH(aData)
01109   {
01110   }
01111 
01112   virtual ~nsHTMLAppletElementSH()
01113   {
01114   }
01115 
01116   virtual nsresult GetPluginJSObject(JSContext *cx, JSObject *obj,
01117                                      nsIPluginInstance *plugin_inst,
01118                                      JSObject **plugin_obj,
01119                                      JSObject **plugin_proto);
01120 
01121 public:
01122   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
01123   {
01124     return new nsHTMLAppletElementSH(aData);
01125   }
01126 };
01127 
01128 
01129 // HTMLEmbed/ObjectElement helper
01130 
01131 class nsHTMLPluginObjElementSH : public nsHTMLAppletElementSH
01132 {
01133 protected:
01134   nsHTMLPluginObjElementSH(nsDOMClassInfoData* aData)
01135     : nsHTMLAppletElementSH(aData)
01136   {
01137   }
01138 
01139   virtual ~nsHTMLPluginObjElementSH()
01140   {
01141   }
01142 
01143   virtual nsresult GetPluginJSObject(JSContext *cx, JSObject *obj,
01144                                      nsIPluginInstance *plugin_inst,
01145                                      JSObject **plugin_obj,
01146                                      JSObject **plugin_proto);
01147 
01148 public:
01149   NS_IMETHOD NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
01150                         JSObject *obj, jsval id, PRUint32 flags,
01151                         JSObject **objp, PRBool *_retval);
01152 
01153   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
01154   {
01155     return new nsHTMLPluginObjElementSH(aData);
01156   }
01157 };
01158 
01159 
01160 // HTMLOptionsCollection helper
01161 
01162 class nsHTMLOptionsCollectionSH : public nsHTMLCollectionSH
01163 {
01164 protected:
01165   nsHTMLOptionsCollectionSH(nsDOMClassInfoData* aData)
01166     : nsHTMLCollectionSH(aData)
01167   {
01168   }
01169 
01170   virtual ~nsHTMLOptionsCollectionSH()
01171   {
01172   }
01173 
01174   static JSBool JS_DLL_CALLBACK Add(JSContext *cx, JSObject *obj, uintN argc,
01175                                     jsval *argv, jsval *rval);
01176 
01177 public:
01178   NS_IMETHOD SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
01179                          JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
01180   NS_IMETHOD NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
01181                         JSObject *obj, jsval id, PRUint32 flags,
01182                         JSObject **objp, PRBool *_retval);
01183   
01184   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
01185   {
01186     return new nsHTMLOptionsCollectionSH(aData);
01187   }
01188 };
01189 
01190 
01191 // Plugin helper
01192 
01193 class nsPluginSH : public nsNamedArraySH
01194 {
01195 protected:
01196   nsPluginSH(nsDOMClassInfoData* aData) : nsNamedArraySH(aData)
01197   {
01198   }
01199 
01200   virtual ~nsPluginSH()
01201   {
01202   }
01203 
01204   // Override nsArraySH::GetItemAt() since our list isn't a
01205   // nsIDOMNodeList
01206   virtual nsresult GetItemAt(nsISupports *aNative, PRUint32 aIndex,
01207                              nsISupports **aResult);
01208 
01209   // Override nsNamedArraySH::GetNamedItem()
01210   virtual nsresult GetNamedItem(nsISupports *aNative, const nsAString& aName,
01211                                 nsISupports **aResult);
01212 
01213 public:
01214   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
01215   {
01216     return new nsPluginSH(aData);
01217   }
01218 };
01219 
01220 
01221 // PluginArray helper
01222 
01223 class nsPluginArraySH : public nsNamedArraySH
01224 {
01225 protected:
01226   nsPluginArraySH(nsDOMClassInfoData* aData) : nsNamedArraySH(aData)
01227   {
01228   }
01229 
01230   virtual ~nsPluginArraySH()
01231   {
01232   }
01233 
01234   // Override nsArraySH::GetItemAt() since our list isn't a
01235   // nsIDOMNodeList
01236   virtual nsresult GetItemAt(nsISupports *aNative, PRUint32 aIndex,
01237                              nsISupports **aResult);
01238 
01239   // Override nsNamedArraySH::GetNamedItem()
01240   virtual nsresult GetNamedItem(nsISupports *aNative, const nsAString& aName,
01241                                 nsISupports **aResult);
01242 
01243 public:
01244   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
01245   {
01246     return new nsPluginArraySH(aData);
01247   }
01248 };
01249 
01250 
01251 // MimeTypeArray helper
01252 
01253 class nsMimeTypeArraySH : public nsNamedArraySH
01254 {
01255 protected:
01256   nsMimeTypeArraySH(nsDOMClassInfoData* aData) : nsNamedArraySH(aData)
01257   {
01258   }
01259 
01260   virtual ~nsMimeTypeArraySH()
01261   {
01262   }
01263 
01264   // Override nsArraySH::GetItemAt() since our list isn't a
01265   // nsIDOMNodeList
01266   virtual nsresult GetItemAt(nsISupports *aNative, PRUint32 aIndex,
01267                              nsISupports **aResult);
01268 
01269   // Override nsNamedArraySH::GetNamedItem()
01270   virtual nsresult GetNamedItem(nsISupports *aNative, const nsAString& aName,
01271                                 nsISupports **aResult);
01272 
01273 public:
01274   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
01275   {
01276     return new nsMimeTypeArraySH(aData);
01277   }
01278 };
01279 
01280 
01281 // String array helper
01282 
01283 class nsStringArraySH : public nsGenericArraySH
01284 {
01285 protected:
01286   nsStringArraySH(nsDOMClassInfoData* aData) : nsGenericArraySH(aData)
01287   {
01288   }
01289 
01290   virtual ~nsStringArraySH()
01291   {
01292   }
01293 
01294   virtual nsresult GetStringAt(nsISupports *aNative, PRInt32 aIndex,
01295                                nsAString& aResult) = 0;
01296 
01297 public:
01298   NS_IMETHOD GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
01299                          JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
01300 };
01301 
01302 
01303 // History helper
01304 
01305 class nsHistorySH : public nsStringArraySH
01306 {
01307 protected:
01308   nsHistorySH(nsDOMClassInfoData* aData) : nsStringArraySH(aData)
01309   {
01310   }
01311 
01312   virtual ~nsHistorySH()
01313   {
01314   }
01315 
01316   virtual nsresult GetStringAt(nsISupports *aNative, PRInt32 aIndex,
01317                                nsAString& aResult);
01318 
01319 public:
01320   NS_IMETHOD GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
01321                          JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
01322 
01323   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
01324   {
01325     return new nsHistorySH(aData);
01326   }
01327 };
01328 
01329 // StringList scriptable helper
01330 
01331 class nsStringListSH : public nsStringArraySH
01332 {
01333 protected:
01334   nsStringListSH(nsDOMClassInfoData* aData) : nsStringArraySH(aData)
01335   {
01336   }
01337 
01338   virtual ~nsStringListSH()
01339   {
01340   }
01341 
01342   virtual nsresult GetStringAt(nsISupports *aNative, PRInt32 aIndex,
01343                                nsAString& aResult);
01344 
01345 public:
01346   // Inherit GetProperty, Enumerate from nsStringArraySH
01347   
01348   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
01349   {
01350     return new nsStringListSH(aData);
01351   }
01352 };
01353 
01354 
01355 // MediaList helper
01356 
01357 class nsMediaListSH : public nsStringArraySH
01358 {
01359 protected:
01360   nsMediaListSH(nsDOMClassInfoData* aData) : nsStringArraySH(aData)
01361   {
01362   }
01363 
01364   virtual ~nsMediaListSH()
01365   {
01366   }
01367 
01368   virtual nsresult GetStringAt(nsISupports *aNative, PRInt32 aIndex,
01369                                nsAString& aResult);
01370 
01371 public:
01372   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
01373   {
01374     return new nsMediaListSH(aData);
01375   }
01376 };
01377 
01378 
01379 // StyleSheetList helper
01380 
01381 class nsStyleSheetListSH : public nsArraySH
01382 {
01383 protected:
01384   nsStyleSheetListSH(nsDOMClassInfoData* aData) : nsArraySH(aData)
01385   {
01386   }
01387 
01388   virtual ~nsStyleSheetListSH()
01389   {
01390   }
01391 
01392   // Override nsArraySH::GetItemAt() since our list isn't a
01393   // nsIDOMNodeList
01394   virtual nsresult GetItemAt(nsISupports *aNative, PRUint32 aIndex,
01395                              nsISupports **aResult);
01396 
01397 public:
01398   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
01399   {
01400     return new nsStyleSheetListSH(aData);
01401   }
01402 };
01403 
01404 
01405 // CSSValueList helper
01406 
01407 class nsCSSValueListSH : public nsArraySH
01408 {
01409 protected:
01410   nsCSSValueListSH(nsDOMClassInfoData* aData) : nsArraySH(aData)
01411   {
01412   }
01413 
01414   virtual ~nsCSSValueListSH()
01415   {
01416   }
01417 
01418   // Override nsArraySH::GetItemAt() since our list isn't a
01419   // nsIDOMNodeList
01420   virtual nsresult GetItemAt(nsISupports *aNative, PRUint32 aIndex,
01421                              nsISupports **aResult);
01422 
01423 public:
01424   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
01425   {
01426     return new nsCSSValueListSH(aData);
01427   }
01428 };
01429 
01430 
01431 // CSSStyleDeclaration helper
01432 
01433 class nsCSSStyleDeclSH : public nsStringArraySH
01434 {
01435 protected:
01436   nsCSSStyleDeclSH(nsDOMClassInfoData* aData) : nsStringArraySH(aData)
01437   {
01438   }
01439 
01440   virtual ~nsCSSStyleDeclSH()
01441   {
01442   }
01443 
01444   virtual nsresult GetStringAt(nsISupports *aNative, PRInt32 aIndex,
01445                                nsAString& aResult);
01446 
01447 public:
01448   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
01449   {
01450     return new nsCSSStyleDeclSH(aData);
01451   }
01452 };
01453 
01454 
01455 // CSSRuleList helper
01456 
01457 class nsCSSRuleListSH : public nsArraySH
01458 {
01459 protected:
01460   nsCSSRuleListSH(nsDOMClassInfoData* aData) : nsArraySH(aData)
01461   {
01462   }
01463 
01464   virtual ~nsCSSRuleListSH()
01465   {
01466   }
01467 
01468   // Override nsArraySH::GetItemAt() since our list isn't a
01469   // nsIDOMNodeList
01470   virtual nsresult GetItemAt(nsISupports *aNative, PRUint32 aIndex,
01471                              nsISupports **aResult);
01472 
01473 public:
01474   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
01475   {
01476     return new nsCSSRuleListSH(aData);
01477   }
01478 };
01479 
01480 
01481 #ifdef MOZ_XUL
01482 // TreeColumns helper
01483 
01484 class nsTreeColumnsSH : public nsNamedArraySH
01485 {
01486 protected:
01487   nsTreeColumnsSH(nsDOMClassInfoData* aData) : nsNamedArraySH(aData)
01488   {
01489   }
01490 
01491   virtual ~nsTreeColumnsSH()
01492   {
01493   }
01494 
01495   // Override nsArraySH::GetItemAt() since our list isn't a
01496   // nsIDOMNodeList
01497   virtual nsresult GetItemAt(nsISupports *aNative, PRUint32 aIndex,
01498                              nsISupports **aResult);
01499 
01500   // Override nsNamedArraySH::GetNamedItem()
01501   virtual nsresult GetNamedItem(nsISupports *aNative, const nsAString& aName,
01502                                 nsISupports **aResult);
01503 
01504 public:
01505   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
01506   {
01507     return new nsTreeColumnsSH(aData);
01508   }
01509 };
01510 #endif
01511 
01512 // WebApps Storage helpers
01513 
01514 class nsStorageSH : public nsNamedArraySH
01515 {
01516 protected:
01517   nsStorageSH(nsDOMClassInfoData* aData) : nsNamedArraySH(aData)
01518   {
01519   }
01520 
01521   virtual ~nsStorageSH()
01522   {
01523   }
01524 
01525   NS_IMETHOD NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
01526                         JSObject *obj, jsval id, PRUint32 flags,
01527                         JSObject **objp, PRBool *_retval);
01528   NS_IMETHOD SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
01529                          JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
01530   NS_IMETHOD DelProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
01531                          JSObject *obj, jsval id, jsval *vp, PRBool *_retval);
01532   NS_IMETHOD NewEnumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
01533                           JSObject *obj, PRUint32 enum_op, jsval *statep,
01534                           jsid *idp, PRBool *_retval);
01535 
01536   // Override nsNamedArraySH::GetNamedItem()
01537   virtual nsresult GetNamedItem(nsISupports *aNative, const nsAString& aName,
01538                                 nsISupports **aResult);
01539 
01540 public:
01541   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
01542   {
01543     return new nsStorageSH(aData);
01544   }
01545 };
01546 
01547 class nsStorageListSH : public nsNamedArraySH
01548 {
01549 protected:
01550   nsStorageListSH(nsDOMClassInfoData* aData) : nsNamedArraySH(aData)
01551   {
01552   }
01553 
01554   virtual ~nsStorageListSH()
01555   {
01556   }
01557 
01558   // Override nsNamedArraySH::GetNamedItem()
01559   virtual nsresult GetNamedItem(nsISupports *aNative, const nsAString& aName,
01560                                 nsISupports **aResult);
01561 
01562 public:
01563   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
01564   {
01565     return new nsStorageListSH(aData);
01566   }
01567 };
01568 
01569 
01570 // Event handler 'this' translator class, this is called by XPConnect
01571 // when a "function interface" (nsIDOMEventListener) is called, this
01572 // class extracts 'this' fomr the first argument to the called
01573 // function (nsIDOMEventListener::HandleEvent(in nsIDOMEvent)), this
01574 // class will pass back nsIDOMEvent::currentTarget to be used as
01575 // 'this'.
01576 
01577 class nsEventListenerThisTranslator : public nsIXPCFunctionThisTranslator
01578 {
01579 public:
01580   nsEventListenerThisTranslator()
01581   {
01582   }
01583 
01584   virtual ~nsEventListenerThisTranslator()
01585   {
01586   }
01587 
01588   // nsISupports
01589   NS_DECL_ISUPPORTS
01590 
01591   // nsIXPCFunctionThisTranslator
01592   NS_DECL_NSIXPCFUNCTIONTHISTRANSLATOR
01593 };
01594 
01595 class nsDOMConstructorSH : public nsDOMGenericSH
01596 {
01597 protected:
01598   nsDOMConstructorSH(nsDOMClassInfoData* aData) : nsDOMGenericSH(aData)
01599   {
01600   }
01601 
01602   virtual ~nsDOMConstructorSH()
01603   {
01604   }
01605 
01606 public:
01607   NS_IMETHOD Construct(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
01608                        JSObject *obj, PRUint32 argc, jsval *argv,
01609                        jsval *vp, PRBool *_retval);
01610 
01611   NS_IMETHOD HasInstance(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
01612                          JSObject *obj, jsval val, PRBool *bp,
01613                          PRBool *_retval);
01614 
01615   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
01616   {
01617     return new nsDOMConstructorSH(aData);
01618   }
01619 };
01620 
01621 class nsNonDOMObjectSH : public nsDOMGenericSH
01622 {
01623 protected:
01624   nsNonDOMObjectSH(nsDOMClassInfoData* aData) : nsDOMGenericSH(aData)
01625   {
01626   }
01627 
01628   virtual ~nsNonDOMObjectSH()
01629   {
01630   }
01631 
01632 public:
01633   NS_IMETHOD GetFlags(PRUint32 *aFlags);
01634 
01635   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
01636   {
01637     return new nsNonDOMObjectSH(aData);
01638   }
01639 };
01640 
01641 void InvalidateContextAndWrapperCache();
01642 
01643 
01648 #define NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(_class)                          \
01649   if (aIID.Equals(NS_GET_IID(nsIClassInfo))) {                                \
01650     foundInterface =                                                          \
01651       nsDOMClassInfo::GetClassInfoInstance(eDOMClassInfo_##_class##_id);      \
01652     if (!foundInterface) {                                                    \
01653       *aInstancePtr = nsnull;                                                 \
01654       return NS_ERROR_OUT_OF_MEMORY;                                          \
01655     }                                                                         \
01656   } else
01657 
01658 #endif /* nsDOMClassInfo_h___ */