From 76c028b7c201b4f9d09b30dec64189698aea4893 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Mon, 27 Dec 2010 18:34:39 +0100 Subject: [PATCH] mshtml: Pass DispatchEx pointer instead of outer IUnknown to DispatchEx's vtbl functions. --- dlls/mshtml/dispex.c | 34 ++++++----- dlls/mshtml/htmlelem.c | 63 +++++++++---------- dlls/mshtml/htmlelemcol.c | 50 +++++++++------- dlls/mshtml/htmlimg.c | 35 ++++++----- dlls/mshtml/htmlnode.c | 51 +++++++++------- dlls/mshtml/htmlstyle.c | 44 +++++++------- dlls/mshtml/htmlwindow.c | 140 ++++++++++++++++++++++--------------------- dlls/mshtml/mshtml_private.h | 12 ++-- 8 files changed, 230 insertions(+), 199 deletions(-) diff --git a/dlls/mshtml/dispex.c b/dlls/mshtml/dispex.c index 17764d7f6b4..dd75d89ac6d 100644 --- a/dlls/mshtml/dispex.c +++ b/dlls/mshtml/dispex.c @@ -445,7 +445,7 @@ static HRESULT dispex_value(DispatchEx *This, LCID lcid, WORD flags, DISPPARAMS VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller) { if(This->data->vtbl && This->data->vtbl->value) - return This->data->vtbl->value(This->outer, lcid, flags, params, res, ei, caller); + return This->data->vtbl->value(This, lcid, flags, params, res, ei, caller); switch(flags) { case DISPATCH_PROPERTYGET: @@ -526,10 +526,23 @@ static ULONG WINAPI Function_Release(IUnknown *iface) return IDispatchEx_Release(DISPATCHEX(This->obj)); } -static HRESULT function_value(IUnknown *iface, LCID lcid, WORD flags, DISPPARAMS *params, +#undef FUNCTION_THIS + +static const IUnknownVtbl FunctionUnkVtbl = { + Function_QueryInterface, + Function_AddRef, + Function_Release +}; + +static inline func_disp_t *impl_from_DispatchEx(DispatchEx *iface) +{ + return CONTAINING_RECORD(iface, func_disp_t, dispex); +} + +static HRESULT function_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller) { - func_disp_t *This = FUNCTION_THIS(iface); + func_disp_t *This = impl_from_DispatchEx(dispex); HRESULT hres; switch(flags) { @@ -547,14 +560,6 @@ static HRESULT function_value(IUnknown *iface, LCID lcid, WORD flags, DISPPARAMS return hres; } -#undef FUNCTION_THIS - -static const IUnknownVtbl FunctionUnkVtbl = { - Function_QueryInterface, - Function_AddRef, - Function_Release -}; - static const dispex_static_data_vtbl_t function_dispex_vtbl = { function_value, NULL, @@ -702,7 +707,7 @@ static HRESULT get_builtin_id(DispatchEx *This, BSTR name, DWORD grfdex, DISPID if(This->data->vtbl && This->data->vtbl->get_dispid) { HRESULT hres; - hres = This->data->vtbl->get_dispid(This->outer, name, grfdex, ret); + hres = This->data->vtbl->get_dispid(This, name, grfdex, ret); if(hres != DISP_E_UNKNOWNNAME) return hres; } @@ -886,13 +891,12 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller); if(is_custom_dispid(id) && This->data->vtbl && This->data->vtbl->invoke) - return This->data->vtbl->invoke(This->outer, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller); + return This->data->vtbl->invoke(This, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller); if(wFlags == DISPATCH_CONSTRUCT) { if(id == DISPID_VALUE) { if(This->data->vtbl && This->data->vtbl->value) { - return This->data->vtbl->value(This->outer, lcid, wFlags, pdp, - pvarRes, pei, pspCaller); + return This->data->vtbl->value(This, lcid, wFlags, pdp, pvarRes, pei, pspCaller); } FIXME("DISPATCH_CONSTRUCT flag but missing value function\n"); return E_FAIL; diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c index d5c742dfb8b..6349b017e92 100644 --- a/dlls/mshtml/htmlelem.c +++ b/dlls/mshtml/htmlelem.c @@ -1492,31 +1492,6 @@ static HRESULT WINAPI HTMLElement_get_all(IHTMLElement *iface, IDispatch **p) return S_OK; } -static HRESULT HTMLElement_get_dispid(IUnknown *iface, BSTR name, - DWORD grfdex, DISPID *pid) -{ - HTMLElement *This = HTMLELEM_THIS(iface); - - if(This->node.vtbl->get_dispid) - return This->node.vtbl->get_dispid(&This->node, name, grfdex, pid); - - return DISP_E_UNKNOWNNAME; -} - -static HRESULT HTMLElement_invoke(IUnknown *iface, DISPID id, LCID lcid, - WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, - IServiceProvider *caller) -{ - HTMLElement *This = HTMLELEM_THIS(iface); - - if(This->node.vtbl->invoke) - return This->node.vtbl->invoke(&This->node, id, lcid, flags, - params, res, ei, caller); - - ERR("(%p): element has no invoke method\n", This); - return E_NOTIMPL; -} - #undef HTMLELEM_THIS static const IHTMLElementVtbl HTMLElementVtbl = { @@ -1683,6 +1658,36 @@ static const NodeImplVtbl HTMLElementImplVtbl = { HTMLElement_clone }; +static inline HTMLElement *impl_from_DispatchEx(DispatchEx *iface) +{ + return CONTAINING_RECORD(iface, HTMLElement, node.dispex); +} + +static HRESULT HTMLElement_get_dispid(DispatchEx *dispex, BSTR name, + DWORD grfdex, DISPID *pid) +{ + HTMLElement *This = impl_from_DispatchEx(dispex); + + if(This->node.vtbl->get_dispid) + return This->node.vtbl->get_dispid(&This->node, name, grfdex, pid); + + return DISP_E_UNKNOWNNAME; +} + +static HRESULT HTMLElement_invoke(DispatchEx *dispex, DISPID id, LCID lcid, + WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, + IServiceProvider *caller) +{ + HTMLElement *This = impl_from_DispatchEx(dispex); + + if(This->node.vtbl->invoke) + return This->node.vtbl->invoke(&This->node, id, lcid, flags, + params, res, ei, caller); + + ERR("(%p): element has no invoke method\n", This); + return E_NOTIMPL; +} + static const tid_t HTMLElement_iface_tids[] = { HTMLELEMENT_TIDS, 0 @@ -1888,7 +1893,7 @@ static const IHTMLFiltersCollectionVtbl HTMLFiltersCollectionVtbl = { HTMLFiltersCollection_item }; -static HRESULT HTMLFiltersCollection_get_dispid(IUnknown *iface, BSTR name, DWORD flags, DISPID *dispid) +static HRESULT HTMLFiltersCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid) { WCHAR *ptr; int idx = 0; @@ -1903,12 +1908,10 @@ static HRESULT HTMLFiltersCollection_get_dispid(IUnknown *iface, BSTR name, DWOR return S_OK; } -static HRESULT HTMLFiltersCollection_invoke(IUnknown *iface, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params, +static HRESULT HTMLFiltersCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller) { - HTMLFiltersCollection *This = HTMLFILTERSCOLLECTION_THIS(iface); - - TRACE("(%p)->(%x %x %x %p %p %p)\n", This, id, lcid, flags, params, res, ei); + TRACE("(%p)->(%x %x %x %p %p %p)\n", dispex, id, lcid, flags, params, res, ei); V_VT(res) = VT_DISPATCH; V_DISPATCH(res) = NULL; diff --git a/dlls/mshtml/htmlelemcol.c b/dlls/mshtml/htmlelemcol.c index a3e8be736c1..459268afc4b 100644 --- a/dlls/mshtml/htmlelemcol.c +++ b/dlls/mshtml/htmlelemcol.c @@ -382,11 +382,34 @@ static HRESULT WINAPI HTMLElementCollection_tags(IHTMLElementCollection *iface, return S_OK; } +#undef ELEMCOL_THIS + +static const IHTMLElementCollectionVtbl HTMLElementCollectionVtbl = { + HTMLElementCollection_QueryInterface, + HTMLElementCollection_AddRef, + HTMLElementCollection_Release, + HTMLElementCollection_GetTypeInfoCount, + HTMLElementCollection_GetTypeInfo, + HTMLElementCollection_GetIDsOfNames, + HTMLElementCollection_Invoke, + HTMLElementCollection_toString, + HTMLElementCollection_put_length, + HTMLElementCollection_get_length, + HTMLElementCollection_get__newEnum, + HTMLElementCollection_item, + HTMLElementCollection_tags +}; + +static inline HTMLElementCollection *impl_from_DispatchEx(DispatchEx *iface) +{ + return CONTAINING_RECORD(iface, HTMLElementCollection, dispex); +} + #define DISPID_ELEMCOL_0 MSHTML_DISPID_CUSTOM_MIN -static HRESULT HTMLElementCollection_get_dispid(IUnknown *iface, BSTR name, DWORD flags, DISPID *dispid) +static HRESULT HTMLElementCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid) { - HTMLElementCollection *This = ELEMCOL_THIS(iface); + HTMLElementCollection *This = impl_from_DispatchEx(dispex); WCHAR *ptr; DWORD idx=0; @@ -413,10 +436,10 @@ static HRESULT HTMLElementCollection_get_dispid(IUnknown *iface, BSTR name, DWOR return S_OK; } -static HRESULT HTMLElementCollection_invoke(IUnknown *iface, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params, +static HRESULT HTMLElementCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller) { - HTMLElementCollection *This = ELEMCOL_THIS(iface); + 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); @@ -439,24 +462,6 @@ static HRESULT HTMLElementCollection_invoke(IUnknown *iface, DISPID id, LCID lci return S_OK; } -#undef ELEMCOL_THIS - -static const IHTMLElementCollectionVtbl HTMLElementCollectionVtbl = { - HTMLElementCollection_QueryInterface, - HTMLElementCollection_AddRef, - HTMLElementCollection_Release, - HTMLElementCollection_GetTypeInfoCount, - HTMLElementCollection_GetTypeInfo, - HTMLElementCollection_GetIDsOfNames, - HTMLElementCollection_Invoke, - HTMLElementCollection_toString, - HTMLElementCollection_put_length, - HTMLElementCollection_get_length, - HTMLElementCollection_get__newEnum, - HTMLElementCollection_item, - HTMLElementCollection_tags -}; - static const dispex_static_data_vtbl_t HTMLElementColection_dispex_vtbl = { NULL, HTMLElementCollection_get_dispid, @@ -467,6 +472,7 @@ static const tid_t HTMLElementCollection_iface_tids[] = { IHTMLElementCollection_tid, 0 }; + static dispex_static_data_t HTMLElementCollection_dispex = { &HTMLElementColection_dispex_vtbl, DispHTMLElementCollection_tid, diff --git a/dlls/mshtml/htmlimg.c b/dlls/mshtml/htmlimg.c index 413f02c428d..8b0972a4869 100644 --- a/dlls/mshtml/htmlimg.c +++ b/dlls/mshtml/htmlimg.c @@ -851,11 +851,29 @@ static HRESULT WINAPI HTMLImageElementFactory_create(IHTMLImageElementFactory *i return S_OK; } -static HRESULT HTMLImageElementFactory_value(IUnknown *iface, LCID lcid, +#undef HTMLIMGFACTORY_THIS + +static const IHTMLImageElementFactoryVtbl HTMLImageElementFactoryVtbl = { + HTMLImageElementFactory_QueryInterface, + HTMLImageElementFactory_AddRef, + HTMLImageElementFactory_Release, + HTMLImageElementFactory_GetTypeInfoCount, + HTMLImageElementFactory_GetTypeInfo, + HTMLImageElementFactory_GetIDsOfNames, + HTMLImageElementFactory_Invoke, + HTMLImageElementFactory_create +}; + +static inline HTMLImageElementFactory *impl_from_DispatchEx(DispatchEx *iface) +{ + return CONTAINING_RECORD(iface, HTMLImageElementFactory, dispex); +} + +static HRESULT HTMLImageElementFactory_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller) { - HTMLImageElementFactory *This = HTMLIMGFACTORY_THIS(iface); + HTMLImageElementFactory *This = impl_from_DispatchEx(dispex); IHTMLImgElement *img; VARIANT empty, *width, *height; HRESULT hres; @@ -878,19 +896,6 @@ static HRESULT HTMLImageElementFactory_value(IUnknown *iface, LCID lcid, return S_OK; } -#undef HTMLIMGFACTORY_THIS - -static const IHTMLImageElementFactoryVtbl HTMLImageElementFactoryVtbl = { - HTMLImageElementFactory_QueryInterface, - HTMLImageElementFactory_AddRef, - HTMLImageElementFactory_Release, - HTMLImageElementFactory_GetTypeInfoCount, - HTMLImageElementFactory_GetTypeInfo, - HTMLImageElementFactory_GetIDsOfNames, - HTMLImageElementFactory_Invoke, - HTMLImageElementFactory_create -}; - static const tid_t HTMLImageElementFactory_iface_tids[] = { IHTMLImageElementFactory_tid, 0 diff --git a/dlls/mshtml/htmlnode.c b/dlls/mshtml/htmlnode.c index 2795bb73c33..12b053d3558 100644 --- a/dlls/mshtml/htmlnode.c +++ b/dlls/mshtml/htmlnode.c @@ -184,11 +184,31 @@ static HRESULT WINAPI HTMLDOMChildrenCollection_item(IHTMLDOMChildrenCollection return S_OK; } +#undef HTMLCHILDCOL_THIS + +static const IHTMLDOMChildrenCollectionVtbl HTMLDOMChildrenCollectionVtbl = { + HTMLDOMChildrenCollection_QueryInterface, + HTMLDOMChildrenCollection_AddRef, + HTMLDOMChildrenCollection_Release, + HTMLDOMChildrenCollection_GetTypeInfoCount, + HTMLDOMChildrenCollection_GetTypeInfo, + HTMLDOMChildrenCollection_GetIDsOfNames, + HTMLDOMChildrenCollection_Invoke, + HTMLDOMChildrenCollection_get_length, + HTMLDOMChildrenCollection__newEnum, + HTMLDOMChildrenCollection_item +}; + +static inline HTMLDOMChildrenCollection *impl_from_DispatchEx(DispatchEx *iface) +{ + return CONTAINING_RECORD(iface, HTMLDOMChildrenCollection, dispex); +} + #define DISPID_CHILDCOL_0 MSHTML_DISPID_CUSTOM_MIN -static HRESULT HTMLDOMChildrenCollection_get_dispid(IUnknown *iface, BSTR name, DWORD flags, DISPID *dispid) +static HRESULT HTMLDOMChildrenCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid) { - HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface); + HTMLDOMChildrenCollection *This = impl_from_DispatchEx(dispex); WCHAR *ptr; DWORD idx=0; PRUint32 len = 0; @@ -207,10 +227,10 @@ static HRESULT HTMLDOMChildrenCollection_get_dispid(IUnknown *iface, BSTR name, return S_OK; } -static HRESULT HTMLDOMChildrenCollection_invoke(IUnknown *iface, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params, +static HRESULT HTMLDOMChildrenCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller) { - HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface); + HTMLDOMChildrenCollection *This = impl_from_DispatchEx(dispex); TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller); @@ -236,19 +256,10 @@ static HRESULT HTMLDOMChildrenCollection_invoke(IUnknown *iface, DISPID id, LCID return S_OK; } -#undef HTMLCHILDCOL_THIS - -static const IHTMLDOMChildrenCollectionVtbl HTMLDOMChildrenCollectionVtbl = { - HTMLDOMChildrenCollection_QueryInterface, - HTMLDOMChildrenCollection_AddRef, - HTMLDOMChildrenCollection_Release, - HTMLDOMChildrenCollection_GetTypeInfoCount, - HTMLDOMChildrenCollection_GetTypeInfo, - HTMLDOMChildrenCollection_GetIDsOfNames, - HTMLDOMChildrenCollection_Invoke, - HTMLDOMChildrenCollection_get_length, - HTMLDOMChildrenCollection__newEnum, - HTMLDOMChildrenCollection_item +static const dispex_static_data_vtbl_t HTMLDOMChildrenCollection_dispex_vtbl = { + NULL, + HTMLDOMChildrenCollection_get_dispid, + HTMLDOMChildrenCollection_invoke }; static const tid_t HTMLDOMChildrenCollection_iface_tids[] = { @@ -256,12 +267,6 @@ static const tid_t HTMLDOMChildrenCollection_iface_tids[] = { 0 }; -static const dispex_static_data_vtbl_t HTMLDOMChildrenCollection_dispex_vtbl = { - NULL, - HTMLDOMChildrenCollection_get_dispid, - HTMLDOMChildrenCollection_invoke -}; - static dispex_static_data_t HTMLDOMChildrenCollection_dispex = { &HTMLDOMChildrenCollection_dispex_vtbl, DispDOMChildrenCollection_tid, diff --git a/dlls/mshtml/htmlstyle.c b/dlls/mshtml/htmlstyle.c index 6bd74adf38b..99611ed5e19 100644 --- a/dlls/mshtml/htmlstyle.c +++ b/dlls/mshtml/htmlstyle.c @@ -2463,28 +2463,6 @@ static HRESULT WINAPI HTMLStyle_toString(IHTMLStyle *iface, BSTR *String) return E_NOTIMPL; } -static HRESULT HTMLStyle_get_dispid(IUnknown *iface, BSTR name, DWORD flags, DISPID *dispid) -{ - int c, i, min=0, max = sizeof(style_tbl)/sizeof(*style_tbl)-1; - - while(min <= max) { - i = (min+max)/2; - - c = strcmpW(style_tbl[i].name, name); - if(!c) { - *dispid = style_tbl[i].dispid; - return S_OK; - } - - if(c > 0) - max = i-1; - else - min = i+1; - } - - return DISP_E_UNKNOWNNAME; -} - static const IHTMLStyleVtbl HTMLStyleVtbl = { HTMLStyle_QueryInterface, HTMLStyle_AddRef, @@ -2674,6 +2652,28 @@ static const IHTMLStyleVtbl HTMLStyleVtbl = { HTMLStyle_toString }; +static HRESULT HTMLStyle_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid) +{ + int c, i, min=0, max = sizeof(style_tbl)/sizeof(*style_tbl)-1; + + while(min <= max) { + i = (min+max)/2; + + c = strcmpW(style_tbl[i].name, name); + if(!c) { + *dispid = style_tbl[i].dispid; + return S_OK; + } + + if(c > 0) + max = i-1; + else + min = i+1; + } + + return DISP_E_UNKNOWNNAME; +} + static const dispex_static_data_vtbl_t HTMLStyle_dispex_vtbl = { NULL, HTMLStyle_get_dispid, diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c index 9391ccfd491..c98eb1da68d 100644 --- a/dlls/mshtml/htmlwindow.c +++ b/dlls/mshtml/htmlwindow.c @@ -1236,67 +1236,6 @@ static HRESULT WINAPI HTMLWindow2_get_external(IHTMLWindow2 *iface, IDispatch ** return IDocHostUIHandler_GetExternal(This->doc_obj->hostui, p); } -static HRESULT HTMLWindow_invoke(IUnknown *iface, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params, - VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller) -{ - HTMLWindow *This = impl_from_IHTMLWindow2((IHTMLWindow2*)iface); - global_prop_t *prop; - DWORD idx; - HRESULT hres; - - idx = id - MSHTML_DISPID_CUSTOM_MIN; - if(idx >= This->global_prop_cnt) - return DISP_E_MEMBERNOTFOUND; - - prop = This->global_props+idx; - - switch(prop->type) { - case GLOBAL_SCRIPTVAR: { - IDispatchEx *dispex; - IDispatch *disp; - - disp = get_script_disp(prop->script_host); - if(!disp) - return E_UNEXPECTED; - - hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex); - if(SUCCEEDED(hres)) { - TRACE("%s >>>\n", debugstr_w(prop->name)); - hres = IDispatchEx_InvokeEx(dispex, prop->id, lcid, flags, params, res, ei, caller); - if(hres == S_OK) - TRACE("%s <<<\n", debugstr_w(prop->name)); - else - WARN("%s <<< %08x\n", debugstr_w(prop->name), hres); - IDispatchEx_Release(dispex); - }else { - FIXME("No IDispatchEx\n"); - } - IDispatch_Release(disp); - break; - } - case GLOBAL_ELEMENTVAR: { - IHTMLElement *elem; - - hres = IHTMLDocument3_getElementById(&This->doc->basedoc.IHTMLDocument3_iface, - prop->name, &elem); - if(FAILED(hres)) - return hres; - - if(!elem) - return DISP_E_MEMBERNOTFOUND; - - V_VT(res) = VT_DISPATCH; - V_DISPATCH(res) = (IDispatch*)elem; - break; - } - default: - ERR("invalid type %d\n", prop->type); - hres = DISP_E_MEMBERNOTFOUND; - } - - return hres; -} - static const IHTMLWindow2Vtbl HTMLWindow2Vtbl = { HTMLWindow2_QueryInterface, HTMLWindow2_AddRef, @@ -2170,12 +2109,72 @@ static const IServiceProviderVtbl ServiceProviderVtbl = { HTMLWindowSP_QueryService }; -static const tid_t HTMLWindow_iface_tids[] = { - IHTMLWindow2_tid, - IHTMLWindow3_tid, - IHTMLWindow4_tid, - 0 -}; +static inline HTMLWindow *impl_from_DispatchEx(DispatchEx *iface) +{ + return CONTAINING_RECORD(iface, HTMLWindow, dispex); +} + +static HRESULT HTMLWindow_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params, + VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller) +{ + HTMLWindow *This = impl_from_DispatchEx(dispex); + global_prop_t *prop; + DWORD idx; + HRESULT hres; + + idx = id - MSHTML_DISPID_CUSTOM_MIN; + if(idx >= This->global_prop_cnt) + return DISP_E_MEMBERNOTFOUND; + + prop = This->global_props+idx; + + switch(prop->type) { + case GLOBAL_SCRIPTVAR: { + IDispatchEx *dispex; + IDispatch *disp; + + disp = get_script_disp(prop->script_host); + if(!disp) + return E_UNEXPECTED; + + hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex); + if(SUCCEEDED(hres)) { + TRACE("%s >>>\n", debugstr_w(prop->name)); + hres = IDispatchEx_InvokeEx(dispex, prop->id, lcid, flags, params, res, ei, caller); + if(hres == S_OK) + TRACE("%s <<<\n", debugstr_w(prop->name)); + else + WARN("%s <<< %08x\n", debugstr_w(prop->name), hres); + IDispatchEx_Release(dispex); + }else { + FIXME("No IDispatchEx\n"); + } + IDispatch_Release(disp); + break; + } + case GLOBAL_ELEMENTVAR: { + IHTMLElement *elem; + + hres = IHTMLDocument3_getElementById(&This->doc->basedoc.IHTMLDocument3_iface, + prop->name, &elem); + if(FAILED(hres)) + return hres; + + if(!elem) + return DISP_E_MEMBERNOTFOUND; + + V_VT(res) = VT_DISPATCH; + V_DISPATCH(res) = (IDispatch*)elem; + break; + } + default: + ERR("invalid type %d\n", prop->type); + hres = DISP_E_MEMBERNOTFOUND; + } + + return hres; +} + static const dispex_static_data_vtbl_t HTMLWindow_dispex_vtbl = { NULL, @@ -2183,6 +2182,13 @@ static const dispex_static_data_vtbl_t HTMLWindow_dispex_vtbl = { HTMLWindow_invoke }; +static const tid_t HTMLWindow_iface_tids[] = { + IHTMLWindow2_tid, + IHTMLWindow3_tid, + IHTMLWindow4_tid, + 0 +}; + static dispex_static_data_t HTMLWindow_dispex = { &HTMLWindow_dispex_vtbl, DispHTMLWindow2_tid, diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index e605ad88641..59618561f1c 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -171,10 +171,12 @@ typedef struct dispex_dynamic_data_t dispex_dynamic_data_t; #define MSHTML_DISPID_CUSTOM_MAX 0x6fffffff #define MSHTML_CUSTOM_DISPID_CNT (MSHTML_DISPID_CUSTOM_MAX-MSHTML_DISPID_CUSTOM_MIN) +typedef struct DispatchEx DispatchEx; + typedef struct { - HRESULT (*value)(IUnknown*,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,IServiceProvider*); - HRESULT (*get_dispid)(IUnknown*,BSTR,DWORD,DISPID*); - HRESULT (*invoke)(IUnknown*,DISPID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,IServiceProvider*); + HRESULT (*value)(DispatchEx*,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,IServiceProvider*); + HRESULT (*get_dispid)(DispatchEx*,BSTR,DWORD,DISPID*); + HRESULT (*invoke)(DispatchEx*,DISPID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,IServiceProvider*); } dispex_static_data_vtbl_t; typedef struct { @@ -184,14 +186,14 @@ typedef struct { const tid_t* const iface_tids; } dispex_static_data_t; -typedef struct { +struct DispatchEx { const IDispatchExVtbl *lpIDispatchExVtbl; IUnknown *outer; dispex_static_data_t *data; dispex_dynamic_data_t *dynamic_data; -} DispatchEx; +}; void init_dispex(DispatchEx*,IUnknown*,dispex_static_data_t*); void release_dispex(DispatchEx*); -- 2.11.4.GIT