Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
cf51da73
Commit
cf51da73
authored
Jun 23, 2008
by
Jacek Caban
Committed by
Alexandre Julliard
Jun 23, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mshtml: Added generic HTML event listener and use it for click event.
parent
97298e66
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
104 additions
and
5 deletions
+104
-5
htmlevent.c
dlls/mshtml/htmlevent.c
+38
-5
mshtml_private.h
dlls/mshtml/mshtml_private.h
+5
-0
nsevents.c
dlls/mshtml/nsevents.c
+61
-0
No files found.
dlls/mshtml/htmlevent.c
View file @
cf51da73
...
...
@@ -44,13 +44,29 @@ static const WCHAR onloadW[] = {'o','n','l','o','a','d',0};
typedef
struct
{
LPCWSTR
name
;
LPCWSTR
attr_name
;
DWORD
flags
;
}
event_info_t
;
#define EVENT_DEFAULTLISTENER 0x0001
static
const
event_info_t
event_info
[]
=
{
{
clickW
,
onclickW
},
{
loadW
,
onloadW
}
{
clickW
,
onclickW
,
EVENT_DEFAULTLISTENER
},
{
loadW
,
onloadW
,
0
}
};
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
;
}
typedef
struct
{
const
IHTMLEventObjVtbl
*
lpIHTMLEventObjVtbl
;
LONG
ref
;
...
...
@@ -385,6 +401,24 @@ void fire_event(HTMLDocument *doc, eventid_t eid, nsIDOMNode *target)
}
}
static
HRESULT
set_node_event_disp
(
HTMLDOMNode
*
node
,
eventid_t
eid
,
IDispatch
*
disp
)
{
if
(
!
node
->
event_target
)
node
->
event_target
=
heap_alloc_zero
(
sizeof
(
event_target_t
));
else
if
(
node
->
event_target
->
event_table
[
eid
])
IDispatch_Release
(
node
->
event_target
->
event_table
[
eid
]);
IDispatch_AddRef
(
disp
);
node
->
event_target
->
event_table
[
eid
]
=
disp
;
if
((
event_info
[
eid
].
flags
&
EVENT_DEFAULTLISTENER
)
&&
!
node
->
doc
->
nscontainer
->
event_vector
[
eid
])
{
node
->
doc
->
nscontainer
->
event_vector
[
eid
]
=
TRUE
;
add_nsevent_listener
(
node
->
doc
->
nscontainer
,
event_info
[
eid
].
name
);
}
return
S_OK
;
}
void
check_event_attr
(
HTMLDocument
*
doc
,
nsIDOMElement
*
nselem
)
{
const
PRUnichar
*
attr_value
;
...
...
@@ -410,9 +444,8 @@ void check_event_attr(HTMLDocument *doc, nsIDOMElement *nselem)
disp
=
script_parse_event
(
doc
,
attr_value
);
if
(
disp
)
{
node
=
get_node
(
doc
,
(
nsIDOMNode
*
)
nselem
,
TRUE
);
if
(
!
node
->
event_target
)
node
->
event_target
=
heap_alloc_zero
(
sizeof
(
event_target_t
));
node
->
event_target
->
event_table
[
i
]
=
disp
;
set_node_event_disp
(
node
,
i
,
disp
);
IDispatch_Release
(
disp
);
}
}
}
...
...
dlls/mshtml/mshtml_private.h
View file @
cf51da73
...
...
@@ -289,6 +289,7 @@ struct NSContainer {
nsEventListener
keypress_listener
;
nsEventListener
load_listener
;
nsEventListener
node_insert_listener
;
nsEventListener
htmlevent_listener
;
nsIWebBrowser
*
webbrowser
;
nsIWebNavigation
*
navigation
;
...
...
@@ -309,6 +310,8 @@ struct NSContainer {
nsChannelBSC
*
bscallback
;
/* hack */
HWND
reset_focus
;
/* hack */
BOOL
event_vector
[
EVENTID_LAST
];
};
typedef
struct
{
...
...
@@ -496,11 +499,13 @@ nsIWritableVariant *create_nsvariant(void);
void
nsnode_to_nsstring
(
nsIDOMNode
*
,
nsAString
*
);
void
get_editor_controller
(
NSContainer
*
);
void
init_nsevents
(
NSContainer
*
);
void
add_nsevent_listener
(
NSContainer
*
,
LPCWSTR
);
nsresult
get_nsinterface
(
nsISupports
*
,
REFIID
,
void
**
);
void
check_event_attr
(
HTMLDocument
*
,
nsIDOMElement
*
);
void
release_event_target
(
event_target_t
*
);
void
fire_event
(
HTMLDocument
*
,
eventid_t
,
nsIDOMNode
*
);
eventid_t
str_to_eid
(
LPCWSTR
);
void
set_document_bscallback
(
HTMLDocument
*
,
nsChannelBSC
*
);
void
set_current_mon
(
HTMLDocument
*
,
IMoniker
*
);
...
...
dlls/mshtml/nsevents.c
View file @
cf51da73
...
...
@@ -211,6 +211,42 @@ static nsresult NSAPI handle_node_insert(nsIDOMEventListener *iface, nsIDOMEvent
return
NS_OK
;
}
static
nsresult
NSAPI
handle_htmlevent
(
nsIDOMEventListener
*
iface
,
nsIDOMEvent
*
event
)
{
NSContainer
*
This
=
NSEVENTLIST_THIS
(
iface
)
->
This
;
const
PRUnichar
*
type
;
nsIDOMEventTarget
*
event_target
;
nsIDOMNode
*
nsnode
;
nsAString
type_str
;
eventid_t
eid
;
nsresult
nsres
;
nsAString_Init
(
&
type_str
,
NULL
);
nsIDOMEvent_GetType
(
event
,
&
type_str
);
nsAString_GetData
(
&
type_str
,
&
type
);
eid
=
str_to_eid
(
type
);
nsAString_Finish
(
&
type_str
);
nsres
=
nsIDOMEvent_GetTarget
(
event
,
&
event_target
);
if
(
NS_FAILED
(
nsres
)
||
!
event_target
)
{
ERR
(
"GetEventTarget failed: %08x
\n
"
,
nsres
);
return
NS_OK
;
}
nsres
=
nsIDOMEventTarget_QueryInterface
(
event_target
,
&
IID_nsIDOMNode
,
(
void
**
)
&
nsnode
);
nsIDOMEventTarget_Release
(
event_target
);
if
(
NS_FAILED
(
nsres
))
{
ERR
(
"Could not get nsIDOMNode: %08x
\n
"
,
nsres
);
return
NS_OK
;
}
fire_event
(
This
->
doc
,
eid
,
nsnode
);
nsIDOMNode_Release
(
nsnode
);
return
NS_OK
;
}
#undef NSEVENTLIST_THIS
#define EVENTLISTENER_VTBL(handler) \
...
...
@@ -226,6 +262,7 @@ static const nsIDOMEventListenerVtbl focus_vtbl = EVENTLISTENER_VTBL(handle_
static
const
nsIDOMEventListenerVtbl
keypress_vtbl
=
EVENTLISTENER_VTBL
(
handle_keypress
);
static
const
nsIDOMEventListenerVtbl
load_vtbl
=
EVENTLISTENER_VTBL
(
handle_load
);
static
const
nsIDOMEventListenerVtbl
node_insert_vtbl
=
EVENTLISTENER_VTBL
(
handle_node_insert
);
static
const
nsIDOMEventListenerVtbl
htmlevent_vtbl
=
EVENTLISTENER_VTBL
(
handle_htmlevent
);
static
void
init_event
(
nsIDOMEventTarget
*
target
,
const
PRUnichar
*
type
,
nsIDOMEventListener
*
listener
,
BOOL
capture
)
...
...
@@ -248,6 +285,29 @@ static void init_listener(nsEventListener *This, NSContainer *container,
This
->
This
=
container
;
}
void
add_nsevent_listener
(
NSContainer
*
container
,
LPCWSTR
type
)
{
nsIDOMWindow
*
dom_window
;
nsIDOMEventTarget
*
target
;
nsresult
nsres
;
nsres
=
nsIWebBrowser_GetContentDOMWindow
(
container
->
webbrowser
,
&
dom_window
);
if
(
NS_FAILED
(
nsres
))
{
ERR
(
"GetContentDOMWindow failed: %08x
\n
"
,
nsres
);
return
;
}
nsres
=
nsIDOMWindow_QueryInterface
(
dom_window
,
&
IID_nsIDOMEventTarget
,
(
void
**
)
&
target
);
nsIDOMWindow_Release
(
dom_window
);
if
(
NS_FAILED
(
nsres
))
{
ERR
(
"Could not get nsIDOMEventTarget interface: %08x
\n
"
,
nsres
);
return
;
}
init_event
(
target
,
type
,
NSEVENTLIST
(
&
container
->
htmlevent_listener
),
TRUE
);
nsIDOMEventTarget_Release
(
target
);
}
void
init_nsevents
(
NSContainer
*
This
)
{
nsIDOMWindow
*
dom_window
;
...
...
@@ -266,6 +326,7 @@ void init_nsevents(NSContainer *This)
init_listener
(
&
This
->
keypress_listener
,
This
,
&
keypress_vtbl
);
init_listener
(
&
This
->
load_listener
,
This
,
&
load_vtbl
);
init_listener
(
&
This
->
node_insert_listener
,
This
,
&
node_insert_vtbl
);
init_listener
(
&
This
->
htmlevent_listener
,
This
,
&
htmlevent_vtbl
);
nsres
=
nsIWebBrowser_GetContentDOMWindow
(
This
->
webbrowser
,
&
dom_window
);
if
(
NS_FAILED
(
nsres
))
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment