From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/dispex.c | 43 +++++++++++++++++++- dlls/mshtml/htmlimg.c | 71 +++++++------------------------- dlls/mshtml/htmlselect.c | 71 +++++++------------------------- dlls/mshtml/mshtml_private.h | 31 +++++++------- dlls/mshtml/mutation.c | 38 +++++------------- dlls/mshtml/xmlhttprequest.c | 78 +++++++----------------------------- 6 files changed, 111 insertions(+), 221 deletions(-)
diff --git a/dlls/mshtml/dispex.c b/dlls/mshtml/dispex.c index 518d009db41..d590fd46f37 100644 --- a/dlls/mshtml/dispex.c +++ b/dlls/mshtml/dispex.c @@ -3052,6 +3052,31 @@ HRESULT get_prototype(HTMLInnerWindow *script_global, object_id_t id, DispatchEx return S_OK; }
+void constructor_traverse(DispatchEx *dispex, nsCycleCollectionTraversalCallback *cb) +{ + struct constructor *This = constructor_from_DispatchEx(dispex); + + if(This->window) + note_cc_edge((nsISupports*)&This->window->base.IHTMLWindow2_iface, "window", cb); +} + +void constructor_unlink(DispatchEx *dispex) +{ + struct constructor *This = constructor_from_DispatchEx(dispex); + + if(This->window) { + HTMLInnerWindow *window = This->window; + This->window = NULL; + IHTMLWindow2_Release(&window->base.IHTMLWindow2_iface); + } +} + +void constructor_destructor(DispatchEx *dispex) +{ + struct constructor *This = constructor_from_DispatchEx(dispex); + free(This); +} + struct stub_constructor { DispatchEx dispex; @@ -3115,6 +3140,7 @@ static dispex_static_data_t stub_constructor_dispex = { HRESULT get_constructor(HTMLInnerWindow *script_global, object_id_t id, DispatchEx **ret) { dispex_static_data_t *info; + HRESULT hres;
if(script_global->constructors[id]) { *ret = script_global->constructors[id]; @@ -3123,9 +3149,22 @@ HRESULT get_constructor(HTMLInnerWindow *script_global, object_id_t id, Dispatch
info = object_descriptors[id]; if(info->init_constructor) { - HRESULT hres = info->init_constructor(script_global, &script_global->constructors[id]); - if(FAILED(hres)) + struct constructor *constr = malloc(sizeof(*constr)); + + if(!constr) + return E_OUTOFMEMORY; + + constr->window = script_global; + IHTMLWindow2_AddRef(&script_global->base.IHTMLWindow2_iface); + + hres = info->init_constructor(constr); + if(FAILED(hres)) { + IHTMLWindow2_Release(&script_global->base.IHTMLWindow2_iface); + free(constr); return hres; + } + + script_global->constructors[id] = &constr->dispex; }else { struct stub_constructor *constr;
diff --git a/dlls/mshtml/htmlimg.c b/dlls/mshtml/htmlimg.c index 942cf885cc4..fda2037f392 100644 --- a/dlls/mshtml/htmlimg.c +++ b/dlls/mshtml/htmlimg.c @@ -707,9 +707,9 @@ HRESULT HTMLImgElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTML return S_OK; }
-static inline HTMLImageElementFactory *impl_from_IHTMLImageElementFactory(IHTMLImageElementFactory *iface) +static inline struct constructor *impl_from_IHTMLImageElementFactory(IHTMLImageElementFactory *iface) { - return CONTAINING_RECORD(iface, HTMLImageElementFactory, IHTMLImageElementFactory_iface); + return CONTAINING_RECORD(iface, struct constructor, iface); }
DISPEX_IDISPATCH_IMPL(HTMLImageElementFactory, IHTMLImageElementFactory, @@ -742,7 +742,7 @@ static LONG var_to_size(const VARIANT *v) static HRESULT WINAPI HTMLImageElementFactory_create(IHTMLImageElementFactory *iface, VARIANT width, VARIANT height, IHTMLImgElement **img_elem) { - HTMLImageElementFactory *This = impl_from_IHTMLImageElementFactory(iface); + struct constructor *This = impl_from_IHTMLImageElementFactory(iface); HTMLDocumentNode *doc = This->window->doc; IHTMLImgElement *img; HTMLElement *elem; @@ -796,51 +796,21 @@ static const IHTMLImageElementFactoryVtbl HTMLImageElementFactoryVtbl = { HTMLImageElementFactory_create };
-static inline HTMLImageElementFactory *impl_from_DispatchEx(DispatchEx *iface) -{ - return CONTAINING_RECORD(iface, HTMLImageElementFactory, dispex); -} - static void *HTMLImageElementFactory_query_interface(DispatchEx *dispex, REFIID riid) { - HTMLImageElementFactory *This = impl_from_DispatchEx(dispex); + struct constructor *This = constructor_from_DispatchEx(dispex);
if(IsEqualGUID(&IID_IHTMLImageElementFactory, riid)) - return &This->IHTMLImageElementFactory_iface; + return &This->iface;
return NULL; }
-static void HTMLImageElementFactory_traverse(DispatchEx *dispex, nsCycleCollectionTraversalCallback *cb) -{ - HTMLImageElementFactory *This = impl_from_DispatchEx(dispex); - - if(This->window) - note_cc_edge((nsISupports*)&This->window->base.IHTMLWindow2_iface, "window", cb); -} - -static void HTMLImageElementFactory_unlink(DispatchEx *dispex) -{ - HTMLImageElementFactory *This = impl_from_DispatchEx(dispex); - - if(This->window) { - HTMLInnerWindow *window = This->window; - This->window = NULL; - IHTMLWindow2_Release(&window->base.IHTMLWindow2_iface); - } -} - -static void HTMLImageElementFactory_destructor(DispatchEx *dispex) -{ - HTMLImageElementFactory *This = impl_from_DispatchEx(dispex); - free(This); -} - static HRESULT HTMLImageElementFactory_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller) { - HTMLImageElementFactory *This = impl_from_DispatchEx(dispex); + struct constructor *This = constructor_from_DispatchEx(dispex); IHTMLImgElement *img; VARIANT empty, *width, *height; HRESULT hres; @@ -853,7 +823,7 @@ static HRESULT HTMLImageElementFactory_value(DispatchEx *dispex, LCID lcid, width = argc >= 1 ? params->rgvarg + (params->cArgs - 1) : ∅ height = argc >= 2 ? params->rgvarg + (params->cArgs - 2) : ∅
- hres = IHTMLImageElementFactory_create(&This->IHTMLImageElementFactory_iface, *width, *height, + hres = IHTMLImageElementFactory_create((IHTMLImageElementFactory*)&This->iface, *width, *height, &img); if(FAILED(hres)) return hres; @@ -872,35 +842,24 @@ static void HTMLImageElementFactory_init_dispex_info(dispex_data_t *info, compat
static const dispex_static_data_vtbl_t HTMLImageElementFactory_dispex_vtbl = { .query_interface = HTMLImageElementFactory_query_interface, - .destructor = HTMLImageElementFactory_destructor, - .traverse = HTMLImageElementFactory_traverse, - .unlink = HTMLImageElementFactory_unlink, + .destructor = constructor_destructor, + .traverse = constructor_traverse, + .unlink = constructor_unlink, .value = HTMLImageElementFactory_value, };
-static HRESULT HTMLImageElementFactory_Create(HTMLInnerWindow *window, DispatchEx **ret_val) +static HRESULT HTMLImageElementFactory_init(struct constructor *constr) { - HTMLImageElementFactory *ret; - - ret = malloc(sizeof(HTMLImageElementFactory)); - if(!ret) - return E_OUTOFMEMORY; - - ret->IHTMLImageElementFactory_iface.lpVtbl = &HTMLImageElementFactoryVtbl; - ret->window = window; - IHTMLWindow2_AddRef(&window->base.IHTMLWindow2_iface); - - init_dispatch(&ret->dispex, &Image_dispex, window, - dispex_compat_mode(&window->event_target.dispex)); - - *ret_val = &ret->dispex; + constr->iface.lpVtbl = (const IUnknownVtbl*)&HTMLImageElementFactoryVtbl; + init_dispatch(&constr->dispex, &Image_dispex, constr->window, + dispex_compat_mode(&constr->window->event_target.dispex)); return S_OK; }
dispex_static_data_t Image_dispex = { .name = "Function", .constructor_id = OBJID_HTMLImageElement, - .init_constructor = HTMLImageElementFactory_Create, + .init_constructor = HTMLImageElementFactory_init, .vtbl = &HTMLImageElementFactory_dispex_vtbl, .disp_tid = IHTMLImageElementFactory_tid, .init_info = HTMLImageElementFactory_init_dispex_info, diff --git a/dlls/mshtml/htmlselect.c b/dlls/mshtml/htmlselect.c index 29875d91d7e..232f9104bc7 100644 --- a/dlls/mshtml/htmlselect.c +++ b/dlls/mshtml/htmlselect.c @@ -374,9 +374,9 @@ HRESULT HTMLOptionElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, H return S_OK; }
-static inline HTMLOptionElementFactory *impl_from_IHTMLOptionElementFactory(IHTMLOptionElementFactory *iface) +static inline struct constructor *impl_from_IHTMLOptionElementFactory(IHTMLOptionElementFactory *iface) { - return CONTAINING_RECORD(iface, HTMLOptionElementFactory, IHTMLOptionElementFactory_iface); + return CONTAINING_RECORD(iface, struct constructor, iface); }
DISPEX_IDISPATCH_IMPL(HTMLOptionElementFactory, IHTMLOptionElementFactory, @@ -386,7 +386,7 @@ static HRESULT WINAPI HTMLOptionElementFactory_create(IHTMLOptionElementFactory VARIANT text, VARIANT value, VARIANT defaultselected, VARIANT selected, IHTMLOptionElement **optelem) { - HTMLOptionElementFactory *This = impl_from_IHTMLOptionElementFactory(iface); + struct constructor *This = impl_from_IHTMLOptionElementFactory(iface); nsIDOMElement *nselem; HTMLDOMNode *node; HRESULT hres; @@ -438,51 +438,21 @@ static const IHTMLOptionElementFactoryVtbl HTMLOptionElementFactoryVtbl = { HTMLOptionElementFactory_create };
-static inline HTMLOptionElementFactory *HTMLOptionElementFactory_from_DispatchEx(DispatchEx *iface) -{ - return CONTAINING_RECORD(iface, HTMLOptionElementFactory, dispex); -} - static void *HTMLOptionElementFactory_query_interface(DispatchEx *dispex, REFIID riid) { - HTMLOptionElementFactory *This = HTMLOptionElementFactory_from_DispatchEx(dispex); + struct constructor *This = constructor_from_DispatchEx(dispex);
if(IsEqualGUID(&IID_IHTMLOptionElementFactory, riid)) - return &This->IHTMLOptionElementFactory_iface; + return &This->iface;
return NULL; }
-static void HTMLOptionElementFactory_traverse(DispatchEx *dispex, nsCycleCollectionTraversalCallback *cb) -{ - HTMLOptionElementFactory *This = HTMLOptionElementFactory_from_DispatchEx(dispex); - - if(This->window) - note_cc_edge((nsISupports*)&This->window->base.IHTMLWindow2_iface, "window", cb); -} - -static void HTMLOptionElementFactory_unlink(DispatchEx *dispex) -{ - HTMLOptionElementFactory *This = HTMLOptionElementFactory_from_DispatchEx(dispex); - - if(This->window) { - HTMLInnerWindow *window = This->window; - This->window = NULL; - IHTMLWindow2_Release(&window->base.IHTMLWindow2_iface); - } -} - -static void HTMLOptionElementFactory_destructor(DispatchEx *dispex) -{ - HTMLOptionElementFactory *This = HTMLOptionElementFactory_from_DispatchEx(dispex); - free(This); -} - static HRESULT HTMLOptionElementFactory_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller) { - HTMLOptionElementFactory *This = HTMLOptionElementFactory_from_DispatchEx(dispex); + struct constructor *This = constructor_from_DispatchEx(dispex); unsigned int i, argc = params->cArgs - params->cNamedArgs; IHTMLOptionElement *opt; VARIANT empty, *arg[4]; @@ -499,7 +469,7 @@ static HRESULT HTMLOptionElementFactory_value(DispatchEx *dispex, LCID lcid, for(i = 0; i < ARRAY_SIZE(arg); i++) arg[i] = argc > i ? ¶ms->rgvarg[params->cArgs - 1 - i] : ∅
- hres = IHTMLOptionElementFactory_create(&This->IHTMLOptionElementFactory_iface, + hres = IHTMLOptionElementFactory_create((IHTMLOptionElementFactory*)&This->iface, *arg[0], *arg[1], *arg[2], *arg[3], &opt); if(FAILED(hres)) return hres; @@ -518,35 +488,24 @@ static void HTMLOptionElementFactory_init_dispex_info(dispex_data_t *info, compa
static const dispex_static_data_vtbl_t HTMLOptionElementFactory_dispex_vtbl = { .query_interface = HTMLOptionElementFactory_query_interface, - .destructor = HTMLOptionElementFactory_destructor, - .traverse = HTMLOptionElementFactory_traverse, - .unlink = HTMLOptionElementFactory_unlink, + .destructor = constructor_destructor, + .traverse = constructor_traverse, + .unlink = constructor_unlink, .value = HTMLOptionElementFactory_value, };
-static HRESULT HTMLOptionElementFactory_Create(HTMLInnerWindow *window, DispatchEx **ret_ptr) +static HRESULT HTMLOptionElementFactory_init(struct constructor *constr) { - HTMLOptionElementFactory *ret; - - ret = malloc(sizeof(*ret)); - if(!ret) - return E_OUTOFMEMORY; - - ret->IHTMLOptionElementFactory_iface.lpVtbl = &HTMLOptionElementFactoryVtbl; - ret->window = window; - IHTMLWindow2_AddRef(&window->base.IHTMLWindow2_iface); - - init_dispatch(&ret->dispex, &Option_dispex, window, - dispex_compat_mode(&window->event_target.dispex)); - - *ret_ptr = &ret->dispex; + constr->iface.lpVtbl = (const IUnknownVtbl*)&HTMLOptionElementFactoryVtbl; + init_dispatch(&constr->dispex, &Option_dispex, constr->window, + dispex_compat_mode(&constr->window->event_target.dispex)); return S_OK; }
dispex_static_data_t Option_dispex = { .name = "Function", .constructor_id = OBJID_HTMLOptionElement, - .init_constructor = HTMLOptionElementFactory_Create, + .init_constructor = HTMLOptionElementFactory_init, .vtbl = &HTMLOptionElementFactory_dispex_vtbl, .disp_tid = IHTMLOptionElementFactory_tid, .init_info = HTMLOptionElementFactory_init_dispex_info, diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index cf8c2a5162b..50e0c869280 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -92,6 +92,7 @@ typedef struct ConnectionPoint ConnectionPoint; typedef struct BSCallback BSCallback; typedef struct EventTarget EventTarget; typedef struct ScriptHost ScriptHost; +struct constructor;
#define TID_LIST \ XIID(NULL) \ @@ -520,7 +521,7 @@ struct dispex_static_data_t { const tid_t disp_tid; const tid_t* const iface_tids; void (*init_info)(dispex_data_t*,compat_mode_t); - HRESULT (*init_constructor)(HTMLInnerWindow*,DispatchEx**); + HRESULT (*init_constructor)(struct constructor*); dispex_data_t *info_cache[COMPAT_MODE_CNT]; dispex_data_t *prototype_info[COMPAT_MODE_CNT - COMPAT_MODE_IE9]; dispex_data_t *delayed_init_info; @@ -657,6 +658,20 @@ typedef enum {
dispex_prop_type_t get_dispid_type(DISPID);
+struct constructor { + DispatchEx dispex; + IUnknown iface; + HTMLInnerWindow *window; +}; + +static inline struct constructor *constructor_from_DispatchEx(DispatchEx *iface) +{ + return CONTAINING_RECORD(iface, struct constructor, dispex); +} +void constructor_traverse(DispatchEx*,nsCycleCollectionTraversalCallback*); +void constructor_unlink(DispatchEx*); +void constructor_destructor(DispatchEx*); + typedef enum { GLOBAL_SCRIPTVAR, GLOBAL_ELEMENTVAR, @@ -677,20 +692,6 @@ struct EventTarget { struct wine_rb_tree handler_map; };
-typedef struct { - DispatchEx dispex; - IHTMLOptionElementFactory IHTMLOptionElementFactory_iface; - - HTMLInnerWindow *window; -} HTMLOptionElementFactory; - -typedef struct { - DispatchEx dispex; - IHTMLImageElementFactory IHTMLImageElementFactory_iface; - - HTMLInnerWindow *window; -} HTMLImageElementFactory; - struct HTMLLocation { DispatchEx dispex; IHTMLLocation IHTMLLocation_iface; diff --git a/dlls/mshtml/mutation.c b/dlls/mshtml/mutation.c index 91cc61b6191..0ba3ce4a62f 100644 --- a/dlls/mshtml/mutation.c +++ b/dlls/mshtml/mutation.c @@ -1198,7 +1198,7 @@ static void mutation_observer_destructor(DispatchEx *dispex) free(This); }
-static HRESULT create_mutation_observer_ctor(HTMLInnerWindow *script_global, DispatchEx **ret); +static HRESULT init_mutation_observer_ctor(struct constructor*);
static const dispex_static_data_vtbl_t mutation_observer_dispex_vtbl = { .query_interface = mutation_observer_query_interface, @@ -1213,7 +1213,7 @@ static const tid_t mutation_observer_iface_tids[] = { }; dispex_static_data_t MutationObserver_dispex = { .id = OBJID_MutationObserver, - .init_constructor = create_mutation_observer_ctor, + .init_constructor = init_mutation_observer_ctor, .vtbl = &mutation_observer_dispex_vtbl, .disp_tid = IWineMSHTMLMutationObserver_tid, .iface_tids = mutation_observer_iface_tids, @@ -1247,22 +1247,11 @@ struct mutation_observer_ctor { DispatchEx dispex; };
-static inline struct mutation_observer_ctor *mutation_observer_ctor_from_DispatchEx(DispatchEx *iface) -{ - return CONTAINING_RECORD(iface, struct mutation_observer_ctor, dispex); -} - -static void mutation_observer_ctor_destructor(DispatchEx *dispex) -{ - struct mutation_observer_ctor *This = mutation_observer_ctor_from_DispatchEx(dispex); - free(This); -} - static HRESULT mutation_observer_ctor_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller) { - struct mutation_observer_ctor *This = mutation_observer_ctor_from_DispatchEx(dispex); + struct constructor *This = constructor_from_DispatchEx(dispex); VARIANT *callback; IWineMSHTMLMutationObserver *mutation_observer; HRESULT hres; @@ -1305,7 +1294,9 @@ static HRESULT mutation_observer_ctor_value(DispatchEx *dispex, LCID lcid, }
static const dispex_static_data_vtbl_t mutation_observer_ctor_dispex_vtbl = { - .destructor = mutation_observer_ctor_destructor, + .destructor = constructor_destructor, + .traverse = constructor_traverse, + .unlink = constructor_unlink, .value = mutation_observer_ctor_value };
@@ -1315,20 +1306,9 @@ static dispex_static_data_t mutation_observer_ctor_dispex = { .vtbl = &mutation_observer_ctor_dispex_vtbl, };
-static HRESULT create_mutation_observer_ctor(HTMLInnerWindow *script_global, DispatchEx **ret) +static HRESULT init_mutation_observer_ctor(struct constructor *constr) { - struct mutation_observer_ctor *obj; - - obj = calloc(1, sizeof(*obj)); - if(!obj) - { - ERR("No memory.\n"); - return E_OUTOFMEMORY; - } - - init_dispatch(&obj->dispex, &mutation_observer_ctor_dispex, script_global, - dispex_compat_mode(&script_global->event_target.dispex)); - - *ret = &obj->dispex; + init_dispatch(&constr->dispex, &mutation_observer_ctor_dispex, constr->window, + dispex_compat_mode(&constr->window->event_target.dispex)); return S_OK; } diff --git a/dlls/mshtml/xmlhttprequest.c b/dlls/mshtml/xmlhttprequest.c index 109ef990f67..5845d56514c 100644 --- a/dlls/mshtml/xmlhttprequest.c +++ b/dlls/mshtml/xmlhttprequest.c @@ -36,13 +36,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
-typedef struct { - DispatchEx dispex; - IHTMLXMLHttpRequestFactory IHTMLXMLHttpRequestFactory_iface; - - HTMLInnerWindow *window; -} HTMLXMLHttpRequestFactory; - static HRESULT bstr_to_nsacstr(BSTR bstr, nsACString *str) { char *cstr = strdupWtoU(bstr); @@ -1490,9 +1483,9 @@ static const event_target_vtbl_t HTMLXMLHttpRequest_event_target_vtbl = { };
/* IHTMLXMLHttpRequestFactory */ -static inline HTMLXMLHttpRequestFactory *impl_from_IHTMLXMLHttpRequestFactory(IHTMLXMLHttpRequestFactory *iface) +static inline struct constructor *impl_from_IHTMLXMLHttpRequestFactory(IHTMLXMLHttpRequestFactory *iface) { - return CONTAINING_RECORD(iface, HTMLXMLHttpRequestFactory, IHTMLXMLHttpRequestFactory_iface); + return CONTAINING_RECORD(iface, struct constructor, iface); }
DISPEX_IDISPATCH_IMPL(HTMLXMLHttpRequestFactory, IHTMLXMLHttpRequestFactory, @@ -1500,7 +1493,7 @@ DISPEX_IDISPATCH_IMPL(HTMLXMLHttpRequestFactory, IHTMLXMLHttpRequestFactory,
static HRESULT WINAPI HTMLXMLHttpRequestFactory_create(IHTMLXMLHttpRequestFactory *iface, IHTMLXMLHttpRequest **p) { - HTMLXMLHttpRequestFactory *This = impl_from_IHTMLXMLHttpRequestFactory(iface); + struct constructor *This = impl_from_IHTMLXMLHttpRequestFactory(iface); HTMLXMLHttpRequest *ret; nsIXMLHttpRequest *nsxhr; nsIDOMEventTarget *nstarget; @@ -1577,50 +1570,20 @@ static const IHTMLXMLHttpRequestFactoryVtbl HTMLXMLHttpRequestFactoryVtbl = { HTMLXMLHttpRequestFactory_create };
-static inline HTMLXMLHttpRequestFactory *factory_from_DispatchEx(DispatchEx *iface) -{ - return CONTAINING_RECORD(iface, HTMLXMLHttpRequestFactory, dispex); -} - static void *HTMLXMLHttpRequestFactory_query_interface(DispatchEx *dispex, REFIID riid) { - HTMLXMLHttpRequestFactory *This = factory_from_DispatchEx(dispex); + struct constructor *This = constructor_from_DispatchEx(dispex);
if(IsEqualGUID(&IID_IHTMLXMLHttpRequestFactory, riid)) - return &This->IHTMLXMLHttpRequestFactory_iface; + return &This->iface;
return NULL; }
-static void HTMLXMLHttpRequestFactory_traverse(DispatchEx *dispex, nsCycleCollectionTraversalCallback *cb) -{ - HTMLXMLHttpRequestFactory *This = factory_from_DispatchEx(dispex); - - if(This->window) - note_cc_edge((nsISupports*)&This->window->base.IHTMLWindow2_iface, "window", cb); -} - -static void HTMLXMLHttpRequestFactory_unlink(DispatchEx *dispex) -{ - HTMLXMLHttpRequestFactory *This = factory_from_DispatchEx(dispex); - - if(This->window) { - HTMLInnerWindow *window = This->window; - This->window = NULL; - IHTMLWindow2_Release(&window->base.IHTMLWindow2_iface); - } -} - -static void HTMLXMLHttpRequestFactory_destructor(DispatchEx *dispex) -{ - HTMLXMLHttpRequestFactory *This = factory_from_DispatchEx(dispex); - free(This); -} - static HRESULT HTMLXMLHttpRequestFactory_value(DispatchEx *iface, LCID lcid, WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller) { - HTMLXMLHttpRequestFactory *This = factory_from_DispatchEx(iface); + struct constructor *This = constructor_from_DispatchEx(iface); IHTMLXMLHttpRequest *xhr; HRESULT hres;
@@ -1631,7 +1594,7 @@ static HRESULT HTMLXMLHttpRequestFactory_value(DispatchEx *iface, LCID lcid, WOR return E_NOTIMPL; }
- hres = IHTMLXMLHttpRequestFactory_create(&This->IHTMLXMLHttpRequestFactory_iface, &xhr); + hres = IHTMLXMLHttpRequestFactory_create((IHTMLXMLHttpRequestFactory*)&This->iface, &xhr); if(FAILED(hres)) return hres;
@@ -1642,9 +1605,9 @@ static HRESULT HTMLXMLHttpRequestFactory_value(DispatchEx *iface, LCID lcid, WOR
static const dispex_static_data_vtbl_t HTMLXMLHttpRequestFactory_dispex_vtbl = { .query_interface = HTMLXMLHttpRequestFactory_query_interface, - .destructor = HTMLXMLHttpRequestFactory_destructor, - .traverse = HTMLXMLHttpRequestFactory_traverse, - .unlink = HTMLXMLHttpRequestFactory_unlink, + .destructor = constructor_destructor, + .traverse = constructor_traverse, + .unlink = constructor_unlink, .value = HTMLXMLHttpRequestFactory_value };
@@ -1660,22 +1623,11 @@ static dispex_static_data_t HTMLXMLHttpRequestFactory_dispex = { .iface_tids = HTMLXMLHttpRequestFactory_iface_tids, };
-static HRESULT HTMLXMLHttpRequestFactory_Create(HTMLInnerWindow *window, DispatchEx **ret_ptr) +static HRESULT HTMLXMLHttpRequestFactory_init(struct constructor *constr) { - HTMLXMLHttpRequestFactory *ret; - - ret = malloc(sizeof(*ret)); - if(!ret) - return E_OUTOFMEMORY; - - ret->IHTMLXMLHttpRequestFactory_iface.lpVtbl = &HTMLXMLHttpRequestFactoryVtbl; - ret->window = window; - IHTMLWindow2_AddRef(&window->base.IHTMLWindow2_iface); - - init_dispatch(&ret->dispex, &HTMLXMLHttpRequestFactory_dispex, window, - dispex_compat_mode(&window->event_target.dispex)); - - *ret_ptr = &ret->dispex; + constr->iface.lpVtbl = (const IUnknownVtbl*)&HTMLXMLHttpRequestFactoryVtbl; + init_dispatch(&constr->dispex, &HTMLXMLHttpRequestFactory_dispex, constr->window, + dispex_compat_mode(&constr->window->event_target.dispex)); return S_OK; }
@@ -1685,7 +1637,7 @@ static const tid_t HTMLXMLHttpRequest_iface_tids[] = { }; dispex_static_data_t XMLHttpRequest_dispex = { .id = OBJID_XMLHttpRequest, - .init_constructor = HTMLXMLHttpRequestFactory_Create, + .init_constructor = HTMLXMLHttpRequestFactory_init, .vtbl = &HTMLXMLHttpRequest_event_target_vtbl.dispex_vtbl, .disp_tid = DispHTMLXMLHttpRequest_tid, .iface_tids = HTMLXMLHttpRequest_iface_tids,