mshtml: Always use event target as script this in call_event_handlers.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2017-10-18 16:39:40 +02:00 committed by Alexandre Julliard
parent 0c35bf7c8e
commit 62c7dd0576
9 changed files with 25 additions and 30 deletions

View File

@ -5191,7 +5191,7 @@ HRESULT HTMLElement_handle_event(HTMLDOMNode *iface, DWORD eid, nsIDOMEvent *eve
switch(code) {
case VK_F1: /* DOM_VK_F1 */
TRACE("F1 pressed\n");
fire_event(This->node.doc, EVENTID_HELP, TRUE, &This->node, NULL, NULL);
fire_event(This->node.doc, EVENTID_HELP, TRUE, &This->node, NULL);
*prevent_default = TRUE;
}

View File

@ -937,7 +937,7 @@ static BOOL is_cp_event(cp_static_data_t *data, DISPID dispid)
return FALSE;
}
void call_event_handlers(HTMLEventObj *event_obj, EventTarget *event_target, eventid_t eid, IDispatch *this_obj)
void call_event_handlers(HTMLEventObj *event_obj, EventTarget *event_target, eventid_t eid)
{
handler_vector_t *handler_vector = get_handler_vector(event_target, eid, FALSE);
const BOOL cancelable = event_info[eid].flags & EVENT_CANCELABLE;
@ -955,7 +955,7 @@ void call_event_handlers(HTMLEventObj *event_obj, EventTarget *event_target, eve
FIXME("Event argument not supported\n");
V_VT(&arg) = VT_DISPATCH;
V_DISPATCH(&arg) = this_obj;
V_DISPATCH(&arg) = (IDispatch*)&event_target->dispex.IDispatchEx_iface;
V_VT(&v) = VT_EMPTY;
TRACE("%s >>>\n", debugstr_w(event_info[eid].name));
@ -1055,7 +1055,7 @@ void call_event_handlers(HTMLEventObj *event_obj, EventTarget *event_target, eve
}
static void fire_event_obj(HTMLDocumentNode *doc, eventid_t eid, HTMLEventObj *event_obj,
HTMLDOMNode *target, IDispatch *script_this)
HTMLDOMNode *target)
{
IHTMLEventObj *prev_event;
nsIDOMNode *parent, *nsnode = NULL;
@ -1090,8 +1090,7 @@ static void fire_event_obj(HTMLDocumentNode *doc, eventid_t eid, HTMLEventObj *e
do {
hres = get_node(doc, nsnode, FALSE, &node);
if(SUCCEEDED(hres) && node) {
call_event_handlers(event_obj, &node->event_target, eid,
script_this ? script_this : (IDispatch*)&node->IHTMLDOMNode_iface);
call_event_handlers(event_obj, &node->event_target, eid);
node_release(node);
}
@ -1112,15 +1111,13 @@ static void fire_event_obj(HTMLDocumentNode *doc, eventid_t eid, HTMLEventObj *e
/* fallthrough */
case DOCUMENT_NODE:
call_event_handlers(event_obj, &doc->node.event_target, eid,
script_this ? script_this : (IDispatch*)&doc->basedoc.IHTMLDocument2_iface);
call_event_handlers(event_obj, &doc->node.event_target, eid);
if(!(event_info[eid].flags & EVENT_BUBBLE) || (event_obj && event_obj->cancel_bubble))
break;
/* fallthrough */
default: /* window object */
call_event_handlers(event_obj, &doc->window->event_target, eid,
script_this ? script_this : (IDispatch*)&doc->window->base.IHTMLWindow2_iface);
call_event_handlers(event_obj, &doc->window->event_target, eid);
}
if(nsnode)
@ -1167,8 +1164,7 @@ static void fire_event_obj(HTMLDocumentNode *doc, eventid_t eid, HTMLEventObj *e
htmldoc_release(&doc->basedoc);
}
void fire_event(HTMLDocumentNode *doc, eventid_t eid, BOOL set_event, HTMLDOMNode *target, nsIDOMEvent *nsevent,
IDispatch *script_this)
void fire_event(HTMLDocumentNode *doc, eventid_t eid, BOOL set_event, HTMLDOMNode *target, nsIDOMEvent *nsevent)
{
HTMLEventObj *event_obj = NULL;
HRESULT hres;
@ -1185,7 +1181,7 @@ void fire_event(HTMLDocumentNode *doc, eventid_t eid, BOOL set_event, HTMLDOMNod
}
}
fire_event_obj(doc, eid, event_obj, target, script_this);
fire_event_obj(doc, eid, event_obj, target);
if(event_obj)
IHTMLEventObj_Release(&event_obj->IHTMLEventObj_iface);
@ -1230,13 +1226,13 @@ HRESULT dispatch_event(HTMLDOMNode *node, const WCHAR *event_name, VARIANT *even
if(event_obj) {
hres = set_event_info(event_obj, node, eid, NULL);
if(SUCCEEDED(hres))
fire_event_obj(node->doc, eid, event_obj, node, NULL);
fire_event_obj(node->doc, eid, event_obj, node);
IHTMLEventObj_Release(&event_obj->IHTMLEventObj_iface);
if(FAILED(hres))
return hres;
}else {
fire_event(node->doc, eid, TRUE, node, NULL, NULL);
fire_event(node->doc, eid, TRUE, node, NULL);
}
*cancelled = VARIANT_TRUE; /* FIXME */

View File

@ -58,7 +58,7 @@ typedef enum {
eventid_t str_to_eid(LPCWSTR) DECLSPEC_HIDDEN;
void check_event_attr(HTMLDocumentNode*,nsIDOMHTMLElement*) DECLSPEC_HIDDEN;
void release_event_target(EventTarget*) DECLSPEC_HIDDEN;
void fire_event(HTMLDocumentNode*,eventid_t,BOOL,HTMLDOMNode*,nsIDOMEvent*,IDispatch*) DECLSPEC_HIDDEN;
void fire_event(HTMLDocumentNode*,eventid_t,BOOL,HTMLDOMNode*,nsIDOMEvent*) DECLSPEC_HIDDEN;
HRESULT set_event_handler(EventTarget*,eventid_t,VARIANT*) DECLSPEC_HIDDEN;
HRESULT get_event_handler(EventTarget*,eventid_t,VARIANT*) DECLSPEC_HIDDEN;
HRESULT attach_event(EventTarget*,BSTR,IDispatch*,VARIANT_BOOL*) DECLSPEC_HIDDEN;
@ -72,7 +72,7 @@ void bind_target_event(HTMLDocumentNode*,EventTarget*,const WCHAR*,IDispatch*) D
HRESULT ensure_doc_nsevent_handler(HTMLDocumentNode*,eventid_t) DECLSPEC_HIDDEN;
typedef struct HTMLEventObj HTMLEventObj;
void call_event_handlers(HTMLEventObj*,EventTarget*,eventid_t,IDispatch*);
void call_event_handlers(HTMLEventObj*,EventTarget*,eventid_t);
void init_nsevents(HTMLDocumentNode*) DECLSPEC_HIDDEN;
void release_nsevents(HTMLDocumentNode*) DECLSPEC_HIDDEN;

View File

@ -2155,7 +2155,7 @@ static HRESULT WINAPI HTMLWindow6_postMessage(IHTMLWindow6 *iface, BSTR msg, VAR
return E_FAIL;
}
fire_event(This->inner_window->doc, EVENTID_MESSAGE, TRUE, NULL, NULL, NULL);
fire_event(This->inner_window->doc, EVENTID_MESSAGE, TRUE, NULL, NULL);
return S_OK;
}

View File

@ -1499,7 +1499,7 @@ static nsresult NSAPI nsContextMenuListener_OnShowContextMenu(nsIContextMenuList
if(FAILED(hres))
return NS_ERROR_FAILURE;
fire_event(This->doc->basedoc.doc_node /* FIXME */, EVENTID_CONTEXTMENU, TRUE, node, aEvent, NULL);
fire_event(This->doc->basedoc.doc_node /* FIXME */, EVENTID_CONTEXTMENU, TRUE, node, aEvent);
nsres = nsIDOMEvent_QueryInterface(aEvent, &IID_nsIDOMMouseEvent, (void**)&event);
assert(NS_SUCCEEDED(nsres));

View File

@ -269,8 +269,8 @@ static nsresult NSAPI handle_load(nsIDOMEventListener *iface, nsIDOMEvent *event
if(doc->nsdoc) {
flush_pending_tasks(doc->basedoc.task_magic);
fire_event(doc, EVENTID_LOAD, TRUE, &doc->node, event, (IDispatch*)&doc->window->base.IDispatchEx_iface);
fire_event(doc, EVENTID_LOAD, TRUE, NULL, event, (IDispatch*)&doc->window->base.IDispatchEx_iface);
fire_event(doc, EVENTID_LOAD, TRUE, &doc->node, event);
fire_event(doc, EVENTID_LOAD, TRUE, NULL, event);
}else {
ERR("NULL nsdoc\n");
nsres = NS_ERROR_FAILURE;
@ -328,17 +328,17 @@ static nsresult NSAPI handle_htmlevent(nsIDOMEventListener *iface, nsIDOMEvent *
switch(eid) {
case EVENTID_FOCUS:
if(doc->event_vector[EVENTID_FOCUSIN])
fire_event(doc, EVENTID_FOCUSIN, TRUE, node, NULL, NULL);
fire_event(doc, EVENTID_FOCUSIN, TRUE, node, NULL);
break;
case EVENTID_BLUR:
if(doc->event_vector[EVENTID_FOCUSOUT])
fire_event(doc, EVENTID_FOCUSOUT, TRUE, node, NULL, NULL);
fire_event(doc, EVENTID_FOCUSOUT, TRUE, node, NULL);
break;
default:
break;
}
fire_event(doc, eid, TRUE, node, event, NULL);
fire_event(doc, eid, TRUE, node, event);
node_release(node);
return NS_OK;

View File

@ -449,11 +449,11 @@ static void notif_readystate(HTMLOuterWindow *window)
call_property_onchanged(&window->doc_obj->basedoc.cp_container, DISPID_READYSTATE);
fire_event(window->base.inner_window->doc, EVENTID_READYSTATECHANGE, FALSE,
&window->base.inner_window->doc->node, NULL, NULL);
&window->base.inner_window->doc->node, NULL);
if(window->frame_element)
fire_event(window->frame_element->element.node.doc, EVENTID_READYSTATECHANGE,
TRUE, &window->frame_element->element.node, NULL, NULL);
TRUE, &window->frame_element->element.node, NULL);
}
typedef struct {

View File

@ -737,7 +737,7 @@ static void fire_readystatechange_proc(task_t *_task)
return;
task->elem->pending_readystatechange_event = FALSE;
fire_event(task->elem->element.node.doc, EVENTID_READYSTATECHANGE, FALSE, &task->elem->element.node, NULL, NULL);
fire_event(task->elem->element.node.doc, EVENTID_READYSTATECHANGE, FALSE, &task->elem->element.node, NULL);
}
static void fire_readystatechange_task_destr(task_t *_task)
@ -773,7 +773,7 @@ static void set_script_elem_readystate(HTMLScriptElement *script_elem, READYSTAT
}else {
script_elem->pending_readystatechange_event = FALSE;
fire_event(script_elem->element.node.doc, EVENTID_READYSTATECHANGE, FALSE,
&script_elem->element.node, NULL, NULL);
&script_elem->element.node, NULL);
}
}
}

View File

@ -190,8 +190,7 @@ static nsresult NSAPI XMLHttpReqEventListener_HandleEvent(nsIDOMEventListener *i
if(!This->xhr)
return NS_OK;
call_event_handlers(NULL, &This->xhr->event_target, EVENTID_READYSTATECHANGE,
(IDispatch*)&This->xhr->IHTMLXMLHttpRequest_iface);
call_event_handlers(NULL, &This->xhr->event_target, EVENTID_READYSTATECHANGE);
return NS_OK;
}