Jacek Caban : mshtml: Store event target in DOMEvent.

Alexandre Julliard julliard at winehq.org
Thu Oct 19 14:31:35 CDT 2017


Module: wine
Branch: master
Commit: 8def42e7552517c2de7dc0999bff1cfdc872aa52
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=8def42e7552517c2de7dc0999bff1cfdc872aa52

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Thu Oct 19 17:02:54 2017 +0200

mshtml: Store event target in DOMEvent.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/mshtml/htmlevent.c | 15 ++++++---------
 dlls/mshtml/htmlevent.h |  1 +
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/dlls/mshtml/htmlevent.c b/dlls/mshtml/htmlevent.c
index 981c611..294c65c 100644
--- a/dlls/mshtml/htmlevent.c
+++ b/dlls/mshtml/htmlevent.c
@@ -229,7 +229,6 @@ struct HTMLEventObj {
 
     LONG ref;
 
-    EventTarget *target;
     const event_info_t *type;
     DOMEvent *event;
     VARIANT return_value;
@@ -282,8 +281,6 @@ static ULONG WINAPI HTMLEventObj_Release(IHTMLEventObj *iface)
     TRACE("(%p) ref=%d\n", This, ref);
 
     if(!ref) {
-        if(This->target)
-            IDispatchEx_Release(&This->target->dispex.IDispatchEx_iface);
         if(This->event)
             IDOMEvent_Release(&This->event->IDOMEvent_iface);
         release_dispex(&This->dispex);
@@ -331,8 +328,8 @@ static HRESULT WINAPI HTMLEventObj_get_srcElement(IHTMLEventObj *iface, IHTMLEle
     TRACE("(%p)->(%p)\n", This, p);
 
     *p = NULL;
-    if(This->target)
-        IDispatchEx_QueryInterface(&This->target->dispex.IDispatchEx_iface, &IID_IHTMLElement, (void**)p);
+    if(This->event && This->event->target)
+        IDispatchEx_QueryInterface(&This->event->target->dispex.IDispatchEx_iface, &IID_IHTMLElement, (void**)p);
     return S_OK;
 }
 
@@ -871,6 +868,8 @@ static ULONG WINAPI DOMEvent_Release(IDOMEvent *iface)
     TRACE("(%p) ref=%u\n", This, ref);
 
     if(!ref) {
+        if(This->target)
+            IDispatchEx_Release(&This->target->dispex.IDispatchEx_iface);
         nsIDOMEvent_Release(This->nsevent);
         release_dispex(&This->dispex);
         heap_free(This);
@@ -1415,10 +1414,8 @@ static void fire_event_obj(EventTarget *event_target, DOMEvent *event, HTMLEvent
     if(target_vtbl && target_vtbl->set_current_event)
         prev_event = target_vtbl->set_current_event(&event_target->dispex, event_obj ? &event_obj->IHTMLEventObj_iface : NULL);
 
-    if(event_obj) {
-        event_obj->target = event_target;
-        IDispatchEx_AddRef(&event_target->dispex.IDispatchEx_iface);
-    }
+    event->target = event_target;
+    IDispatchEx_AddRef(&event_target->dispex.IDispatchEx_iface);
 
     for(i = 0; i < chain_cnt; i++) {
         call_event_handlers(event_obj, target_chain[i], event->event_id);
diff --git a/dlls/mshtml/htmlevent.h b/dlls/mshtml/htmlevent.h
index 9dfd5e7..0bec4ff 100644
--- a/dlls/mshtml/htmlevent.h
+++ b/dlls/mshtml/htmlevent.h
@@ -63,6 +63,7 @@ typedef struct {
 
     nsIDOMEvent *nsevent;
     eventid_t event_id;
+    EventTarget *target;
 } DOMEvent;
 
 eventid_t str_to_eid(LPCWSTR) DECLSPEC_HIDDEN;




More information about the wine-cvs mailing list