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
c4e9787e
Commit
c4e9787e
authored
Feb 13, 2017
by
Jacek Caban
Committed by
Alexandre Julliard
Feb 14, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mshtml: Store event handlers in rb tree.
Signed-off-by:
Jacek Caban
<
jacek@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
357bf1b5
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
49 additions
and
47 deletions
+49
-47
htmlevent.c
dlls/mshtml/htmlevent.c
+44
-45
htmlevent.h
dlls/mshtml/htmlevent.h
+1
-0
htmlnode.c
dlls/mshtml/htmlnode.c
+1
-0
htmlwindow.c
dlls/mshtml/htmlwindow.c
+1
-0
mshtml_private.h
dlls/mshtml/mshtml_private.h
+1
-2
xmlhttprequest.c
dlls/mshtml/xmlhttprequest.c
+1
-0
No files found.
dlls/mshtml/htmlevent.c
View file @
c4e9787e
...
...
@@ -36,15 +36,13 @@
WINE_DEFAULT_DEBUG_CHANNEL
(
mshtml
);
typedef
struct
{
struct
wine_rb_entry
entry
;
eventid_t
event_id
;
IDispatch
*
handler_prop
;
DWORD
handler_cnt
;
IDispatch
**
handlers
;
}
handler_vector_t
;
struct
event_target_t
{
handler_vector_t
*
event_table
[
EVENTID_LAST
];
};
static
const
WCHAR
abortW
[]
=
{
'a'
,
'b'
,
'o'
,
'r'
,
't'
,
0
};
static
const
WCHAR
onabortW
[]
=
{
'o'
,
'n'
,
'a'
,
'b'
,
'o'
,
'r'
,
't'
,
0
};
...
...
@@ -899,37 +897,35 @@ HRESULT create_event_obj(IHTMLEventObj **ret)
return
S_OK
;
}
static
inline
event_target_t
*
get_event_target_data
(
EventTarget
*
event_target
,
BOOL
alloc
)
static
handler_vector_t
*
get_handler_vector
(
EventTarget
*
event_target
,
eventid_t
eid
,
BOOL
alloc
)
{
const
dispex_static_data_vtbl_t
*
vtbl
=
dispex_get_vtbl
(
&
event_target
->
dispex
);
const
dispex_static_data_vtbl_t
*
vtbl
;
handler_vector_t
*
handler_vector
;
struct
wine_rb_entry
*
entry
;
if
(
vtbl
&&
vtbl
->
get_event_target
)
vtbl
=
dispex_get_vtbl
(
&
event_target
->
dispex
);
if
(
vtbl
->
get_event_target
)
event_target
=
vtbl
->
get_event_target
(
&
event_target
->
dispex
);
if
(
event_target
->
ptr
||
!
alloc
)
return
event_target
->
ptr
;
return
event_target
->
ptr
=
heap_alloc_zero
(
sizeof
(
event_target_t
));
}
static
handler_vector_t
*
get_handler_vector
(
EventTarget
*
event_target
,
eventid_t
eid
,
BOOL
alloc
)
{
event_target_t
*
data
;
entry
=
wine_rb_get
(
&
event_target
->
handler_map
,
(
const
void
*
)
eid
);
if
(
entry
)
return
WINE_RB_ENTRY_VALUE
(
entry
,
handler_vector_t
,
entry
);
if
(
!
alloc
)
return
NULL
;
data
=
get_event_target_data
(
event_target
,
alloc
);
if
(
!
data
)
handler_vector
=
heap_alloc_zero
(
sizeof
(
*
handler_vector
)
);
if
(
!
handler_vector
)
return
NULL
;
if
(
alloc
&&
!
data
->
event_table
[
eid
])
{
data
->
event_table
[
eid
]
=
heap_alloc_zero
(
sizeof
(
*
data
->
event_table
[
eid
]));
if
(
data
->
event_table
[
eid
])
{
const
dispex_static_data_vtbl_t
*
vtbl
=
dispex_get_vtbl
(
&
event_target
->
dispex
);
if
(
vtbl
->
bind_event
)
vtbl
->
bind_event
(
&
event_target
->
dispex
,
eid
);
else
FIXME
(
"Unsupported event binding on target %p
\n
"
,
event_target
);
}
}
return
data
->
event_table
[
eid
];
handler_vector
->
event_id
=
eid
;
vtbl
=
dispex_get_vtbl
(
&
event_target
->
dispex
);
if
(
vtbl
->
bind_event
)
vtbl
->
bind_event
(
&
event_target
->
dispex
,
eid
);
else
FIXME
(
"Unsupported event binding on target %p
\n
"
,
event_target
);
wine_rb_put
(
&
event_target
->
handler_map
,
(
const
void
*
)
eid
,
&
handler_vector
->
entry
);
return
handler_vector
;
}
static
HRESULT
call_disp_func
(
IDispatch
*
disp
,
DISPPARAMS
*
dp
,
VARIANT
*
retv
)
...
...
@@ -1642,25 +1638,28 @@ HRESULT doc_init_events(HTMLDocumentNode *doc)
return
S_OK
;
}
void
release_event_target
(
EventTarget
*
event_target
)
static
int
event_id_cmp
(
const
void
*
key
,
const
struct
wine_rb_entry
*
entry
)
{
int
i
;
unsigned
int
j
;
return
(
INT_PTR
)
key
-
WINE_RB_ENTRY_VALUE
(
entry
,
handler_vector_t
,
entry
)
->
event_id
;
}
if
(
!
event_target
->
ptr
)
return
;
void
init_event_target
(
EventTarget
*
event_target
)
{
wine_rb_init
(
&
event_target
->
handler_map
,
event_id_cmp
);
}
for
(
i
=
0
;
i
<
EVENTID_LAST
;
i
++
)
{
if
(
event_target
->
ptr
->
event_table
[
i
])
{
if
(
event_target
->
ptr
->
event_table
[
i
]
->
handler_prop
)
IDispatch_Release
(
event_target
->
ptr
->
event_table
[
i
]
->
handler_prop
);
for
(
j
=
0
;
j
<
event_target
->
ptr
->
event_table
[
i
]
->
handler_cnt
;
j
++
)
if
(
event_target
->
ptr
->
event_table
[
i
]
->
handlers
[
j
])
IDispatch_Release
(
event_target
->
ptr
->
event_table
[
i
]
->
handlers
[
j
]);
heap_free
(
event_target
->
ptr
->
event_table
[
i
]
->
handlers
);
heap_free
(
event_target
->
ptr
->
event_table
[
i
]);
}
}
void
release_event_target
(
EventTarget
*
event_target
)
{
handler_vector_t
*
iter
,
*
iter2
;
unsigned
i
;
heap_free
(
event_target
->
ptr
);
WINE_RB_FOR_EACH_ENTRY_DESTRUCTOR
(
iter
,
iter2
,
&
event_target
->
handler_map
,
handler_vector_t
,
entry
)
{
if
(
iter
->
handler_prop
)
IDispatch_Release
(
iter
->
handler_prop
);
for
(
i
=
0
;
i
<
iter
->
handler_cnt
;
i
++
)
if
(
iter
->
handlers
[
i
])
IDispatch_Release
(
iter
->
handlers
[
i
]);
heap_free
(
iter
->
handlers
);
heap_free
(
iter
);
}
}
dlls/mshtml/htmlevent.h
View file @
c4e9787e
...
...
@@ -55,6 +55,7 @@ typedef enum {
eventid_t
str_to_eid
(
LPCWSTR
)
DECLSPEC_HIDDEN
;
void
check_event_attr
(
HTMLDocumentNode
*
,
nsIDOMHTMLElement
*
)
DECLSPEC_HIDDEN
;
void
init_event_target
(
EventTarget
*
)
DECLSPEC_HIDDEN
;
void
release_event_target
(
EventTarget
*
)
DECLSPEC_HIDDEN
;
void
fire_event
(
HTMLDocumentNode
*
,
eventid_t
,
BOOL
,
HTMLDOMNode
*
,
nsIDOMEvent
*
,
IDispatch
*
)
DECLSPEC_HIDDEN
;
HRESULT
set_event_handler
(
EventTarget
*
,
eventid_t
,
VARIANT
*
)
DECLSPEC_HIDDEN
;
...
...
dlls/mshtml/htmlnode.c
View file @
c4e9787e
...
...
@@ -1214,6 +1214,7 @@ void HTMLDOMNode_Init(HTMLDocumentNode *doc, HTMLDOMNode *node, nsIDOMNode *nsno
node
->
IHTMLDOMNode2_iface
.
lpVtbl
=
&
HTMLDOMNode2Vtbl
;
ccref_init
(
&
node
->
ccref
,
1
);
init_event_target
(
&
node
->
event_target
);
if
(
&
doc
->
node
!=
node
)
htmldoc_addref
(
&
doc
->
basedoc
);
...
...
dlls/mshtml/htmlwindow.c
View file @
c4e9787e
...
...
@@ -3020,6 +3020,7 @@ static HRESULT create_inner_window(HTMLOuterWindow *outer_window, IMoniker *mon,
window
->
base
.
outer_window
=
outer_window
;
window
->
base
.
inner_window
=
window
;
init_event_target
(
&
window
->
event_target
);
init_dispex
(
&
window
->
event_target
.
dispex
,
(
IUnknown
*
)
&
window
->
base
.
IHTMLWindow2_iface
,
&
HTMLWindow_dispex
);
window
->
task_magic
=
get_task_target_magic
();
...
...
dlls/mshtml/mshtml_private.h
View file @
c4e9787e
...
...
@@ -72,7 +72,6 @@
typedef
struct
HTMLDOMNode
HTMLDOMNode
;
typedef
struct
ConnectionPoint
ConnectionPoint
;
typedef
struct
BSCallback
BSCallback
;
typedef
struct
event_target_t
event_target_t
;
typedef
struct
EventTarget
EventTarget
;
#define TID_LIST \
...
...
@@ -366,7 +365,7 @@ typedef struct {
struct
EventTarget
{
DispatchEx
dispex
;
event_target_t
*
ptr
;
struct
wine_rb_tree
handler_map
;
};
typedef
struct
{
...
...
dlls/mshtml/xmlhttprequest.c
View file @
c4e9787e
...
...
@@ -851,6 +851,7 @@ static HRESULT WINAPI HTMLXMLHttpRequestFactory_create(IHTMLXMLHttpRequestFactor
ret
->
nsxhr
=
nsxhr
;
ret
->
IHTMLXMLHttpRequest_iface
.
lpVtbl
=
&
HTMLXMLHttpRequestVtbl
;
init_event_target
(
&
ret
->
event_target
);
init_dispex
(
&
ret
->
event_target
.
dispex
,
(
IUnknown
*
)
&
ret
->
IHTMLXMLHttpRequest_iface
,
&
HTMLXMLHttpRequest_dispex
);
ret
->
ref
=
1
;
...
...
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