2008-04-18 18:16:35 +00:00
|
|
|
/*
|
2009-09-06 17:05:40 +00:00
|
|
|
* Copyright 2008-2009 Jacek Caban for CodeWeavers
|
2008-04-18 18:16:35 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "ole2.h"
|
2009-11-23 18:28:43 +00:00
|
|
|
#include "mshtmdid.h"
|
2008-04-18 18:16:35 +00:00
|
|
|
|
|
|
|
#include "mshtml_private.h"
|
2008-10-09 20:36:01 +00:00
|
|
|
#include "htmlevent.h"
|
2008-04-18 18:16:35 +00:00
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
|
|
|
|
|
2009-09-06 17:05:40 +00:00
|
|
|
typedef struct {
|
|
|
|
IDispatch *handler_prop;
|
|
|
|
DWORD handler_cnt;
|
|
|
|
IDispatch *handlers[0];
|
|
|
|
} handler_vector_t;
|
|
|
|
|
2008-04-18 18:16:35 +00:00
|
|
|
struct event_target_t {
|
2010-03-18 00:05:38 +00:00
|
|
|
DWORD node_handlers_mask;
|
2009-09-06 17:05:40 +00:00
|
|
|
handler_vector_t *event_table[EVENTID_LAST];
|
2008-04-18 18:16:35 +00:00
|
|
|
};
|
|
|
|
|
2009-09-08 20:30:14 +00:00
|
|
|
static const WCHAR beforeunloadW[] = {'b','e','f','o','r','e','u','n','l','o','a','d',0};
|
|
|
|
static const WCHAR onbeforeunloadW[] = {'o','n','b','e','f','o','r','e','u','n','l','o','a','d',0};
|
|
|
|
|
2008-10-10 20:49:09 +00:00
|
|
|
static const WCHAR blurW[] = {'b','l','u','r',0};
|
|
|
|
static const WCHAR onblurW[] = {'o','n','b','l','u','r',0};
|
|
|
|
|
2008-06-24 20:23:30 +00:00
|
|
|
static const WCHAR changeW[] = {'c','h','a','n','g','e',0};
|
|
|
|
static const WCHAR onchangeW[] = {'o','n','c','h','a','n','g','e',0};
|
|
|
|
|
2008-06-23 14:54:00 +00:00
|
|
|
static const WCHAR clickW[] = {'c','l','i','c','k',0};
|
|
|
|
static const WCHAR onclickW[] = {'o','n','c','l','i','c','k',0};
|
|
|
|
|
2010-05-07 13:20:33 +00:00
|
|
|
static const WCHAR contextmenuW[] = {'c','o','n','t','e','x','t','m','e','n','u',0};
|
|
|
|
static const WCHAR oncontextmenuW[] = {'o','n','c','o','n','t','e','x','t','m','e','n','u',0};
|
|
|
|
|
2009-09-08 20:32:47 +00:00
|
|
|
static const WCHAR dblclickW[] = {'d','b','l','c','l','i','c','k',0};
|
|
|
|
static const WCHAR ondblclickW[] = {'o','n','d','b','l','c','l','i','c','k',0};
|
|
|
|
|
2008-10-10 20:49:09 +00:00
|
|
|
static const WCHAR dragW[] = {'d','r','a','g',0};
|
|
|
|
static const WCHAR ondragW[] = {'o','n','d','r','a','g',0};
|
|
|
|
|
2008-10-10 20:49:25 +00:00
|
|
|
static const WCHAR dragstartW[] = {'d','r','a','g','s','t','a','r','t',0};
|
|
|
|
static const WCHAR ondragstartW[] = {'o','n','d','r','a','g','s','t','a','r','t',0};
|
|
|
|
|
2008-10-10 20:49:09 +00:00
|
|
|
static const WCHAR focusW[] = {'f','o','c','u','s',0};
|
|
|
|
static const WCHAR onfocusW[] = {'o','n','f','o','c','u','s',0};
|
|
|
|
|
2008-10-10 20:49:16 +00:00
|
|
|
static const WCHAR keydownW[] = {'k','e','y','d','o','w','n',0};
|
|
|
|
static const WCHAR onkeydownW[] = {'o','n','k','e','y','d','o','w','n',0};
|
|
|
|
|
2008-06-24 01:01:04 +00:00
|
|
|
static const WCHAR keyupW[] = {'k','e','y','u','p',0};
|
|
|
|
static const WCHAR onkeyupW[] = {'o','n','k','e','y','u','p',0};
|
|
|
|
|
2008-04-18 18:16:35 +00:00
|
|
|
static const WCHAR loadW[] = {'l','o','a','d',0};
|
|
|
|
static const WCHAR onloadW[] = {'o','n','l','o','a','d',0};
|
|
|
|
|
2008-10-10 20:49:16 +00:00
|
|
|
static const WCHAR mousedownW[] = {'m','o','u','s','e','d','o','w','n',0};
|
|
|
|
static const WCHAR onmousedownW[] = {'o','n','m','o','u','s','e','d','o','w','n',0};
|
|
|
|
|
2008-10-10 20:49:33 +00:00
|
|
|
static const WCHAR mouseoutW[] = {'m','o','u','s','e','o','u','t',0};
|
|
|
|
static const WCHAR onmouseoutW[] = {'o','n','m','o','u','s','e','o','u','t',0};
|
|
|
|
|
2008-10-10 20:46:08 +00:00
|
|
|
static const WCHAR mouseoverW[] = {'m','o','u','s','e','o','v','e','r',0};
|
|
|
|
static const WCHAR onmouseoverW[] = {'o','n','m','o','u','s','e','o','v','e','r',0};
|
|
|
|
|
2008-10-10 20:49:16 +00:00
|
|
|
static const WCHAR mouseupW[] = {'m','o','u','s','e','u','p',0};
|
|
|
|
static const WCHAR onmouseupW[] = {'o','n','m','o','u','s','e','u','p',0};
|
|
|
|
|
2008-10-10 20:49:09 +00:00
|
|
|
static const WCHAR pasteW[] = {'p','a','s','t','e',0};
|
|
|
|
static const WCHAR onpasteW[] = {'o','n','p','a','s','t','e',0};
|
|
|
|
|
2009-09-13 22:35:40 +00:00
|
|
|
static const WCHAR readystatechangeW[] = {'r','e','a','d','y','s','t','a','t','e','c','h','a','n','g','e',0};
|
|
|
|
static const WCHAR onreadystatechangeW[] = {'o','n','r','e','a','d','y','s','t','a','t','e','c','h','a','n','g','e',0};
|
|
|
|
|
2009-12-07 22:28:10 +00:00
|
|
|
static const WCHAR resizeW[] = {'r','e','s','i','z','e',0};
|
|
|
|
static const WCHAR onresizeW[] = {'o','n','r','e','s','i','z','e',0};
|
|
|
|
|
2008-10-10 20:49:25 +00:00
|
|
|
static const WCHAR selectstartW[] = {'s','e','l','e','c','t','s','t','a','r','t',0};
|
|
|
|
static const WCHAR onselectstartW[] = {'o','n','s','e','l','e','c','t','s','t','a','r','t',0};
|
|
|
|
|
2009-10-12 22:41:44 +00:00
|
|
|
static const WCHAR HTMLEventsW[] = {'H','T','M','L','E','v','e','n','t','s',0};
|
|
|
|
static const WCHAR KeyboardEventW[] = {'K','e','y','b','o','a','r','d','E','v','e','n','t',0};
|
|
|
|
static const WCHAR MouseEventW[] = {'M','o','u','s','e','E','v','e','n','t',0};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
EVENTT_NONE,
|
|
|
|
EVENTT_HTML,
|
|
|
|
EVENTT_KEY,
|
|
|
|
EVENTT_MOUSE
|
|
|
|
};
|
|
|
|
|
|
|
|
static const WCHAR *event_types[] = {
|
|
|
|
NULL,
|
|
|
|
HTMLEventsW,
|
|
|
|
KeyboardEventW,
|
|
|
|
MouseEventW
|
|
|
|
};
|
|
|
|
|
2008-04-18 18:16:35 +00:00
|
|
|
typedef struct {
|
|
|
|
LPCWSTR name;
|
|
|
|
LPCWSTR attr_name;
|
2009-10-12 22:41:44 +00:00
|
|
|
DWORD type;
|
2009-11-23 18:28:43 +00:00
|
|
|
DISPID dispid;
|
2008-06-23 14:54:33 +00:00
|
|
|
DWORD flags;
|
2008-04-18 18:16:35 +00:00
|
|
|
} event_info_t;
|
|
|
|
|
2008-06-23 14:54:33 +00:00
|
|
|
#define EVENT_DEFAULTLISTENER 0x0001
|
2008-10-10 20:46:47 +00:00
|
|
|
#define EVENT_BUBBLE 0x0002
|
2009-09-08 20:32:08 +00:00
|
|
|
#define EVENT_FORWARDBODY 0x0004
|
2010-03-18 00:05:38 +00:00
|
|
|
#define EVENT_NODEHANDLER 0x0008
|
2008-06-23 14:54:33 +00:00
|
|
|
|
2008-04-18 18:16:35 +00:00
|
|
|
static const event_info_t event_info[] = {
|
2009-11-23 18:28:43 +00:00
|
|
|
{beforeunloadW, onbeforeunloadW, EVENTT_NONE, DISPID_EVMETH_ONBEFOREUNLOAD,
|
|
|
|
EVENT_DEFAULTLISTENER|EVENT_FORWARDBODY},
|
|
|
|
{blurW, onblurW, EVENTT_HTML, DISPID_EVMETH_ONBLUR,
|
|
|
|
EVENT_DEFAULTLISTENER},
|
|
|
|
{changeW, onchangeW, EVENTT_HTML, DISPID_EVMETH_ONCHANGE,
|
|
|
|
EVENT_DEFAULTLISTENER|EVENT_BUBBLE},
|
|
|
|
{clickW, onclickW, EVENTT_MOUSE, DISPID_EVMETH_ONCLICK,
|
|
|
|
EVENT_DEFAULTLISTENER|EVENT_BUBBLE},
|
2010-05-07 13:20:33 +00:00
|
|
|
{contextmenuW, oncontextmenuW, EVENTT_MOUSE, DISPID_EVMETH_ONCONTEXTMENU,
|
|
|
|
EVENT_BUBBLE},
|
2009-11-23 18:28:43 +00:00
|
|
|
{dblclickW, ondblclickW, EVENTT_MOUSE, DISPID_EVMETH_ONDBLCLICK,
|
|
|
|
EVENT_DEFAULTLISTENER|EVENT_BUBBLE},
|
|
|
|
{dragW, ondragW, EVENTT_MOUSE, DISPID_EVMETH_ONDRAG,
|
|
|
|
0},
|
|
|
|
{dragstartW, ondragstartW, EVENTT_MOUSE, DISPID_EVMETH_ONDRAGSTART,
|
|
|
|
0},
|
|
|
|
{focusW, onfocusW, EVENTT_HTML, DISPID_EVMETH_ONFOCUS,
|
|
|
|
EVENT_DEFAULTLISTENER},
|
|
|
|
{keydownW, onkeydownW, EVENTT_KEY, DISPID_EVMETH_ONKEYDOWN,
|
|
|
|
EVENT_DEFAULTLISTENER|EVENT_BUBBLE},
|
|
|
|
{keyupW, onkeyupW, EVENTT_KEY, DISPID_EVMETH_ONKEYUP,
|
|
|
|
EVENT_DEFAULTLISTENER|EVENT_BUBBLE},
|
|
|
|
{loadW, onloadW, EVENTT_HTML, DISPID_EVMETH_ONLOAD,
|
2010-03-18 00:05:38 +00:00
|
|
|
EVENT_NODEHANDLER},
|
2009-11-23 18:28:43 +00:00
|
|
|
{mousedownW, onmousedownW, EVENTT_MOUSE, DISPID_EVMETH_ONMOUSEDOWN,
|
|
|
|
EVENT_DEFAULTLISTENER|EVENT_BUBBLE},
|
|
|
|
{mouseoutW, onmouseoutW, EVENTT_MOUSE, DISPID_EVMETH_ONMOUSEOUT,
|
|
|
|
EVENT_DEFAULTLISTENER|EVENT_BUBBLE},
|
|
|
|
{mouseoverW, onmouseoverW, EVENTT_MOUSE, DISPID_EVMETH_ONMOUSEOVER,
|
|
|
|
EVENT_DEFAULTLISTENER|EVENT_BUBBLE},
|
|
|
|
{mouseupW, onmouseupW, EVENTT_MOUSE, DISPID_EVMETH_ONMOUSEUP,
|
|
|
|
EVENT_DEFAULTLISTENER|EVENT_BUBBLE},
|
|
|
|
{pasteW, onpasteW, EVENTT_NONE, DISPID_EVMETH_ONPASTE,
|
|
|
|
0},
|
|
|
|
{readystatechangeW, onreadystatechangeW, EVENTT_NONE, DISPID_EVMETH_ONREADYSTATECHANGE,
|
|
|
|
0},
|
2009-12-07 22:28:10 +00:00
|
|
|
{resizeW, onresizeW, EVENTT_NONE, DISPID_EVMETH_ONRESIZE,
|
|
|
|
EVENT_DEFAULTLISTENER|EVENT_BUBBLE},
|
2009-11-23 18:28:43 +00:00
|
|
|
{selectstartW, onselectstartW, EVENTT_MOUSE, DISPID_EVMETH_ONSELECTSTART,
|
|
|
|
0}
|
2008-04-18 18:16:35 +00:00
|
|
|
};
|
|
|
|
|
2010-03-18 00:05:38 +00:00
|
|
|
static const eventid_t node_handled_list[] = { EVENTID_LOAD };
|
|
|
|
|
2008-06-23 14:54:33 +00:00
|
|
|
eventid_t str_to_eid(LPCWSTR str)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for(i=0; i < sizeof(event_info)/sizeof(event_info[0]); i++) {
|
|
|
|
if(!strcmpW(event_info[i].name, str))
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
ERR("unknown type %s\n", debugstr_w(str));
|
|
|
|
return EVENTID_LAST;
|
|
|
|
}
|
|
|
|
|
2009-09-06 17:06:10 +00:00
|
|
|
static eventid_t attr_to_eid(LPCWSTR str)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for(i=0; i < sizeof(event_info)/sizeof(event_info[0]); i++) {
|
|
|
|
if(!strcmpW(event_info[i].attr_name, str))
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return EVENTID_LAST;
|
|
|
|
}
|
|
|
|
|
2010-03-18 00:05:38 +00:00
|
|
|
static DWORD get_node_handler_mask(eventid_t eid)
|
|
|
|
{
|
|
|
|
DWORD i;
|
|
|
|
|
|
|
|
for(i=0; i<sizeof(node_handled_list)/sizeof(*node_handled_list); i++) {
|
|
|
|
if(node_handled_list[i] == eid)
|
|
|
|
return 1 << i;
|
|
|
|
}
|
|
|
|
|
|
|
|
ERR("Invalid eid %d\n", eid);
|
|
|
|
return ~0;
|
|
|
|
}
|
|
|
|
|
2008-04-20 22:48:18 +00:00
|
|
|
typedef struct {
|
2008-10-09 20:33:21 +00:00
|
|
|
DispatchEx dispex;
|
2010-12-06 22:31:16 +00:00
|
|
|
IHTMLEventObj IHTMLEventObj_iface;
|
2008-10-10 20:47:38 +00:00
|
|
|
|
2008-04-20 22:48:18 +00:00
|
|
|
LONG ref;
|
2008-10-10 20:47:38 +00:00
|
|
|
|
|
|
|
HTMLDOMNode *target;
|
2009-09-06 16:55:06 +00:00
|
|
|
const event_info_t *type;
|
2009-09-06 16:55:25 +00:00
|
|
|
nsIDOMEvent *nsevent;
|
2008-04-20 22:48:18 +00:00
|
|
|
} HTMLEventObj;
|
|
|
|
|
2010-12-06 22:31:16 +00:00
|
|
|
static inline HTMLEventObj *impl_from_IHTMLEventObj(IHTMLEventObj *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, HTMLEventObj, IHTMLEventObj_iface);
|
|
|
|
}
|
2008-04-20 22:48:18 +00:00
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLEventObj_QueryInterface(IHTMLEventObj *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
2010-12-06 22:31:16 +00:00
|
|
|
HTMLEventObj *This = impl_from_IHTMLEventObj(iface);
|
2008-04-20 22:48:18 +00:00
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
|
2010-12-06 22:31:16 +00:00
|
|
|
*ppv = &This->IHTMLEventObj_iface;
|
2008-04-20 22:48:18 +00:00
|
|
|
}else if(IsEqualGUID(&IID_IHTMLEventObj, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IHTMLEventObj %p)\n", This, ppv);
|
2010-12-06 22:31:16 +00:00
|
|
|
*ppv = &This->IHTMLEventObj_iface;
|
2008-10-09 20:33:21 +00:00
|
|
|
}else if(dispex_query_interface(&This->dispex, riid, ppv)) {
|
|
|
|
return *ppv ? S_OK : E_NOINTERFACE;
|
2008-04-20 22:48:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(*ppv) {
|
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HTMLEventObj_AddRef(IHTMLEventObj *iface)
|
|
|
|
{
|
2010-12-06 22:31:16 +00:00
|
|
|
HTMLEventObj *This = impl_from_IHTMLEventObj(iface);
|
2008-04-20 22:48:18 +00:00
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HTMLEventObj_Release(IHTMLEventObj *iface)
|
|
|
|
{
|
2010-12-06 22:31:16 +00:00
|
|
|
HTMLEventObj *This = impl_from_IHTMLEventObj(iface);
|
2008-04-20 22:48:18 +00:00
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
2009-08-31 18:47:55 +00:00
|
|
|
if(!ref) {
|
2009-09-06 16:55:25 +00:00
|
|
|
if(This->nsevent)
|
|
|
|
nsIDOMEvent_Release(This->nsevent);
|
2009-08-31 18:47:55 +00:00
|
|
|
release_dispex(&This->dispex);
|
2008-04-20 22:48:18 +00:00
|
|
|
heap_free(This);
|
2009-08-31 18:47:55 +00:00
|
|
|
}
|
2008-04-20 22:48:18 +00:00
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLEventObj_GetTypeInfoCount(IHTMLEventObj *iface, UINT *pctinfo)
|
|
|
|
{
|
2010-12-06 22:31:16 +00:00
|
|
|
HTMLEventObj *This = impl_from_IHTMLEventObj(iface);
|
2010-04-21 04:56:41 +00:00
|
|
|
return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->dispex), pctinfo);
|
2008-04-20 22:48:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLEventObj_GetTypeInfo(IHTMLEventObj *iface, UINT iTInfo,
|
|
|
|
LCID lcid, ITypeInfo **ppTInfo)
|
|
|
|
{
|
2010-12-06 22:31:16 +00:00
|
|
|
HTMLEventObj *This = impl_from_IHTMLEventObj(iface);
|
2010-04-21 04:56:41 +00:00
|
|
|
return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->dispex), iTInfo, lcid, ppTInfo);
|
2008-04-20 22:48:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLEventObj_GetIDsOfNames(IHTMLEventObj *iface, REFIID riid,
|
|
|
|
LPOLESTR *rgszNames, UINT cNames,
|
|
|
|
LCID lcid, DISPID *rgDispId)
|
|
|
|
{
|
2010-12-06 22:31:16 +00:00
|
|
|
HTMLEventObj *This = impl_from_IHTMLEventObj(iface);
|
2010-04-21 04:56:41 +00:00
|
|
|
return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->dispex), riid, rgszNames, cNames, lcid, rgDispId);
|
2008-04-20 22:48:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLEventObj_Invoke(IHTMLEventObj *iface, DISPID dispIdMember,
|
|
|
|
REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
|
|
|
|
VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
|
|
|
|
{
|
2010-12-06 22:31:16 +00:00
|
|
|
HTMLEventObj *This = impl_from_IHTMLEventObj(iface);
|
2010-04-21 04:56:41 +00:00
|
|
|
return IDispatchEx_Invoke(DISPATCHEX(&This->dispex), dispIdMember, riid, lcid,
|
|
|
|
wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
|
2008-04-20 22:48:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLEventObj_get_srcElement(IHTMLEventObj *iface, IHTMLElement **p)
|
|
|
|
{
|
2010-12-06 22:31:16 +00:00
|
|
|
HTMLEventObj *This = impl_from_IHTMLEventObj(iface);
|
2008-10-10 20:47:38 +00:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(This->target), &IID_IHTMLElement, (void**)p);
|
2008-04-20 22:48:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLEventObj_get_altKey(IHTMLEventObj *iface, VARIANT_BOOL *p)
|
|
|
|
{
|
2010-12-06 22:31:16 +00:00
|
|
|
HTMLEventObj *This = impl_from_IHTMLEventObj(iface);
|
2009-09-06 16:55:25 +00:00
|
|
|
PRBool ret = FALSE;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
if(This->nsevent) {
|
|
|
|
nsIDOMKeyEvent *key_event;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
nsres = nsIDOMEvent_QueryInterface(This->nsevent, &IID_nsIDOMKeyEvent, (void**)&key_event);
|
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
|
|
|
nsIDOMKeyEvent_GetAltKey(key_event, &ret);
|
|
|
|
nsIDOMKeyEvent_Release(key_event);
|
|
|
|
}else {
|
|
|
|
nsIDOMMouseEvent *mouse_event;
|
|
|
|
|
|
|
|
nsres = nsIDOMEvent_QueryInterface(This->nsevent, &IID_nsIDOMMouseEvent, (void**)&mouse_event);
|
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
|
|
|
nsIDOMMouseEvent_GetAltKey(mouse_event, &ret);
|
|
|
|
nsIDOMMouseEvent_Release(mouse_event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*p = ret ? VARIANT_TRUE : VARIANT_FALSE;
|
|
|
|
return S_OK;
|
2008-04-20 22:48:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLEventObj_get_ctrlKey(IHTMLEventObj *iface, VARIANT_BOOL *p)
|
|
|
|
{
|
2010-12-06 22:31:16 +00:00
|
|
|
HTMLEventObj *This = impl_from_IHTMLEventObj(iface);
|
2009-09-06 16:55:41 +00:00
|
|
|
PRBool ret = FALSE;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
if(This->nsevent) {
|
|
|
|
nsIDOMKeyEvent *key_event;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
nsres = nsIDOMEvent_QueryInterface(This->nsevent, &IID_nsIDOMKeyEvent, (void**)&key_event);
|
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
|
|
|
nsIDOMKeyEvent_GetCtrlKey(key_event, &ret);
|
|
|
|
nsIDOMKeyEvent_Release(key_event);
|
|
|
|
}else {
|
|
|
|
nsIDOMMouseEvent *mouse_event;
|
|
|
|
|
|
|
|
nsres = nsIDOMEvent_QueryInterface(This->nsevent, &IID_nsIDOMMouseEvent, (void**)&mouse_event);
|
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
|
|
|
nsIDOMMouseEvent_GetCtrlKey(mouse_event, &ret);
|
|
|
|
nsIDOMMouseEvent_Release(mouse_event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*p = ret ? VARIANT_TRUE : VARIANT_FALSE;
|
|
|
|
return S_OK;
|
2008-04-20 22:48:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLEventObj_get_shiftKey(IHTMLEventObj *iface, VARIANT_BOOL *p)
|
|
|
|
{
|
2010-12-06 22:31:16 +00:00
|
|
|
HTMLEventObj *This = impl_from_IHTMLEventObj(iface);
|
2009-09-06 16:55:56 +00:00
|
|
|
PRBool ret = FALSE;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
if(This->nsevent) {
|
|
|
|
nsIDOMKeyEvent *key_event;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
nsres = nsIDOMEvent_QueryInterface(This->nsevent, &IID_nsIDOMKeyEvent, (void**)&key_event);
|
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
|
|
|
nsIDOMKeyEvent_GetShiftKey(key_event, &ret);
|
|
|
|
nsIDOMKeyEvent_Release(key_event);
|
|
|
|
}else {
|
|
|
|
nsIDOMMouseEvent *mouse_event;
|
|
|
|
|
|
|
|
nsres = nsIDOMEvent_QueryInterface(This->nsevent, &IID_nsIDOMMouseEvent, (void**)&mouse_event);
|
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
|
|
|
nsIDOMMouseEvent_GetShiftKey(mouse_event, &ret);
|
|
|
|
nsIDOMMouseEvent_Release(mouse_event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*p = ret ? VARIANT_TRUE : VARIANT_FALSE;
|
|
|
|
return S_OK;
|
2008-04-20 22:48:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLEventObj_put_returnValue(IHTMLEventObj *iface, VARIANT v)
|
|
|
|
{
|
2010-12-06 22:31:16 +00:00
|
|
|
HTMLEventObj *This = impl_from_IHTMLEventObj(iface);
|
2008-04-20 22:48:18 +00:00
|
|
|
FIXME("(%p)->()\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLEventObj_get_returnValue(IHTMLEventObj *iface, VARIANT *p)
|
|
|
|
{
|
2010-12-06 22:31:16 +00:00
|
|
|
HTMLEventObj *This = impl_from_IHTMLEventObj(iface);
|
2009-09-06 16:58:26 +00:00
|
|
|
|
2008-04-20 22:48:18 +00:00
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
2009-09-06 16:58:26 +00:00
|
|
|
|
|
|
|
V_VT(p) = VT_EMPTY;
|
|
|
|
return S_OK;
|
2008-04-20 22:48:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLEventObj_put_cancelBubble(IHTMLEventObj *iface, VARIANT_BOOL v)
|
|
|
|
{
|
2010-12-06 22:31:16 +00:00
|
|
|
HTMLEventObj *This = impl_from_IHTMLEventObj(iface);
|
2008-04-20 22:48:18 +00:00
|
|
|
FIXME("(%p)->(%x)\n", This, v);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLEventObj_get_cancelBubble(IHTMLEventObj *iface, VARIANT_BOOL *p)
|
|
|
|
{
|
2010-12-06 22:31:16 +00:00
|
|
|
HTMLEventObj *This = impl_from_IHTMLEventObj(iface);
|
2009-09-06 16:58:26 +00:00
|
|
|
|
2008-04-20 22:48:18 +00:00
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
2009-09-06 16:58:26 +00:00
|
|
|
|
|
|
|
*p = VARIANT_FALSE;
|
|
|
|
return S_OK;
|
2008-04-20 22:48:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLEventObj_get_fromElement(IHTMLEventObj *iface, IHTMLElement **p)
|
|
|
|
{
|
2010-12-06 22:31:16 +00:00
|
|
|
HTMLEventObj *This = impl_from_IHTMLEventObj(iface);
|
2009-09-06 16:58:26 +00:00
|
|
|
|
2008-04-20 22:48:18 +00:00
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
2009-09-06 16:58:26 +00:00
|
|
|
|
|
|
|
*p = NULL;
|
|
|
|
return S_OK;
|
2008-04-20 22:48:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLEventObj_get_toElement(IHTMLEventObj *iface, IHTMLElement **p)
|
|
|
|
{
|
2010-12-06 22:31:16 +00:00
|
|
|
HTMLEventObj *This = impl_from_IHTMLEventObj(iface);
|
2009-09-06 16:58:26 +00:00
|
|
|
|
2008-04-20 22:48:18 +00:00
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
2009-09-06 16:58:26 +00:00
|
|
|
|
|
|
|
*p = NULL;
|
|
|
|
return S_OK;
|
2008-04-20 22:48:18 +00:00
|
|
|
}
|
|
|
|
|
2009-03-12 00:43:31 +00:00
|
|
|
static HRESULT WINAPI HTMLEventObj_put_keyCode(IHTMLEventObj *iface, LONG v)
|
2008-04-20 22:48:18 +00:00
|
|
|
{
|
2010-12-06 22:31:16 +00:00
|
|
|
HTMLEventObj *This = impl_from_IHTMLEventObj(iface);
|
2009-03-12 00:43:31 +00:00
|
|
|
FIXME("(%p)->(%d)\n", This, v);
|
2008-04-20 22:48:18 +00:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2009-03-12 00:43:31 +00:00
|
|
|
static HRESULT WINAPI HTMLEventObj_get_keyCode(IHTMLEventObj *iface, LONG *p)
|
2008-04-20 22:48:18 +00:00
|
|
|
{
|
2010-12-06 22:31:16 +00:00
|
|
|
HTMLEventObj *This = impl_from_IHTMLEventObj(iface);
|
2009-09-06 16:56:13 +00:00
|
|
|
PRUint32 key_code = 0;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
if(This->nsevent) {
|
|
|
|
nsIDOMKeyEvent *key_event;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
nsres = nsIDOMEvent_QueryInterface(This->nsevent, &IID_nsIDOMKeyEvent, (void**)&key_event);
|
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
|
|
|
nsIDOMKeyEvent_GetKeyCode(key_event, &key_code);
|
|
|
|
nsIDOMKeyEvent_Release(key_event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*p = key_code;
|
|
|
|
return S_OK;
|
2008-04-20 22:48:18 +00:00
|
|
|
}
|
|
|
|
|
2009-03-12 00:43:31 +00:00
|
|
|
static HRESULT WINAPI HTMLEventObj_get_button(IHTMLEventObj *iface, LONG *p)
|
2008-04-20 22:48:18 +00:00
|
|
|
{
|
2010-12-06 22:31:16 +00:00
|
|
|
HTMLEventObj *This = impl_from_IHTMLEventObj(iface);
|
2009-09-06 16:56:28 +00:00
|
|
|
PRUint16 button = 0;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
if(This->nsevent) {
|
|
|
|
nsIDOMMouseEvent *mouse_event;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
nsres = nsIDOMEvent_QueryInterface(This->nsevent, &IID_nsIDOMMouseEvent, (void**)&mouse_event);
|
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
|
|
|
nsIDOMMouseEvent_GetButton(mouse_event, &button);
|
|
|
|
nsIDOMMouseEvent_Release(mouse_event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*p = button;
|
|
|
|
return S_OK;
|
2008-04-20 22:48:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLEventObj_get_type(IHTMLEventObj *iface, BSTR *p)
|
|
|
|
{
|
2010-12-06 22:31:16 +00:00
|
|
|
HTMLEventObj *This = impl_from_IHTMLEventObj(iface);
|
2009-09-06 16:55:06 +00:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
*p = SysAllocString(This->type->name);
|
|
|
|
return *p ? S_OK : E_OUTOFMEMORY;
|
2008-04-20 22:48:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLEventObj_get_qualifier(IHTMLEventObj *iface, BSTR *p)
|
|
|
|
{
|
2010-12-06 22:31:16 +00:00
|
|
|
HTMLEventObj *This = impl_from_IHTMLEventObj(iface);
|
2009-09-06 16:58:26 +00:00
|
|
|
|
2008-04-20 22:48:18 +00:00
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
2009-09-06 16:58:26 +00:00
|
|
|
|
|
|
|
*p = NULL;
|
|
|
|
return S_OK;
|
2008-04-20 22:48:18 +00:00
|
|
|
}
|
|
|
|
|
2009-03-12 00:43:31 +00:00
|
|
|
static HRESULT WINAPI HTMLEventObj_get_reason(IHTMLEventObj *iface, LONG *p)
|
2008-04-20 22:48:18 +00:00
|
|
|
{
|
2010-12-06 22:31:16 +00:00
|
|
|
HTMLEventObj *This = impl_from_IHTMLEventObj(iface);
|
2009-09-06 16:58:26 +00:00
|
|
|
|
2008-04-20 22:48:18 +00:00
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
2009-09-06 16:58:26 +00:00
|
|
|
|
|
|
|
*p = 0;
|
|
|
|
return S_OK;
|
2008-04-20 22:48:18 +00:00
|
|
|
}
|
|
|
|
|
2009-03-12 00:43:31 +00:00
|
|
|
static HRESULT WINAPI HTMLEventObj_get_x(IHTMLEventObj *iface, LONG *p)
|
2008-04-20 22:48:18 +00:00
|
|
|
{
|
2010-12-06 22:31:16 +00:00
|
|
|
HTMLEventObj *This = impl_from_IHTMLEventObj(iface);
|
2009-09-06 16:58:26 +00:00
|
|
|
|
2008-04-20 22:48:18 +00:00
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
2009-09-06 16:58:26 +00:00
|
|
|
|
|
|
|
*p = -1;
|
|
|
|
return S_OK;
|
2008-04-20 22:48:18 +00:00
|
|
|
}
|
|
|
|
|
2009-03-12 00:43:31 +00:00
|
|
|
static HRESULT WINAPI HTMLEventObj_get_y(IHTMLEventObj *iface, LONG *p)
|
2008-04-20 22:48:18 +00:00
|
|
|
{
|
2010-12-06 22:31:16 +00:00
|
|
|
HTMLEventObj *This = impl_from_IHTMLEventObj(iface);
|
2009-09-06 16:58:26 +00:00
|
|
|
|
2008-04-20 22:48:18 +00:00
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
2009-09-06 16:58:26 +00:00
|
|
|
|
|
|
|
*p = -1;
|
|
|
|
return S_OK;
|
2008-04-20 22:48:18 +00:00
|
|
|
}
|
|
|
|
|
2009-03-12 00:43:31 +00:00
|
|
|
static HRESULT WINAPI HTMLEventObj_get_clientX(IHTMLEventObj *iface, LONG *p)
|
2008-04-20 22:48:18 +00:00
|
|
|
{
|
2010-12-06 22:31:16 +00:00
|
|
|
HTMLEventObj *This = impl_from_IHTMLEventObj(iface);
|
2009-09-06 16:56:46 +00:00
|
|
|
PRInt32 x = 0;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
if(This->nsevent) {
|
|
|
|
nsIDOMMouseEvent *mouse_event;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
nsres = nsIDOMEvent_QueryInterface(This->nsevent, &IID_nsIDOMMouseEvent, (void**)&mouse_event);
|
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
|
|
|
nsIDOMMouseEvent_GetClientX(mouse_event, &x);
|
|
|
|
nsIDOMMouseEvent_Release(mouse_event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*p = x;
|
|
|
|
return S_OK;
|
2008-04-20 22:48:18 +00:00
|
|
|
}
|
|
|
|
|
2009-03-12 00:43:31 +00:00
|
|
|
static HRESULT WINAPI HTMLEventObj_get_clientY(IHTMLEventObj *iface, LONG *p)
|
2008-04-20 22:48:18 +00:00
|
|
|
{
|
2010-12-06 22:31:16 +00:00
|
|
|
HTMLEventObj *This = impl_from_IHTMLEventObj(iface);
|
2009-09-06 16:56:46 +00:00
|
|
|
PRInt32 y = 0;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
if(This->nsevent) {
|
|
|
|
nsIDOMMouseEvent *mouse_event;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
nsres = nsIDOMEvent_QueryInterface(This->nsevent, &IID_nsIDOMMouseEvent, (void**)&mouse_event);
|
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
|
|
|
nsIDOMMouseEvent_GetClientY(mouse_event, &y);
|
|
|
|
nsIDOMMouseEvent_Release(mouse_event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*p = y;
|
|
|
|
return S_OK;
|
2008-04-20 22:48:18 +00:00
|
|
|
}
|
|
|
|
|
2009-03-12 00:43:31 +00:00
|
|
|
static HRESULT WINAPI HTMLEventObj_get_offsetX(IHTMLEventObj *iface, LONG *p)
|
2008-04-20 22:48:18 +00:00
|
|
|
{
|
2010-12-06 22:31:16 +00:00
|
|
|
HTMLEventObj *This = impl_from_IHTMLEventObj(iface);
|
2009-09-06 16:58:26 +00:00
|
|
|
|
2008-04-20 22:48:18 +00:00
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
2009-09-06 16:58:26 +00:00
|
|
|
|
|
|
|
*p = 0;
|
|
|
|
return S_OK;
|
2008-04-20 22:48:18 +00:00
|
|
|
}
|
|
|
|
|
2009-03-12 00:43:31 +00:00
|
|
|
static HRESULT WINAPI HTMLEventObj_get_offsetY(IHTMLEventObj *iface, LONG *p)
|
2008-04-20 22:48:18 +00:00
|
|
|
{
|
2010-12-06 22:31:16 +00:00
|
|
|
HTMLEventObj *This = impl_from_IHTMLEventObj(iface);
|
2009-09-06 16:58:26 +00:00
|
|
|
|
2008-04-20 22:48:18 +00:00
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
2009-09-06 16:58:26 +00:00
|
|
|
|
|
|
|
*p = 0;
|
|
|
|
return S_OK;
|
2008-04-20 22:48:18 +00:00
|
|
|
}
|
|
|
|
|
2009-03-12 00:43:31 +00:00
|
|
|
static HRESULT WINAPI HTMLEventObj_get_screenX(IHTMLEventObj *iface, LONG *p)
|
2008-04-20 22:48:18 +00:00
|
|
|
{
|
2010-12-06 22:31:16 +00:00
|
|
|
HTMLEventObj *This = impl_from_IHTMLEventObj(iface);
|
2009-09-06 16:57:02 +00:00
|
|
|
PRInt32 x = 0;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
if(This->nsevent) {
|
|
|
|
nsIDOMMouseEvent *mouse_event;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
nsres = nsIDOMEvent_QueryInterface(This->nsevent, &IID_nsIDOMMouseEvent, (void**)&mouse_event);
|
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
|
|
|
nsIDOMMouseEvent_GetScreenX(mouse_event, &x);
|
|
|
|
nsIDOMMouseEvent_Release(mouse_event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*p = x;
|
|
|
|
return S_OK;
|
2008-04-20 22:48:18 +00:00
|
|
|
}
|
|
|
|
|
2009-03-12 00:43:31 +00:00
|
|
|
static HRESULT WINAPI HTMLEventObj_get_screenY(IHTMLEventObj *iface, LONG *p)
|
2008-04-20 22:48:18 +00:00
|
|
|
{
|
2010-12-06 22:31:16 +00:00
|
|
|
HTMLEventObj *This = impl_from_IHTMLEventObj(iface);
|
2009-09-06 16:57:02 +00:00
|
|
|
PRInt32 y = 0;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
if(This->nsevent) {
|
|
|
|
nsIDOMMouseEvent *mouse_event;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
nsres = nsIDOMEvent_QueryInterface(This->nsevent, &IID_nsIDOMMouseEvent, (void**)&mouse_event);
|
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
|
|
|
nsIDOMMouseEvent_GetScreenY(mouse_event, &y);
|
|
|
|
nsIDOMMouseEvent_Release(mouse_event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*p = y;
|
|
|
|
return S_OK;
|
2008-04-20 22:48:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLEventObj_get_srcFilter(IHTMLEventObj *iface, IDispatch **p)
|
|
|
|
{
|
2010-12-06 22:31:16 +00:00
|
|
|
HTMLEventObj *This = impl_from_IHTMLEventObj(iface);
|
2009-09-06 16:58:26 +00:00
|
|
|
|
2008-04-20 22:48:18 +00:00
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
2009-09-06 16:58:26 +00:00
|
|
|
|
|
|
|
*p = NULL;
|
|
|
|
return S_OK;
|
2008-04-20 22:48:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IHTMLEventObjVtbl HTMLEventObjVtbl = {
|
|
|
|
HTMLEventObj_QueryInterface,
|
|
|
|
HTMLEventObj_AddRef,
|
|
|
|
HTMLEventObj_Release,
|
|
|
|
HTMLEventObj_GetTypeInfoCount,
|
|
|
|
HTMLEventObj_GetTypeInfo,
|
|
|
|
HTMLEventObj_GetIDsOfNames,
|
|
|
|
HTMLEventObj_Invoke,
|
|
|
|
HTMLEventObj_get_srcElement,
|
|
|
|
HTMLEventObj_get_altKey,
|
|
|
|
HTMLEventObj_get_ctrlKey,
|
|
|
|
HTMLEventObj_get_shiftKey,
|
|
|
|
HTMLEventObj_put_returnValue,
|
|
|
|
HTMLEventObj_get_returnValue,
|
|
|
|
HTMLEventObj_put_cancelBubble,
|
|
|
|
HTMLEventObj_get_cancelBubble,
|
|
|
|
HTMLEventObj_get_fromElement,
|
|
|
|
HTMLEventObj_get_toElement,
|
|
|
|
HTMLEventObj_put_keyCode,
|
|
|
|
HTMLEventObj_get_keyCode,
|
|
|
|
HTMLEventObj_get_button,
|
|
|
|
HTMLEventObj_get_type,
|
|
|
|
HTMLEventObj_get_qualifier,
|
|
|
|
HTMLEventObj_get_reason,
|
|
|
|
HTMLEventObj_get_x,
|
|
|
|
HTMLEventObj_get_y,
|
|
|
|
HTMLEventObj_get_clientX,
|
|
|
|
HTMLEventObj_get_clientY,
|
|
|
|
HTMLEventObj_get_offsetX,
|
|
|
|
HTMLEventObj_get_offsetY,
|
|
|
|
HTMLEventObj_get_screenX,
|
|
|
|
HTMLEventObj_get_screenY,
|
|
|
|
HTMLEventObj_get_srcFilter
|
|
|
|
};
|
|
|
|
|
2008-10-09 20:33:21 +00:00
|
|
|
static const tid_t HTMLEventObj_iface_tids[] = {
|
|
|
|
IHTMLEventObj_tid,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
static dispex_static_data_t HTMLEventObj_dispex = {
|
|
|
|
NULL,
|
|
|
|
DispCEventObj_tid,
|
|
|
|
NULL,
|
|
|
|
HTMLEventObj_iface_tids
|
|
|
|
};
|
|
|
|
|
2009-09-06 16:55:25 +00:00
|
|
|
static IHTMLEventObj *create_event(HTMLDOMNode *target, eventid_t eid, nsIDOMEvent *nsevent)
|
2008-04-20 22:48:18 +00:00
|
|
|
{
|
|
|
|
HTMLEventObj *ret;
|
|
|
|
|
|
|
|
ret = heap_alloc(sizeof(*ret));
|
2009-10-12 22:41:44 +00:00
|
|
|
if(!ret)
|
|
|
|
return NULL;
|
|
|
|
|
2010-12-06 22:31:16 +00:00
|
|
|
ret->IHTMLEventObj_iface.lpVtbl = &HTMLEventObjVtbl;
|
2008-04-20 22:48:18 +00:00
|
|
|
ret->ref = 1;
|
2009-09-06 16:55:06 +00:00
|
|
|
ret->type = event_info+eid;
|
2008-04-20 22:48:18 +00:00
|
|
|
|
2009-09-06 16:55:25 +00:00
|
|
|
ret->nsevent = nsevent;
|
2009-10-12 22:41:44 +00:00
|
|
|
if(nsevent) {
|
2009-09-06 16:55:25 +00:00
|
|
|
nsIDOMEvent_AddRef(nsevent);
|
2009-10-12 22:41:44 +00:00
|
|
|
}else if(event_types[event_info[eid].type]) {
|
|
|
|
nsIDOMDocumentEvent *doc_event;
|
|
|
|
nsresult nsres;
|
|
|
|
|
2009-10-21 19:27:42 +00:00
|
|
|
nsres = nsIDOMHTMLDocument_QueryInterface(target->doc->nsdoc, &IID_nsIDOMDocumentEvent,
|
2009-10-12 22:41:44 +00:00
|
|
|
(void**)&doc_event);
|
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
|
|
|
nsAString type_str;
|
|
|
|
|
2010-01-28 22:55:51 +00:00
|
|
|
nsAString_InitDepend(&type_str, event_types[event_info[eid].type]);
|
2009-10-12 22:41:44 +00:00
|
|
|
nsres = nsIDOMDocumentEvent_CreateEvent(doc_event, &type_str, &ret->nsevent);
|
|
|
|
nsAString_Finish(&type_str);
|
|
|
|
nsIDOMDocumentEvent_Release(doc_event);
|
|
|
|
}
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
ERR("Could not create event: %08x\n", nsres);
|
2010-12-06 22:31:16 +00:00
|
|
|
IHTMLEventObj_Release(&ret->IHTMLEventObj_iface);
|
2009-10-12 22:41:44 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ret->target = target;
|
|
|
|
IHTMLDOMNode_AddRef(HTMLDOMNODE(target));
|
2009-09-06 16:55:25 +00:00
|
|
|
|
2010-12-06 22:31:16 +00:00
|
|
|
init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLEventObj_iface, &HTMLEventObj_dispex);
|
2008-10-09 20:33:21 +00:00
|
|
|
|
2010-12-06 22:31:16 +00:00
|
|
|
return &ret->IHTMLEventObj_iface;
|
2008-04-20 22:48:18 +00:00
|
|
|
}
|
|
|
|
|
2009-11-23 18:28:43 +00:00
|
|
|
static HRESULT call_cp_func(IDispatch *disp, DISPID dispid)
|
|
|
|
{
|
|
|
|
DISPPARAMS dp = {NULL,NULL,0,0};
|
|
|
|
ULONG argerr;
|
|
|
|
EXCEPINFO ei;
|
|
|
|
VARIANT vres;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
V_VT(&vres) = VT_EMPTY;
|
|
|
|
memset(&ei, 0, sizeof(ei));
|
|
|
|
hres = IDispatch_Invoke(disp, dispid, &IID_NULL, 0, DISPATCH_METHOD, &dp, &vres, &ei, &argerr);
|
|
|
|
if(SUCCEEDED(hres) && V_VT(&vres) != VT_EMPTY) {
|
|
|
|
FIXME("handle result %s\n", debugstr_variant(&vres));
|
|
|
|
VariantClear(&vres);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2010-01-03 23:37:47 +00:00
|
|
|
static BOOL is_cp_event(cp_static_data_t *data, DISPID dispid)
|
2009-11-23 18:28:43 +00:00
|
|
|
{
|
2009-12-03 00:12:30 +00:00
|
|
|
int min, max, i;
|
2009-11-23 18:28:43 +00:00
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if(!data)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if(!data->ids) {
|
|
|
|
hres = get_dispids(data->tid, &data->id_cnt, &data->ids);
|
|
|
|
if(FAILED(hres))
|
2009-12-03 00:12:30 +00:00
|
|
|
return FALSE;
|
2009-11-23 18:28:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
min = 0;
|
2009-12-03 00:12:30 +00:00
|
|
|
max = data->id_cnt-1;
|
2009-11-23 18:28:43 +00:00
|
|
|
while(min <= max) {
|
|
|
|
i = (min+max)/2;
|
|
|
|
if(data->ids[i] == dispid)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
if(data->ids[i] < dispid)
|
|
|
|
min = i+1;
|
|
|
|
else
|
|
|
|
max = i-1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-09-16 20:13:31 +00:00
|
|
|
static void call_event_handlers(HTMLDocumentNode *doc, IHTMLEventObj *event_obj, event_target_t *event_target,
|
2009-11-23 18:28:43 +00:00
|
|
|
ConnectionPointContainer *cp_container, eventid_t eid, IDispatch *this_obj)
|
2009-09-06 16:54:30 +00:00
|
|
|
{
|
2009-11-23 18:28:43 +00:00
|
|
|
handler_vector_t *handler_vector = NULL;
|
2010-01-24 20:37:15 +00:00
|
|
|
int i;
|
2009-09-06 16:54:30 +00:00
|
|
|
HRESULT hres;
|
|
|
|
|
2009-11-23 18:28:43 +00:00
|
|
|
if(event_target)
|
|
|
|
handler_vector = event_target->event_table[eid];
|
2009-09-06 16:54:30 +00:00
|
|
|
|
2009-11-23 18:28:43 +00:00
|
|
|
if(handler_vector && handler_vector->handler_prop) {
|
2009-09-06 16:54:30 +00:00
|
|
|
DISPID named_arg = DISPID_THIS;
|
|
|
|
VARIANTARG arg;
|
|
|
|
DISPPARAMS dp = {&arg, &named_arg, 1, 1};
|
|
|
|
|
|
|
|
V_VT(&arg) = VT_DISPATCH;
|
|
|
|
V_DISPATCH(&arg) = this_obj;
|
|
|
|
|
|
|
|
TRACE("%s >>>\n", debugstr_w(event_info[eid].name));
|
2009-09-06 17:05:40 +00:00
|
|
|
hres = call_disp_func(handler_vector->handler_prop, &dp);
|
2009-09-06 16:54:30 +00:00
|
|
|
if(hres == S_OK)
|
|
|
|
TRACE("%s <<<\n", debugstr_w(event_info[eid].name));
|
|
|
|
else
|
|
|
|
WARN("%s <<< %08x\n", debugstr_w(event_info[eid].name), hres);
|
|
|
|
}
|
2009-09-06 17:06:10 +00:00
|
|
|
|
2009-11-23 18:28:43 +00:00
|
|
|
if(handler_vector && handler_vector->handler_cnt) {
|
2009-09-06 17:06:10 +00:00
|
|
|
VARIANTARG arg;
|
|
|
|
DISPPARAMS dp = {&arg, NULL, 1, 0};
|
|
|
|
|
|
|
|
V_VT(&arg) = VT_DISPATCH;
|
|
|
|
V_DISPATCH(&arg) = (IDispatch*)event_obj;
|
|
|
|
|
2010-01-24 20:37:15 +00:00
|
|
|
i = handler_vector->handler_cnt;
|
|
|
|
while(i--) {
|
2009-09-06 17:06:10 +00:00
|
|
|
if(handler_vector->handlers[i]) {
|
|
|
|
TRACE("%s [%d] >>>\n", debugstr_w(event_info[eid].name), i);
|
|
|
|
hres = call_disp_func(handler_vector->handlers[i], &dp);
|
|
|
|
if(hres == S_OK)
|
|
|
|
TRACE("%s [%d] <<<\n", debugstr_w(event_info[eid].name), i);
|
|
|
|
else
|
|
|
|
WARN("%s [%d] <<< %08x\n", debugstr_w(event_info[eid].name), i, hres);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-11-23 18:28:43 +00:00
|
|
|
|
|
|
|
if(cp_container) {
|
|
|
|
ConnectionPoint *cp;
|
|
|
|
|
|
|
|
if(cp_container->forward_container)
|
|
|
|
cp_container = cp_container->forward_container;
|
|
|
|
|
|
|
|
for(cp = cp_container->cp_list; cp; cp = cp->next) {
|
2010-01-03 23:37:47 +00:00
|
|
|
if(cp->sinks_size && is_cp_event(cp->data, event_info[eid].dispid)) {
|
2009-11-23 18:28:43 +00:00
|
|
|
for(i=0; i < cp->sinks_size; i++) {
|
2010-02-08 20:49:37 +00:00
|
|
|
if(!cp->sinks[i].disp)
|
|
|
|
continue;
|
|
|
|
|
2009-11-23 18:28:43 +00:00
|
|
|
TRACE("cp %s [%d] >>>\n", debugstr_w(event_info[eid].name), i);
|
|
|
|
hres = call_cp_func(cp->sinks[i].disp, event_info[eid].dispid);
|
|
|
|
if(hres == S_OK)
|
|
|
|
TRACE("cp %s [%d] <<<\n", debugstr_w(event_info[eid].name), i);
|
|
|
|
else
|
|
|
|
WARN("cp %s [%d] <<< %08x\n", debugstr_w(event_info[eid].name), i, hres);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-09-06 16:54:30 +00:00
|
|
|
}
|
|
|
|
|
2010-03-18 00:04:45 +00:00
|
|
|
void fire_event(HTMLDocumentNode *doc, eventid_t eid, BOOL set_event, nsIDOMNode *target, nsIDOMEvent *nsevent)
|
2008-04-20 22:48:18 +00:00
|
|
|
{
|
2008-10-10 20:46:47 +00:00
|
|
|
IHTMLEventObj *prev_event, *event_obj = NULL;
|
|
|
|
nsIDOMNode *parent, *nsnode;
|
2008-04-20 22:48:18 +00:00
|
|
|
HTMLDOMNode *node;
|
2008-10-10 20:46:47 +00:00
|
|
|
PRUint16 node_type;
|
2010-12-01 11:52:08 +00:00
|
|
|
HRESULT hres;
|
2008-04-20 22:48:18 +00:00
|
|
|
|
2009-09-08 20:31:35 +00:00
|
|
|
TRACE("(%p) %s\n", doc, debugstr_w(event_info[eid].name));
|
2008-10-10 20:46:47 +00:00
|
|
|
|
2009-09-16 20:13:31 +00:00
|
|
|
prev_event = doc->basedoc.window->event;
|
2010-12-01 11:52:08 +00:00
|
|
|
if(set_event) {
|
|
|
|
hres = get_node(doc, target, TRUE, &node);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return;
|
|
|
|
|
|
|
|
event_obj = create_event(node, eid, nsevent);
|
|
|
|
}
|
2010-03-18 00:04:45 +00:00
|
|
|
doc->basedoc.window->event = event_obj;
|
2009-09-08 20:31:35 +00:00
|
|
|
|
|
|
|
nsIDOMNode_GetNodeType(target, &node_type);
|
2008-10-10 20:46:47 +00:00
|
|
|
nsnode = target;
|
|
|
|
nsIDOMNode_AddRef(nsnode);
|
|
|
|
|
2009-09-08 20:31:35 +00:00
|
|
|
switch(node_type) {
|
|
|
|
case ELEMENT_NODE:
|
|
|
|
do {
|
2010-12-01 11:52:08 +00:00
|
|
|
hres = get_node(doc, nsnode, FALSE, &node);
|
|
|
|
if(SUCCEEDED(hres) && node)
|
2009-11-23 18:28:43 +00:00
|
|
|
call_event_handlers(doc, event_obj, *get_node_event_target(node), node->cp_container, eid,
|
|
|
|
(IDispatch*)HTMLDOMNODE(node));
|
2009-09-08 20:31:35 +00:00
|
|
|
|
|
|
|
if(!(event_info[eid].flags & EVENT_BUBBLE))
|
|
|
|
break;
|
|
|
|
|
|
|
|
nsIDOMNode_GetParentNode(nsnode, &parent);
|
|
|
|
nsIDOMNode_Release(nsnode);
|
|
|
|
nsnode = parent;
|
|
|
|
if(!nsnode)
|
|
|
|
break;
|
2008-10-10 20:46:47 +00:00
|
|
|
|
2009-09-08 20:31:35 +00:00
|
|
|
nsIDOMNode_GetNodeType(nsnode, &node_type);
|
|
|
|
}while(node_type == ELEMENT_NODE);
|
2008-04-20 22:48:18 +00:00
|
|
|
|
2008-10-10 20:46:47 +00:00
|
|
|
if(!(event_info[eid].flags & EVENT_BUBBLE))
|
|
|
|
break;
|
2008-04-20 22:48:18 +00:00
|
|
|
|
2009-09-08 20:31:35 +00:00
|
|
|
case DOCUMENT_NODE:
|
2009-09-08 20:32:08 +00:00
|
|
|
if(event_info[eid].flags & EVENT_FORWARDBODY) {
|
|
|
|
nsIDOMHTMLElement *nsbody;
|
|
|
|
nsresult nsres;
|
|
|
|
|
2009-10-21 19:27:42 +00:00
|
|
|
nsres = nsIDOMHTMLDocument_GetBody(doc->nsdoc, &nsbody);
|
2009-09-08 20:32:08 +00:00
|
|
|
if(NS_SUCCEEDED(nsres) && nsbody) {
|
2010-12-01 11:52:08 +00:00
|
|
|
hres = get_node(doc, (nsIDOMNode*)nsbody, FALSE, &node);
|
|
|
|
if(SUCCEEDED(hres) && node)
|
2009-11-23 18:28:43 +00:00
|
|
|
call_event_handlers(doc, event_obj, *get_node_event_target(node), node->cp_container,
|
|
|
|
eid, (IDispatch*)HTMLDOMNODE(node));
|
2009-09-08 20:32:08 +00:00
|
|
|
nsIDOMHTMLElement_Release(nsbody);
|
|
|
|
}else {
|
|
|
|
ERR("Could not get body: %08x\n", nsres);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-03 23:39:31 +00:00
|
|
|
call_event_handlers(doc, event_obj, doc->node.event_target, &doc->basedoc.cp_container, eid,
|
2010-12-16 13:59:51 +00:00
|
|
|
(IDispatch*)&doc->basedoc.IHTMLDocument2_iface);
|
2009-09-08 20:31:35 +00:00
|
|
|
break;
|
2008-10-10 20:46:47 +00:00
|
|
|
|
2009-09-08 20:31:35 +00:00
|
|
|
default:
|
|
|
|
FIXME("unimplemented node type %d\n", node_type);
|
2008-10-10 20:46:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(nsnode)
|
|
|
|
nsIDOMNode_Release(nsnode);
|
|
|
|
|
2010-03-18 00:04:45 +00:00
|
|
|
if(event_obj)
|
|
|
|
IHTMLEventObj_Release(event_obj);
|
2009-09-16 20:13:31 +00:00
|
|
|
doc->basedoc.window->event = prev_event;
|
2008-04-20 22:48:18 +00:00
|
|
|
}
|
|
|
|
|
2009-10-12 22:42:02 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2010-03-18 00:04:45 +00:00
|
|
|
fire_event(node->doc, eid, TRUE, node->nsnode, NULL);
|
2009-10-12 22:42:02 +00:00
|
|
|
|
|
|
|
*cancelled = VARIANT_TRUE; /* FIXME */
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2009-10-12 22:42:22 +00:00
|
|
|
HRESULT call_event(HTMLDOMNode *node, eventid_t eid)
|
|
|
|
{
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if(node->vtbl->call_event) {
|
|
|
|
BOOL handled = FALSE;
|
|
|
|
|
|
|
|
hres = node->vtbl->call_event(node, eid, &handled);
|
|
|
|
if(handled)
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2010-03-18 00:04:45 +00:00
|
|
|
fire_event(node->doc, eid, TRUE, node->nsnode, NULL);
|
2009-10-12 22:42:22 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2009-09-06 17:05:40 +00:00
|
|
|
static inline event_target_t *get_event_target(event_target_t **event_target_ptr)
|
|
|
|
{
|
|
|
|
if(!*event_target_ptr)
|
|
|
|
*event_target_ptr = heap_alloc_zero(sizeof(event_target_t));
|
|
|
|
return *event_target_ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL alloc_handler_vector(event_target_t *event_target, eventid_t eid, int cnt)
|
2008-06-23 14:54:33 +00:00
|
|
|
{
|
2009-09-06 17:05:40 +00:00
|
|
|
handler_vector_t *new_vector, *handler_vector = event_target->event_table[eid];
|
|
|
|
|
|
|
|
if(handler_vector) {
|
|
|
|
if(cnt <= handler_vector->handler_cnt)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
new_vector = heap_realloc_zero(handler_vector, sizeof(handler_vector_t) + sizeof(IDispatch*)*cnt);
|
|
|
|
}else {
|
|
|
|
new_vector = heap_alloc_zero(sizeof(handler_vector_t) + sizeof(IDispatch*)*cnt);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!new_vector)
|
|
|
|
return FALSE;
|
2008-06-23 14:54:33 +00:00
|
|
|
|
2009-09-06 17:05:40 +00:00
|
|
|
new_vector->handler_cnt = cnt;
|
|
|
|
event_target->event_table[eid] = new_vector;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2010-03-18 00:05:38 +00:00
|
|
|
static HRESULT ensure_nsevent_handler(HTMLDocumentNode *doc, event_target_t *event_target, nsIDOMNode *nsnode, eventid_t eid)
|
2010-01-03 23:37:47 +00:00
|
|
|
{
|
2010-03-18 00:05:38 +00:00
|
|
|
if(!doc->nsdoc)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
if(event_info[eid].flags & EVENT_NODEHANDLER) {
|
|
|
|
DWORD mask;
|
|
|
|
|
|
|
|
mask = get_node_handler_mask(eid);
|
|
|
|
if(event_target->node_handlers_mask & mask)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
add_nsevent_listener(doc, nsnode, event_info[eid].name);
|
|
|
|
event_target->node_handlers_mask |= mask;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!(event_info[eid].flags & EVENT_DEFAULTLISTENER))
|
2010-01-03 23:37:47 +00:00
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
if(!doc->event_vector) {
|
|
|
|
doc->event_vector = heap_alloc_zero(EVENTID_LAST*sizeof(BOOL));
|
|
|
|
if(!doc->event_vector)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!doc->event_vector[eid]) {
|
|
|
|
doc->event_vector[eid] = TRUE;
|
2010-03-18 00:05:38 +00:00
|
|
|
add_nsevent_listener(doc, NULL, event_info[eid].name);
|
2010-01-03 23:37:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-03-18 00:05:10 +00:00
|
|
|
static HRESULT remove_event_handler(event_target_t **event_target, eventid_t eid)
|
|
|
|
{
|
2010-06-19 20:25:32 +00:00
|
|
|
if(*event_target && (*event_target)->event_table[eid] && (*event_target)->event_table[eid]->handler_prop) {
|
2010-03-18 00:05:10 +00:00
|
|
|
IDispatch_Release((*event_target)->event_table[eid]->handler_prop);
|
|
|
|
(*event_target)->event_table[eid]->handler_prop = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-03-18 00:05:38 +00:00
|
|
|
static HRESULT set_event_handler_disp(event_target_t **event_target_ptr, nsIDOMNode *nsnode, HTMLDocumentNode *doc,
|
2009-10-27 20:10:02 +00:00
|
|
|
eventid_t eid, IDispatch *disp)
|
2009-09-06 17:05:40 +00:00
|
|
|
{
|
|
|
|
event_target_t *event_target;
|
|
|
|
|
2010-03-18 00:05:10 +00:00
|
|
|
if(!disp)
|
|
|
|
return remove_event_handler(event_target_ptr, eid);
|
|
|
|
|
2009-09-06 17:05:40 +00:00
|
|
|
event_target = get_event_target(event_target_ptr);
|
|
|
|
if(!event_target)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if(!alloc_handler_vector(event_target, eid, 0))
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if(event_target->event_table[eid]->handler_prop)
|
|
|
|
IDispatch_Release(event_target->event_table[eid]->handler_prop);
|
|
|
|
|
|
|
|
event_target->event_table[eid]->handler_prop = disp;
|
2008-06-23 14:54:33 +00:00
|
|
|
IDispatch_AddRef(disp);
|
|
|
|
|
2010-03-18 00:05:38 +00:00
|
|
|
return ensure_nsevent_handler(doc, event_target, nsnode, eid);
|
2008-06-23 14:54:33 +00:00
|
|
|
}
|
|
|
|
|
2010-03-18 00:05:38 +00:00
|
|
|
HRESULT set_event_handler(event_target_t **event_target, nsIDOMNode *nsnode, HTMLDocumentNode *doc, eventid_t eid, VARIANT *var)
|
2008-06-23 14:54:51 +00:00
|
|
|
{
|
|
|
|
switch(V_VT(var)) {
|
2008-10-10 20:47:27 +00:00
|
|
|
case VT_NULL:
|
2010-03-18 00:05:10 +00:00
|
|
|
return remove_event_handler(event_target, eid);
|
2008-10-10 20:47:27 +00:00
|
|
|
|
2008-06-23 14:54:51 +00:00
|
|
|
case VT_DISPATCH:
|
2010-03-18 00:05:38 +00:00
|
|
|
return set_event_handler_disp(event_target, nsnode, doc, eid, V_DISPATCH(var));
|
2008-06-23 14:54:51 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME("not supported vt=%d\n", V_VT(var));
|
2009-12-06 21:10:24 +00:00
|
|
|
case VT_EMPTY:
|
2008-10-10 20:47:27 +00:00
|
|
|
return E_NOTIMPL;
|
2008-06-23 14:54:51 +00:00
|
|
|
}
|
|
|
|
|
2008-10-10 20:47:27 +00:00
|
|
|
return S_OK;
|
2008-06-23 14:54:51 +00:00
|
|
|
}
|
|
|
|
|
2008-10-10 20:46:32 +00:00
|
|
|
HRESULT get_event_handler(event_target_t **event_target, eventid_t eid, VARIANT *var)
|
|
|
|
{
|
2009-09-06 17:05:40 +00:00
|
|
|
if(*event_target && (*event_target)->event_table[eid] && (*event_target)->event_table[eid]->handler_prop) {
|
2008-10-10 20:46:32 +00:00
|
|
|
V_VT(var) = VT_DISPATCH;
|
2009-09-06 17:05:40 +00:00
|
|
|
V_DISPATCH(var) = (*event_target)->event_table[eid]->handler_prop;
|
2008-10-10 20:46:32 +00:00
|
|
|
IDispatch_AddRef(V_DISPATCH(var));
|
|
|
|
}else {
|
|
|
|
V_VT(var) = VT_NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-03-18 00:05:38 +00:00
|
|
|
HRESULT attach_event(event_target_t **event_target_ptr, nsIDOMNode *nsnode, HTMLDocument *doc, BSTR name,
|
|
|
|
IDispatch *disp, VARIANT_BOOL *res)
|
2009-09-06 17:06:10 +00:00
|
|
|
{
|
|
|
|
event_target_t *event_target;
|
|
|
|
eventid_t eid;
|
|
|
|
DWORD i = 0;
|
|
|
|
|
|
|
|
eid = attr_to_eid(name);
|
|
|
|
if(eid == EVENTID_LAST) {
|
|
|
|
WARN("Unknown event\n");
|
|
|
|
*res = VARIANT_TRUE;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
event_target = get_event_target(event_target_ptr);
|
|
|
|
if(!event_target)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if(event_target->event_table[eid]) {
|
|
|
|
while(i < event_target->event_table[eid]->handler_cnt && event_target->event_table[eid]->handlers[i])
|
|
|
|
i++;
|
|
|
|
if(i == event_target->event_table[eid]->handler_cnt && !alloc_handler_vector(event_target, eid, i+1))
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}else if(!alloc_handler_vector(event_target, eid, i+1)) {
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
IDispatch_AddRef(disp);
|
|
|
|
event_target->event_table[eid]->handlers[i] = disp;
|
|
|
|
|
|
|
|
*res = VARIANT_TRUE;
|
2010-03-18 00:05:38 +00:00
|
|
|
return ensure_nsevent_handler(doc->doc_node, event_target, nsnode, eid);
|
2009-09-06 17:06:10 +00:00
|
|
|
}
|
|
|
|
|
2010-02-08 20:49:37 +00:00
|
|
|
HRESULT detach_event(event_target_t *event_target, HTMLDocument *doc, BSTR name, IDispatch *disp)
|
|
|
|
{
|
|
|
|
eventid_t eid;
|
|
|
|
DWORD i = 0;
|
|
|
|
|
|
|
|
if(!event_target)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
eid = attr_to_eid(name);
|
|
|
|
if(eid == EVENTID_LAST) {
|
|
|
|
WARN("Unknown event\n");
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!event_target->event_table[eid])
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
while(i < event_target->event_table[eid]->handler_cnt) {
|
|
|
|
if(event_target->event_table[eid]->handlers[i] == disp) {
|
|
|
|
IDispatch_Release(event_target->event_table[eid]->handlers[i]);
|
|
|
|
event_target->event_table[eid]->handlers[i] = NULL;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-03-18 00:05:38 +00:00
|
|
|
void update_cp_events(HTMLWindow *window, event_target_t **event_target_ptr, cp_static_data_t *cp, nsIDOMNode *nsnode)
|
2010-01-03 23:37:47 +00:00
|
|
|
{
|
2010-03-18 00:05:38 +00:00
|
|
|
event_target_t *event_target;
|
2010-01-03 23:37:47 +00:00
|
|
|
int i;
|
|
|
|
|
2010-03-18 00:05:38 +00:00
|
|
|
event_target = get_event_target(event_target_ptr);
|
|
|
|
if(!event_target)
|
|
|
|
return; /* FIXME */
|
|
|
|
|
2010-01-03 23:37:47 +00:00
|
|
|
for(i=0; i < EVENTID_LAST; i++) {
|
|
|
|
if((event_info[i].flags & EVENT_DEFAULTLISTENER) && is_cp_event(cp, event_info[i].dispid))
|
2010-03-18 00:05:38 +00:00
|
|
|
ensure_nsevent_handler(window->doc, event_target, nsnode, i);
|
2010-01-03 23:37:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-16 20:13:31 +00:00
|
|
|
void check_event_attr(HTMLDocumentNode *doc, nsIDOMElement *nselem)
|
2008-04-18 18:16:35 +00:00
|
|
|
{
|
|
|
|
const PRUnichar *attr_value;
|
|
|
|
nsAString attr_name_str, attr_value_str;
|
|
|
|
IDispatch *disp;
|
|
|
|
HTMLDOMNode *node;
|
|
|
|
int i;
|
|
|
|
nsresult nsres;
|
2010-12-01 11:52:08 +00:00
|
|
|
HRESULT hres;
|
2008-04-18 18:16:35 +00:00
|
|
|
|
|
|
|
nsAString_Init(&attr_value_str, NULL);
|
|
|
|
nsAString_Init(&attr_name_str, NULL);
|
|
|
|
|
|
|
|
for(i=0; i < EVENTID_LAST; i++) {
|
|
|
|
nsAString_SetData(&attr_name_str, event_info[i].attr_name);
|
|
|
|
nsres = nsIDOMElement_GetAttribute(nselem, &attr_name_str, &attr_value_str);
|
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
|
|
|
nsAString_GetData(&attr_value_str, &attr_value);
|
|
|
|
if(!*attr_value)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
TRACE("%p.%s = %s\n", nselem, debugstr_w(event_info[i].attr_name), debugstr_w(attr_value));
|
|
|
|
|
2009-09-16 20:13:31 +00:00
|
|
|
disp = script_parse_event(doc->basedoc.window, attr_value);
|
2008-04-18 18:16:35 +00:00
|
|
|
if(disp) {
|
2010-12-01 11:52:08 +00:00
|
|
|
hres = get_node(doc, (nsIDOMNode*)nselem, TRUE, &node);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
set_event_handler_disp(get_node_event_target(node), node->nsnode, node->doc, i, disp);
|
2008-06-23 14:54:33 +00:00
|
|
|
IDispatch_Release(disp);
|
2008-04-18 18:16:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAString_Finish(&attr_value_str);
|
|
|
|
nsAString_Finish(&attr_name_str);
|
|
|
|
}
|
|
|
|
|
|
|
|
void release_event_target(event_target_t *event_target)
|
|
|
|
{
|
2009-09-06 17:05:40 +00:00
|
|
|
int i, j;
|
2008-04-18 18:16:35 +00:00
|
|
|
|
|
|
|
for(i=0; i < EVENTID_LAST; i++) {
|
2009-09-06 17:05:40 +00:00
|
|
|
if(event_target->event_table[i]) {
|
|
|
|
if(event_target->event_table[i]->handler_prop)
|
|
|
|
IDispatch_Release(event_target->event_table[i]->handler_prop);
|
|
|
|
for(j=0; j < event_target->event_table[i]->handler_cnt; j++)
|
|
|
|
IDispatch_Release(event_target->event_table[i]->handlers[j]);
|
|
|
|
}
|
2008-04-18 18:16:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
heap_free(event_target);
|
|
|
|
}
|