mshtml: Added IHTMLWindow3::setInterval implementation.
This commit is contained in:
parent
0d56f1058f
commit
74f29f1087
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue