mirror of
https://github.com/rkd77/elinks.git
synced 2025-02-02 15:09:23 -05:00
[js] Distinguish between document.write(ln) and other modifications
Reparse document only for document.write(ln).
This commit is contained in:
parent
15da44d9ea
commit
4375984708
@ -312,7 +312,7 @@ delayed_reload(void *data)
|
||||
|
||||
assert(rel);
|
||||
reset_document(rel->document);
|
||||
dump_xhtml(rel->cached, rel->document, 1);
|
||||
dump_xhtml(rel->cached, rel->document, rel->was_write);
|
||||
sort_links(rel->document);
|
||||
draw_formatted(rel->ses, 0);
|
||||
mem_free(rel);
|
||||
@ -355,17 +355,18 @@ check_for_rerender(struct ecmascript_interpreter *interpreter, const char* text)
|
||||
//fprintf(stderr, "%s\n", text);
|
||||
|
||||
if (document->dom) {
|
||||
interpreter->changed = false;
|
||||
|
||||
struct delayed_rel *rel = (struct delayed_rel *)mem_calloc(1, sizeof(*rel));
|
||||
|
||||
if (rel) {
|
||||
rel->cached = cached;
|
||||
rel->document = document;
|
||||
rel->ses = ses;
|
||||
rel->was_write = interpreter->was_write;
|
||||
object_lock(document);
|
||||
register_bottom_half(delayed_reload, rel);
|
||||
}
|
||||
interpreter->changed = 0;
|
||||
interpreter->was_write = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -110,8 +110,9 @@ struct ecmascript_interpreter {
|
||||
#ifdef CONFIG_MUJS
|
||||
const char *fun;
|
||||
#endif
|
||||
bool changed;
|
||||
int element_offset;
|
||||
unsigned int changed:1;
|
||||
unsigned int was_write:1;
|
||||
};
|
||||
|
||||
struct ecmascript_timeout {
|
||||
|
@ -786,7 +786,8 @@ mjs_document_write_do(js_State *J, int newline)
|
||||
done_string(&string);
|
||||
interpreter->current_writecode = interpreter->current_writecode->next;
|
||||
}
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
interpreter->was_write = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1137,7 +1137,7 @@ mjs_element_set_property_className(js_State *J)
|
||||
|
||||
if (exc == DOM_NO_ERR && classstr) {
|
||||
exc = dom_element_set_attribute(el, corestring_dom_class, classstr);
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
dom_string_unref(classstr);
|
||||
}
|
||||
js_pushundefined(J);
|
||||
@ -1170,7 +1170,7 @@ mjs_element_set_property_dir(js_State *J)
|
||||
|
||||
if (exc == DOM_NO_ERR && dir) {
|
||||
exc = dom_element_set_attribute(el, corestring_dom_dir, dir);
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
dom_string_unref(dir);
|
||||
}
|
||||
}
|
||||
@ -1202,7 +1202,7 @@ mjs_element_set_property_id(js_State *J)
|
||||
|
||||
if (exc == DOM_NO_ERR && idstr) {
|
||||
exc = dom_element_set_attribute(el, corestring_dom_id, idstr);
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
dom_string_unref(idstr);
|
||||
}
|
||||
js_pushundefined(J);
|
||||
@ -1337,7 +1337,7 @@ out:
|
||||
if (body != NULL) {
|
||||
dom_node_unref(body);
|
||||
}
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
js_pushundefined(J);
|
||||
}
|
||||
|
||||
@ -1365,7 +1365,7 @@ mjs_element_set_property_innerText(js_State *J)
|
||||
xmlpp::Node::remove_node(*it);
|
||||
}
|
||||
el->add_child_text(val);
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
#endif
|
||||
js_pushundefined(J);
|
||||
}
|
||||
@ -1395,7 +1395,7 @@ mjs_element_set_property_lang(js_State *J)
|
||||
|
||||
if (exc == DOM_NO_ERR && langstr) {
|
||||
exc = dom_element_set_attribute(el, corestring_dom_lang, langstr);
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
dom_string_unref(langstr);
|
||||
}
|
||||
js_pushundefined(J);
|
||||
@ -1427,7 +1427,7 @@ mjs_element_set_property_title(js_State *J)
|
||||
|
||||
if (exc == DOM_NO_ERR && titlestr) {
|
||||
exc = dom_element_set_attribute(el, corestring_dom_title, titlestr);
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
dom_string_unref(titlestr);
|
||||
}
|
||||
js_pushundefined(J);
|
||||
@ -1675,7 +1675,7 @@ mjs_element_appendChild(js_State *J)
|
||||
exc = dom_node_append_child(el, el2, &res);
|
||||
|
||||
if (exc == DOM_NO_ERR && res) {
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
mjs_push_element(J, res);
|
||||
return;
|
||||
}
|
||||
@ -2142,7 +2142,7 @@ mjs_element_insertBefore(js_State *J)
|
||||
js_pushundefined(J);
|
||||
return;
|
||||
}
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
mjs_push_element(J, spare);
|
||||
}
|
||||
|
||||
@ -2329,7 +2329,7 @@ mjs_element_remove(js_State *J)
|
||||
return;
|
||||
}
|
||||
xmlpp::Node::remove_node(el);
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
#endif
|
||||
js_pushundefined(J);
|
||||
}
|
||||
@ -2348,7 +2348,7 @@ mjs_element_removeChild(js_State *J)
|
||||
exc = dom_node_remove_child(el, el2, &spare);
|
||||
|
||||
if (exc == DOM_NO_ERR && spare) {
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
mjs_push_element(J, spare);
|
||||
return;
|
||||
}
|
||||
@ -2375,7 +2375,7 @@ mjs_element_replaceWith(js_State *J)
|
||||
auto n = xmlAddPrevSibling(el->cobj(), rep->cobj());
|
||||
xmlpp::Node::create_wrapper(n);
|
||||
xmlpp::Node::remove_node(el);
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
#endif
|
||||
js_pushundefined(J);
|
||||
}
|
||||
@ -2433,7 +2433,7 @@ mjs_element_setAttribute(js_State *J)
|
||||
js_pushundefined(J);
|
||||
return;
|
||||
}
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
js_pushundefined(J);
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ mjs_set_style(js_State *J, const char *property)
|
||||
|
||||
if (exc == DOM_NO_ERR && stylestr) {
|
||||
exc = dom_element_set_attribute(el, corestring_dom_style, stylestr);
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
dom_string_unref(stylestr);
|
||||
}
|
||||
mem_free(res);
|
||||
|
@ -862,7 +862,8 @@ js_document_write_do(JSContext *ctx, JSValueConst this_val, int argc, JSValueCon
|
||||
done_string(&string);
|
||||
interpreter->current_writecode = interpreter->current_writecode->next;
|
||||
}
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
interpreter->was_write = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1164,7 +1164,7 @@ js_element_set_property_className(JSContext *ctx, JSValueConst this_val, JSValue
|
||||
|
||||
if (exc == DOM_NO_ERR && classstr) {
|
||||
exc = dom_element_set_attribute(el, corestring_dom_class, classstr);
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
dom_string_unref(classstr);
|
||||
}
|
||||
JS_FreeCString(ctx, str);
|
||||
@ -1200,7 +1200,7 @@ js_element_set_property_dir(JSContext *ctx, JSValueConst this_val, JSValue val)
|
||||
|
||||
if (exc == DOM_NO_ERR && dir) {
|
||||
exc = dom_element_set_attribute(el, corestring_dom_dir, dir);
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
dom_string_unref(dir);
|
||||
}
|
||||
}
|
||||
@ -1236,7 +1236,7 @@ js_element_set_property_id(JSContext *ctx, JSValueConst this_val, JSValue val)
|
||||
|
||||
if (exc == DOM_NO_ERR && idstr) {
|
||||
exc = dom_element_set_attribute(el, corestring_dom_id, idstr);
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
dom_string_unref(idstr);
|
||||
}
|
||||
JS_FreeCString(ctx, str);
|
||||
@ -1377,7 +1377,7 @@ out:
|
||||
dom_node_unref(body);
|
||||
}
|
||||
JS_FreeCString(ctx, s);
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
|
||||
return JS_UNDEFINED;
|
||||
}
|
||||
@ -1413,7 +1413,7 @@ js_element_set_property_innerText(JSContext *ctx, JSValueConst this_val, JSValue
|
||||
return JS_EXCEPTION;
|
||||
}
|
||||
el->add_child_text(str);
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
JS_FreeCString(ctx, str);
|
||||
#endif
|
||||
|
||||
@ -1447,7 +1447,7 @@ js_element_set_property_lang(JSContext *ctx, JSValueConst this_val, JSValue val)
|
||||
|
||||
if (exc == DOM_NO_ERR && langstr) {
|
||||
exc = dom_element_set_attribute(el, corestring_dom_lang, langstr);
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
dom_string_unref(langstr);
|
||||
}
|
||||
JS_FreeCString(ctx, str);
|
||||
@ -1482,7 +1482,7 @@ js_element_set_property_title(JSContext *ctx, JSValueConst this_val, JSValue val
|
||||
|
||||
if (exc == DOM_NO_ERR && titlestr) {
|
||||
exc = dom_element_set_attribute(el, corestring_dom_title, titlestr);
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
dom_string_unref(titlestr);
|
||||
}
|
||||
JS_FreeCString(ctx, str);
|
||||
@ -1743,7 +1743,7 @@ js_element_appendChild(JSContext *ctx, JSValueConst this_val, int argc, JSValueC
|
||||
exc = dom_node_append_child(el, el2, &res);
|
||||
|
||||
if (exc == DOM_NO_ERR && res) {
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
|
||||
return getElement(ctx, res);
|
||||
}
|
||||
@ -2288,7 +2288,7 @@ js_element_insertBefore(JSContext *ctx, JSValueConst this_val, int argc, JSValue
|
||||
if (err != DOM_NO_ERR) {
|
||||
return JS_UNDEFINED;
|
||||
}
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
|
||||
return getElement(ctx, spare);
|
||||
}
|
||||
@ -2538,7 +2538,7 @@ js_element_remove(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst
|
||||
}
|
||||
|
||||
xmlpp::Node::remove_node(el);
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
#endif
|
||||
|
||||
return JS_UNDEFINED;
|
||||
@ -2571,7 +2571,7 @@ js_element_removeChild(JSContext *ctx, JSValueConst this_val, int argc, JSValueC
|
||||
exc = dom_node_remove_child(el, el2, &spare);
|
||||
|
||||
if (exc == DOM_NO_ERR && spare) {
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
|
||||
return getElement(ctx, spare);
|
||||
}
|
||||
@ -2607,7 +2607,7 @@ js_element_replaceWith(JSContext *ctx, JSValueConst this_val, int argc, JSValueC
|
||||
auto n = xmlAddPrevSibling(el->cobj(), rep->cobj());
|
||||
xmlpp::Node::create_wrapper(n);
|
||||
xmlpp::Node::remove_node(el);
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
#endif
|
||||
|
||||
return JS_UNDEFINED;
|
||||
@ -2672,7 +2672,7 @@ js_element_setAttribute(JSContext *ctx, JSValueConst this_val, int argc, JSValue
|
||||
if (exc != DOM_NO_ERR) {
|
||||
return JS_UNDEFINED;
|
||||
}
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
|
||||
return JS_UNDEFINED;
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ js_set_style(JSContext *ctx, JSValueConst this_val, JSValue val, const char *pro
|
||||
|
||||
if (exc == DOM_NO_ERR && stylestr) {
|
||||
exc = dom_element_set_attribute(el, corestring_dom_style, stylestr);
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
dom_string_unref(stylestr);
|
||||
}
|
||||
mem_free(res);
|
||||
|
@ -1172,7 +1172,8 @@ document_write_do(JSContext *ctx, unsigned int argc, JS::Value *rval, int newlin
|
||||
done_string(&string);
|
||||
interpreter->current_writecode = interpreter->current_writecode->next;
|
||||
}
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
interpreter->was_write = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2266,7 +2266,7 @@ element_set_property_className(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
||||
|
||||
if (exc == DOM_NO_ERR && classstr) {
|
||||
exc = dom_element_set_attribute(el, corestring_dom_class, classstr);
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
dom_string_unref(classstr);
|
||||
}
|
||||
mem_free(str);
|
||||
@ -2328,7 +2328,7 @@ element_set_property_dir(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
||||
|
||||
if (exc == DOM_NO_ERR && dir) {
|
||||
exc = dom_element_set_attribute(el, corestring_dom_dir, dir);
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
dom_string_unref(dir);
|
||||
}
|
||||
}
|
||||
@ -2390,7 +2390,7 @@ element_set_property_id(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
||||
|
||||
if (exc == DOM_NO_ERR && idstr) {
|
||||
exc = dom_element_set_attribute(el, corestring_dom_id, idstr);
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
dom_string_unref(idstr);
|
||||
}
|
||||
mem_free(str);
|
||||
@ -2557,7 +2557,7 @@ out:
|
||||
dom_node_unref(body);
|
||||
}
|
||||
mem_free(s);
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -2615,7 +2615,7 @@ element_set_property_innerText(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
||||
|
||||
char *text = jsval_to_string(ctx, args[0]);
|
||||
el->add_child_text(text);
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
mem_free_if(text);
|
||||
#endif
|
||||
|
||||
@ -2674,7 +2674,7 @@ element_set_property_lang(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
||||
|
||||
if (exc == DOM_NO_ERR && langstr) {
|
||||
exc = dom_element_set_attribute(el, corestring_dom_lang, langstr);
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
dom_string_unref(langstr);
|
||||
}
|
||||
mem_free(str);
|
||||
@ -2812,7 +2812,7 @@ element_set_property_title(JSContext *ctx, unsigned int argc, JS::Value *vp)
|
||||
|
||||
if (exc == DOM_NO_ERR && titlestr) {
|
||||
exc = dom_element_set_attribute(el, corestring_dom_title, titlestr);
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
dom_string_unref(titlestr);
|
||||
}
|
||||
mem_free(str);
|
||||
@ -3173,7 +3173,7 @@ element_appendChild(JSContext *ctx, unsigned int argc, JS::Value *rval)
|
||||
exc = dom_node_append_child(el, el2, &res);
|
||||
|
||||
if (exc == DOM_NO_ERR && res) {
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
JSObject *obj = getElement(ctx, res);
|
||||
args.rval().setObject(*obj);
|
||||
return true;
|
||||
@ -3894,7 +3894,7 @@ element_insertBefore(JSContext *ctx, unsigned int argc, JS::Value *rval)
|
||||
}
|
||||
JSObject *obj = getElement(ctx, spare);
|
||||
args.rval().setObject(*obj);
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -4219,7 +4219,7 @@ element_remove(JSContext *ctx, unsigned int argc, JS::Value *rval)
|
||||
}
|
||||
|
||||
xmlpp::Node::remove_node(el);
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
@ -4263,7 +4263,7 @@ element_removeChild(JSContext *ctx, unsigned int argc, JS::Value *rval)
|
||||
exc = dom_node_remove_child(el, el2, &spare);
|
||||
|
||||
if (exc == DOM_NO_ERR && spare) {
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
JSObject *obj = getElement(ctx, spare);
|
||||
args.rval().setObject(*obj);
|
||||
return true;
|
||||
@ -4314,7 +4314,7 @@ element_replaceWith(JSContext *ctx, unsigned int argc, JS::Value *rval)
|
||||
auto n = xmlAddPrevSibling(el->cobj(), rep->cobj());
|
||||
xmlpp::Node::create_wrapper(n);
|
||||
xmlpp::Node::remove_node(el);
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
args.rval().setUndefined();
|
||||
#endif
|
||||
return true;
|
||||
@ -4393,7 +4393,7 @@ element_setAttribute(JSContext *ctx, unsigned int argc, JS::Value *rval)
|
||||
if (exc != DOM_NO_ERR) {
|
||||
return true;
|
||||
}
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -576,7 +576,7 @@ style_set_style(JSContext *ctx, unsigned int argc, JS::Value *vp, const char *pr
|
||||
|
||||
if (exc == DOM_NO_ERR && stylestr) {
|
||||
exc = dom_element_set_attribute(el, corestring_dom_style, stylestr);
|
||||
interpreter->changed = true;
|
||||
interpreter->changed = 1;
|
||||
dom_string_unref(stylestr);
|
||||
}
|
||||
mem_free(res);
|
||||
|
@ -37,6 +37,7 @@ struct delayed_rel {
|
||||
struct cache_entry *cached;
|
||||
struct document *document;
|
||||
struct session *ses;
|
||||
int was_write;
|
||||
};
|
||||
|
||||
enum remote_session_flags {
|
||||
|
Loading…
x
Reference in New Issue
Block a user