diff --git a/src/document/libdom/doc.c b/src/document/libdom/doc.c index 2d714760..65052156 100644 --- a/src/document/libdom/doc.c +++ b/src/document/libdom/doc.c @@ -132,12 +132,18 @@ document_parse(struct document *document, struct string *source) void free_document(void *doc) { +#ifdef ECMASCRIPT_DEBUG + fprintf(stderr, "%s:%s\n", __FILE__, __FUNCTION__); +#endif if (!doc) { return; } dom_html_document *ddd = (dom_html_document *)doc; if (((dom_node *)ddd)->refcnt > 0) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(ddd); } } diff --git a/src/ecmascript/mujs.c b/src/ecmascript/mujs.c index 7f4b914e..5f453712 100644 --- a/src/ecmascript/mujs.c +++ b/src/ecmascript/mujs.c @@ -147,7 +147,6 @@ mujs_get_interpreter(struct ecmascript_interpreter *interpreter) mjs_localstorage_init(J); mjs_element_init(J); mjs_location_init(J); - mjs_push_document(J, document->dom); mjs_xhr_init(J); mjs_event_init(J); mjs_keyboardEvent_init(J); @@ -156,6 +155,8 @@ mujs_get_interpreter(struct ecmascript_interpreter *interpreter) mjs_url_init(J); mjs_domparser_init(J); + mjs_push_document(J, document->dom); + return J; #if 0 diff --git a/src/ecmascript/mujs/document.c b/src/ecmascript/mujs/document.c index dea18f44..93508439 100644 --- a/src/ecmascript/mujs/document.c +++ b/src/ecmascript/mujs/document.c @@ -178,6 +178,9 @@ mjs_document_get_property_body(js_State *J) return; } mjs_push_element(J, body); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(body); } @@ -290,6 +293,9 @@ mjs_document_get_property_childNodes(js_State *J) } dom_nodelist *nodes = NULL; exc = dom_node_get_child_nodes(root, &nodes); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(root); if (exc != DOM_NO_ERR || !nodes) { @@ -345,6 +351,9 @@ mjs_document_get_property_documentElement(js_State *J) return; } mjs_push_element(J, root); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(root); } @@ -1093,6 +1102,9 @@ mjs_document_createComment(js_State *J) return; } mjs_push_element(J, comment); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(comment); } @@ -1116,6 +1128,9 @@ mjs_document_createDocumentFragment(js_State *J) return; } mjs_push_element(J, fragment); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(fragment); } @@ -1149,6 +1164,9 @@ mjs_document_createElement(js_State *J) return; } mjs_push_element(J, element); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(element); } @@ -1182,6 +1200,9 @@ mjs_document_createTextNode(js_State *J) return; } mjs_push_element(J, text_node); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(text_node); } @@ -1220,6 +1241,9 @@ mjs_document_getElementById(js_State *J) return; } mjs_push_element(J, element); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(element); } @@ -1350,11 +1374,17 @@ mjs_document_querySelector(js_State *J) const char *selector = js_tostring(J, 1); if (!selector) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(root); js_pushnull(J); return; } void *ret = walk_tree_query(root, selector, 0); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(root); if (!ret) { @@ -1362,6 +1392,9 @@ mjs_document_querySelector(js_State *J) return; } mjs_push_element(J, ret); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(ret); } @@ -1388,6 +1421,9 @@ mjs_document_querySelectorAll(js_State *J) const char *selector = js_tostring(J, 1); if (!selector) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(doc_root); js_pushnull(J); return; @@ -1395,12 +1431,18 @@ mjs_document_querySelectorAll(js_State *J) LIST_OF(struct selector_node) *result_list = (LIST_OF(struct selector_node) *)mem_calloc(1, sizeof(*result_list)); if (!result_list) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(doc_root); js_pushnull(J); return; } init_list(*result_list); walk_tree_query_append(doc_root, selector, 0, result_list); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(doc_root); mjs_push_nodelist2(J, result_list); } @@ -1556,6 +1598,9 @@ mjs_doctype_finalizer(js_State *J, void *node) attr_erase_from_map(map_doctypes, node); if (node) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref((dom_node *)node); } } @@ -1595,6 +1640,9 @@ mjs_doc_private_finalizer(js_State *J, void *priv) } free_list(doc_private->listeners); if (doc_private->node) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(doc_private->node); } if (doc_private->thisval) { @@ -1672,6 +1720,9 @@ mjs_push_document(js_State *J, void *doc) doc_private->ref_count = 1; doc_private->thisval = js_ref(J); if (doc) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_ref((dom_node *)doc); } } @@ -1744,6 +1795,9 @@ mjs_push_document2(js_State *J, void *doc) doc_private->ref_count = 1; //doc_private->thisval = js_ref(J); if (doc) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_ref((dom_node *)doc); } } diff --git a/src/ecmascript/mujs/element.c b/src/ecmascript/mujs/element.c index d7d87a11..f5791305 100644 --- a/src/ecmascript/mujs/element.c +++ b/src/ecmascript/mujs/element.c @@ -265,9 +265,15 @@ mjs_element_get_property_classList(js_State *J) js_pushnull(J); return; } +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_ref(el); dom_tokenlist *tl = NULL; dom_exception exc = dom_tokenlist_create(el, corestring_dom_class, &tl); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(el); if (exc != DOM_NO_ERR || !tl) { @@ -520,6 +526,9 @@ mjs_element_get_property_firstChild(js_State *J) return; } mjs_push_element(J, node); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(node); } @@ -567,9 +576,15 @@ mjs_element_get_property_firstElementChild(js_State *J) if (exc == DOM_NO_ERR && type == DOM_ELEMENT_NODE) { dom_nodelist_unref(nodes); mjs_push_element(J, child); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(child); return; } +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(child); } dom_nodelist_unref(nodes); @@ -683,6 +698,9 @@ mjs_element_get_property_lastChild(js_State *J) return; } mjs_push_element(J, last_child); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(last_child); } @@ -729,9 +747,15 @@ mjs_element_get_property_lastElementChild(js_State *J) if (exc == DOM_NO_ERR && type == DOM_ELEMENT_NODE) { dom_nodelist_unref(nodes); mjs_push_element(J, child); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(child); return; } +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(child); } dom_nodelist_unref(nodes); @@ -760,6 +784,9 @@ mjs_element_get_property_nextElementSibling(js_State *J) dom_node_type type; if (prev_next) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(prev_next); } @@ -771,6 +798,9 @@ mjs_element_get_property_nextElementSibling(js_State *J) if (exc == DOM_NO_ERR && type == DOM_ELEMENT_NODE) { mjs_push_element(J, next); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(next); return; } @@ -872,6 +902,9 @@ mjs_element_get_property_nextSibling(js_State *J) return; } mjs_push_element(J, node); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(node); } @@ -946,6 +979,9 @@ mjs_element_get_property_offsetLeft(js_State *J) return; } int dx = int_max(0, (rect->x0 - rect_parent->x0) * ses->tab->term->cell_width); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(node); js_pushnumber(J, dx); } @@ -972,6 +1008,9 @@ mjs_element_get_property_offsetParent(js_State *J) return; } mjs_push_element(J, node); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(node); } @@ -1035,6 +1074,9 @@ mjs_element_get_property_offsetTop(js_State *J) return; } int dy = int_max(0, (rect->y0 - rect_parent->y0) * ses->tab->term->cell_height); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(node); js_pushnumber(J, dy); } @@ -1083,6 +1125,9 @@ mjs_element_get_property_parentElement(js_State *J) return; } mjs_push_element(J, node); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(node); } @@ -1107,6 +1152,9 @@ mjs_element_get_property_parentNode(js_State *J) return; } mjs_push_element(J, node); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(node); } @@ -1132,6 +1180,9 @@ mjs_element_get_property_previousElementSibling(js_State *J) dom_node_type type; if (prev_prev) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(prev_prev); } @@ -1143,6 +1194,9 @@ mjs_element_get_property_previousElementSibling(js_State *J) if (exc == DOM_NO_ERR && type == DOM_ELEMENT_NODE) { mjs_push_element(J, prev); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(prev); return; } @@ -1173,6 +1227,9 @@ mjs_element_get_property_previousSibling(js_State *J) return; } mjs_push_element(J, node); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(node); } @@ -1633,8 +1690,14 @@ mjs_element_set_property_innerHtml(js_State *J) struct dom_node *cref; exc = dom_node_remove_child(el, child, &cref); if (exc != DOM_NO_ERR) goto out; +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(child); child = NULL; +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(cref); exc = dom_node_get_first_child(el, &child); if (exc != DOM_NO_ERR) goto out; @@ -1663,10 +1726,19 @@ mjs_element_set_property_innerHtml(js_State *J) struct dom_node *cref; exc = dom_node_remove_child(body, child, &cref); if (exc != DOM_NO_ERR) goto out; +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(cref); exc = dom_node_append_child(el, child, &cref); if (exc != DOM_NO_ERR) goto out; +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(cref); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(child); child = NULL; exc = dom_node_get_first_child(body, &child); @@ -1677,21 +1749,36 @@ out: dom_hubbub_parser_destroy(parser); } if (doc != NULL) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(doc); } if (fragment != NULL) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(fragment); } if (child != NULL) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(child); } if (html != NULL) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(html); } if (bodies != NULL) { dom_nodelist_unref(bodies); } if (body != NULL) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(body); } interpreter->changed = 1; @@ -1834,14 +1921,26 @@ mjs_element_set_property_outerHtml(js_State *J) while (child != NULL) { exc = dom_node_remove_child(body, child, &cref); if (exc != DOM_NO_ERR) goto out; +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(cref); dom_node *spare = NULL; exc = dom_node_insert_before(parent, child, el, &spare); if (exc != DOM_NO_ERR) goto out; +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(spare); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(cref); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(child); child = NULL; exc = dom_node_get_first_child(body, &child); @@ -1855,26 +1954,47 @@ out: dom_hubbub_parser_destroy(parser); } if (doc != NULL) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(doc); } if (fragment != NULL) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(fragment); } if (child != NULL) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(child); } if (html != NULL) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(html); } if (bodies != NULL) { dom_nodelist_unref(bodies); } if (body != NULL) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(body); } if (cref != NULL) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(cref); } +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(parent); interpreter->changed = 1; @@ -2209,6 +2329,9 @@ mjs_element_appendChild(js_State *J) if (exc == DOM_NO_ERR && res) { interpreter->changed = 1; mjs_push_element(J, res); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(res); return; } @@ -2302,6 +2425,9 @@ mjs_element_cloneNode(js_State *J) return; } mjs_push_element(J, clone); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(clone); } @@ -2314,6 +2440,9 @@ isAncestor(dom_node *el, dom_node *node) dom_exception exc; dom_node *next = NULL; if (prev_next) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(prev_next); } if (el == node) { @@ -2378,6 +2507,9 @@ mjs_element_closest(js_State *J) } el = node; } +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(root); if (!res) { @@ -2385,6 +2517,9 @@ mjs_element_closest(js_State *J) return; } mjs_push_element(J, res); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(res); } @@ -2406,12 +2541,24 @@ mjs_element_contains(js_State *J) js_pushboolean(J, 0); return; } +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_ref(el); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_ref(el2); while (1) { if (el == el2) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(el); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(el2); js_pushboolean(J, 1); return; @@ -2420,11 +2567,20 @@ mjs_element_contains(js_State *J) dom_exception exc = dom_node_get_parent_node(el2, &node); if (exc != DOM_NO_ERR || !node) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(el); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(el2); js_pushboolean(J, 0); return; } +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(el2); el2 = node; } @@ -2721,6 +2877,9 @@ mjs_element_insertBefore(js_State *J) } interpreter->changed = 1; mjs_push_element(J, spare); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(spare); } @@ -2823,6 +2982,9 @@ mjs_element_querySelector(js_State *J) return; } mjs_push_element(J, ret); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(ret); } @@ -2886,9 +3048,15 @@ mjs_element_remove(js_State *J) } dom_node *res = NULL; exc = dom_node_remove_child(parent, el, &res); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(parent); if (exc == DOM_NO_ERR) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(res); interpreter->changed = 1; } @@ -2944,6 +3112,9 @@ mjs_element_removeChild(js_State *J) if (exc == DOM_NO_ERR && spare) { interpreter->changed = 1; mjs_push_element(J, spare); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(spare); return; } @@ -3067,6 +3238,9 @@ mjs_element_finalizer(js_State *J, void *priv) free_list(el_private->listeners); if (node && (node->refcnt > 0)) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(node); } if (el_private->thisval) { @@ -3110,6 +3284,9 @@ mjs_push_element(js_State *J, void *node) el_private->interpreter = interpreter; el_private->node = node; el_private->ref_count = 1; +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_ref((dom_node *)node); attr_save_in_map(map_privates, node, el_private); diff --git a/src/ecmascript/mujs/nodelist.c b/src/ecmascript/mujs/nodelist.c index 7f178c61..1b5e4adb 100644 --- a/src/ecmascript/mujs/nodelist.c +++ b/src/ecmascript/mujs/nodelist.c @@ -47,6 +47,9 @@ mjs_push_nodeList_item2(js_State *J, int idx) return; } mjs_push_element(J, element); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(element); } @@ -89,6 +92,9 @@ mjs_nodeList_set_items(js_State *J, void *node) } mjs_push_element(J, element); js_setindex(J, -2, i); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(element); } js_setlength(J, -1, length); diff --git a/src/ecmascript/quickjs/document.c b/src/ecmascript/quickjs/document.c index 52c2b864..164c9bc1 100644 --- a/src/ecmascript/quickjs/document.c +++ b/src/ecmascript/quickjs/document.c @@ -186,6 +186,9 @@ js_document_get_property_body(JSContext *ctx, JSValueConst this_val) } //dom_node_unref(doc); JSValue rr = getElement(ctx, body); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(body); return rr; @@ -318,6 +321,9 @@ js_document_get_property_childNodes(JSContext *ctx, JSValueConst this_val) } dom_nodelist *nodes = NULL; exc = dom_node_get_child_nodes(root, &nodes); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(root); if (exc != DOM_NO_ERR || !nodes) { @@ -387,6 +393,9 @@ js_document_get_property_documentElement(JSContext *ctx, JSValueConst this_val) } //dom_node_unref(doc); JSValue rr = getElement(ctx, root); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(root); return rr; @@ -1351,6 +1360,9 @@ js_document_createElement(JSContext *ctx, JSValueConst this_val, int argc, JSVal } //dom_node_unref(doc); JSValue rr = getElement(ctx, element); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(element); return rr; @@ -1451,6 +1463,9 @@ js_document_getElementById(JSContext *ctx, JSValueConst this_val, int argc, JSVa } //dom_node_unref(doc); JSValue rr = getElement(ctx, element); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(element); return rr; @@ -1616,11 +1631,17 @@ js_document_querySelector(JSContext *ctx, JSValueConst this_val, int argc, JSVal if (!selector) { //dom_node_unref(doc); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(root); return JS_NULL; } void *ret = walk_tree_query(root, selector, 0); JS_FreeCString(ctx, selector); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(root); if (!ret) { @@ -1662,6 +1683,9 @@ js_document_querySelectorAll(JSContext *ctx, JSValueConst this_val, int argc, JS if (!selector) { //dom_node_unref(doc); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(doc_root); return JS_NULL; } @@ -1669,6 +1693,9 @@ js_document_querySelectorAll(JSContext *ctx, JSValueConst this_val, int argc, JS if (!result_list) { //dom_node_unref(doc); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(doc_root); JS_FreeCString(ctx, selector); return JS_NULL; @@ -1676,6 +1703,9 @@ js_document_querySelectorAll(JSContext *ctx, JSValueConst this_val, int argc, JS init_list(*result_list); walk_tree_query_append(doc_root, selector, 0, result_list); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(doc_root); JS_FreeCString(ctx, selector); //dom_node_unref(doc); @@ -1850,6 +1880,9 @@ js_document_finalizer(JSRuntime *rt, JSValue val) } free_list(doc_private->listeners); if (doc_private->node) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref((dom_node *)doc_private->node); } mem_free(doc_private); @@ -1892,6 +1925,9 @@ js_doctype_finalizer(JSRuntime *rt, JSValue val) attr_erase_from_map_str(map_doctypes, node); if (node) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(node); } } @@ -1969,6 +2005,9 @@ getDocument(JSContext *ctx, void *doc) init_list(doc_private->listeners); if (doc) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_ref((dom_node *)doc); } doc_private->node = doc; diff --git a/src/ecmascript/quickjs/element.c b/src/ecmascript/quickjs/element.c index 820be976..0d282489 100644 --- a/src/ecmascript/quickjs/element.c +++ b/src/ecmascript/quickjs/element.c @@ -609,6 +609,9 @@ js_element_get_property_firstChild(JSContext *ctx, JSValueConst this_val) return JS_NULL; } JSValue rr = getElement(ctx, node); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(node); return rr; @@ -660,9 +663,15 @@ js_element_get_property_firstElementChild(JSContext *ctx, JSValueConst this_val) if (exc == DOM_NO_ERR && type == DOM_ELEMENT_NODE) { dom_nodelist_unref(nodes); JSValue rr = getElement(ctx, child); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(child); return rr; } +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(child); } dom_nodelist_unref(nodes); @@ -796,6 +805,9 @@ js_element_get_property_lastChild(JSContext *ctx, JSValueConst this_val) return JS_NULL; } JSValue rr = getElement(ctx, last_child); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(last_child); return rr; @@ -846,9 +858,15 @@ js_element_get_property_lastElementChild(JSContext *ctx, JSValueConst this_val) if (exc == DOM_NO_ERR && type == DOM_ELEMENT_NODE) { dom_nodelist_unref(nodes); JSValue rr = getElement(ctx, child); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(child); return rr; } +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(child); } dom_nodelist_unref(nodes); @@ -881,6 +899,9 @@ js_element_get_property_nextElementSibling(JSContext *ctx, JSValueConst this_val dom_node_type type; if (prev_next) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(prev_next); } @@ -891,6 +912,9 @@ js_element_get_property_nextElementSibling(JSContext *ctx, JSValueConst this_val if (exc == DOM_NO_ERR && type == DOM_ELEMENT_NODE) { JSValue rr = getElement(ctx, next); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(next); return rr; } @@ -1015,6 +1039,9 @@ js_element_get_property_nextSibling(JSContext *ctx, JSValueConst this_val) } //dom_node_unref(el); JSValue rr = getElement(ctx, node); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(node); return rr; @@ -1083,6 +1110,9 @@ js_element_get_property_offsetLeft(JSContext *ctx, JSValueConst this_val) return JS_NewInt32(ctx, 0); } int dx = int_max(0, (rect->x0 - rect_parent->x0) * ses->tab->term->cell_width); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(node); return JS_NewInt32(ctx, dx); } @@ -1166,6 +1196,9 @@ js_element_get_property_offsetTop(JSContext *ctx, JSValueConst this_val) return JS_NewInt32(ctx, 0); } int dy = int_max(0, (rect->y0 - rect_parent->y0) * ses->tab->term->cell_height); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(node); return JS_NewInt32(ctx, dy); } @@ -1219,6 +1252,9 @@ js_element_get_property_parentElement(JSContext *ctx, JSValueConst this_val) return JS_NULL; } JSValue rr = getElement(ctx, node); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(node); return rr; @@ -1246,6 +1282,9 @@ js_element_get_property_parentNode(JSContext *ctx, JSValueConst this_val) return JS_NULL; } JSValue rr = getElement(ctx, node); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(node); return rr; @@ -1275,6 +1314,9 @@ js_element_get_property_previousElementSibling(JSContext *ctx, JSValueConst this dom_node_type type; if (prev_prev) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(prev_prev); } @@ -1285,6 +1327,9 @@ js_element_get_property_previousElementSibling(JSContext *ctx, JSValueConst this if (exc == DOM_NO_ERR && type == DOM_ELEMENT_NODE) { JSValue rr = getElement(ctx, prev); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(prev); return rr; } @@ -1319,6 +1364,9 @@ js_element_get_property_previousSibling(JSContext *ctx, JSValueConst this_val) } //dom_node_unref(el); JSValue rr = getElement(ctx, node); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(node); return rr; @@ -1780,8 +1828,14 @@ js_element_set_property_innerHtml(JSContext *ctx, JSValueConst this_val, JSValue struct dom_node *cref; exc = dom_node_remove_child(el, child, &cref); if (exc != DOM_NO_ERR) goto out; +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(child); child = NULL; +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(cref); exc = dom_node_get_first_child(el, &child); if (exc != DOM_NO_ERR) goto out; @@ -1810,10 +1864,19 @@ js_element_set_property_innerHtml(JSContext *ctx, JSValueConst this_val, JSValue struct dom_node *cref; exc = dom_node_remove_child(body, child, &cref); if (exc != DOM_NO_ERR) goto out; +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(cref); exc = dom_node_append_child(el, child, &cref); if (exc != DOM_NO_ERR) goto out; +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(cref); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(child); child = NULL; exc = dom_node_get_first_child(body, &child); @@ -1824,21 +1887,36 @@ out: dom_hubbub_parser_destroy(parser); } if (doc != NULL) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(doc); } if (fragment != NULL) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(fragment); } if (child != NULL) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(child); } if (html != NULL) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(html); } if (bodies != NULL) { dom_nodelist_unref(bodies); } if (body != NULL) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(body); } JS_FreeCString(ctx, s); @@ -1992,14 +2070,26 @@ js_element_set_property_outerHtml(JSContext *ctx, JSValueConst this_val, JSValue while (child != NULL) { exc = dom_node_remove_child(body, child, &cref); if (exc != DOM_NO_ERR) goto out; +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(cref); dom_node *spare = NULL; exc = dom_node_insert_before(parent, child, el, &spare); if (exc != DOM_NO_ERR) goto out; +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(spare); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(cref); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(child); child = NULL; exc = dom_node_get_first_child(body, &child); @@ -2013,26 +2103,47 @@ out: dom_hubbub_parser_destroy(parser); } if (doc != NULL) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(doc); } if (fragment != NULL) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(fragment); } if (child != NULL) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(child); } if (html != NULL) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(html); } if (bodies != NULL) { dom_nodelist_unref(bodies); } if (body != NULL) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(body); } if (cref != NULL) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(cref); } +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(parent); JS_FreeCString(ctx, s); interpreter->changed = 1; @@ -2460,6 +2571,9 @@ js_element_appendChild(JSContext *ctx, JSValueConst this_val, int argc, JSValueC interpreter->changed = 1; //dom_node_unref(el); JSValue rr = getElement(ctx, res); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(res); return rr; @@ -2570,6 +2684,9 @@ js_element_cloneNode(JSContext *ctx, JSValueConst this_val, int argc, JSValueCon } //dom_node_unref(el); JSValue rr = getElement(ctx, clone); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(clone); return rr; @@ -2584,6 +2701,9 @@ isAncestor(dom_node *el, dom_node *node) dom_exception exc; dom_node *next = NULL; if (prev_next) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(prev_next); } if (el == node) { @@ -2640,6 +2760,9 @@ js_element_closest(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst dom_node *el_copy = el; if (el_copy) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_ref(el_copy); } @@ -2660,9 +2783,15 @@ js_element_closest(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst el = node; } JS_FreeCString(ctx, selector); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(root); if (el_copy) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(el_copy); } @@ -2698,11 +2827,17 @@ js_element_contains(JSContext *ctx, JSValueConst this_val, int argc, JSValueCons //dom_node_unref(el); return JS_FALSE; } +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_ref(el2); while (1) { if (el == el2) { //dom_node_unref(el); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(el2); return JS_TRUE; } @@ -2711,9 +2846,15 @@ js_element_contains(JSContext *ctx, JSValueConst this_val, int argc, JSValueCons if (exc != DOM_NO_ERR || !node) { //dom_node_unref(el); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(el2); return JS_FALSE; } +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(el2); el2 = node; } @@ -3241,6 +3382,9 @@ js_element_querySelector(JSContext *ctx, JSValueConst this_val, int argc, JSValu } //dom_node_unref(el); JSValue rr = getElement(ctx, ret); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref((dom_node *)ret); return rr; @@ -3319,9 +3463,15 @@ js_element_remove(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst } dom_node *res = NULL; exc = dom_node_remove_child(parent, el, &res); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(parent); if (exc == DOM_NO_ERR) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(res); interpreter->changed = 1; } @@ -3631,6 +3781,9 @@ void js_element_finalizer(JSRuntime *rt, JSValue val) (void *) &old_node_data); if (el->refcnt > 0) { +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(el); } } @@ -3737,6 +3890,9 @@ getElement(JSContext *ctx, void *node) JS_SetPropertyFunctionList(ctx, element_obj, js_element_proto_funcs, countof(js_element_proto_funcs)); JS_SetClassProto(ctx, js_element_class_id, element_obj); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_ref((dom_node *)node); JS_SetOpaque(element_obj, el_private); diff --git a/src/ecmascript/quickjs/nodelist.c b/src/ecmascript/quickjs/nodelist.c index cb6fecc3..39543fb1 100644 --- a/src/ecmascript/quickjs/nodelist.c +++ b/src/ecmascript/quickjs/nodelist.c @@ -105,6 +105,9 @@ js_nodeList_item2(JSContext *ctx, JSValueConst this_val, int idx) return JS_UNDEFINED; } ret = getElement(ctx, element); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(element); dom_nodelist_unref(nl); @@ -166,6 +169,9 @@ js_nodeList_set_items(JSContext *ctx, JSValue this_val, void *node) JS_SetPropertyUint32(ctx, this_val, i, JS_DupValue(ctx, obj)); JS_FreeValue(ctx, obj); +#ifdef ECMASCRIPT_DEBUG +fprintf(stderr, "Before: %s:%d\n", __FUNCTION__, __LINE__); +#endif dom_node_unref(element); } dom_nodelist_unref(nl);