static HRESULT HTMLDOMChildrenCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller) { HTMLDOMChildrenCollection *This = impl_from_DispatchEx(dispex); TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller); switch(flags) { case DISPATCH_PROPERTYGET: { IDispatch *disp = NULL; HRESULT hres; hres = IHTMLDOMChildrenCollection_item(&This->IHTMLDOMChildrenCollection_iface, id - DISPID_CHILDCOL_0, &disp); if(FAILED(hres)) return hres; V_VT(res) = VT_DISPATCH; V_DISPATCH(res) = disp; break; } default: FIXME("unimplemented flags %x\n", flags); return E_NOTIMPL; } return S_OK; }
static HRESULT HTMLElementCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller) { HTMLElementCollection *This = impl_from_DispatchEx(dispex); DWORD idx; TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller); idx = id - DISPID_ELEMCOL_0; if(idx >= This->len) return DISP_E_UNKNOWNNAME; switch(flags) { case DISPATCH_PROPERTYGET: V_VT(res) = VT_DISPATCH; V_DISPATCH(res) = (IDispatch*)&This->elems[idx]->IHTMLElement_iface; IHTMLElement_AddRef(&This->elems[idx]->IHTMLElement_iface); break; default: FIXME("unimplemented flags %x\n", flags); return E_NOTIMPL; } return S_OK; }
static HRESULT HTMLElementCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid) { HTMLElementCollection *This = impl_from_DispatchEx(dispex); WCHAR *ptr; DWORD idx=0; if(!*name) return DISP_E_UNKNOWNNAME; for(ptr = name; *ptr && isdigitW(*ptr); ptr++) idx = idx*10 + (*ptr-'0'); if(*ptr) { /* the name contains alpha characters, so search by name & id */ for(idx = 0; idx < This->len; ++idx) { if(is_elem_id(This->elems[idx], name) || is_elem_name(This->elems[idx], name)) break; } } if(idx >= This->len) return DISP_E_UNKNOWNNAME; *dispid = DISPID_ELEMCOL_0 + idx; TRACE("ret %x\n", *dispid); return S_OK; }
static void HTMLXMLHttpRequest_bind_event(DispatchEx *dispex, int eid) { HTMLXMLHttpRequest *This = impl_from_DispatchEx(dispex); nsIDOMEventTarget *nstarget; nsAString type_str; nsresult nsres; static const WCHAR readystatechangeW[] = {'r','e','a','d','y','s','t','a','t','e','c','h','a','n','g','e',0}; TRACE("(%p)\n", This); assert(eid == EVENTID_READYSTATECHANGE); if(This->event_listener) return; This->event_listener = heap_alloc(sizeof(*This->event_listener)); if(!This->event_listener) return; This->event_listener->nsIDOMEventListener_iface.lpVtbl = &XMLHttpReqEventListenerVtbl; This->event_listener->ref = 1; This->event_listener->xhr = This; nsres = nsIXMLHttpRequest_QueryInterface(This->nsxhr, &IID_nsIDOMEventTarget, (void**)&nstarget); assert(nsres == NS_OK); nsAString_InitDepend(&type_str, readystatechangeW); nsres = nsIDOMEventTarget_AddEventListener(nstarget, &type_str, &This->event_listener->nsIDOMEventListener_iface, FALSE, TRUE, 2); nsAString_Finish(&type_str); nsIDOMEventTarget_Release(nstarget); if(NS_FAILED(nsres)) ERR("AddEventListener failed: %08x\n", nsres); }
static HRESULT HTMLImageElementFactory_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller) { HTMLImageElementFactory *This = impl_from_DispatchEx(dispex); IHTMLImgElement *img; VARIANT empty, *width, *height; HRESULT hres; int argc = params->cArgs - params->cNamedArgs; V_VT(res) = VT_NULL; V_VT(&empty) = VT_EMPTY; width = argc >= 1 ? params->rgvarg + (params->cArgs - 1) : ∅ height = argc >= 2 ? params->rgvarg + (params->cArgs - 2) : ∅ hres = IHTMLImageElementFactory_create(&This->IHTMLImageElementFactory_iface, *width, *height, &img); if(FAILED(hres)) return hres; V_VT(res) = VT_DISPATCH; V_DISPATCH(res) = (IDispatch*)img; return S_OK; }
static HRESULT function_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller) { func_disp_t *This = impl_from_DispatchEx(dispex); HRESULT hres; switch(flags) { case DISPATCH_METHOD|DISPATCH_PROPERTYGET: if(!res) return E_INVALIDARG; /* fall through */ case DISPATCH_METHOD: if(!This->obj) return E_UNEXPECTED; hres = typeinfo_invoke(This->obj, This->info, flags, params, res, ei); break; case DISPATCH_PROPERTYGET: { unsigned name_len; WCHAR *ptr; BSTR str; static const WCHAR func_prefixW[] = {'\n','f','u','n','c','t','i','o','n',' '}; static const WCHAR func_suffixW[] = {'(',')',' ','{','\n',' ',' ',' ',' ','[','n','a','t','i','v','e',' ','c','o','d','e',']','\n','}','\n'}; /* FIXME: This probably should be more generic. Also we should try to get IID_IActiveScriptSite and SID_GetCaller. */ if(!caller) return E_ACCESSDENIED; name_len = SysStringLen(This->info->name); ptr = str = SysAllocStringLen(NULL, name_len + (sizeof(func_prefixW)+sizeof(func_suffixW))/sizeof(WCHAR)); if(!str) return E_OUTOFMEMORY; memcpy(ptr, func_prefixW, sizeof(func_prefixW)); ptr += sizeof(func_prefixW)/sizeof(WCHAR); memcpy(ptr, This->info->name, name_len*sizeof(WCHAR)); ptr += name_len; memcpy(ptr, func_suffixW, sizeof(func_suffixW)); V_VT(res) = VT_BSTR; V_BSTR(res) = str; return S_OK; } default: FIXME("Unimplemented flags %x\n", flags); hres = E_NOTIMPL; } return hres; }
static HRESULT HTMLDOMChildrenCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid) { HTMLDOMChildrenCollection *This = impl_from_DispatchEx(dispex); WCHAR *ptr; DWORD idx=0; PRUint32 len = 0; for(ptr = name; *ptr && isdigitW(*ptr); ptr++) idx = idx*10 + (*ptr-'0'); if(*ptr) return DISP_E_UNKNOWNNAME; nsIDOMNodeList_GetLength(This->nslist, &len); if(idx >= len) return DISP_E_UNKNOWNNAME; *dispid = DISPID_CHILDCOL_0 + idx; TRACE("ret %x\n", *dispid); return S_OK; }
static HRESULT function_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller) { func_disp_t *This = impl_from_DispatchEx(dispex); HRESULT hres; switch(flags) { case DISPATCH_METHOD|DISPATCH_PROPERTYGET: if(!res) return E_INVALIDARG; case DISPATCH_METHOD: hres = typeinfo_invoke(This->obj, This->info, flags, params, res, ei); break; default: FIXME("Unimplemented flags %x\n", flags); hres = E_NOTIMPL; } return hres; }