vp = INT_TO_JSVAL(nsIDOMEvent::MOUSEDOWN); JS_SetProperty(jscontext, constructor, "MOUSEDOWN", &vp);  vp = INT_TO_JSVAL(nsIDOMEvent::MOUSEUP); JS_SetProperty(jscontext, constructor, "MOUSEUP", &vp);  vp = INT_TO_JSVAL(nsIDOMEvent::MOUSEOVER); JS_SetProperty(jscontext, constructor, "MOUSEOVER", &vp);  vp = INT_TO_JSVAL(nsIDOMEvent::MOUSEOUT); JS_SetProperty(jscontext, constructor, "MOUSEOUT", &vp);  vp = INT_TO_JSVAL(nsIDOMEvent::MOUSEMOVE); JS_SetProperty(jscontext, constructor, "MOUSEMOVE", &vp);  vp = INT_TO_JSVAL(nsIDOMEvent::MOUSEDRAG); JS_SetProperty(jscontext, constructor, "MOUSEDRAG", &vp);  vp = INT_TO_JSVAL(nsIDOMEvent::CLICK); JS_SetProperty(jscontext, constructor, "CLICK", &vp);  vp = INT_TO_JSVAL(nsIDOMEvent::DBLCLICK); JS_SetProperty(jscontext, constructor, "DBLCLICK", &vp);  vp = INT_TO_JSVAL(nsIDOMEvent::KEYDOWN); JS_SetProperty(jscontext, constructor, "KEYDOWN", &vp);  vp = INT_TO_JSVAL(nsIDOMEvent::KEYUP); JS_SetProperty(jscontext, constructor, "KEYUP", &vp);  vp = INT_TO_JSVAL(nsIDOMEvent::KEYPRESS); JS_SetProperty(jscontext, constructor, "KEYPRESS", &vp);  vp = INT_TO_JSVAL(nsIDOMEvent::DRAGDROP); JS_SetProperty(jscontext, constructor, "DRAGDROP", &vp);  vp = INT_TO_JSVAL(nsIDOMEvent::FOCUS); JS_SetProperty(jscontext, constructor, "FOCUS", &vp);  vp = INT_TO_JSVAL(nsIDOMEvent::BLUR); JS_SetProperty(jscontext, constructor, "BLUR", &vp);  vp = INT_TO_JSVAL(nsIDOMEvent::SELECT); JS_SetProperty(jscontext, constructor, "SELECT", &vp);  vp = INT_TO_JSVAL(nsIDOMEvent::CHANGE); JS_SetProperty(jscontext, constructor, "CHANGE", &vp);  vp = INT_TO_JSVAL(nsIDOMEvent::RESET); JS_SetProperty(jscontext, constructor, "RESET", &vp);  vp = INT_TO_JSVAL(nsIDOMEvent::SUBMIT); JS_SetProperty(jscontext, constructor, "SUBMIT", &vp);  vp = INT_TO_JSVAL(nsIDOMEvent::SCROLL); JS_SetProperty(jscontext, constructor, "SCROLL", &vp);  vp = INT_TO_JSVAL(nsIDOMEvent::LOAD); JS_SetProperty(jscontext, constructor, "LOAD", &vp);  vp = INT_TO_JSVAL(nsIDOMEvent::UNLOAD); JS_SetProperty(jscontext, constructor, "UNLOAD", &vp);  vp = INT_TO_JSVAL(nsIDOMEvent::XFER_DONE); JS_SetProperty(jscontext, constructor, "XFER_DONE", &vp);  vp = INT_TO_JSVAL(nsIDOMEvent::ABORT); JS_SetProperty(jscontext, constructor, "ABORT", &vp);  vp = INT_TO_JSVAL(nsIDOMEvent::ERROR); JS_SetProperty(jscontext, constructor, "ERROR", &vp);  vp = INT_TO_JSVAL(nsIDOMEvent::LOCATE); JS_SetProperty(jscontext, constructor, "LOCATE", &vp);  vp = INT_TO_JSVAL(nsIDOMEvent::MOVE); JS_SetProperty(jscontext, constructor, "MOVE", &vp);  vp = INT_TO_JSVAL(nsIDOMEvent::RESIZE); JS_SetProperty(jscontext, constructor, "RESIZE", &vp);  vp = INT_TO_JSVAL(nsIDOMEvent::FORWARD); JS_SetProperty(jscontext, constructor, "FORWARD", &vp);  vp = INT_TO_JSVAL(nsIDOMEvent::HELP); JS_SetProperty(jscontext, constructor, "HELP", &vp);  vp = INT_TO_JSVAL(nsIDOMEvent::BACK); JS_SetProperty(jscontext, constructor, "BACK", &vp);  vp = INT_TO_JSVAL(nsIDOMEvent::TEXT); JS_SetProperty(jscontext, constructor, "TEXT", &vp);  vp = INT_TO_JSVAL(nsIDOMEvent::ALT_MASK); JS_SetProperty(jscontext, constructor, "ALT_MASK", &vp);  vp = INT_TO_JSVAL(nsIDOMEvent::CONTROL_MASK); JS_SetProperty(jscontext, constructor, "CONTROL_MASK", &vp);  vp = INT_TO_JSVAL(nsIDOMEvent::SHIFT_MASK); JS_SetProperty(jscontext, constructor, "SHIFT_MASK", &vp);  vp = INT_TO_JSVAL(nsIDOMEvent::META_MASK); JS_SetProperty(jscontext, constructor, "META_MASK", &vp);
extern "C" NS_DOM nsresult NS_InitEventClass(nsIScriptContext *aContext, void **aPrototype){  JSContext *jscontext = (JSContext *)aContext->GetNativeContext();  JSObject *proto = nsnull;  JSObject *constructor = nsnull;  JSObject *parent_proto = nsnull;  JSObject *global = JS_GetGlobalObject(jscontext);  jsval vp;  if ((PR_TRUE != JS_LookupProperty(jscontext, global, "Event", &vp)) ||      !JSVAL_IS_OBJECT(vp) ||      ((constructor = JSVAL_TO_OBJECT(vp)) == nsnull) ||      (PR_TRUE != JS_LookupProperty(jscontext, JSVAL_TO_OBJECT(vp), "prototype", &vp)) ||       !JSVAL_IS_OBJECT(vp)) {    proto = JS_InitClass(jscontext,     // context                         global,        // global object                         parent_proto,  // parent proto                          &EventClass,      // JSClass                         Event,            // JSNative ctor                         0,             // ctor args                         EventProperties,  // proto props                         EventMethods,     // proto funcs                         nsnull,        // ctor props (static)                         nsnull);       // ctor funcs (static)    if (nsnull == proto) {      return NS_ERROR_FAILURE;    }    if ((PR_TRUE == JS_LookupProperty(jscontext, global, "Event", &vp)) &&        JSVAL_IS_OBJECT(vp) &&        ((constructor = JSVAL_TO_OBJECT(vp)) != nsnull)) {      vp = INT_TO_JSVAL(nsIDOMEvent::BUBBLING_PHASE);      JS_SetProperty(jscontext, constructor, "BUBBLING_PHASE", &vp);      vp = INT_TO_JSVAL(nsIDOMEvent::CAPTURING_PHASE);      JS_SetProperty(jscontext, constructor, "CAPTURING_PHASE", &vp);      vp = INT_TO_JSVAL(nsIDOMEvent::AT_TARGET);      JS_SetProperty(jscontext, constructor, "AT_TARGET", &vp);    }  }  else if ((nsnull != constructor) && JSVAL_IS_OBJECT(vp)) {    proto = JSVAL_TO_OBJECT(vp);  }  else {    return NS_ERROR_FAILURE;  }  if (aPrototype) {    *aPrototype = proto;  }  return NS_OK;}