mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
[ecmascript] clearTimeout without iteration over timeouts list
This commit is contained in:
parent
bce7e87bb8
commit
fb30cb3bf4
@ -25,6 +25,7 @@
|
|||||||
#include "ecmascript/timer.h"
|
#include "ecmascript/timer.h"
|
||||||
#include "intl/libintl.h"
|
#include "intl/libintl.h"
|
||||||
#include "main/select.h"
|
#include "main/select.h"
|
||||||
|
#include "main/timer.h"
|
||||||
#include "osdep/newwin.h"
|
#include "osdep/newwin.h"
|
||||||
#include "osdep/sysname.h"
|
#include "osdep/sysname.h"
|
||||||
#include "protocol/http/http.h"
|
#include "protocol/http/http.h"
|
||||||
@ -194,17 +195,11 @@ mjs_window_clearTimeout(js_State *J)
|
|||||||
timer_id_T id = reinterpret_cast<timer_id_T>(number);
|
timer_id_T id = reinterpret_cast<timer_id_T>(number);
|
||||||
|
|
||||||
if (found_in_map_timer(id)) {
|
if (found_in_map_timer(id)) {
|
||||||
struct ecmascript_timeout *t;
|
struct ecmascript_timeout *t = (struct ecmascript_timeout *)(id->data);
|
||||||
|
kill_timer(&t->tid);
|
||||||
foreach (t, interpreter->vs->doc_view->document->timeouts) {
|
done_string(&t->code);
|
||||||
if (id == t->tid) {
|
del_from_list(t);
|
||||||
kill_timer(&t->tid);
|
mem_free(t);
|
||||||
done_string(&t->code);
|
|
||||||
del_from_list(t);
|
|
||||||
mem_free(t);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
js_pushundefined(J);
|
js_pushundefined(J);
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "ecmascript/timer.h"
|
#include "ecmascript/timer.h"
|
||||||
#include "intl/libintl.h"
|
#include "intl/libintl.h"
|
||||||
#include "main/select.h"
|
#include "main/select.h"
|
||||||
|
#include "main/timer.h"
|
||||||
#include "osdep/newwin.h"
|
#include "osdep/newwin.h"
|
||||||
#include "osdep/sysname.h"
|
#include "osdep/sysname.h"
|
||||||
#include "protocol/http/http.h"
|
#include "protocol/http/http.h"
|
||||||
@ -247,17 +248,11 @@ js_window_clearTimeout(JSContext *ctx, JSValueConst this_val, int argc, JSValueC
|
|||||||
timer_id_T id = reinterpret_cast<timer_id_T>(number);
|
timer_id_T id = reinterpret_cast<timer_id_T>(number);
|
||||||
|
|
||||||
if (found_in_map_timer(id)) {
|
if (found_in_map_timer(id)) {
|
||||||
struct ecmascript_timeout *t;
|
struct ecmascript_timeout *t = (struct ecmascript_timeout *)(id->data);
|
||||||
|
kill_timer(&t->tid);
|
||||||
foreach (t, interpreter->vs->doc_view->document->timeouts) {
|
done_string(&t->code);
|
||||||
if (id == t->tid) {
|
del_from_list(t);
|
||||||
kill_timer(&t->tid);
|
mem_free(t);
|
||||||
done_string(&t->code);
|
|
||||||
del_from_list(t);
|
|
||||||
mem_free(t);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return JS_UNDEFINED;
|
return JS_UNDEFINED;
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "ecmascript/timer.h"
|
#include "ecmascript/timer.h"
|
||||||
#include "intl/libintl.h"
|
#include "intl/libintl.h"
|
||||||
#include "main/select.h"
|
#include "main/select.h"
|
||||||
|
#include "main/timer.h"
|
||||||
#include "osdep/newwin.h"
|
#include "osdep/newwin.h"
|
||||||
#include "osdep/sysname.h"
|
#include "osdep/sysname.h"
|
||||||
#include "protocol/http/http.h"
|
#include "protocol/http/http.h"
|
||||||
@ -407,17 +408,11 @@ window_clearTimeout(JSContext *ctx, unsigned int argc, JS::Value *rval)
|
|||||||
timer_id_T id = reinterpret_cast<timer_id_T>(number);
|
timer_id_T id = reinterpret_cast<timer_id_T>(number);
|
||||||
|
|
||||||
if (found_in_map_timer(id)) {
|
if (found_in_map_timer(id)) {
|
||||||
struct ecmascript_timeout *t;
|
struct ecmascript_timeout *t = (struct ecmascript_timeout *)(id->data);
|
||||||
|
kill_timer(&t->tid);
|
||||||
foreach (t, interpreter->vs->doc_view->document->timeouts) {
|
done_string(&t->code);
|
||||||
if (id == t->tid) {
|
del_from_list(t);
|
||||||
kill_timer(&t->tid);
|
mem_free(t);
|
||||||
done_string(&t->code);
|
|
||||||
del_from_list(t);
|
|
||||||
mem_free(t);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -37,14 +37,6 @@
|
|||||||
#include "ecmascript/timer.h"
|
#include "ecmascript/timer.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct timer {
|
|
||||||
LIST_HEAD(struct timer);
|
|
||||||
|
|
||||||
timeval_T interval;
|
|
||||||
void (*func)(void *);
|
|
||||||
void *data;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* @timers.next points to the timer with the smallest interval,
|
/* @timers.next points to the timer with the smallest interval,
|
||||||
* @timers.next->next to the second smallest, and so on. */
|
* @timers.next->next to the second smallest, and so on. */
|
||||||
static INIT_LIST_OF(struct timer, timers);
|
static INIT_LIST_OF(struct timer, timers);
|
||||||
|
@ -1,14 +1,20 @@
|
|||||||
#ifndef EL__MAIN_TIMER_H
|
#ifndef EL__MAIN_TIMER_H
|
||||||
#define EL__MAIN_TIMER_H
|
#define EL__MAIN_TIMER_H
|
||||||
|
|
||||||
|
#include "util/lists.h"
|
||||||
#include "util/time.h"
|
#include "util/time.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Only available internally. */
|
struct timer {
|
||||||
struct timer;
|
LIST_HEAD(struct timer);
|
||||||
|
|
||||||
|
timeval_T interval;
|
||||||
|
void (*func)(void *);
|
||||||
|
void *data;
|
||||||
|
};
|
||||||
|
|
||||||
/* Little hack, timer_id_T is in fact a pointer to the timer, so
|
/* Little hack, timer_id_T is in fact a pointer to the timer, so
|
||||||
* it has to be of a pointer type.
|
* it has to be of a pointer type.
|
||||||
|
Loading…
Reference in New Issue
Block a user