And let the hooks forward using invoke_builtin_function as well.
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/dispex.c | 14 ++++++++++---- dlls/mshtml/htmlelem.c | 5 ++--- dlls/mshtml/htmlevent.c | 10 ++++------ dlls/mshtml/mshtml_private.h | 4 ++-- dlls/mshtml/tests/documentmode.js | 14 +++++++++++++- dlls/mshtml/xmlhttprequest.c | 5 ++--- 6 files changed, 33 insertions(+), 19 deletions(-)
diff --git a/dlls/mshtml/dispex.c b/dlls/mshtml/dispex.c index 3ab8202..465748a 100644 --- a/dlls/mshtml/dispex.c +++ b/dlls/mshtml/dispex.c @@ -1176,6 +1176,12 @@ HRESULT invoke_builtin_function(DispatchEx *This, func_info_t *func, WORD flags, IUnknown *iface; HRESULT hres;
+ if(func->hook) { + hres = func->hook(This, func, flags, dp, res, ei, caller); + if(hres != S_FALSE) + return hres; + } + if(!func->call_vtbl_off) return typeinfo_invoke(This, func, flags, dp, res, ei);
@@ -1365,15 +1371,15 @@ static HRESULT invoke_builtin_prop(DispatchEx *This, DISPID id, LCID lcid, WORD if(FAILED(hres)) return hres;
+ if(func->func_disp_idx != -1) + return function_invoke(This, func, flags, dp, res, ei, caller); + if(func->hook) { - hres = func->hook(This, lcid, flags, dp, res, ei, caller); + hres = func->hook(This, func, flags, dp, res, ei, caller); if(hres != S_FALSE) return hres; }
- if(func->func_disp_idx != -1) - return function_invoke(This, func, flags, dp, res, ei, caller); - switch(flags) { case DISPATCH_PROPERTYPUT: if(res) diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c index a205728..99d6249 100644 --- a/dlls/mshtml/htmlelem.c +++ b/dlls/mshtml/htmlelem.c @@ -6643,7 +6643,7 @@ static IHTMLEventObj *HTMLElement_set_current_event(DispatchEx *dispex, IHTMLEve return default_set_current_event(This->node.doc->window, event); }
-static HRESULT IHTMLElement6_setAttribute_hook(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *dp, +static HRESULT IHTMLElement6_setAttribute_hook(DispatchEx *dispex, func_info_t *func, WORD flags, DISPPARAMS *dp, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller) { VARIANT args[2]; @@ -6667,8 +6667,7 @@ static HRESULT IHTMLElement6_setAttribute_hook(DispatchEx *dispex, LCID lcid, WO return hres; args[1] = dp->rgvarg[dp->cArgs - 1];
- hres = IDispatchEx_InvokeEx(&dispex->IDispatchEx_iface, DISPID_IHTMLELEMENT6_IE9_SETATTRIBUTE, - lcid, flags, &new_dp, res, ei, caller); + hres = invoke_builtin_function(dispex, func, flags, &new_dp, res, ei, caller); VariantClear(&args[0]); return hres; } diff --git a/dlls/mshtml/htmlevent.c b/dlls/mshtml/htmlevent.c index 3f545bb..c88e8fd 100644 --- a/dlls/mshtml/htmlevent.c +++ b/dlls/mshtml/htmlevent.c @@ -3314,7 +3314,7 @@ static HRESULT WINAPI EventTarget_dispatchEvent(IEventTarget *iface, IDOMEvent * return dispatch_event_object(This, event, DISPATCH_STANDARD, result); }
-static HRESULT IEventTarget_addEventListener_hook(DispatchEx *dispex, LCID lcid, WORD flags, +static HRESULT IEventTarget_addEventListener_hook(DispatchEx *dispex, func_info_t *func, WORD flags, DISPPARAMS *dp, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller) { /* If only two arguments were given, implicitly set capture to false */ @@ -3328,14 +3328,13 @@ static HRESULT IEventTarget_addEventListener_hook(DispatchEx *dispex, LCID lcid,
TRACE("implicit capture\n");
- return IDispatchEx_InvokeEx(&dispex->IDispatchEx_iface, DISPID_IEVENTTARGET_ADDEVENTLISTENER, - lcid, flags, &new_dp, res, ei, caller); + return invoke_builtin_function(dispex, func, flags, &new_dp, res, ei, caller); }
return S_FALSE; /* fallback to default */ }
-static HRESULT IEventTarget_removeEventListener_hook(DispatchEx *dispex, LCID lcid, WORD flags, +static HRESULT IEventTarget_removeEventListener_hook(DispatchEx *dispex, func_info_t *func, WORD flags, DISPPARAMS *dp, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller) { /* If only two arguments were given, implicitly set capture to false */ @@ -3349,8 +3348,7 @@ static HRESULT IEventTarget_removeEventListener_hook(DispatchEx *dispex, LCID lc
TRACE("implicit capture\n");
- return IDispatchEx_InvokeEx(&dispex->IDispatchEx_iface, DISPID_IEVENTTARGET_REMOVEEVENTLISTENER, - lcid, flags, &new_dp, res, ei, caller); + return invoke_builtin_function(dispex, func, flags, &new_dp, res, ei, caller); }
return S_FALSE; /* fallback to default */ diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index 03ccc7e..26ea22e 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -338,8 +338,8 @@ typedef struct { dispex_data_t *delayed_init_info; } dispex_static_data_t;
-typedef HRESULT (*dispex_hook_invoke_t)(DispatchEx*,LCID,WORD,DISPPARAMS*,VARIANT*, - EXCEPINFO*,IServiceProvider*); +typedef HRESULT (*dispex_hook_invoke_t)(DispatchEx*,func_info_t*,WORD,DISPPARAMS*, + VARIANT*,EXCEPINFO*,IServiceProvider*);
typedef struct { DISPID dispid; diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index 6555e8b..2af5fae 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -1166,6 +1166,18 @@ sync_test("elem_attr", function() { r = elem.removeAttribute("testattr"); ok(r === (v < 9 ? true : undefined), "testattr removeAttribute with custom valueOf returned " + r); ok(elem.testattr === (v < 9 ? undefined : arr), "removed testattr with custom valueOf = " + elem.testattr); + + var func = elem.setAttribute; + try { + func("testattr", arr); + todo_wine_if(v >= 9). + ok(v < 9, "expected exception setting testattr via func"); + }catch(ex) { + ok(v >= 9, "did not expect exception setting testattr via func"); + elem.setAttribute("testattr", arr); + } + r = elem.getAttribute("testattr"); + ok(r === (v < 8 ? arr : (v < 10 ? "arrval" : "42")), "testattr after setAttribute (as func) = " + r); delete arr.valueOf; delete arr.toString;
@@ -1177,7 +1189,7 @@ sync_test("elem_attr", function() { ok(r === (v < 9 ? true : undefined), "id removeAttribute returned " + r); ok(elem.id === "", "removed id = " + elem.id);
- var func = function() { }; + func = function() { }; elem.onclick = func; ok(elem.onclick === func, "onclick = " + elem.onclick); r = elem.getAttribute("onclick"); diff --git a/dlls/mshtml/xmlhttprequest.c b/dlls/mshtml/xmlhttprequest.c index 56e18d0..f608558 100644 --- a/dlls/mshtml/xmlhttprequest.c +++ b/dlls/mshtml/xmlhttprequest.c @@ -475,7 +475,7 @@ static HRESULT WINAPI HTMLXMLHttpRequest_abort(IHTMLXMLHttpRequest *iface) return S_OK; }
-static HRESULT HTMLXMLHttpRequest_open_hook(DispatchEx *dispex, LCID lcid, WORD flags, +static HRESULT HTMLXMLHttpRequest_open_hook(DispatchEx *dispex, func_info_t *func, WORD flags, DISPPARAMS *dp, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller) { /* If only two arguments were given, implicitly set async to false */ @@ -491,8 +491,7 @@ static HRESULT HTMLXMLHttpRequest_open_hook(DispatchEx *dispex, LCID lcid, WORD
TRACE("implicit async\n");
- return IDispatchEx_InvokeEx(&dispex->IDispatchEx_iface, DISPID_IHTMLXMLHTTPREQUEST_OPEN, - lcid, flags, &new_dp, res, ei, caller); + return invoke_builtin_function(dispex, func, flags, &new_dp, res, ei, caller); }
return S_FALSE; /* fallback to default */