Jacek Caban : mshtml: Added IHTMLWindow3::setInterval implementation.
Alexandre Julliard
julliard at winehq.org
Mon Jun 30 08:26:41 CDT 2008
Module: wine
Branch: master
Commit: 74f29f10878ef423c60121c5a383074880d844f7
URL: http://source.winehq.org/git/wine.git/?a=commit;h=74f29f10878ef423c60121c5a383074880d844f7
Author: Jacek Caban <jacek at codeweavers.com>
Date: Fri Jun 27 14:11:38 2008 -0500
mshtml: Added IHTMLWindow3::setInterval implementation.
---
dlls/mshtml/htmlwindow.c | 13 ++++++----
dlls/mshtml/mshtml_private.h | 2 +-
dlls/mshtml/task.c | 50 ++++++++++++++++++++++++++---------------
3 files changed, 41 insertions(+), 24 deletions(-)
diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c
index c76c132..839858b 100644
--- a/dlls/mshtml/htmlwindow.c
+++ b/dlls/mshtml/htmlwindow.c
@@ -846,7 +846,8 @@ static HRESULT WINAPI HTMLWindow3_detachEvent(IHTMLWindow3 *iface, BSTR event, I
return E_NOTIMPL;
}
-static HRESULT window_set_timer(HTMLWindow *This, VARIANT *expr, long msec, VARIANT *language, long *timer_id)
+static HRESULT window_set_timer(HTMLWindow *This, VARIANT *expr, long msec, VARIANT *language,
+ BOOL interval, long *timer_id)
{
IDispatch *disp = NULL;
@@ -868,7 +869,7 @@ static HRESULT window_set_timer(HTMLWindow *This, VARIANT *expr, long msec, VARI
if(!disp)
return E_FAIL;
- *timer_id = set_task_timer(This->doc, msec, disp);
+ *timer_id = set_task_timer(This->doc, msec, interval, disp);
IDispatch_Release(disp);
return S_OK;
@@ -881,15 +882,17 @@ static HRESULT WINAPI HTMLWindow3_setTimeout(IHTMLWindow3 *iface, VARIANT *expre
TRACE("(%p)->(%p(%d) %ld %p %p)\n", This, expression, V_VT(expression), msec, language, timerID);
- return window_set_timer(This, expression, msec, language, timerID);
+ return window_set_timer(This, expression, msec, language, FALSE, timerID);
}
static HRESULT WINAPI HTMLWindow3_setInterval(IHTMLWindow3 *iface, VARIANT *expression, long msec,
VARIANT *language, long *timerID)
{
HTMLWindow *This = HTMLWINDOW3_THIS(iface);
- FIXME("(%p)->(%p %ld %p %p)\n", This, expression, msec, language, timerID);
- return E_NOTIMPL;
+
+ TRACE("(%p)->(%p %ld %p %p)\n", This, expression, msec, language, timerID);
+
+ return window_set_timer(This, expression, msec, language, TRUE, timerID);
}
static HRESULT WINAPI HTMLWindow3_print(IHTMLWindow3 *iface)
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index 7b2bf9e..e6fd13d 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -623,7 +623,7 @@ thread_data_t *get_thread_data(BOOL);
HWND get_thread_hwnd(void);
void push_task(task_t*);
void remove_doc_tasks(const HTMLDocument*);
-DWORD set_task_timer(HTMLDocument*,DWORD,IDispatch*);
+DWORD set_task_timer(HTMLDocument*,DWORD,BOOL,IDispatch*);
HRESULT get_typeinfo(tid_t,ITypeInfo**);
void release_typelib(void);
diff --git a/dlls/mshtml/task.c b/dlls/mshtml/task.c
index f9969c5..329c6ac 100644
--- a/dlls/mshtml/task.c
+++ b/dlls/mshtml/task.c
@@ -43,6 +43,7 @@ typedef struct {
HTMLDocument *doc;
DWORD id;
DWORD time;
+ DWORD interval;
IDispatch *disp;
struct list entry;
@@ -123,7 +124,29 @@ void remove_doc_tasks(const HTMLDocument *doc)
}
}
-DWORD set_task_timer(HTMLDocument *doc, DWORD msec, IDispatch *disp)
+static BOOL queue_timer(thread_data_t *thread_data, task_timer_t *timer)
+{
+ task_timer_t *iter;
+
+ if(list_empty(&thread_data->timer_list)
+ || LIST_ENTRY(list_head(&thread_data->timer_list), task_timer_t, entry)->time > timer->time) {
+
+ list_add_head(&thread_data->timer_list, &timer->entry);
+ return TRUE;
+ }
+
+ LIST_FOR_EACH_ENTRY(iter, &thread_data->timer_list, task_timer_t, entry) {
+ if(iter->time > timer->time) {
+ list_add_tail(&iter->entry, &timer->entry);
+ return FALSE;
+ }
+ }
+
+ list_add_tail(&thread_data->timer_list, &timer->entry);
+ return FALSE;
+}
+
+DWORD set_task_timer(HTMLDocument *doc, DWORD msec, BOOL interval, IDispatch *disp)
{
thread_data_t *thread_data = get_thread_data(TRUE);
task_timer_t *timer;
@@ -135,27 +158,13 @@ DWORD set_task_timer(HTMLDocument *doc, DWORD msec, IDispatch *disp)
timer->id = id_cnt++;
timer->doc = doc;
timer->time = tc + msec;
+ timer->interval = interval ? msec : 0;
IDispatch_AddRef(disp);
timer->disp = disp;
- if(list_empty(&thread_data->timer_list)
- || LIST_ENTRY(list_head(&thread_data->timer_list), task_timer_t, entry)->time > timer->time) {
-
- list_add_head(&thread_data->timer_list, &timer->entry);
+ if(queue_timer(thread_data, timer))
SetTimer(thread_data->thread_hwnd, TIMER_ID, msec, NULL);
- }else {
- task_timer_t *iter;
-
- LIST_FOR_EACH_ENTRY(iter, &thread_data->timer_list, task_timer_t, entry) {
- if(iter->time > timer->time) {
- list_add_tail(&iter->entry, &timer->entry);
- return timer->id;
- }
- }
-
- list_add_tail(&thread_data->timer_list, &timer->entry);
- }
return timer->id;
}
@@ -354,7 +363,12 @@ static LRESULT process_timer(void)
call_disp_func(timer->doc, timer->disp);
- release_task_timer(thread_data->thread_hwnd, timer);
+ if(timer->interval) {
+ timer->time += timer->interval;
+ queue_timer(thread_data, timer);
+ }else {
+ release_task_timer(thread_data->thread_hwnd, timer);
+ }
}
KillTimer(thread_data->thread_hwnd, TIMER_ID);
More information about the wine-cvs
mailing list