From: Jacek Caban jacek@codeweavers.com
--- dlls/mshtml/htmlimg.c | 16 +++++++++------- dlls/mshtml/mshtml_private.h | 1 + dlls/mshtml/tests/documentmode.js | 2 ++ 3 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/dlls/mshtml/htmlimg.c b/dlls/mshtml/htmlimg.c index fb3be13b918..9295c5cc2e2 100644 --- a/dlls/mshtml/htmlimg.c +++ b/dlls/mshtml/htmlimg.c @@ -683,12 +683,14 @@ static void HTMLImgElement_init_dispex_info(dispex_data_t *info, compat_mode_t m dispex_info_add_interface(info, IHTMLImgElement_tid, mode >= COMPAT_MODE_IE11 ? img_ie11_hooks : NULL); }
-static dispex_static_data_t HTMLImgElement_dispex = { - "HTMLImageElement", - &HTMLImgElement_event_target_vtbl.dispex_vtbl, - DispHTMLImg_tid, - HTMLImgElement_iface_tids, - HTMLImgElement_init_dispex_info +dispex_static_data_t HTMLImageElement_dispex = { + .name = "HTMLImageElement", + .id = PROT_HTMLImageElement, + .prototype_id = PROT_HTMLElement, + .vtbl = &HTMLImgElement_event_target_vtbl.dispex_vtbl, + .disp_tid = DispHTMLImg_tid, + .iface_tids = HTMLImgElement_iface_tids, + .init_info = HTMLImgElement_init_dispex_info, };
HRESULT HTMLImgElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem) @@ -703,7 +705,7 @@ HRESULT HTMLImgElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTML ret->IHTMLImgElement_iface.lpVtbl = &HTMLImgElementVtbl; ret->element.node.vtbl = &HTMLImgElementImplVtbl;
- HTMLElement_Init(&ret->element, doc, nselem, &HTMLImgElement_dispex); + HTMLElement_Init(&ret->element, doc, nselem, &HTMLImageElement_dispex);
nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLImageElement, (void**)&ret->nsimg); assert(nsres == NS_OK); diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index e5f842a2f4d..21b2866de2c 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -413,6 +413,7 @@ typedef struct { X(HTMLBodyElement) \ X(HTMLDocument) \ X(HTMLElement) \ + X(HTMLImageElement) \ X(Navigator) \ X(Node) \ X(Storage) \ diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index 08e2daeff1e..40dc74ccfcf 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -3136,4 +3136,6 @@ sync_test("prototypes", function() { } check(window, Window.prototype, "window"); check(Window.prototype, Object.prototype, "window prototype"); + check(document.createElement("img"), HTMLImageElement.prototype, "img elem"); + check(HTMLImageElement.prototype, HTMLElement.prototype, "img elem prototype"); });
From: Jacek Caban jacek@codeweavers.com
Based on patch by Gabriel Ivăncescu. --- dlls/jscript/function.c | 125 +++++++++++++++++++++++++++++++++++++++ dlls/jscript/jscript.c | 8 +++ dlls/jscript/jscript.h | 1 + dlls/jscript/jsdisp.idl | 2 + dlls/mshtml/dispex.c | 11 ++++ dlls/mshtml/htmlwindow.c | 10 ++++ 6 files changed, 157 insertions(+)
diff --git a/dlls/jscript/function.c b/dlls/jscript/function.c index ceaf50e8538..c814f8fd4f6 100644 --- a/dlls/jscript/function.c +++ b/dlls/jscript/function.c @@ -70,6 +70,11 @@ typedef struct { UINT32 iid; } HostFunction;
+typedef struct { + FunctionInstance function; + IWineJSDispatchHost *host_iface; +} HostConstructor; + typedef struct { jsdisp_t jsdisp; jsval_t *buf; @@ -1083,6 +1088,126 @@ HRESULT create_host_function(script_ctx_t *ctx, const struct property_info *desc return S_OK; }
+static ULONG HostConstructor_addref(jsdisp_t *jsdisp) +{ + HostConstructor *constr = (HostConstructor*)jsdisp; + return IWineJSDispatchHost_AddRef(constr->host_iface); +} + +static ULONG HostConstructor_release(jsdisp_t *jsdisp) +{ + HostConstructor *constr = (HostConstructor*)jsdisp; + return IWineJSDispatchHost_Release(constr->host_iface); +} + +static HRESULT HostConstructor_lookup_prop(jsdisp_t *jsdisp, const WCHAR *name, unsigned flags, struct property_info *desc) +{ + HostConstructor *constr = (HostConstructor*)jsdisp; + HRESULT hres = IWineJSDispatchHost_LookupProperty(constr->host_iface, name, flags, desc); + assert(hres != S_OK || desc->func_iid); /* external properties are not allowed */ + return hres; +} + +static const builtin_info_t HostConstructor_info = { + .class = JSCLASS_FUNCTION, + .addref = HostConstructor_addref, + .release = HostConstructor_release, + .call = Function_value, + .destructor = Function_destructor, + .gc_traverse = Function_gc_traverse, + .lookup_prop = HostConstructor_lookup_prop, +}; + +static HRESULT HostConstructor_call(script_ctx_t *ctx, FunctionInstance *func, jsval_t vthis, unsigned flags, + unsigned argc, jsval_t *argv, jsval_t *r) +{ + HostConstructor *function = (HostConstructor*)func; + VARIANT buf[6], ret; + DISPPARAMS dp = { .cArgs = argc, .rgvarg = buf }; + EXCEPINFO ei = { 0 }; + HRESULT hres; + unsigned i; + + flags &= ~DISPATCH_JSCRIPT_INTERNAL_MASK; + if(argc > ARRAYSIZE(buf) && !(dp.rgvarg = malloc(argc * sizeof(*dp.rgvarg)))) + return E_OUTOFMEMORY; + + for(i = 0; i < argc; i++) { + hres = jsval_to_variant(argv[i], &dp.rgvarg[dp.cArgs - i - 1]); + if(FAILED(hres)) + break; + } + + if(SUCCEEDED(hres)) { + V_VT(&ret) = VT_EMPTY; + hres = IWineJSDispatchHost_Construct(function->host_iface, ctx->lcid, flags, &dp, &ret, &ei, + &ctx->jscaller->IServiceProvider_iface); + if(hres == DISP_E_EXCEPTION) + handle_dispatch_exception(ctx, &ei); + if(SUCCEEDED(hres) && r) { + hres = variant_to_jsval(ctx, &ret, r); + VariantClear(&ret); + } + } + + while(i--) + VariantClear(&dp.rgvarg[dp.cArgs - i - 1]); + if(dp.rgvarg != buf) + free(dp.rgvarg); + return hres; +} + +static HRESULT HostConstructor_toString(FunctionInstance *function, jsstr_t **ret) +{ + *ret = jsstr_alloc(L"\nfunction() {\n [native code]\n}\n"); + return *ret ? S_OK : E_OUTOFMEMORY; +} + +static function_code_t *HostConstructor_get_code(FunctionInstance *function) +{ + return NULL; +} + +static void HostConstructor_destructor(FunctionInstance *func) +{ +} + +static HRESULT HostConstructor_gc_traverse(struct gc_ctx *gc_ctx, enum gc_traverse_op op, FunctionInstance *func) +{ + return S_OK; +} + +static const function_vtbl_t HostConstructorVtbl = { + HostConstructor_call, + HostConstructor_toString, + HostConstructor_get_code, + HostConstructor_destructor, + HostConstructor_gc_traverse +}; + +HRESULT init_host_constructor(script_ctx_t *ctx, IWineJSDispatchHost *host_constr, IWineJSDispatch *prototype, + IWineJSDispatch **ret) +{ + HostConstructor *function; + HRESULT hres; + + hres = create_function(ctx, &HostConstructor_info, &HostConstructorVtbl, sizeof(*function), PROPF_METHOD, + FALSE, NULL, (void**)&function); + if(FAILED(hres)) + return hres; + function->host_iface = host_constr; + + hres = jsdisp_define_data_property(&function->function.dispex, L"prototype", PROPF_WRITABLE | PROPF_CONFIGURABLE, + jsval_disp((IDispatch *)prototype)); + if(FAILED(hres)) { + IWineJSDispatch_Free(&function->function.dispex.IWineJSDispatch_iface); + return hres; + } + + *ret = &function->function.dispex.IWineJSDispatch_iface; + return S_OK; +} + static HRESULT BindFunction_get_arguments(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r) { return JS_E_INVALID_ACTION; diff --git a/dlls/jscript/jscript.c b/dlls/jscript/jscript.c index 5822cf1222f..c42109b4143 100644 --- a/dlls/jscript/jscript.c +++ b/dlls/jscript/jscript.c @@ -1458,11 +1458,19 @@ static HRESULT WINAPI WineJScript_InitHostObject(IWineJScript *iface, IWineJSDis return init_host_object(This->ctx, host_obj, prototype, flags, ret); }
+static HRESULT WINAPI WineJScript_InitHostConstructor(IWineJScript *iface, IWineJSDispatchHost *constr, + IWineJSDispatch *prototype, IWineJSDispatch **ret) +{ + JScript *This = impl_from_IWineJScript(iface); + return init_host_constructor(This->ctx, constr, prototype, ret); +} + static const IWineJScriptVtbl WineJScriptVtbl = { WineJScript_QueryInterface, WineJScript_AddRef, WineJScript_Release, WineJScript_InitHostObject, + WineJScript_InitHostConstructor, };
HRESULT create_jscript_object(BOOL is_encode, REFIID riid, void **ppv) diff --git a/dlls/jscript/jscript.h b/dlls/jscript/jscript.h index 5e3640b69b7..b413b4d1ae9 100644 --- a/dlls/jscript/jscript.h +++ b/dlls/jscript/jscript.h @@ -244,6 +244,7 @@ HRESULT create_dispex(script_ctx_t*,const builtin_info_t*,jsdisp_t*,jsdisp_t**); HRESULT init_dispex(jsdisp_t*,script_ctx_t*,const builtin_info_t*,jsdisp_t*); HRESULT init_dispex_from_constr(jsdisp_t*,script_ctx_t*,const builtin_info_t*,jsdisp_t*); HRESULT init_host_object(script_ctx_t*,IWineJSDispatchHost*,IWineJSDispatch*,UINT32,IWineJSDispatch**); +HRESULT init_host_constructor(script_ctx_t*,IWineJSDispatchHost*,IWineJSDispatch*,IWineJSDispatch**);
HRESULT disp_call(script_ctx_t*,IDispatch*,DISPID,WORD,unsigned,jsval_t*,jsval_t*); HRESULT disp_call_name(script_ctx_t*,IDispatch*,const WCHAR*,WORD,unsigned,jsval_t*,jsval_t*); diff --git a/dlls/jscript/jsdisp.idl b/dlls/jscript/jsdisp.idl index a1b63579fce..bae00d40a3d 100644 --- a/dlls/jscript/jsdisp.idl +++ b/dlls/jscript/jsdisp.idl @@ -66,6 +66,7 @@ interface IWineJSDispatchHost : IDispatchEx HRESULT DeleteProperty(DISPID id); HRESULT ConfigureProperty(DISPID id, UINT32 flags); HRESULT CallFunction(DISPID id, UINT32 iid, DISPPARAMS *dp, VARIANT *ret, EXCEPINFO *ei, IServiceProvider *caller); + HRESULT Construct(LCID lcid, DWORD flags, DISPPARAMS *dp, VARIANT *ret, EXCEPINFO *ei, IServiceProvider *caller); HRESULT GetOuterDispatch(IWineJSDispatchHost **ret); HRESULT ToString(BSTR *str); } @@ -78,4 +79,5 @@ interface IWineJSDispatchHost : IDispatchEx interface IWineJScript : IUnknown { HRESULT InitHostObject(IWineJSDispatchHost *host_obj, IWineJSDispatch *prototype, UINT32 flags, IWineJSDispatch **ret); + HRESULT InitHostConstructor(IWineJSDispatchHost *constr, IWineJSDispatch *prototype, IWineJSDispatch **ret); } diff --git a/dlls/mshtml/dispex.c b/dlls/mshtml/dispex.c index 817547581e3..d4c560bab75 100644 --- a/dlls/mshtml/dispex.c +++ b/dlls/mshtml/dispex.c @@ -2551,6 +2551,16 @@ static HRESULT WINAPI JSDispatchHost_CallFunction(IWineJSDispatchHost *iface, DI return call_builtin_function(This, func, dp, ret, ei, caller); }
+static HRESULT WINAPI JSDispatchHost_Construct(IWineJSDispatchHost *iface, LCID lcid, DWORD flags, DISPPARAMS *dp, VARIANT *ret, + EXCEPINFO *ei, IServiceProvider *caller) +{ + DispatchEx *This = impl_from_IWineJSDispatchHost(iface); + + TRACE("%s (%p)->(%p %p %p %p)\n", This->info->name, This, dp, ret, ei, caller); + + return dispex_prop_call(This, DISPID_VALUE, lcid, flags, dp, ret, ei, caller); +} + static HRESULT WINAPI JSDispatchHost_GetOuterDispatch(IWineJSDispatchHost *iface, IWineJSDispatchHost **ret) { DispatchEx *This = impl_from_IWineJSDispatchHost(iface); @@ -2592,6 +2602,7 @@ static IWineJSDispatchHostVtbl JSDispatchHostVtbl = { JSDispatchHost_DeleteProperty, JSDispatchHost_ConfigureProperty, JSDispatchHost_CallFunction, + JSDispatchHost_Construct, JSDispatchHost_GetOuterDispatch, JSDispatchHost_ToString, }; diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c index a2afcdfdfbc..c9ad3dbd0c3 100644 --- a/dlls/mshtml/htmlwindow.c +++ b/dlls/mshtml/htmlwindow.c @@ -3505,6 +3505,15 @@ static HRESULT WINAPI WindowDispEx_CallFunction(IWineJSDispatchHost *iface, DISP id, iid, dp, ret, ei, caller); }
+static HRESULT WINAPI WindowDispEx_Construct(IWineJSDispatchHost *iface, LCID lcid, DWORD flags, DISPPARAMS *dp, VARIANT *ret, + EXCEPINFO *ei, IServiceProvider *caller) +{ + HTMLOuterWindow *This = impl_from_IWineJSDispatchHost(iface); + + return IWineJSDispatchHost_Construct(&This->base.inner_window->event_target.dispex.IWineJSDispatchHost_iface, + lcid, flags, dp, ret, ei, caller); +} + static HRESULT WINAPI WindowDispEx_GetOuterDispatch(IWineJSDispatchHost *iface, IWineJSDispatchHost **ret) { HTMLOuterWindow *This = impl_from_IWineJSDispatchHost(iface); @@ -3545,6 +3554,7 @@ static const IWineJSDispatchHostVtbl WindowDispExVtbl = { WindowDispEx_DeleteProperty, WindowDispEx_ConfigureProperty, WindowDispEx_CallFunction, + WindowDispEx_Construct, WindowDispEx_GetOuterDispatch, WindowDispEx_ToString, };
From: Jacek Caban jacek@codeweavers.com
--- dlls/mshtml/dispex.c | 13 ++++++++++--- dlls/mshtml/htmlimg.c | 11 ++++++----- dlls/mshtml/mshtml_private.h | 1 + dlls/mshtml/tests/documentmode.js | 1 + dlls/mshtml/tests/es5.js | 5 +++++ 5 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/dlls/mshtml/dispex.c b/dlls/mshtml/dispex.c index d4c560bab75..c464d6f5607 100644 --- a/dlls/mshtml/dispex.c +++ b/dlls/mshtml/dispex.c @@ -1800,9 +1800,16 @@ static void init_host_object(DispatchEx *dispex, HTMLInnerWindow *script_global, if(!script_global->jscript) initialize_script_global(script_global); if(script_global->jscript && !dispex->jsdisp) { - hres = IWineJScript_InitHostObject(script_global->jscript, &dispex->IWineJSDispatchHost_iface, - prototype ? prototype->jsdisp : NULL, - dispex->info->desc->js_flags, &dispex->jsdisp); + if(dispex->info->desc->constructor_id) { + DispatchEx *prototype; + if(FAILED(hres = get_prototype(script_global, dispex->info->desc->constructor_id, &prototype))) + return; + hres = IWineJScript_InitHostConstructor(script_global->jscript, &dispex->IWineJSDispatchHost_iface, + prototype->jsdisp, &dispex->jsdisp); + }else + hres = IWineJScript_InitHostObject(script_global->jscript, &dispex->IWineJSDispatchHost_iface, + prototype ? prototype->jsdisp : NULL, + dispex->info->desc->js_flags, &dispex->jsdisp); if(FAILED(hres)) ERR("Failed to initialize jsdisp: %08lx\n", hres); } diff --git a/dlls/mshtml/htmlimg.c b/dlls/mshtml/htmlimg.c index 9295c5cc2e2..08119464806 100644 --- a/dlls/mshtml/htmlimg.c +++ b/dlls/mshtml/htmlimg.c @@ -885,10 +885,11 @@ static const dispex_static_data_vtbl_t HTMLImageElementFactory_dispex_vtbl = { };
static dispex_static_data_t HTMLImageElementFactory_dispex = { - "Function", - &HTMLImageElementFactory_dispex_vtbl, - IHTMLImageElementFactory_tid, - HTMLImageElementFactory_iface_tids + .name = "Function", + .constructor_id = PROT_HTMLImageElement, + .vtbl = &HTMLImageElementFactory_dispex_vtbl, + .disp_tid = IHTMLImageElementFactory_tid, + .iface_tids = HTMLImageElementFactory_iface_tids, };
HRESULT HTMLImageElementFactory_Create(HTMLInnerWindow *window, HTMLImageElementFactory **ret_val) @@ -903,7 +904,7 @@ HRESULT HTMLImageElementFactory_Create(HTMLInnerWindow *window, HTMLImageElement ret->window = window; IHTMLWindow2_AddRef(&window->base.IHTMLWindow2_iface);
- init_dispatch(&ret->dispex, &HTMLImageElementFactory_dispex, NULL, + init_dispatch(&ret->dispex, &HTMLImageElementFactory_dispex, window, dispex_compat_mode(&window->event_target.dispex));
*ret_val = ret; diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index 21b2866de2c..9d5833b7e09 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -438,6 +438,7 @@ typedef struct { dispex_data_t *delayed_init_info; prototype_id_t id; prototype_id_t prototype_id; + prototype_id_t constructor_id; UINT32 js_flags; char prototype_name[64]; } dispex_static_data_t; diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index 40dc74ccfcf..14c797a10da 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -3138,4 +3138,5 @@ sync_test("prototypes", function() { check(Window.prototype, Object.prototype, "window prototype"); check(document.createElement("img"), HTMLImageElement.prototype, "img elem"); check(HTMLImageElement.prototype, HTMLElement.prototype, "img elem prototype"); + check(Image, Function.prototype, "Image constructor"); }); diff --git a/dlls/mshtml/tests/es5.js b/dlls/mshtml/tests/es5.js index b5fdbdf708a..f049a526bf4 100644 --- a/dlls/mshtml/tests/es5.js +++ b/dlls/mshtml/tests/es5.js @@ -2761,6 +2761,11 @@ sync_test("prototypes", function() { ok(!Element.prototype.hasOwnProperty("removeChild"), "Element prototype has own removeChild property"); ok(Node.prototype.hasOwnProperty("removeChild"), "Node prototype does not have own removeChild property");
+ ok(Image != HTMLImageElement, "Image == HTMLImageElement"); + ok(typeof(HTMLImageElement) === "object", "typeof(HTMLImageElement) = " + typeof(HTMLImageElement)); + ok(typeof(Image) === "function", "typeof(Image) = " + typeof(Image)); + ok(Image.prototype === HTMLImageElement.prototype, "Image.prototype != HTMLImageElement.prototype"); + ok(document.implementation instanceof DOMImplementation, "document.implementation is not an instance of DOMImplementation"); ok(navigator instanceof Navigator, "navigator is not an instance of Navigator"); ok(!(navigator instanceof DOMImplementation), "navigator is an instance of DOMImplementation");
From: Jacek Caban jacek@codeweavers.com
--- dlls/mshtml/dispex.c | 24 +++++++++++++------ dlls/mshtml/htmlwindow.c | 19 +++++----------- dlls/mshtml/mshtml_private.h | 14 ++++-------- dlls/mshtml/tests/documentmode.js | 3 +++ dlls/mshtml/tests/es5.js | 15 ++++++++++++ dlls/mshtml/xmlhttprequest.c | 38 +++++++++++++++++++------------ 6 files changed, 69 insertions(+), 44 deletions(-)
diff --git a/dlls/mshtml/dispex.c b/dlls/mshtml/dispex.c index c464d6f5607..65139c88b77 100644 --- a/dlls/mshtml/dispex.c +++ b/dlls/mshtml/dispex.c @@ -2934,7 +2934,7 @@ static dispex_static_data_t constructor_dispex = {
HRESULT get_constructor(HTMLInnerWindow *script_global, prototype_id_t id, DispatchEx **ret) { - struct constructor *constr; + dispex_static_data_t *info;
assert(script_global->doc->document_mode >= COMPAT_MODE_IE9);
@@ -2943,13 +2943,23 @@ HRESULT get_constructor(HTMLInnerWindow *script_global, prototype_id_t id, Dispa return S_OK; }
- if(!(constr = calloc(sizeof(*constr), 1))) - return E_OUTOFMEMORY; + info = object_descriptors[id]; + if(info->init_constructor) { + HRESULT hres = info->init_constructor(script_global, &script_global->constructors[id]); + if(FAILED(hres)) + return hres; + }else { + struct constructor *constr; + if(!(constr = calloc(sizeof(*constr), 1))) + return E_OUTOFMEMORY; + + init_dispatch(&constr->dispex, &constructor_dispex, script_global, + dispex_compat_mode(&script_global->event_target.dispex)); + constr->id = id; + script_global->constructors[id] = &constr->dispex; + }
- init_dispatch(&constr->dispex, &constructor_dispex, script_global, - dispex_compat_mode(&script_global->event_target.dispex)); - constr->id = id; - *ret = script_global->constructors[id] = &constr->dispex; + *ret = script_global->constructors[id]; return S_OK;
} diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c index c9ad3dbd0c3..6c6ad2178eb 100644 --- a/dlls/mshtml/htmlwindow.c +++ b/dlls/mshtml/htmlwindow.c @@ -1921,17 +1921,16 @@ static HRESULT WINAPI HTMLWindow5_get_XMLHttpRequest(IHTMLWindow5 *iface, VARIAN return S_OK; }
- if(!window->xhr_factory) { + if(!window->constructors[PROT_XMLHttpRequest]) { HRESULT hres;
- hres = HTMLXMLHttpRequestFactory_Create(window, &window->xhr_factory); - if(FAILED(hres)) { + hres = HTMLXMLHttpRequestFactory_Create(window, &window->constructors[PROT_XMLHttpRequest]); + if(FAILED(hres)) return hres; - } }
V_VT(p) = VT_DISPATCH; - V_DISPATCH(p) = (IDispatch*)&window->xhr_factory->IHTMLXMLHttpRequestFactory_iface; + V_DISPATCH(p) = (IDispatch*)&window->constructors[PROT_XMLHttpRequest]->IWineJSDispatchHost_iface; IDispatch_AddRef(V_DISPATCH(p));
return S_OK; @@ -3709,8 +3708,6 @@ static void HTMLWindow_traverse(DispatchEx *dispex, nsCycleCollectionTraversalCa note_cc_edge((nsISupports*)&This->image_factory->IHTMLImageElementFactory_iface, "image_factory", cb); if(This->option_factory) note_cc_edge((nsISupports*)&This->option_factory->IHTMLOptionElementFactory_iface, "option_factory", cb); - if(This->xhr_factory) - note_cc_edge((nsISupports*)&This->xhr_factory->IHTMLXMLHttpRequestFactory_iface, "xhr_factory", cb); if(This->mutation_observer_ctor) note_cc_edge((nsISupports*)This->mutation_observer_ctor, "mutation_observer_ctor", cb); if(This->screen) @@ -3761,11 +3758,6 @@ static void HTMLWindow_unlink(DispatchEx *dispex) This->option_factory = NULL; IHTMLOptionElementFactory_Release(&option_factory->IHTMLOptionElementFactory_iface); } - if(This->xhr_factory) { - HTMLXMLHttpRequestFactory *xhr_factory = This->xhr_factory; - This->xhr_factory = NULL; - IHTMLXMLHttpRequestFactory_Release(&xhr_factory->IHTMLXMLHttpRequestFactory_iface); - } unlink_ref(&This->mutation_observer_ctor); unlink_ref(&This->screen); if(This->history) { @@ -4184,7 +4176,8 @@ static void HTMLWindow_init_dispex_info(dispex_data_t *info, compat_mode_t compa compat_mode >= COMPAT_MODE_IE11 ? NULL : private_ie10_hooks);
dispex_info_add_interface(info, IHTMLWindow6_tid, window6_hooks); - dispex_info_add_interface(info, IHTMLWindow5_tid, NULL); + if(compat_mode < COMPAT_MODE_IE9) + dispex_info_add_interface(info, IHTMLWindow5_tid, NULL); dispex_info_add_interface(info, IHTMLWindow4_tid, compat_mode >= COMPAT_MODE_IE11 ? window4_ie11_hooks : NULL); dispex_info_add_interface(info, IHTMLWindow3_tid, compat_mode >= COMPAT_MODE_IE11 ? window3_ie11_hooks : window3_hooks); dispex_info_add_interface(info, IHTMLWindow2_tid, compat_mode >= COMPAT_MODE_IE11 ? window2_ie11_hooks : window2_hooks); diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index 9d5833b7e09..40b81df8f6b 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -417,7 +417,8 @@ typedef struct { X(Navigator) \ X(Node) \ X(Storage) \ - X(Window) + X(Window) \ + X(XMLHttpRequest)
typedef enum { PROT_NONE, @@ -433,6 +434,7 @@ typedef struct { 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**); 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; @@ -599,13 +601,6 @@ typedef struct { HTMLInnerWindow *window; } HTMLImageElementFactory;
-typedef struct { - DispatchEx dispex; - IHTMLXMLHttpRequestFactory IHTMLXMLHttpRequestFactory_iface; - - HTMLInnerWindow *window; -} HTMLXMLHttpRequestFactory; - struct HTMLLocation { DispatchEx dispex; IHTMLLocation IHTMLLocation_iface; @@ -689,7 +684,6 @@ struct HTMLInnerWindow {
HTMLImageElementFactory *image_factory; HTMLOptionElementFactory *option_factory; - HTMLXMLHttpRequestFactory *xhr_factory; IHTMLScreen *screen; OmHistory *history; IOmNavigator *navigator; @@ -1094,7 +1088,7 @@ HTMLOuterWindow *mozwindow_to_window(const mozIDOMWindowProxy*); void get_top_window(HTMLOuterWindow*,HTMLOuterWindow**); HRESULT HTMLOptionElementFactory_Create(HTMLInnerWindow*,HTMLOptionElementFactory**); HRESULT HTMLImageElementFactory_Create(HTMLInnerWindow*,HTMLImageElementFactory**); -HRESULT HTMLXMLHttpRequestFactory_Create(HTMLInnerWindow*,HTMLXMLHttpRequestFactory**); +HRESULT HTMLXMLHttpRequestFactory_Create(HTMLInnerWindow*,DispatchEx**); HRESULT create_location(HTMLOuterWindow*,HTMLLocation**); HRESULT create_navigator(HTMLInnerWindow*,IOmNavigator**); HRESULT create_html_screen(HTMLInnerWindow*,IHTMLScreen**); diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index 14c797a10da..e933358c706 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -3136,6 +3136,9 @@ sync_test("prototypes", function() { } check(window, Window.prototype, "window"); check(Window.prototype, Object.prototype, "window prototype"); + check(new XMLHttpRequest(), XMLHttpRequest.prototype, "xhr"); + check(XMLHttpRequest.prototype, Object.prototype, "xhr prototype"); + check(XMLHttpRequest, Function.prototype, "xhr constructor"); check(document.createElement("img"), HTMLImageElement.prototype, "img elem"); check(HTMLImageElement.prototype, HTMLElement.prototype, "img elem prototype"); check(Image, Function.prototype, "Image constructor"); diff --git a/dlls/mshtml/tests/es5.js b/dlls/mshtml/tests/es5.js index f049a526bf4..c44d6d6667d 100644 --- a/dlls/mshtml/tests/es5.js +++ b/dlls/mshtml/tests/es5.js @@ -2761,6 +2761,21 @@ sync_test("prototypes", function() { ok(!Element.prototype.hasOwnProperty("removeChild"), "Element prototype has own removeChild property"); ok(Node.prototype.hasOwnProperty("removeChild"), "Node prototype does not have own removeChild property");
+ test_own_data_prop_desc(window, "XMLHttpRequest", true, false, true); + ok(typeof(XMLHttpRequest) === "function", "typeof(XMLHttpRequest) = " + typeof(XMLHttpRequest)); + ok(XMLHttpRequest.hasOwnProperty("create"), "XMLHttpRequest does not have create property"); + ok(Object.getPrototypeOf(XMLHttpRequest) === Function.prototype, + "Object.getPrototypeOf(XMLHttpRequest) = " + Object.getPrototypeOf(XMLHttpRequest)); + ok(XMLHttpRequest.prototype.constructor === XMLHttpRequest, + "XMLHttpRequest.prototype.constructor !== XMLHttpRequest"); + var xhr = new XMLHttpRequest(); + ok(Object.getPrototypeOf(xhr) === XMLHttpRequest.prototype, + "Object.getPrototypeOf(xhr) = " + Object.getPrototypeOf(xhr)); + constr = XMLHttpRequest; + XMLHttpRequest = 1; + ok(XMLHttpRequest === 1, "XMLHttpRequest = " + XMLHttpRequest); + XMLHttpRequest = constr; + ok(Image != HTMLImageElement, "Image == HTMLImageElement"); ok(typeof(HTMLImageElement) === "object", "typeof(HTMLImageElement) = " + typeof(HTMLImageElement)); ok(typeof(Image) === "function", "typeof(Image) = " + typeof(Image)); diff --git a/dlls/mshtml/xmlhttprequest.c b/dlls/mshtml/xmlhttprequest.c index 0ab7fba2862..0798b2e2abb 100644 --- a/dlls/mshtml/xmlhttprequest.c +++ b/dlls/mshtml/xmlhttprequest.c @@ -36,6 +36,13 @@
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); @@ -1474,12 +1481,14 @@ static const tid_t HTMLXMLHttpRequest_iface_tids[] = { IHTMLXMLHttpRequest2_tid, 0 }; -static dispex_static_data_t HTMLXMLHttpRequest_dispex = { - "XMLHttpRequest", - &HTMLXMLHttpRequest_event_target_vtbl.dispex_vtbl, - DispHTMLXMLHttpRequest_tid, - HTMLXMLHttpRequest_iface_tids, - HTMLXMLHttpRequest_init_dispex_info +dispex_static_data_t XMLHttpRequest_dispex = { + .name = "XMLHttpRequest", + .id = PROT_XMLHttpRequest, + .init_constructor = HTMLXMLHttpRequestFactory_Create, + .vtbl = &HTMLXMLHttpRequest_event_target_vtbl.dispex_vtbl, + .disp_tid = DispHTMLXMLHttpRequest_tid, + .iface_tids = HTMLXMLHttpRequest_iface_tids, + .init_info = HTMLXMLHttpRequest_init_dispex_info, };
@@ -1530,7 +1539,7 @@ static HRESULT WINAPI HTMLXMLHttpRequestFactory_create(IHTMLXMLHttpRequestFactor ret->IHTMLXMLHttpRequest2_iface.lpVtbl = &HTMLXMLHttpRequest2Vtbl; ret->IWineXMLHttpRequestPrivate_iface.lpVtbl = &WineXMLHttpRequestPrivateVtbl; ret->IProvideClassInfo2_iface.lpVtbl = &ProvideClassInfo2Vtbl; - init_event_target(&ret->event_target, &HTMLXMLHttpRequest_dispex, This->window); + init_event_target(&ret->event_target, &XMLHttpRequest_dispex, This->window);
/* Always register the handlers because we need them to track state */ event_listener->nsIDOMEventListener_iface.lpVtbl = &XMLHttpReqEventListenerVtbl; @@ -1647,13 +1656,14 @@ static const tid_t HTMLXMLHttpRequestFactory_iface_tids[] = { 0 }; static dispex_static_data_t HTMLXMLHttpRequestFactory_dispex = { - "Function", - &HTMLXMLHttpRequestFactory_dispex_vtbl, - IHTMLXMLHttpRequestFactory_tid, - HTMLXMLHttpRequestFactory_iface_tids + .name = "Function", + .constructor_id = PROT_XMLHttpRequest, + .vtbl = &HTMLXMLHttpRequestFactory_dispex_vtbl, + .disp_tid = IHTMLXMLHttpRequestFactory_tid, + .iface_tids = HTMLXMLHttpRequestFactory_iface_tids, };
-HRESULT HTMLXMLHttpRequestFactory_Create(HTMLInnerWindow* window, HTMLXMLHttpRequestFactory **ret_ptr) +HRESULT HTMLXMLHttpRequestFactory_Create(HTMLInnerWindow* window, DispatchEx **ret_ptr) { HTMLXMLHttpRequestFactory *ret;
@@ -1665,9 +1675,9 @@ HRESULT HTMLXMLHttpRequestFactory_Create(HTMLInnerWindow* window, HTMLXMLHttpReq ret->window = window; IHTMLWindow2_AddRef(&window->base.IHTMLWindow2_iface);
- init_dispatch(&ret->dispex, &HTMLXMLHttpRequestFactory_dispex, NULL, + init_dispatch(&ret->dispex, &HTMLXMLHttpRequestFactory_dispex, window, dispex_compat_mode(&window->event_target.dispex));
- *ret_ptr = ret; + *ret_ptr = &ret->dispex; return S_OK; }
From: Jacek Caban jacek@codeweavers.com
--- dlls/mshtml/htmlselect.c | 14 ++++++++------ dlls/mshtml/mshtml_private.h | 1 + dlls/mshtml/tests/documentmode.js | 2 ++ 3 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/dlls/mshtml/htmlselect.c b/dlls/mshtml/htmlselect.c index 4fb0b05f85f..240e353238a 100644 --- a/dlls/mshtml/htmlselect.c +++ b/dlls/mshtml/htmlselect.c @@ -345,12 +345,14 @@ static const tid_t HTMLOptionElement_iface_tids[] = { IHTMLOptionElement_tid, 0 }; -static dispex_static_data_t HTMLOptionElement_dispex = { - "HTMLOptionElement", - &HTMLOptionElement_event_target_vtbl.dispex_vtbl, - DispHTMLOptionElement_tid, - HTMLOptionElement_iface_tids, - HTMLElement_init_dispex_info +dispex_static_data_t HTMLOptionElement_dispex = { + .name = "HTMLOptionElement", + .id = PROT_HTMLOptionElement, + .prototype_id = PROT_HTMLElement, + .vtbl = &HTMLOptionElement_event_target_vtbl.dispex_vtbl, + .disp_tid = DispHTMLOptionElement_tid, + .iface_tids = HTMLOptionElement_iface_tids, + .init_info = HTMLElement_init_dispex_info, };
HRESULT HTMLOptionElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem) diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index 40b81df8f6b..45607cd9fbc 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -414,6 +414,7 @@ typedef struct { X(HTMLDocument) \ X(HTMLElement) \ X(HTMLImageElement) \ + X(HTMLOptionElement) \ X(Navigator) \ X(Node) \ X(Storage) \ diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index e933358c706..a54c23ee153 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -3142,4 +3142,6 @@ sync_test("prototypes", function() { check(document.createElement("img"), HTMLImageElement.prototype, "img elem"); check(HTMLImageElement.prototype, HTMLElement.prototype, "img elem prototype"); check(Image, Function.prototype, "Image constructor"); + check(document.createElement("option"), HTMLOptionElement.prototype, "option elem"); + check(HTMLOptionElement.prototype, HTMLElement.prototype, "option elem prototype"); });
From: Jacek Caban jacek@codeweavers.com
--- dlls/mshtml/htmlselect.c | 11 ++++++----- dlls/mshtml/tests/documentmode.js | 1 + dlls/mshtml/tests/es5.js | 5 +++++ 3 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/dlls/mshtml/htmlselect.c b/dlls/mshtml/htmlselect.c index 240e353238a..765686a1260 100644 --- a/dlls/mshtml/htmlselect.c +++ b/dlls/mshtml/htmlselect.c @@ -526,10 +526,11 @@ static const dispex_static_data_vtbl_t HTMLOptionElementFactory_dispex_vtbl = { };
static dispex_static_data_t HTMLOptionElementFactory_dispex = { - "Function", - &HTMLOptionElementFactory_dispex_vtbl, - IHTMLOptionElementFactory_tid, - HTMLOptionElementFactory_iface_tids, + .name = "Function", + .constructor_id = PROT_HTMLOptionElement, + .vtbl = &HTMLOptionElementFactory_dispex_vtbl, + .disp_tid = IHTMLOptionElementFactory_tid, + .iface_tids = HTMLOptionElementFactory_iface_tids, };
HRESULT HTMLOptionElementFactory_Create(HTMLInnerWindow *window, HTMLOptionElementFactory **ret_ptr) @@ -544,7 +545,7 @@ HRESULT HTMLOptionElementFactory_Create(HTMLInnerWindow *window, HTMLOptionEleme ret->window = window; IHTMLWindow2_AddRef(&window->base.IHTMLWindow2_iface);
- init_dispatch(&ret->dispex, &HTMLOptionElementFactory_dispex, NULL, + init_dispatch(&ret->dispex, &HTMLOptionElementFactory_dispex, window, dispex_compat_mode(&window->event_target.dispex));
*ret_ptr = ret; diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index a54c23ee153..4403e1355b5 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -3144,4 +3144,5 @@ sync_test("prototypes", function() { check(Image, Function.prototype, "Image constructor"); check(document.createElement("option"), HTMLOptionElement.prototype, "option elem"); check(HTMLOptionElement.prototype, HTMLElement.prototype, "option elem prototype"); + check(Option, Function.prototype, "Option constructor"); }); diff --git a/dlls/mshtml/tests/es5.js b/dlls/mshtml/tests/es5.js index c44d6d6667d..630d9079703 100644 --- a/dlls/mshtml/tests/es5.js +++ b/dlls/mshtml/tests/es5.js @@ -2781,6 +2781,11 @@ sync_test("prototypes", function() { ok(typeof(Image) === "function", "typeof(Image) = " + typeof(Image)); ok(Image.prototype === HTMLImageElement.prototype, "Image.prototype != HTMLImageElement.prototype");
+ ok(Option != HTMLOptionElement, "Option == HTMLOptionElement"); + ok(typeof(HTMLOptionElement) === "object", "typeof(HTMLOptionElement) = " + typeof(HTMLOptionElement)); + ok(typeof(Option) === "function", "typeof(Option) = " + typeof(Option)); + ok(Option.prototype === HTMLOptionElement.prototype, "Option.prototype != HTMLOptionElement.prototype"); + ok(document.implementation instanceof DOMImplementation, "document.implementation is not an instance of DOMImplementation"); ok(navigator instanceof Navigator, "navigator is not an instance of Navigator"); ok(!(navigator instanceof DOMImplementation), "navigator is an instance of DOMImplementation");
From: Jacek Caban jacek@codeweavers.com
--- dlls/mshtml/htmlwindow.c | 38 +++++------------------- dlls/mshtml/mshtml_private.h | 5 ++-- dlls/mshtml/mshtml_private_iface.idl | 2 -- dlls/mshtml/mutation.c | 44 +++++++++++++--------------- dlls/mshtml/tests/documentmode.js | 7 ++++- 5 files changed, 37 insertions(+), 59 deletions(-)
diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c index 6c6ad2178eb..799ed0a1f93 100644 --- a/dlls/mshtml/htmlwindow.c +++ b/dlls/mshtml/htmlwindow.c @@ -3185,26 +3185,6 @@ static HRESULT WINAPI window_private_get_console(IWineHTMLWindowPrivate *iface, return S_OK; }
-static HRESULT WINAPI window_private_get_MutationObserver(IWineHTMLWindowPrivate *iface, - IDispatch **mutation_observer) -{ - HTMLWindow *This = impl_from_IWineHTMLWindowPrivateVtbl(iface); - HRESULT hres; - - TRACE("iface %p, mutation_observer %p.\n", iface, mutation_observer); - - if (!This->inner_window->mutation_observer_ctor) { - hres = create_mutation_observer_ctor(dispex_compat_mode(&This->inner_window->event_target.dispex), - &This->inner_window->mutation_observer_ctor); - if (FAILED(hres)) - return hres; - } - - IDispatch_AddRef(This->inner_window->mutation_observer_ctor); - *mutation_observer = This->inner_window->mutation_observer_ctor; - return S_OK; -} - static const IWineHTMLWindowPrivateVtbl WineHTMLWindowPrivateVtbl = { window_private_QueryInterface, window_private_AddRef, @@ -3217,7 +3197,6 @@ static const IWineHTMLWindowPrivateVtbl WineHTMLWindowPrivateVtbl = { window_private_cancelAnimationFrame, window_private_get_console, window_private_matchMedia, - window_private_get_MutationObserver };
static inline HTMLWindow *impl_from_IWineHTMLWindowCompatPrivateVtbl(IWineHTMLWindowCompatPrivate *iface) @@ -3708,8 +3687,6 @@ static void HTMLWindow_traverse(DispatchEx *dispex, nsCycleCollectionTraversalCa note_cc_edge((nsISupports*)&This->image_factory->IHTMLImageElementFactory_iface, "image_factory", cb); if(This->option_factory) note_cc_edge((nsISupports*)&This->option_factory->IHTMLOptionElementFactory_iface, "option_factory", cb); - if(This->mutation_observer_ctor) - note_cc_edge((nsISupports*)This->mutation_observer_ctor, "mutation_observer_ctor", cb); if(This->screen) note_cc_edge((nsISupports*)This->screen, "screen", cb); if(This->history) @@ -3758,7 +3735,6 @@ static void HTMLWindow_unlink(DispatchEx *dispex) This->option_factory = NULL; IHTMLOptionElementFactory_Release(&option_factory->IHTMLOptionElementFactory_iface); } - unlink_ref(&This->mutation_observer_ctor); unlink_ref(&This->screen); if(This->history) { OmHistory *history = This->history; @@ -3837,13 +3813,15 @@ static HRESULT HTMLWindow_find_dispid(DispatchEx *dispex, const WCHAR *name, DWO DispatchEx *constr; VARIANT v;
- hres = get_constructor(This, id, &constr); - if(FAILED(hres)) - return hres; + if(dispex_compat_mode(dispex) >= object_descriptors[id]->min_compat_mode) { + hres = get_constructor(This, id, &constr); + if(FAILED(hres)) + return hres;
- V_VT(&v) = VT_DISPATCH; - V_DISPATCH(&v) = (IDispatch *)&constr->IWineJSDispatchHost_iface; - return dispex_define_property(&This->event_target.dispex, name, PROPF_WRITABLE | PROPF_CONFIGURABLE, &v, dispid); + V_VT(&v) = VT_DISPATCH; + V_DISPATCH(&v) = (IDispatch *)&constr->IWineJSDispatchHost_iface; + return dispex_define_property(&This->event_target.dispex, name, PROPF_WRITABLE | PROPF_CONFIGURABLE, &v, dispid); + } } }
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index 45607cd9fbc..f25662e0d15 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -415,6 +415,7 @@ typedef struct { X(HTMLElement) \ X(HTMLImageElement) \ X(HTMLOptionElement) \ + X(MutationObserver) \ X(Navigator) \ X(Node) \ X(Storage) \ @@ -443,6 +444,7 @@ typedef struct { prototype_id_t prototype_id; prototype_id_t constructor_id; UINT32 js_flags; + compat_mode_t min_compat_mode; char prototype_name[64]; } dispex_static_data_t;
@@ -706,7 +708,6 @@ struct HTMLInnerWindow { LONG task_magic;
IMoniker *mon; - IDispatch *mutation_observer_ctor; nsChannelBSC *bscallback; struct list bindings;
@@ -1606,5 +1607,3 @@ IInternetSecurityManager *get_security_manager(void); extern HINSTANCE hInst; void create_console(HTMLInnerWindow *window, IWineMSHTMLConsole **ret); HRESULT create_media_query_list(HTMLInnerWindow *window, BSTR media_query, IDispatch **ret); - -HRESULT create_mutation_observer_ctor(compat_mode_t compat_mode, IDispatch **ret); diff --git a/dlls/mshtml/mshtml_private_iface.idl b/dlls/mshtml/mshtml_private_iface.idl index 503593d1c25..7be013bcc32 100644 --- a/dlls/mshtml/mshtml_private_iface.idl +++ b/dlls/mshtml/mshtml_private_iface.idl @@ -131,8 +131,6 @@ interface IWineHTMLWindowPrivate : IDispatch HRESULT console([retval, out] IDispatch **console); [id(53)] HRESULT matchMedia([in] BSTR media_query, [retval, out] IDispatch **media_query_list); - [propget, id(DISPID_IWINEHTMLWINDOWPRIVATE_MUTATIONOBSERVER)] - HRESULT MutationObserver([retval, out] IDispatch **observer_ctor); }
[ diff --git a/dlls/mshtml/mutation.c b/dlls/mshtml/mutation.c index 4e0276fd5f6..80079f79560 100644 --- a/dlls/mshtml/mutation.c +++ b/dlls/mshtml/mutation.c @@ -1167,6 +1167,8 @@ static void mutation_observer_destructor(DispatchEx *dispex) free(This); }
+static HRESULT create_mutation_observer_ctor(HTMLInnerWindow *script_global, DispatchEx **ret); + static const dispex_static_data_vtbl_t mutation_observer_dispex_vtbl = { .query_interface = mutation_observer_query_interface, .destructor = mutation_observer_destructor, @@ -1178,19 +1180,22 @@ static const tid_t mutation_observer_iface_tids[] = { IWineMSHTMLMutationObserver_tid, 0 }; -static dispex_static_data_t mutation_observer_dispex = { - "MutationObserver", - &mutation_observer_dispex_vtbl, - IWineMSHTMLMutationObserver_tid, - mutation_observer_iface_tids +dispex_static_data_t MutationObserver_dispex = { + .name = "MutationObserver", + .id = PROT_MutationObserver, + .init_constructor = create_mutation_observer_ctor, + .vtbl = &mutation_observer_dispex_vtbl, + .disp_tid = IWineMSHTMLMutationObserver_tid, + .iface_tids = mutation_observer_iface_tids, + .min_compat_mode = COMPAT_MODE_IE11, };
-static HRESULT create_mutation_observer(compat_mode_t compat_mode, IDispatch *callback, +static HRESULT create_mutation_observer(DispatchEx *owner, IDispatch *callback, IWineMSHTMLMutationObserver **ret) { struct mutation_observer *obj;
- TRACE("(compat_mode = %d, callback = %p, ret = %p)\n", compat_mode, callback, ret); + TRACE("(callback = %p, ret = %p)\n", callback, ret);
obj = calloc(1, sizeof(*obj)); if(!obj) @@ -1200,7 +1205,7 @@ static HRESULT create_mutation_observer(compat_mode_t compat_mode, IDispatch *ca }
obj->IWineMSHTMLMutationObserver_iface.lpVtbl = &WineMSHTMLMutationObserverVtbl; - init_dispatch(&obj->dispex, &mutation_observer_dispex, NULL, compat_mode); + init_dispatch_with_owner(&obj->dispex, &MutationObserver_dispex, owner);
IDispatch_AddRef(callback); obj->callback = callback; @@ -1259,8 +1264,7 @@ static HRESULT mutation_observer_ctor_value(DispatchEx *dispex, LCID lcid, if (!res) return S_OK;
- hres = create_mutation_observer(dispex_compat_mode(&This->dispex), V_DISPATCH(callback), - &mutation_observer); + hres = create_mutation_observer(&This->dispex, V_DISPATCH(callback), &mutation_observer); if (FAILED(hres)) return hres;
@@ -1275,23 +1279,16 @@ static dispex_static_data_vtbl_t mutation_observer_ctor_dispex_vtbl = { .value = mutation_observer_ctor_value };
-static const tid_t mutation_observer_ctor_iface_tids[] = { - 0 -}; - static dispex_static_data_t mutation_observer_ctor_dispex = { - "Function", - &mutation_observer_ctor_dispex_vtbl, - NULL_tid, - mutation_observer_ctor_iface_tids + .name = "Function", + .constructor_id = PROT_MutationObserver, + .vtbl = &mutation_observer_ctor_dispex_vtbl, };
-HRESULT create_mutation_observer_ctor(compat_mode_t compat_mode, IDispatch **ret) +static HRESULT create_mutation_observer_ctor(HTMLInnerWindow *script_global, DispatchEx **ret) { struct mutation_observer_ctor *obj;
- TRACE("(compat_mode = %d, ret = %p)\n", compat_mode, ret); - obj = calloc(1, sizeof(*obj)); if(!obj) { @@ -1299,8 +1296,9 @@ HRESULT create_mutation_observer_ctor(compat_mode_t compat_mode, IDispatch **ret return E_OUTOFMEMORY; }
- init_dispatch(&obj->dispex, &mutation_observer_ctor_dispex, NULL, compat_mode); + init_dispatch(&obj->dispex, &mutation_observer_ctor_dispex, script_global, + dispex_compat_mode(&script_global->event_target.dispex));
- *ret = (IDispatch *)&obj->dispex.IWineJSDispatchHost_iface; + *ret = &obj->dispex; return S_OK; } diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index 4403e1355b5..123523543f0 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -342,7 +342,7 @@ sync_test("builtin_toString", function() { test("mediaQueryList", window.matchMedia("(hover:hover)"), "MediaQueryList"); } if(v >= 11) { - test("MutationObserver", new window.MutationObserver(function() {}), "MutationObserver", null, true); + test("MutationObserver", new window.MutationObserver(function() {}), "MutationObserver"); } if(v >= 9) { document.body.innerHTML = "<!--...-->"; @@ -3145,4 +3145,9 @@ sync_test("prototypes", function() { check(document.createElement("option"), HTMLOptionElement.prototype, "option elem"); check(HTMLOptionElement.prototype, HTMLElement.prototype, "option elem prototype"); check(Option, Function.prototype, "Option constructor"); + if(v >= 11) { + check(new MutationObserver(function() {}), MutationObserver.prototype, "mutation observer"); + check(MutationObserver.prototype, Object.prototype, "mutation observer prototype"); + check(MutationObserver, Function.prototype, "mutation observer constructor"); + } });
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=147561
Your paranoid android.
=== build (build log) ===
error: patch failed: dlls/jscript/function.c:70 error: patch failed: dlls/jscript/jscript.c:1458 error: patch failed: dlls/jscript/jscript.h:244 error: patch failed: dlls/jscript/jsdisp.idl:66 error: patch failed: dlls/mshtml/dispex.c:2551 error: patch failed: dlls/mshtml/htmlwindow.c:3505 Task: Patch failed to apply
=== debian11 (build log) ===
error: patch failed: dlls/jscript/function.c:70 error: patch failed: dlls/jscript/jscript.c:1458 error: patch failed: dlls/jscript/jscript.h:244 error: patch failed: dlls/jscript/jsdisp.idl:66 error: patch failed: dlls/mshtml/dispex.c:2551 error: patch failed: dlls/mshtml/htmlwindow.c:3505 Task: Patch failed to apply
=== debian11b (build log) ===
error: patch failed: dlls/jscript/function.c:70 error: patch failed: dlls/jscript/jscript.c:1458 error: patch failed: dlls/jscript/jscript.h:244 error: patch failed: dlls/jscript/jsdisp.idl:66 error: patch failed: dlls/mshtml/dispex.c:2551 error: patch failed: dlls/mshtml/htmlwindow.c:3505 Task: Patch failed to apply
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=147561
Your paranoid android.
=== build (build log) ===
error: patch failed: dlls/jscript/function.c:70 error: patch failed: dlls/jscript/jscript.c:1458 error: patch failed: dlls/jscript/jscript.h:244 error: patch failed: dlls/jscript/jsdisp.idl:66 error: patch failed: dlls/mshtml/dispex.c:2551 error: patch failed: dlls/mshtml/htmlwindow.c:3505 Task: Patch failed to apply
=== debian11 (build log) ===
error: patch failed: dlls/jscript/function.c:70 error: patch failed: dlls/jscript/jscript.c:1458 error: patch failed: dlls/jscript/jscript.h:244 error: patch failed: dlls/jscript/jsdisp.idl:66 error: patch failed: dlls/mshtml/dispex.c:2551 error: patch failed: dlls/mshtml/htmlwindow.c:3505 Task: Patch failed to apply
=== debian11b (build log) ===
error: patch failed: dlls/jscript/function.c:70 error: patch failed: dlls/jscript/jscript.c:1458 error: patch failed: dlls/jscript/jscript.h:244 error: patch failed: dlls/jscript/jsdisp.idl:66 error: patch failed: dlls/mshtml/dispex.c:2551 error: patch failed: dlls/mshtml/htmlwindow.c:3505 Task: Patch failed to apply