From 2fe0623298a5a16b6a97885de30f5aae1a44855d Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Tue, 24 Oct 2006 16:47:41 +0200 Subject: [PATCH] Moved the setTimeout timer to the struct document. --- src/document/document.c | 4 ++++ src/document/document.h | 3 +++ src/ecmascript/ecmascript.c | 5 ++--- src/ecmascript/ecmascript.h | 1 - 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/document/document.c b/src/document/document.c index 5a39574c1..f8ca3668c 100644 --- a/src/document/document.c +++ b/src/document/document.c @@ -157,6 +157,7 @@ done_document(struct document *document) #ifdef CONFIG_ECMASCRIPT free_string_list(&document->onload_snippets); free_uri_list(&document->ecmascript_imports); + kill_timer(&document->timeout); #endif free_list(document->tags); @@ -177,6 +178,9 @@ release_document(struct document *document) if_assert_failed return; if (document->refresh) kill_document_refresh(document->refresh); +#ifdef CONFIG_ECMASCRIPT + kill_timer(&document->timeout); +#endif object_unlock(document); move_to_top_of_list(format_cache, document); } diff --git a/src/document/document.h b/src/document/document.h index bf9c2c854..ad2944c5d 100644 --- a/src/document/document.h +++ b/src/document/document.h @@ -4,6 +4,7 @@ #include "document/options.h" #include "intl/charsets.h" /* unicode_val_T */ #include "main/object.h" +#include "main/timer.h" #include "protocol/uri.h" #include "util/color.h" #include "util/lists.h" @@ -153,6 +154,8 @@ struct document { * dependencies between the various entries so nothing gets removed * unneeded. */ struct uri_list ecmascript_imports; + /* used by setTimeout */ + timer_id_T timeout; #endif #ifdef CONFIG_CSS /* FIXME: We should externally maybe using cache_entry store the diff --git a/src/ecmascript/ecmascript.c b/src/ecmascript/ecmascript.c index 0d31732bf..a5e14b20e 100644 --- a/src/ecmascript/ecmascript.c +++ b/src/ecmascript/ecmascript.c @@ -144,7 +144,6 @@ ecmascript_put_interpreter(struct ecmascript_interpreter *interpreter) spidermonkey_put_interpreter(interpreter); #endif free_string_list(&interpreter->onload_snippets); - kill_timer(&interpreter->timeout); done_string(&interpreter->code); interpreter->vs->ecmascript = NULL; mem_free(interpreter); @@ -311,13 +310,13 @@ ecmascript_timeout_handler(void *i) void ecmascript_set_timeout(struct ecmascript_interpreter *interpreter, unsigned char *code, int timeout) { - assert(interpreter); + assert(interpreter && interpreter->vs->doc_view->document); if (!code) return; done_string(&interpreter->code); init_string(&interpreter->code); add_to_string(&interpreter->code, code); mem_free(code); - install_timer(&interpreter->timeout, timeout, ecmascript_timeout_handler, interpreter); + install_timer(&interpreter->vs->doc_view->document->timeout, timeout, ecmascript_timeout_handler, interpreter); } static struct module *ecmascript_modules[] = { diff --git a/src/ecmascript/ecmascript.h b/src/ecmascript/ecmascript.h index c54638d88..c1b038f66 100644 --- a/src/ecmascript/ecmascript.h +++ b/src/ecmascript/ecmascript.h @@ -24,7 +24,6 @@ struct ecmascript_interpreter { /* The code evaluated by setTimeout() */ struct string code; - timer_id_T timeout; time_t exec_start;