From 946bd4ae1c3c0c7a596de138e8b865e6656f970e Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Tue, 13 Oct 2009 00:42:02 +0200 Subject: [PATCH] mshtml: Added IHTMLElement3::fireEvent implementation. --- dlls/mshtml/htmlelem3.c | 8 ++++++-- dlls/mshtml/htmlevent.c | 24 ++++++++++++++++++++++++ dlls/mshtml/htmlevent.h | 1 + 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/dlls/mshtml/htmlelem3.c b/dlls/mshtml/htmlelem3.c index 22c93a948a1..30c854637d1 100644 --- a/dlls/mshtml/htmlelem3.c +++ b/dlls/mshtml/htmlelem3.c @@ -29,6 +29,7 @@ #include "wine/unicode.h" #include "mshtml_private.h" +#include "htmlevent.h" WINE_DEFAULT_DEBUG_CHANNEL(mshtml); @@ -292,8 +293,11 @@ static HRESULT WINAPI HTMLElement3_fireEvent(IHTMLElement3 *iface, BSTR bstrEven VARIANT *pvarEventObject, VARIANT_BOOL *pfCancelled) { HTMLElement *This = HTMLELEM3_THIS(iface); - FIXME("(%p)->(%s %p %p)\n", This, debugstr_w(bstrEventName), pvarEventObject, pfCancelled); - return E_NOTIMPL; + + TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(bstrEventName), debugstr_variant(pvarEventObject), + pfCancelled); + + return dispatch_event(&This->node, bstrEventName, pvarEventObject, pfCancelled); } static HRESULT WINAPI HTMLElement3_put_onresizestart(IHTMLElement3 *iface, VARIANT v) diff --git a/dlls/mshtml/htmlevent.c b/dlls/mshtml/htmlevent.c index 73e0540c361..b006478e30c 100644 --- a/dlls/mshtml/htmlevent.c +++ b/dlls/mshtml/htmlevent.c @@ -853,6 +853,30 @@ void fire_event(HTMLDocumentNode *doc, eventid_t eid, nsIDOMNode *target, nsIDOM doc->basedoc.window->event = prev_event; } +HRESULT dispatch_event(HTMLDOMNode *node, const WCHAR *event_name, VARIANT *event_obj, VARIANT_BOOL *cancelled) +{ + eventid_t eid; + + eid = attr_to_eid(event_name); + if(eid == EVENTID_LAST) { + WARN("unknown event %s\n", debugstr_w(event_name)); + return E_INVALIDARG; + } + + if(event_obj && V_VT(event_obj) != VT_EMPTY && V_VT(event_obj) != VT_ERROR) + FIXME("event_obj not implemented\n"); + + if(!(event_info[eid].flags & EVENT_DEFAULTLISTENER)) { + FIXME("not EVENT_DEFAULTEVENTHANDLER\n"); + return E_NOTIMPL; + } + + fire_event(node->doc, eid, node->nsnode, NULL); + + *cancelled = VARIANT_TRUE; /* FIXME */ + return S_OK; +} + static inline event_target_t *get_event_target(event_target_t **event_target_ptr) { if(!*event_target_ptr) diff --git a/dlls/mshtml/htmlevent.h b/dlls/mshtml/htmlevent.h index 4446aa96fba..6c716a81b52 100644 --- a/dlls/mshtml/htmlevent.h +++ b/dlls/mshtml/htmlevent.h @@ -45,6 +45,7 @@ void fire_event(HTMLDocumentNode*,eventid_t,nsIDOMNode*,nsIDOMEvent*); HRESULT set_event_handler(event_target_t**,HTMLDocument*,eventid_t,VARIANT*); HRESULT get_event_handler(event_target_t**,eventid_t,VARIANT*); HRESULT attach_event(event_target_t**,HTMLDocument*,BSTR,IDispatch*,VARIANT_BOOL*); +HRESULT dispatch_event(HTMLDOMNode*,const WCHAR*,VARIANT*,VARIANT_BOOL*); static inline event_target_t **get_node_event_target(HTMLDOMNode *node) {