mirror of
https://github.com/rkd77/elinks.git
synced 2025-01-03 14:57:44 -05:00
[ecmascript] Try to not put_interpreter when page is modified
This commit is contained in:
parent
b3f6f44eaf
commit
761752239f
@ -471,10 +471,12 @@ release_document(struct document *document)
|
|||||||
assert(document);
|
assert(document);
|
||||||
if_assert_failed return;
|
if_assert_failed return;
|
||||||
|
|
||||||
if (document->refresh) kill_document_refresh(document->refresh);
|
if (document->refresh) {
|
||||||
|
kill_document_refresh(document->refresh);
|
||||||
|
}
|
||||||
#if defined(CONFIG_ECMASCRIPT_SMJS) || defined(CONFIG_QUICKJS) || defined(CONFIG_MUJS)
|
#if defined(CONFIG_ECMASCRIPT_SMJS) || defined(CONFIG_QUICKJS) || defined(CONFIG_MUJS)
|
||||||
kill_ecmascript_timeouts(document);
|
// kill_ecmascript_timeouts(document);
|
||||||
free_list(document->timeouts);
|
// free_list(document->timeouts);
|
||||||
#endif
|
#endif
|
||||||
object_unlock(document);
|
object_unlock(document);
|
||||||
move_document_to_top_of_format_cache(document);
|
move_document_to_top_of_format_cache(document);
|
||||||
@ -569,8 +571,8 @@ get_cached_document(struct cache_entry *cached, struct document_options *options
|
|||||||
|| compare_opt(&document->options, options))
|
|| compare_opt(&document->options, options))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (options->no_cache
|
if (
|
||||||
|| cached->cache_id != document->cache_id
|
cached->cache_id != document->cache_id
|
||||||
|| !check_document_css_magic(document)) {
|
|| !check_document_css_magic(document)) {
|
||||||
if (!is_object_used(document)) {
|
if (!is_object_used(document)) {
|
||||||
add_to_document_list(&to_remove, document);
|
add_to_document_list(&to_remove, document);
|
||||||
|
@ -534,7 +534,6 @@ dump_xhtml(struct cache_entry *cached, struct document *document, int parse)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
doc = document->dom;
|
doc = document->dom;
|
||||||
|
|
||||||
in_script = 0;
|
in_script = 0;
|
||||||
/* Get root element */
|
/* Get root element */
|
||||||
exc = dom_document_get_document_element(doc, &root);
|
exc = dom_document_get_document_element(doc, &root);
|
||||||
|
@ -69,29 +69,35 @@ ecmascript_protocol_handler(struct session *ses, struct uri *uri)
|
|||||||
char *redirect_url, *redirect_abs_url;
|
char *redirect_url, *redirect_abs_url;
|
||||||
struct uri *redirect_uri;
|
struct uri *redirect_uri;
|
||||||
|
|
||||||
if (!doc_view) /* Blank initial document. TODO: Start at about:blank? */
|
if (!doc_view) {/* Blank initial document. TODO: Start at about:blank? */
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
assert(doc_view->vs);
|
assert(doc_view->vs);
|
||||||
if (doc_view->vs->ecmascript_fragile)
|
if (doc_view->vs->ecmascript_fragile) {
|
||||||
ecmascript_reset_state(doc_view->vs);
|
ecmascript_reset_state(doc_view->vs);
|
||||||
if (!doc_view->vs->ecmascript)
|
}
|
||||||
|
if (!doc_view->vs->ecmascript) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
redirect_url = ecmascript_eval_stringback(doc_view->vs->ecmascript,
|
redirect_url = ecmascript_eval_stringback(doc_view->vs->ecmascript,
|
||||||
¤t_url);
|
¤t_url);
|
||||||
if (!redirect_url)
|
if (!redirect_url) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
/* XXX: This code snippet is duplicated over here,
|
/* XXX: This code snippet is duplicated over here,
|
||||||
* location_set_property(), html_a() and who knows where else. */
|
* location_set_property(), html_a() and who knows where else. */
|
||||||
redirect_abs_url = join_urls(doc_view->document->uri,
|
redirect_abs_url = join_urls(doc_view->document->uri,
|
||||||
trim_chars(redirect_url, ' ', 0));
|
trim_chars(redirect_url, ' ', 0));
|
||||||
mem_free(redirect_url);
|
mem_free(redirect_url);
|
||||||
if (!redirect_abs_url)
|
if (!redirect_abs_url) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
redirect_uri = get_uri(redirect_abs_url, URI_NONE);
|
redirect_uri = get_uri(redirect_abs_url, URI_NONE);
|
||||||
mem_free(redirect_abs_url);
|
mem_free(redirect_abs_url);
|
||||||
if (!redirect_uri)
|
if (!redirect_uri) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* XXX: Is that safe to do at this point? --pasky */
|
/* XXX: Is that safe to do at this point? --pasky */
|
||||||
goto_uri_frame(ses, redirect_uri, doc_view->name,
|
goto_uri_frame(ses, redirect_uri, doc_view->name,
|
||||||
@ -254,8 +260,10 @@ process_snippets(struct ecmascript_interpreter *interpreter,
|
|||||||
void
|
void
|
||||||
check_for_snippets(struct view_state *vs, struct document_options *options, struct document *document)
|
check_for_snippets(struct view_state *vs, struct document_options *options, struct document *document)
|
||||||
{
|
{
|
||||||
if (!vs->ecmascript_fragile)
|
if (!vs->ecmascript_fragile) {
|
||||||
assert(vs->ecmascript);
|
assert(vs->ecmascript);
|
||||||
|
}
|
||||||
|
|
||||||
if (!options->dump && !options->gradual_rerendering) {
|
if (!options->dump && !options->gradual_rerendering) {
|
||||||
/* We also reset the state if the underlying document changed
|
/* We also reset the state if the underlying document changed
|
||||||
* from the last time we did the snippets. This may be
|
* from the last time we did the snippets. This may be
|
||||||
@ -274,14 +282,13 @@ check_for_snippets(struct view_state *vs, struct document_options *options, stru
|
|||||||
* other tab when we press ^L here? */
|
* other tab when we press ^L here? */
|
||||||
if (vs->ecmascript_fragile
|
if (vs->ecmascript_fragile
|
||||||
|| (vs->ecmascript
|
|| (vs->ecmascript
|
||||||
&& vs->ecmascript->onload_snippets_cache_id
|
&& vs->ecmascript->onload_snippets_cache_id)) {
|
||||||
&& document->cache_id != vs->ecmascript->onload_snippets_cache_id))
|
|
||||||
ecmascript_reset_state(vs);
|
ecmascript_reset_state(vs);
|
||||||
|
}
|
||||||
/* If ecmascript_reset_state cannot construct a new
|
/* If ecmascript_reset_state cannot construct a new
|
||||||
* ECMAScript interpreter, it sets vs->ecmascript =
|
* ECMAScript interpreter, it sets vs->ecmascript =
|
||||||
* NULL and vs->ecmascript_fragile = 1. */
|
* NULL and vs->ecmascript_fragile = 1. */
|
||||||
if (vs->ecmascript) {
|
if (vs->ecmascript) {
|
||||||
vs->ecmascript->onload_snippets_cache_id = document->cache_id;
|
|
||||||
|
|
||||||
/* Passing of the onload_snippets pointers
|
/* Passing of the onload_snippets pointers
|
||||||
* gives *_snippets() some feeling of
|
* gives *_snippets() some feeling of
|
||||||
@ -296,6 +303,8 @@ check_for_snippets(struct view_state *vs, struct document_options *options, stru
|
|||||||
|
|
||||||
fire_onload(document->dom);
|
fire_onload(document->dom);
|
||||||
check_for_rerender(vs->ecmascript, "process_snippets");
|
check_for_rerender(vs->ecmascript, "process_snippets");
|
||||||
|
|
||||||
|
vs->ecmascript->onload_snippets_cache_id = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -381,18 +390,22 @@ ecmascript_reset_state(struct view_state *vs)
|
|||||||
* ecmascript_obj pointers are also NULL. However, they might
|
* ecmascript_obj pointers are also NULL. However, they might
|
||||||
* be non-NULL if the ECMAScript objects have been lazily
|
* be non-NULL if the ECMAScript objects have been lazily
|
||||||
* created because of scripts running in sibling HTML frames. */
|
* created because of scripts running in sibling HTML frames. */
|
||||||
foreach (fv, vs->forms)
|
foreach (fv, vs->forms) {
|
||||||
ecmascript_detach_form_view(fv);
|
ecmascript_detach_form_view(fv);
|
||||||
for (i = 0; i < vs->form_info_len; i++)
|
}
|
||||||
|
for (i = 0; i < vs->form_info_len; i++) {
|
||||||
ecmascript_detach_form_state(&vs->form_info[i]);
|
ecmascript_detach_form_state(&vs->form_info[i]);
|
||||||
|
}
|
||||||
|
|
||||||
vs->ecmascript_fragile = 0;
|
vs->ecmascript_fragile = 0;
|
||||||
if (vs->ecmascript)
|
if (vs->ecmascript) {
|
||||||
ecmascript_put_interpreter(vs->ecmascript);
|
ecmascript_put_interpreter(vs->ecmascript);
|
||||||
|
}
|
||||||
|
|
||||||
vs->ecmascript = ecmascript_get_interpreter(vs);
|
vs->ecmascript = ecmascript_get_interpreter(vs);
|
||||||
if (!vs->ecmascript)
|
if (!vs->ecmascript) {
|
||||||
vs->ecmascript_fragile = 1;
|
vs->ecmascript_fragile = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -1302,6 +1302,7 @@ document_write_do(JSContext *ctx, unsigned int argc, JS::Value *rval, int newlin
|
|||||||
}
|
}
|
||||||
interpreter->changed = 1;
|
interpreter->changed = 1;
|
||||||
interpreter->was_write = 1;
|
interpreter->was_write = 1;
|
||||||
|
interpreter->onload_snippets_cache_id = 1;
|
||||||
debug_dump_xhtml(document->dom);
|
debug_dump_xhtml(document->dom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1812,6 +1813,10 @@ document_event_handler(dom_event *event, void *pw)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp("DOMContentLoaded", dom_string_data(typ))) {
|
if (!strcmp("DOMContentLoaded", dom_string_data(typ))) {
|
||||||
|
if (doc_private->state == COMPLETE) {
|
||||||
|
dom_string_unref(typ);
|
||||||
|
return;
|
||||||
|
}
|
||||||
doc_private->state = COMPLETE;
|
doc_private->state = COMPLETE;
|
||||||
}
|
}
|
||||||
JSObject *obj_ev = getEvent(ctx, event);
|
JSObject *obj_ev = getEvent(ctx, event);
|
||||||
|
@ -69,8 +69,9 @@ destroy_vs(struct view_state *vs, int blast_ecmascript)
|
|||||||
|
|
||||||
if (vs->uri) done_uri(vs->uri);
|
if (vs->uri) done_uri(vs->uri);
|
||||||
#if defined(CONFIG_ECMASCRIPT_SMJS) || defined(CONFIG_QUICKJS) || defined(CONFIG_MUJS)
|
#if defined(CONFIG_ECMASCRIPT_SMJS) || defined(CONFIG_QUICKJS) || defined(CONFIG_MUJS)
|
||||||
if (blast_ecmascript && vs->ecmascript)
|
if (blast_ecmascript && vs->ecmascript) {
|
||||||
ecmascript_put_interpreter(vs->ecmascript);
|
ecmascript_put_interpreter(vs->ecmascript);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
if (vs->doc_view) {
|
if (vs->doc_view) {
|
||||||
vs->doc_view->vs = NULL;
|
vs->doc_view->vs = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user