mshtml: Set 'this' to window object for onload handlers.

This commit is contained in:
Jacek Caban 2012-10-22 11:59:45 +02:00 committed by Alexandre Julliard
parent 610ea94da5
commit 4940275d21
6 changed files with 19 additions and 16 deletions

View File

@ -1664,7 +1664,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);
fire_event(This->node.doc, EVENTID_HELP, TRUE, This->node.nsnode, NULL, NULL);
*prevent_default = TRUE;
}

View File

@ -1033,7 +1033,8 @@ static void call_event_handlers(HTMLDocumentNode *doc, HTMLEventObj *event_obj,
}
}
static void fire_event_obj(HTMLDocumentNode *doc, eventid_t eid, HTMLEventObj *event_obj, nsIDOMNode *target)
static void fire_event_obj(HTMLDocumentNode *doc, eventid_t eid, HTMLEventObj *event_obj,
nsIDOMNode *target, IDispatch *script_this)
{
IHTMLEventObj *prev_event;
nsIDOMNode *parent, *nsnode;
@ -1060,7 +1061,7 @@ static void fire_event_obj(HTMLDocumentNode *doc, eventid_t eid, HTMLEventObj *e
hres = get_node(doc, nsnode, FALSE, &node);
if(SUCCEEDED(hres) && node) {
call_event_handlers(doc, event_obj, *get_node_event_target(node),
node->cp_container, eid, (IDispatch*)&node->IHTMLDOMNode_iface);
node->cp_container, eid, script_this ? script_this : (IDispatch*)&node->IHTMLDOMNode_iface);
node_release(node);
}
@ -1089,7 +1090,7 @@ static void fire_event_obj(HTMLDocumentNode *doc, eventid_t eid, HTMLEventObj *e
hres = get_node(doc, (nsIDOMNode*)nsbody, FALSE, &node);
if(SUCCEEDED(hres) && node) {
call_event_handlers(doc, event_obj, *get_node_event_target(node),
node->cp_container, eid, (IDispatch*)&node->IHTMLDOMNode_iface);
node->cp_container, eid, script_this ? script_this : (IDispatch*)&node->IHTMLDOMNode_iface);
node_release(node);
}
nsIDOMHTMLElement_Release(nsbody);
@ -1099,7 +1100,7 @@ static void fire_event_obj(HTMLDocumentNode *doc, eventid_t eid, HTMLEventObj *e
}
call_event_handlers(doc, event_obj, doc->node.event_target, &doc->basedoc.cp_container, eid,
(IDispatch*)&doc->basedoc.IHTMLDocument2_iface);
script_this ? script_this : (IDispatch*)&doc->basedoc.IHTMLDocument2_iface);
break;
default:
@ -1148,7 +1149,8 @@ static void fire_event_obj(HTMLDocumentNode *doc, eventid_t eid, HTMLEventObj *e
}
}
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, nsIDOMNode *target, nsIDOMEvent *nsevent,
IDispatch *script_this)
{
HTMLEventObj *event_obj = NULL;
HTMLDOMNode *node;
@ -1171,7 +1173,7 @@ void fire_event(HTMLDocumentNode *doc, eventid_t eid, BOOL set_event, nsIDOMNode
}
}
fire_event_obj(doc, eid, event_obj, target);
fire_event_obj(doc, eid, event_obj, target, script_this);
if(event_obj)
IHTMLEventObj_Release(&event_obj->IHTMLEventObj_iface);
@ -1216,7 +1218,7 @@ 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);
fire_event_obj(node->doc, eid, event_obj, node->nsnode, NULL);
IHTMLEventObj_Release(&event_obj->IHTMLEventObj_iface);
if(FAILED(hres))
@ -1227,7 +1229,7 @@ HRESULT dispatch_event(HTMLDOMNode *node, const WCHAR *event_name, VARIANT *even
return E_NOTIMPL;
}
fire_event(node->doc, eid, TRUE, node->nsnode, NULL);
fire_event(node->doc, eid, TRUE, node->nsnode, NULL, NULL);
}
*cancelled = VARIANT_TRUE; /* FIXME */
@ -1246,7 +1248,7 @@ HRESULT call_fire_event(HTMLDOMNode *node, eventid_t eid)
return hres;
}
fire_event(node->doc, eid, TRUE, node->nsnode, NULL);
fire_event(node->doc, eid, TRUE, node->nsnode, NULL, NULL);
return S_OK;
}

View File

@ -51,7 +51,7 @@ typedef enum {
eventid_t str_to_eid(LPCWSTR) DECLSPEC_HIDDEN;
void check_event_attr(HTMLDocumentNode*,nsIDOMElement*) DECLSPEC_HIDDEN;
void release_event_target(event_target_t*) DECLSPEC_HIDDEN;
void fire_event(HTMLDocumentNode*,eventid_t,BOOL,nsIDOMNode*,nsIDOMEvent*) DECLSPEC_HIDDEN;
void fire_event(HTMLDocumentNode*,eventid_t,BOOL,nsIDOMNode*,nsIDOMEvent*,IDispatch*) DECLSPEC_HIDDEN;
HRESULT set_event_handler(event_target_t**,nsIDOMNode*,HTMLDocumentNode*,eventid_t,VARIANT*) DECLSPEC_HIDDEN;
HRESULT get_event_handler(event_target_t**,eventid_t,VARIANT*) DECLSPEC_HIDDEN;
HRESULT attach_event(event_target_t**,nsIDOMNode*,HTMLDocument*,BSTR,IDispatch*,VARIANT_BOOL*) DECLSPEC_HIDDEN;

View File

@ -1418,7 +1418,7 @@ 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);
fire_event(This->doc->basedoc.doc_node /* FIXME */, EVENTID_CONTEXTMENU, TRUE, aNode, aEvent, NULL);
nsres = nsIDOMEvent_QueryInterface(aEvent, &IID_nsIDOMMouseEvent, (void**)&event);
if(NS_FAILED(nsres)) {

View File

@ -269,7 +269,7 @@ static nsresult NSAPI handle_load(nsIDOMEventListener *iface, nsIDOMEvent *event
nsIDOMHTMLDocument_GetBody(doc->nsdoc, &nsbody);
if(nsbody) {
fire_event(doc, EVENTID_LOAD, TRUE, (nsIDOMNode*)nsbody, event);
fire_event(doc, EVENTID_LOAD, TRUE, (nsIDOMNode*)nsbody, event, (IDispatch*)&doc->window->base.IDispatchEx_iface);
nsIDOMHTMLElement_Release(nsbody);
}
@ -313,7 +313,7 @@ static nsresult NSAPI handle_htmlevent(nsIDOMEventListener *iface, nsIDOMEvent *
return NS_OK;
}
fire_event(doc, eid, TRUE, nsnode, event);
fire_event(doc, eid, TRUE, nsnode, event, NULL);
nsIDOMNode_Release(nsnode);

View File

@ -409,11 +409,12 @@ void set_ready_state(HTMLOuterWindow *window, READYSTATE readystate)
if(window->doc_obj && window->doc_obj->basedoc.window == window)
call_property_onchanged(&window->doc_obj->basedoc.cp_propnotif, DISPID_READYSTATE);
fire_event(window->base.inner_window->doc, EVENTID_READYSTATECHANGE, FALSE, window->base.inner_window->doc->node.nsnode, NULL);
fire_event(window->base.inner_window->doc, EVENTID_READYSTATECHANGE, FALSE,
window->base.inner_window->doc->node.nsnode, NULL, NULL);
if(window->frame_element)
fire_event(window->frame_element->element.node.doc, EVENTID_READYSTATECHANGE,
TRUE, window->frame_element->element.node.nsnode, NULL);
TRUE, window->frame_element->element.node.nsnode, NULL, NULL);
}
static HRESULT get_doc_string(HTMLDocumentNode *This, char **str)