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"); + } });