Commit 14db082f authored by Gabriel Ivăncescu's avatar Gabriel Ivăncescu Committed by Alexandre Julliard

mshtml: Get rid of dispatch_nsevent_hook.

Since wine-gecko now implements synchronous events for image loads in legacy modes, this is no longer needed. Signed-off-by: 's avatarGabriel Ivăncescu <gabrielopcode@gmail.com>
parent 6b107d41
......@@ -879,7 +879,6 @@ static const NodeImplVtbl HTMLAnchorElementImplVtbl = {
HTMLElement_destructor,
HTMLElement_cpc,
HTMLElement_clone,
HTMLElement_dispatch_nsevent_hook,
HTMLAnchorElement_handle_event,
HTMLElement_get_attr_col,
NULL,
......
......@@ -467,7 +467,6 @@ static const NodeImplVtbl HTMLAreaElementImplVtbl = {
HTMLElement_destructor,
HTMLElement_cpc,
HTMLElement_clone,
HTMLElement_dispatch_nsevent_hook,
HTMLAreaElement_handle_event,
HTMLElement_get_attr_col
};
......
......@@ -983,7 +983,6 @@ static const NodeImplVtbl HTMLBodyElementImplVtbl = {
HTMLElement_destructor,
HTMLBodyElement_cpc,
HTMLElement_clone,
HTMLElement_dispatch_nsevent_hook,
HTMLElement_handle_event,
HTMLElement_get_attr_col,
HTMLBodyElement_get_event_prop_target,
......
......@@ -189,7 +189,6 @@ static const NodeImplVtbl HTMLCommentElementImplVtbl = {
HTMLCommentElement_destructor,
HTMLElement_cpc,
HTMLCommentElement_clone,
HTMLElement_dispatch_nsevent_hook,
HTMLElement_handle_event,
HTMLElement_get_attr_col
};
......
......@@ -371,7 +371,6 @@ static event_target_vtbl_t DocumentType_event_target_vtbl = {
},
DocumentType_get_gecko_target,
NULL,
NULL,
DocumentType_get_parent_event_target,
NULL,
NULL,
......@@ -5891,7 +5890,6 @@ static const NodeImplVtbl HTMLDocumentNodeImplVtbl = {
NULL,
NULL,
NULL,
NULL,
HTMLDocumentNode_unlink
};
......@@ -6109,7 +6107,6 @@ static const event_target_vtbl_t HTMLDocumentNode_event_target_vtbl = {
},
HTMLDocumentNode_get_gecko_target,
HTMLDocumentNode_bind_event,
NULL,
HTMLDocumentNode_get_parent_event_target,
NULL,
HTMLDocumentNode_get_cp_container,
......@@ -6134,7 +6131,6 @@ static const NodeImplVtbl HTMLDocumentFragmentImplVtbl = {
NULL,
NULL,
NULL,
NULL,
HTMLDocumentFragment_unlink
};
......
......@@ -6873,11 +6873,6 @@ HRESULT HTMLElement_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **
return S_OK;
}
HRESULT HTMLElement_dispatch_nsevent_hook(HTMLDOMNode *iface, DOMEvent *event)
{
return S_FALSE;
}
HRESULT HTMLElement_handle_event(HTMLDOMNode *iface, DWORD eid, nsIDOMEvent *event, BOOL *prevent_default)
{
HTMLElement *This = impl_from_HTMLDOMNode(iface);
......@@ -6928,7 +6923,6 @@ static const NodeImplVtbl HTMLElementImplVtbl = {
HTMLElement_destructor,
HTMLElement_cpc,
HTMLElement_clone,
HTMLElement_dispatch_nsevent_hook,
HTMLElement_handle_event,
HTMLElement_get_attr_col
};
......@@ -7071,12 +7065,6 @@ static void HTMLElement_bind_event(DispatchEx *dispex, eventid_t eid)
ensure_doc_nsevent_handler(This->node.doc, This->node.nsnode, eid);
}
static HRESULT HTMLElement_event_target_dispatch_nsevent_hook(DispatchEx *dispex, DOMEvent *event)
{
HTMLElement *This = impl_from_DispatchEx(dispex);
return This->node.vtbl->dispatch_nsevent_hook(&This->node, event);
}
static HRESULT HTMLElement_handle_event_default(DispatchEx *dispex, eventid_t eid, nsIDOMEvent *nsevent, BOOL *prevent_default)
{
HTMLElement *This = impl_from_DispatchEx(dispex);
......@@ -7350,7 +7338,6 @@ static event_target_vtbl_t HTMLElement_event_target_vtbl = {
},
HTMLElement_get_gecko_target,
HTMLElement_bind_event,
HTMLElement_event_target_dispatch_nsevent_hook,
HTMLElement_get_parent_event_target,
HTMLElement_handle_event_default,
HTMLElement_get_cp_container,
......
......@@ -132,7 +132,6 @@ typedef struct {
dispex_static_data_vtbl_t dispex_vtbl;
nsISupports *(*get_gecko_target)(DispatchEx*);
void (*bind_event)(DispatchEx*,eventid_t);
HRESULT (*dispatch_nsevent_hook)(DispatchEx*,DOMEvent*);
EventTarget *(*get_parent_event_target)(DispatchEx*);
HRESULT (*handle_event_default)(DispatchEx*,eventid_t,nsIDOMEvent*,BOOL*);
ConnectionPointContainer *(*get_cp_container)(DispatchEx*);
......
......@@ -984,7 +984,6 @@ static const NodeImplVtbl HTMLFormElementImplVtbl = {
HTMLElement_destructor,
HTMLElement_cpc,
HTMLElement_clone,
HTMLElement_dispatch_nsevent_hook,
HTMLFormElement_handle_event,
HTMLElement_get_attr_col,
NULL,
......
......@@ -1018,7 +1018,6 @@ static const NodeImplVtbl HTMLFrameElementImplVtbl = {
HTMLFrameElement_destructor,
HTMLElement_cpc,
HTMLElement_clone,
HTMLElement_dispatch_nsevent_hook,
HTMLElement_handle_event,
HTMLElement_get_attr_col,
NULL,
......@@ -1612,7 +1611,6 @@ static const NodeImplVtbl HTMLIFrameImplVtbl = {
HTMLIFrame_destructor,
HTMLElement_cpc,
HTMLElement_clone,
HTMLElement_dispatch_nsevent_hook,
HTMLElement_handle_event,
HTMLElement_get_attr_col,
NULL,
......
......@@ -157,7 +157,6 @@ static const NodeImplVtbl HTMLGenericElementImplVtbl = {
HTMLGenericElement_destructor,
HTMLElement_cpc,
HTMLElement_clone,
HTMLElement_dispatch_nsevent_hook,
HTMLElement_handle_event,
HTMLElement_get_attr_col
};
......
......@@ -173,7 +173,6 @@ static const NodeImplVtbl HTMLTitleElementImplVtbl = {
HTMLTitleElement_destructor,
HTMLElement_cpc,
HTMLElement_clone,
HTMLElement_dispatch_nsevent_hook,
HTMLElement_handle_event,
HTMLElement_get_attr_col
};
......@@ -346,7 +345,6 @@ static const NodeImplVtbl HTMLHtmlElementImplVtbl = {
HTMLHtmlElement_destructor,
HTMLElement_cpc,
HTMLElement_clone,
HTMLElement_dispatch_nsevent_hook,
HTMLElement_handle_event,
HTMLElement_get_attr_col,
NULL,
......@@ -596,7 +594,6 @@ static const NodeImplVtbl HTMLMetaElementImplVtbl = {
HTMLMetaElement_destructor,
HTMLElement_cpc,
HTMLElement_clone,
HTMLElement_dispatch_nsevent_hook,
HTMLElement_handle_event,
HTMLElement_get_attr_col
};
......@@ -762,7 +759,6 @@ static const NodeImplVtbl HTMLHeadElementImplVtbl = {
HTMLHeadElement_destructor,
HTMLElement_cpc,
HTMLElement_clone,
HTMLElement_dispatch_nsevent_hook,
HTMLElement_handle_event,
HTMLElement_get_attr_col
};
......
......@@ -39,7 +39,6 @@ struct HTMLImg {
IHTMLImgElement IHTMLImgElement_iface;
nsIDOMHTMLImageElement *nsimg;
eventid_t skip_event;
};
static inline HTMLImg *impl_from_IHTMLImgElement(IHTMLImgElement *iface)
......@@ -282,7 +281,6 @@ static HRESULT WINAPI HTMLImgElement_get_alt(IHTMLImgElement *iface, BSTR *p)
static HRESULT WINAPI HTMLImgElement_put_src(IHTMLImgElement *iface, BSTR v)
{
HTMLImg *This = impl_from_IHTMLImgElement(iface);
HRESULT hres = S_OK;
nsAString src_str;
nsresult nsres;
......@@ -291,32 +289,7 @@ static HRESULT WINAPI HTMLImgElement_put_src(IHTMLImgElement *iface, BSTR v)
nsAString_InitDepend(&src_str, v);
nsres = nsIDOMHTMLImageElement_SetSrc(This->nsimg, &src_str);
nsAString_Finish(&src_str);
if(NS_FAILED(nsres))
ERR("SetSrc failed: %08lx\n", nsres);
if(dispex_compat_mode(&This->element.node.event_target.dispex) < COMPAT_MODE_IE9) {
eventid_t eventid;
cpp_bool complete;
UINT32 height = 0;
DOMEvent *event;
/* Synchronously send load event if the image was completed immediately (such as from cache) */
This->skip_event = EVENTID_INVALID_ID;
nsres = nsIDOMHTMLImageElement_GetComplete(This->nsimg, &complete);
if(NS_SUCCEEDED(nsres) && complete) {
nsIDOMHTMLImageElement_GetNaturalHeight(This->nsimg, &height);
eventid = height ? EVENTID_LOAD : EVENTID_ERROR;
hres = create_document_event(This->element.node.doc, eventid, &event);
if(SUCCEEDED(hres)) {
This->skip_event = eventid;
dispatch_event(&This->element.node.event_target, event);
IDOMEvent_Release(&event->IDOMEvent_iface);
}
}
}
return hres;
return map_nsresult(nsres);
}
static HRESULT WINAPI HTMLImgElement_get_src(IHTMLImgElement *iface, BSTR *p)
......@@ -702,18 +675,6 @@ static HRESULT HTMLImgElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
return S_OK;
}
static HRESULT HTMLImgElement_dispatch_nsevent_hook(HTMLDOMNode *iface, DOMEvent *event)
{
HTMLImg *This = impl_from_HTMLDOMNode(iface);
if(event->event_id == This->skip_event) {
This->skip_event = EVENTID_INVALID_ID;
return S_OK;
}
return S_FALSE;
}
static HRESULT HTMLImgElement_get_readystate(HTMLDOMNode *iface, BSTR *p)
{
HTMLImg *This = impl_from_HTMLDOMNode(iface);
......@@ -747,7 +708,6 @@ static const NodeImplVtbl HTMLImgElementImplVtbl = {
HTMLElement_destructor,
HTMLElement_cpc,
HTMLElement_clone,
HTMLImgElement_dispatch_nsevent_hook,
HTMLElement_handle_event,
HTMLElement_get_attr_col,
NULL,
......@@ -799,7 +759,6 @@ HRESULT HTMLImgElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTML
ret->IHTMLImgElement_iface.lpVtbl = &HTMLImgElementVtbl;
ret->element.node.vtbl = &HTMLImgElementImplVtbl;
ret->skip_event = EVENTID_INVALID_ID;
HTMLElement_Init(&ret->element, doc, nselem, &HTMLImgElement_dispex);
......
......@@ -1432,7 +1432,6 @@ static const NodeImplVtbl HTMLInputElementImplVtbl = {
HTMLElement_destructor,
HTMLElement_cpc,
HTMLElement_clone,
HTMLElement_dispatch_nsevent_hook,
HTMLElement_handle_event,
HTMLElement_get_attr_col,
NULL,
......@@ -1642,7 +1641,6 @@ static const NodeImplVtbl HTMLLabelElementImplVtbl = {
HTMLElement_destructor,
HTMLElement_cpc,
HTMLElement_clone,
HTMLElement_dispatch_nsevent_hook,
HTMLElement_handle_event,
HTMLElement_get_attr_col,
};
......@@ -1979,7 +1977,6 @@ static const NodeImplVtbl HTMLButtonElementImplVtbl = {
HTMLElement_destructor,
HTMLElement_cpc,
HTMLElement_clone,
HTMLElement_dispatch_nsevent_hook,
HTMLElement_handle_event,
HTMLElement_get_attr_col,
NULL,
......
......@@ -426,7 +426,6 @@ static const NodeImplVtbl HTMLLinkElementImplVtbl = {
HTMLElement_destructor,
HTMLElement_cpc,
HTMLElement_clone,
HTMLElement_dispatch_nsevent_hook,
HTMLElement_handle_event,
HTMLElement_get_attr_col,
NULL,
......
......@@ -754,7 +754,6 @@ static const NodeImplVtbl HTMLObjectElementImplVtbl = {
HTMLObjectElement_destructor,
HTMLElement_cpc,
HTMLElement_clone,
HTMLElement_dispatch_nsevent_hook,
HTMLElement_handle_event,
HTMLElement_get_attr_col,
NULL,
......@@ -1030,7 +1029,6 @@ static const NodeImplVtbl HTMLEmbedElementImplVtbl = {
HTMLEmbedElement_destructor,
HTMLElement_cpc,
HTMLElement_clone,
HTMLElement_dispatch_nsevent_hook,
HTMLElement_handle_event,
HTMLElement_get_attr_col
};
......
......@@ -438,7 +438,6 @@ static const NodeImplVtbl HTMLScriptElementImplVtbl = {
HTMLScriptElement_destructor,
HTMLElement_cpc,
HTMLElement_clone,
HTMLElement_dispatch_nsevent_hook,
HTMLElement_handle_event,
HTMLElement_get_attr_col,
NULL,
......
......@@ -396,7 +396,6 @@ static const NodeImplVtbl HTMLOptionElementImplVtbl = {
HTMLElement_destructor,
HTMLElement_cpc,
HTMLElement_clone,
HTMLElement_dispatch_nsevent_hook,
HTMLElement_handle_event,
HTMLElement_get_attr_col,
NULL,
......@@ -1473,7 +1472,6 @@ static const NodeImplVtbl HTMLSelectElementImplVtbl = {
HTMLElement_destructor,
HTMLElement_cpc,
HTMLElement_clone,
HTMLElement_dispatch_nsevent_hook,
HTMLElement_handle_event,
HTMLElement_get_attr_col,
NULL,
......
......@@ -443,7 +443,6 @@ static const NodeImplVtbl HTMLStyleElementImplVtbl = {
HTMLStyleElement_destructor,
HTMLElement_cpc,
HTMLElement_clone,
HTMLElement_dispatch_nsevent_hook,
HTMLElement_handle_event,
HTMLElement_get_attr_col,
NULL,
......
......@@ -499,7 +499,6 @@ static const NodeImplVtbl HTMLTableCellImplVtbl = {
HTMLTableCell_destructor,
HTMLElement_cpc,
HTMLElement_clone,
HTMLElement_dispatch_nsevent_hook,
HTMLElement_handle_event,
HTMLElement_get_attr_col,
NULL,
......@@ -946,7 +945,6 @@ static const NodeImplVtbl HTMLTableRowImplVtbl = {
HTMLElement_destructor,
HTMLElement_cpc,
HTMLElement_clone,
HTMLElement_dispatch_nsevent_hook,
HTMLElement_handle_event,
HTMLElement_get_attr_col,
NULL,
......@@ -1979,7 +1977,6 @@ static const NodeImplVtbl HTMLTableImplVtbl = {
HTMLElement_destructor,
HTMLTable_cpc,
HTMLElement_clone,
HTMLElement_dispatch_nsevent_hook,
HTMLElement_handle_event,
HTMLElement_get_attr_col,
NULL,
......
......@@ -457,7 +457,6 @@ static const NodeImplVtbl HTMLTextAreaElementImplVtbl = {
HTMLElement_destructor,
HTMLElement_cpc,
HTMLElement_clone,
HTMLElement_dispatch_nsevent_hook,
HTMLElement_handle_event,
HTMLElement_get_attr_col,
NULL,
......
......@@ -4001,7 +4001,6 @@ static const event_target_vtbl_t HTMLWindow_event_target_vtbl = {
NULL,
NULL,
NULL,
NULL,
HTMLWindow_set_current_event
};
......
......@@ -804,7 +804,6 @@ typedef struct {
void (*destructor)(HTMLDOMNode*);
const cpc_entry_t *cpc_entries;
HRESULT (*clone)(HTMLDOMNode*,nsIDOMNode*,HTMLDOMNode**);
HRESULT (*dispatch_nsevent_hook)(HTMLDOMNode*,DOMEvent*);
HRESULT (*handle_event)(HTMLDOMNode*,DWORD,nsIDOMEvent*,BOOL*);
HRESULT (*get_attr_col)(HTMLDOMNode*,HTMLAttributeCollection**);
EventTarget *(*get_event_prop_target)(HTMLDOMNode*,int);
......@@ -1209,7 +1208,6 @@ HRESULT HTMLElement_QI(HTMLDOMNode*,REFIID,void**) DECLSPEC_HIDDEN;
void HTMLElement_destructor(HTMLDOMNode*) DECLSPEC_HIDDEN;
HRESULT HTMLElement_clone(HTMLDOMNode*,nsIDOMNode*,HTMLDOMNode**) DECLSPEC_HIDDEN;
HRESULT HTMLElement_get_attr_col(HTMLDOMNode*,HTMLAttributeCollection**) DECLSPEC_HIDDEN;
HRESULT HTMLElement_dispatch_nsevent_hook(HTMLDOMNode*,DOMEvent*) DECLSPEC_HIDDEN;
HRESULT HTMLElement_handle_event(HTMLDOMNode*,DWORD,nsIDOMEvent*,BOOL*) DECLSPEC_HIDDEN;
void HTMLElement_init_dispex_info(dispex_data_t*,compat_mode_t) DECLSPEC_HIDDEN;
......
......@@ -438,7 +438,6 @@ static nsresult handle_unload(HTMLDocumentNode *doc, nsIDOMEvent *nsevent)
static nsresult handle_htmlevent(HTMLDocumentNode *doc, nsIDOMEvent *nsevent)
{
const event_target_vtbl_t *target_vtbl;
nsIDOMEventTarget *event_target;
EventTarget *target;
nsIDOMNode *nsnode;
......@@ -487,15 +486,7 @@ static nsresult handle_htmlevent(HTMLDocumentNode *doc, nsIDOMEvent *nsevent)
}
}
target_vtbl = dispex_get_vtbl(&target->dispex);
if(target_vtbl && target_vtbl->dispatch_nsevent_hook &&
target_vtbl->dispatch_nsevent_hook(&target->dispex, event) == S_OK) {
/* overridden by hook, so cancel it */
nsIDOMEvent_StopPropagation(nsevent);
}else {
dispatch_event(target, event);
}
dispatch_event(target, event);
IDOMEvent_Release(&event->IDOMEvent_iface);
IEventTarget_Release(&target->IEventTarget_iface);
......
......@@ -198,7 +198,6 @@ static const NodeImplVtbl SVGElementImplVtbl = {
HTMLElement_destructor,
HTMLElement_cpc,
HTMLElement_clone,
HTMLElement_dispatch_nsevent_hook,
NULL,
HTMLElement_get_attr_col,
};
......@@ -740,7 +739,6 @@ static const NodeImplVtbl SVGSVGElementImplVtbl = {
HTMLElement_destructor,
HTMLElement_cpc,
HTMLElement_clone,
HTMLElement_dispatch_nsevent_hook,
NULL,
HTMLElement_get_attr_col,
};
......@@ -910,7 +908,6 @@ static const NodeImplVtbl SVGCircleElementImplVtbl = {
HTMLElement_destructor,
HTMLElement_cpc,
HTMLElement_clone,
HTMLElement_dispatch_nsevent_hook,
NULL,
HTMLElement_get_attr_col,
};
......@@ -1155,7 +1152,6 @@ static const NodeImplVtbl SVGTSpanElementImplVtbl = {
HTMLElement_destructor,
HTMLElement_cpc,
HTMLElement_clone,
HTMLElement_dispatch_nsevent_hook,
NULL,
HTMLElement_get_attr_col,
};
......
......@@ -155,7 +155,12 @@ static const char img_doc_ie9_str[] =
"<body><img id=\"imgid\"></img></body></html>";
static const char input_image_doc_str[] =
"<html><body><input type=\"image\" id=\"inputid\"></input></body></html>";
"<html><head><meta http-equiv=\"x-ua-compatible\" content=\"IE=8\" /></head>"
"<body><input type=\"image\" id=\"inputid\"></input></body></html>";
static const char input_image_doc_ie9_str[] =
"<html><head><meta http-equiv=\"x-ua-compatible\" content=\"IE=9\" /></head>"
"<body><input type=\"image\" id=\"inputid\"></input></body></html>";
static const char link_doc_str[] =
"<html><body><link id=\"linkid\" rel=\"stylesheet\" type=\"text/css\"></link></body></html>";
......@@ -1101,7 +1106,7 @@ static HRESULT WINAPI input_onload(IDispatchEx *iface, DISPID id, LCID lcid, WOR
VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
{
CHECK_EXPECT(input_onload);
test_event_args(&DIID_DispHTMLInputElement, id, wFlags, pdp, pvarRes, pei, pspCaller);
test_event_args(document_mode < 9 ? &DIID_DispHTMLInputElement : NULL, id, wFlags, pdp, pvarRes, pei, pspCaller);
test_event_src(L"INPUT");
return S_OK;
}
......@@ -2419,7 +2424,6 @@ static void test_inputload(IHTMLDocument2 *doc)
elem = get_elem_id(doc, L"inputid");
hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLInputElement, (void**)&input);
IHTMLElement_Release(elem);
ok(hres == S_OK, "Could not get IHTMLInputElement iface: %08lx\n", hres);
V_VT(&v) = VT_EMPTY;
......@@ -2446,7 +2450,6 @@ static void test_inputload(IHTMLDocument2 *doc)
str = SysAllocString(L"http://test.winehq.org/tests/winehq_snapshot/index_files/winehq_logo_text.png?v=2");
hres = IHTMLInputElement_put_src(input, str);
ok(hres == S_OK, "put_src failed: %08lx\n", hres);
SysFreeString(str);
hres = IHTMLInputElement_get_complete(input, &b);
ok(hres == S_OK, "get_complete failed: %08lx\n", hres);
......@@ -2460,7 +2463,40 @@ static void test_inputload(IHTMLDocument2 *doc)
ok(hres == S_OK, "get_complete failed: %08lx\n", hres);
ok(b == VARIANT_TRUE, "complete = %x\n", b);
/* cached images send synchronous load event in legacy modes */
if(document_mode < 9)
SET_EXPECT(input_onload);
hres = IHTMLInputElement_put_src(input, str);
ok(hres == S_OK, "put_src failed: %08lx\n", hres);
if(document_mode < 9) {
CHECK_CALLED(input_onload);
pump_msgs(NULL);
}else {
SET_EXPECT(input_onload);
pump_msgs(&called_input_onload);
CHECK_CALLED(input_onload);
}
if(document_mode < 9)
SET_EXPECT(input_onload);
V_VT(&v) = VT_BSTR;
V_BSTR(&v) = str;
str = SysAllocString(L"src");
hres = IHTMLElement_setAttribute(elem, str, v, 0);
ok(hres == S_OK, "setAttribute failed: %08lx\n", hres);
SysFreeString(str);
VariantClear(&v);
if(document_mode < 9) {
CHECK_CALLED(input_onload);
pump_msgs(NULL);
}else {
SET_EXPECT(input_onload);
pump_msgs(&called_input_onload);
CHECK_CALLED(input_onload);
}
IHTMLInputElement_Release(input);
IHTMLElement_Release(elem);
}
static void test_link_load(IHTMLDocument2 *doc)
......@@ -6306,6 +6342,7 @@ START_TEST(events)
run_test_from_res(L"iframe.html", test_unload_event);
run_test(empty_doc_ie9_str, test_create_event);
run_test(img_doc_ie9_str, test_imgload);
run_test(input_image_doc_ie9_str, test_inputload);
}
test_empty_document();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment