1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-11-04 08:17:17 -05:00

[quikcjs] Added gc_mark function for document

This commit is contained in:
Witold Filipczyk 2024-07-07 13:28:38 +02:00
parent d27c3912fc
commit b2b3b64c9a
3 changed files with 34 additions and 4 deletions

View File

@ -346,6 +346,14 @@ ecmascript_put_interpreter(struct ecmascript_interpreter *interpreter)
#endif #endif
} }
free_list(interpreter->timeouts); free_list(interpreter->timeouts);
#ifdef CONFIG_QUICKJS
if (!JS_IsNull(interpreter->location_obj)) {
//JS_FreeValue(t->ctx, interpreter->location_obj);
}
if (!JS_IsNull(interpreter->document_obj)) {
//JS_FreeValue(t->ctx, interpreter->document_obj);
}
#endif
} }
#ifdef CONFIG_ECMASCRIPT_SMJS #ifdef CONFIG_ECMASCRIPT_SMJS
//js::StopDrainingJobQueue((JSContext *)interpreter->backend_data); //js::StopDrainingJobQueue((JSContext *)interpreter->backend_data);

View File

@ -30,6 +30,7 @@
#else #else
#ifdef CONFIG_QUICKJS #ifdef CONFIG_QUICKJS
#include "ecmascript/quickjs.h" #include "ecmascript/quickjs.h"
#include "ecmascript/quickjs/document.h"
#else #else
#include "ecmascript/spidermonkey.h" #include "ecmascript/spidermonkey.h"
#endif #endif
@ -309,7 +310,7 @@ check_for_rerender(struct ecmascript_interpreter *interpreter, const char* text)
} }
#endif #endif
#ifdef CONFIG_QUICKJS #ifdef CONFIG_QUICKJS
if (1) { if (JS_IsObject(interpreter->document_obj)) {
dom_document *doc = js_doc_getopaque(interpreter->document_obj); dom_document *doc = js_doc_getopaque(interpreter->document_obj);
if (doc) { if (doc) {
@ -637,7 +638,7 @@ ecmascript_set_timeout2q(void *c, JSValueConst fun, int timeout, int timeout_nex
t->interpreter = interpreter; t->interpreter = interpreter;
t->ctx = ctx; t->ctx = ctx;
t->timeout_next = timeout_next; t->timeout_next = timeout_next;
t->fun = fun; t->fun = JS_DupValue(ctx, fun);
add_to_list(interpreter->timeouts, t); add_to_list(interpreter->timeouts, t);
install_timer(&t->tid, timeout, ecmascript_timeout_handler2, t); install_timer(&t->tid, timeout, ecmascript_timeout_handler2, t);

View File

@ -82,6 +82,25 @@ js_doc_getopaque(JSValueConst obj)
return res->node; return res->node;
} }
static void
js_document_mark(JSRuntime *rt, JSValueConst val, JS_MarkFunc *mark_func)
{
#ifdef ECMASCRIPT_DEBUG
fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__);
#endif
REF_JS(val);
struct js_document_private *doc_private = (struct js_document_private *)JS_GetOpaque(val, js_document_class_id);
if (doc_private) {
struct document_listener *l;
foreach(l, doc_private->listeners) {
JS_MarkValue(rt, l->fun, mark_func);
}
}
}
static JSValue static JSValue
js_document_get_property_anchors(JSContext *ctx, JSValueConst this_val) js_document_get_property_anchors(JSContext *ctx, JSValueConst this_val)
{ {
@ -1069,7 +1088,7 @@ js_document_addEventListener(JSContext *ctx, JSValueConst this_val, int argc, JS
if (!n) { if (!n) {
return JS_UNDEFINED; return JS_UNDEFINED;
} }
n->fun = fun; n->fun = JS_DupValue(ctx, fun);
n->typ = method; n->typ = method;
add_to_list_end(doc_private->listeners, n); add_to_list_end(doc_private->listeners, n);
dom_exception exc; dom_exception exc;
@ -1851,6 +1870,7 @@ js_document_finalizer(JSRuntime *rt, JSValue val)
foreach(l, doc_private->listeners) { foreach(l, doc_private->listeners) {
mem_free_set(&l->typ, NULL); mem_free_set(&l->typ, NULL);
JS_FreeValueRT(rt, l->fun);
} }
free_list(doc_private->listeners); free_list(doc_private->listeners);
if (doc_private->node) { if (doc_private->node) {
@ -1862,7 +1882,8 @@ js_document_finalizer(JSRuntime *rt, JSValue val)
static JSClassDef js_document_class = { static JSClassDef js_document_class = {
"document", "document",
js_document_finalizer .finalizer = js_document_finalizer,
.gc_mark = js_document_mark
}; };
static JSValue static JSValue