mirror of
https://github.com/rkd77/elinks.git
synced 2024-09-19 01:36:33 -04:00
[quikcjs] Added gc_mark function for document
This commit is contained in:
parent
d27c3912fc
commit
b2b3b64c9a
@ -346,6 +346,14 @@ ecmascript_put_interpreter(struct ecmascript_interpreter *interpreter)
|
||||
#endif
|
||||
}
|
||||
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
|
||||
//js::StopDrainingJobQueue((JSContext *)interpreter->backend_data);
|
||||
|
@ -30,6 +30,7 @@
|
||||
#else
|
||||
#ifdef CONFIG_QUICKJS
|
||||
#include "ecmascript/quickjs.h"
|
||||
#include "ecmascript/quickjs/document.h"
|
||||
#else
|
||||
#include "ecmascript/spidermonkey.h"
|
||||
#endif
|
||||
@ -309,7 +310,7 @@ check_for_rerender(struct ecmascript_interpreter *interpreter, const char* text)
|
||||
}
|
||||
#endif
|
||||
#ifdef CONFIG_QUICKJS
|
||||
if (1) {
|
||||
if (JS_IsObject(interpreter->document_obj)) {
|
||||
dom_document *doc = js_doc_getopaque(interpreter->document_obj);
|
||||
|
||||
if (doc) {
|
||||
@ -637,7 +638,7 @@ ecmascript_set_timeout2q(void *c, JSValueConst fun, int timeout, int timeout_nex
|
||||
t->interpreter = interpreter;
|
||||
t->ctx = ctx;
|
||||
t->timeout_next = timeout_next;
|
||||
t->fun = fun;
|
||||
t->fun = JS_DupValue(ctx, fun);
|
||||
add_to_list(interpreter->timeouts, t);
|
||||
install_timer(&t->tid, timeout, ecmascript_timeout_handler2, t);
|
||||
|
||||
|
@ -82,6 +82,25 @@ js_doc_getopaque(JSValueConst obj)
|
||||
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
|
||||
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) {
|
||||
return JS_UNDEFINED;
|
||||
}
|
||||
n->fun = fun;
|
||||
n->fun = JS_DupValue(ctx, fun);
|
||||
n->typ = method;
|
||||
add_to_list_end(doc_private->listeners, n);
|
||||
dom_exception exc;
|
||||
@ -1851,6 +1870,7 @@ js_document_finalizer(JSRuntime *rt, JSValue val)
|
||||
|
||||
foreach(l, doc_private->listeners) {
|
||||
mem_free_set(&l->typ, NULL);
|
||||
JS_FreeValueRT(rt, l->fun);
|
||||
}
|
||||
free_list(doc_private->listeners);
|
||||
if (doc_private->node) {
|
||||
@ -1862,7 +1882,8 @@ js_document_finalizer(JSRuntime *rt, JSValue val)
|
||||
|
||||
static JSClassDef js_document_class = {
|
||||
"document",
|
||||
js_document_finalizer
|
||||
.finalizer = js_document_finalizer,
|
||||
.gc_mark = js_document_mark
|
||||
};
|
||||
|
||||
static JSValue
|
||||
|
Loading…
Reference in New Issue
Block a user