mshtml: Pass node as an object to fire_event.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
b692aad3b6
commit
1dc502c5b4
|
@ -4112,7 +4112,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.nsnode, NULL, NULL);
|
||||
fire_event(This->node.doc, EVENTID_HELP, TRUE, &This->node, NULL, NULL);
|
||||
*prevent_default = TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -1085,7 +1085,7 @@ void call_event_handlers(HTMLDocumentNode *doc, HTMLEventObj *event_obj, EventTa
|
|||
}
|
||||
|
||||
static void fire_event_obj(HTMLDocumentNode *doc, eventid_t eid, HTMLEventObj *event_obj,
|
||||
nsIDOMNode *target, IDispatch *script_this)
|
||||
HTMLDOMNode *target, IDispatch *script_this)
|
||||
{
|
||||
IHTMLEventObj *prev_event;
|
||||
nsIDOMNode *parent, *nsnode;
|
||||
|
@ -1109,8 +1109,8 @@ static void fire_event_obj(HTMLDocumentNode *doc, eventid_t eid, HTMLEventObj *e
|
|||
prev_event = window->event;
|
||||
window->event = event_obj ? &event_obj->IHTMLEventObj_iface : NULL;
|
||||
|
||||
nsIDOMNode_GetNodeType(target, &node_type);
|
||||
nsnode = target;
|
||||
nsIDOMNode_GetNodeType(target->nsnode, &node_type);
|
||||
nsnode = target->nsnode;
|
||||
nsIDOMNode_AddRef(nsnode);
|
||||
|
||||
switch(node_type) {
|
||||
|
@ -1173,8 +1173,8 @@ static void fire_event_obj(HTMLDocumentNode *doc, eventid_t eid, HTMLEventObj *e
|
|||
window->event = prev_event;
|
||||
|
||||
if(!prevent_default && (event_info[eid].flags & EVENT_HASDEFAULTHANDLERS)) {
|
||||
nsIDOMNode_AddRef(target);
|
||||
nsnode = target;
|
||||
nsnode = target->nsnode;
|
||||
nsIDOMNode_AddRef(nsnode);
|
||||
|
||||
do {
|
||||
hres = get_node(doc, nsnode, TRUE, &node);
|
||||
|
@ -1209,24 +1209,18 @@ 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, nsIDOMNode *target, nsIDOMEvent *nsevent,
|
||||
void fire_event(HTMLDocumentNode *doc, eventid_t eid, BOOL set_event, HTMLDOMNode *target, nsIDOMEvent *nsevent,
|
||||
IDispatch *script_this)
|
||||
{
|
||||
HTMLEventObj *event_obj = NULL;
|
||||
HTMLDOMNode *node;
|
||||
HRESULT hres;
|
||||
|
||||
if(set_event) {
|
||||
hres = get_node(doc, target, TRUE, &node);
|
||||
if(FAILED(hres))
|
||||
return;
|
||||
|
||||
event_obj = create_event();
|
||||
node_release(node);
|
||||
if(!event_obj)
|
||||
return;
|
||||
|
||||
hres = set_event_info(event_obj, node, eid, nsevent);
|
||||
hres = set_event_info(event_obj, target, eid, nsevent);
|
||||
if(FAILED(hres)) {
|
||||
IHTMLEventObj_Release(&event_obj->IHTMLEventObj_iface);
|
||||
return;
|
||||
|
@ -1278,13 +1272,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->nsnode, NULL);
|
||||
fire_event_obj(node->doc, eid, event_obj, node, NULL);
|
||||
|
||||
IHTMLEventObj_Release(&event_obj->IHTMLEventObj_iface);
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
}else {
|
||||
fire_event(node->doc, eid, TRUE, node->nsnode, NULL, NULL);
|
||||
fire_event(node->doc, eid, TRUE, node, NULL, NULL);
|
||||
}
|
||||
|
||||
*cancelled = VARIANT_TRUE; /* FIXME */
|
||||
|
@ -1303,7 +1297,7 @@ HRESULT call_fire_event(HTMLDOMNode *node, eventid_t eid)
|
|||
return hres;
|
||||
}
|
||||
|
||||
fire_event(node->doc, eid, TRUE, node->nsnode, NULL, NULL);
|
||||
fire_event(node->doc, eid, TRUE, node, NULL, NULL);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ typedef enum {
|
|||
eventid_t str_to_eid(LPCWSTR) DECLSPEC_HIDDEN;
|
||||
void check_event_attr(HTMLDocumentNode*,nsIDOMHTMLElement*) DECLSPEC_HIDDEN;
|
||||
void release_event_target(event_target_t*) DECLSPEC_HIDDEN;
|
||||
void fire_event(HTMLDocumentNode*,eventid_t,BOOL,nsIDOMNode*,nsIDOMEvent*,IDispatch*) DECLSPEC_HIDDEN;
|
||||
void fire_event(HTMLDocumentNode*,eventid_t,BOOL,HTMLDOMNode*,nsIDOMEvent*,IDispatch*) 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;
|
||||
|
|
|
@ -1462,13 +1462,14 @@ static nsresult NSAPI nsContextMenuListener_OnShowContextMenu(nsIContextMenuList
|
|||
|
||||
TRACE("(%p)->(%08x %p %p)\n", This, aContextFlags, aEvent, aNode);
|
||||
|
||||
fire_event(This->doc->basedoc.doc_node /* FIXME */, EVENTID_CONTEXTMENU, TRUE, aNode, aEvent, NULL);
|
||||
hres = get_node(This->doc->basedoc.doc_node, aNode, TRUE, &node);
|
||||
if(FAILED(hres))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
fire_event(This->doc->basedoc.doc_node /* FIXME */, EVENTID_CONTEXTMENU, TRUE, node, aEvent, NULL);
|
||||
|
||||
nsres = nsIDOMEvent_QueryInterface(aEvent, &IID_nsIDOMMouseEvent, (void**)&event);
|
||||
if(NS_FAILED(nsres)) {
|
||||
ERR("Could not get nsIDOMMouseEvent interface: %08x\n", nsres);
|
||||
return nsres;
|
||||
}
|
||||
assert(NS_SUCCEEDED(nsres));
|
||||
|
||||
nsIDOMMouseEvent_GetScreenX(event, &pt.x);
|
||||
nsIDOMMouseEvent_GetScreenY(event, &pt.y);
|
||||
|
@ -1506,10 +1507,6 @@ static nsresult NSAPI nsContextMenuListener_OnShowContextMenu(nsIContextMenuList
|
|||
FIXME("aContextFlags=%08x\n", aContextFlags);
|
||||
};
|
||||
|
||||
hres = get_node(This->doc->basedoc.doc_node, aNode, TRUE, &node);
|
||||
if(FAILED(hres))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
show_context_menu(This->doc, dwID, &pt, (IDispatch*)&node->IHTMLDOMNode_iface);
|
||||
node_release(node);
|
||||
return NS_OK;
|
||||
|
|
|
@ -273,8 +273,16 @@ static nsresult NSAPI handle_load(nsIDOMEventListener *iface, nsIDOMEvent *event
|
|||
|
||||
nsres = nsIDOMHTMLDocument_GetBody(doc->nsdoc, &nsbody);
|
||||
if(NS_SUCCEEDED(nsres) && nsbody) {
|
||||
fire_event(doc, EVENTID_LOAD, TRUE, (nsIDOMNode*)nsbody, event, (IDispatch*)&doc->window->base.IDispatchEx_iface);
|
||||
HTMLDOMNode *node;
|
||||
HRESULT hres;
|
||||
|
||||
hres = get_node(doc, (nsIDOMNode*)nsbody, TRUE, &node);
|
||||
nsIDOMHTMLElement_Release(nsbody);
|
||||
if(SUCCEEDED(hres)) {
|
||||
fire_event(doc, EVENTID_LOAD, TRUE, node, event,
|
||||
(IDispatch*)&doc->window->base.IDispatchEx_iface);
|
||||
node_release(node);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
ERR("NULL nsdoc\n");
|
||||
|
@ -293,8 +301,10 @@ static nsresult NSAPI handle_htmlevent(nsIDOMEventListener *iface, nsIDOMEvent *
|
|||
nsIDOMEventTarget *event_target;
|
||||
nsIDOMNode *nsnode;
|
||||
nsAString type_str;
|
||||
HTMLDOMNode *node;
|
||||
eventid_t eid;
|
||||
nsresult nsres;
|
||||
HRESULT hres;
|
||||
|
||||
TRACE("%p\n", This->This);
|
||||
|
||||
|
@ -322,10 +332,14 @@ static nsresult NSAPI handle_htmlevent(nsIDOMEventListener *iface, nsIDOMEvent *
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
fire_event(doc, eid, TRUE, nsnode, event, NULL);
|
||||
|
||||
hres = get_node(doc, nsnode, TRUE, &node);
|
||||
nsIDOMNode_Release(nsnode);
|
||||
if(FAILED(hres))
|
||||
return NS_OK;
|
||||
|
||||
fire_event(doc, eid, TRUE, node, event, NULL);
|
||||
|
||||
node_release(node);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -448,11 +448,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.nsnode, NULL, NULL);
|
||||
&window->base.inner_window->doc->node, NULL, NULL);
|
||||
|
||||
if(window->frame_element)
|
||||
fire_event(window->frame_element->element.node.doc, EVENTID_READYSTATECHANGE,
|
||||
TRUE, window->frame_element->element.node.nsnode, NULL, NULL);
|
||||
TRUE, &window->frame_element->element.node, NULL, NULL);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -735,7 +735,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.nsnode, NULL, NULL);
|
||||
fire_event(task->elem->element.node.doc, EVENTID_READYSTATECHANGE, FALSE, &task->elem->element.node, NULL, NULL);
|
||||
}
|
||||
|
||||
static void fire_readystatechange_task_destr(task_t *_task)
|
||||
|
@ -771,7 +771,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.nsnode, NULL, NULL);
|
||||
&script_elem->element.node, NULL, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue