Jacek Caban : mshtml: Flush pending document node tasks before firing onload event.

Alexandre Julliard julliard at wine.codeweavers.com
Wed Dec 24 13:40:37 CST 2014


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Wed Dec 24 13:10:10 2014 +0100

mshtml: Flush pending document node tasks before firing onload event.

---

 dlls/mshtml/mshtml_private.h |  1 +
 dlls/mshtml/nsevents.c       |  9 ++++++---
 dlls/mshtml/task.c           | 19 +++++++++++++++++++
 3 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index 5553bf2..4076f8d 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -1038,6 +1038,7 @@ HWND get_thread_hwnd(void) DECLSPEC_HIDDEN;
 LONG get_task_target_magic(void) DECLSPEC_HIDDEN;
 HRESULT push_task(task_t*,task_proc_t,task_proc_t,LONG) DECLSPEC_HIDDEN;
 void remove_target_tasks(LONG) DECLSPEC_HIDDEN;
+void flush_pending_tasks(LONG) DECLSPEC_HIDDEN;
 
 HRESULT set_task_timer(HTMLInnerWindow*,DWORD,BOOL,IDispatch*,LONG*) DECLSPEC_HIDDEN;
 HRESULT clear_task_timer(HTMLInnerWindow*,BOOL,DWORD) DECLSPEC_HIDDEN;
diff --git a/dlls/mshtml/nsevents.c b/dlls/mshtml/nsevents.c
index fc6504b..1444b43 100644
--- a/dlls/mshtml/nsevents.c
+++ b/dlls/mshtml/nsevents.c
@@ -233,7 +233,6 @@ static nsresult NSAPI handle_load(nsIDOMEventListener *iface, nsIDOMEvent *event
 {
     nsEventListener *This = impl_from_nsIDOMEventListener(iface);
     HTMLDocumentNode *doc = This->This->doc;
-    nsIDOMHTMLElement *nsbody = NULL;
     HTMLDocumentObj *doc_obj = NULL;
     nsresult nsres = NS_OK;
 
@@ -268,8 +267,12 @@ static nsresult NSAPI handle_load(nsIDOMEventListener *iface, nsIDOMEvent *event
                 &doc->basedoc.window->base.IHTMLWindow2_iface, 0);
 
     if(doc->nsdoc) {
-        nsIDOMHTMLDocument_GetBody(doc->nsdoc, &nsbody);
-        if(nsbody) {
+        nsIDOMHTMLElement *nsbody;
+
+        flush_pending_tasks(doc->basedoc.task_magic);
+
+        nsres = nsIDOMHTMLDocument_GetBody(doc->nsdoc, &nsbody);
+        if(NS_SUCCEEDED(nsres) && nsbody) {
             fire_event(doc, EVENTID_LOAD, TRUE, (nsIDOMNode*)nsbody, event, (IDispatch*)&doc->window->base.IDispatchEx_iface);
             nsIDOMHTMLElement_Release(nsbody);
         }
diff --git a/dlls/mshtml/task.c b/dlls/mshtml/task.c
index d0c888f..a821031 100644
--- a/dlls/mshtml/task.c
+++ b/dlls/mshtml/task.c
@@ -102,6 +102,25 @@ static void release_task_timer(HWND thread_hwnd, task_timer_t *timer)
     heap_free(timer);
 }
 
+void flush_pending_tasks(LONG target)
+{
+    thread_data_t *thread_data = get_thread_data(FALSE);
+    struct list *liter, *ltmp;
+    task_t *task;
+
+    if(!thread_data)
+        return;
+
+    LIST_FOR_EACH_SAFE(liter, ltmp, &thread_data->task_list) {
+        task = LIST_ENTRY(liter, task_t, entry);
+        if(task->target_magic == target) {
+            list_remove(&task->entry);
+            task->proc(task);
+            task->destr(task);
+        }
+    }
+}
+
 void remove_target_tasks(LONG target)
 {
     thread_data_t *thread_data = get_thread_data(FALSE);




More information about the wine-cvs mailing list