1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-09-30 03:26:23 -04:00

Eval embedded scripts at once

This commit is contained in:
2006-01-27 10:26:58 +01:00
parent 6761b3995d
commit 2f0490cb04
3 changed files with 33 additions and 2 deletions

View File

@ -16,6 +16,7 @@ struct frame_desc;
struct frameset_desc;
struct module;
struct screen_char;
struct view_state;
/* Nodes are used for marking areas of text on the document canvas as
* searchable. */
@ -147,6 +148,8 @@ struct document {
* dependencies between the various entries so nothing gets removed
* unneeded. */
struct uri_list ecmascript_imports;
/* For ecmascript access */
struct view_state *vs;
#endif
#ifdef CONFIG_CSS
/* FIXME: We should externally maybe using cache_entry store the

View File

@ -17,6 +17,7 @@
#include "config/options.h"
#include "document/css/apply.h"
#include "document/document.h"
#include "document/html/frames.h"
#include "document/html/parser/general.h"
#include "document/html/parser/link.h"
@ -26,6 +27,7 @@
#include "document/html/renderer.h"
#include "document/html/tables.h"
#include "document/options.h"
#include "ecmascript/ecmascript.h"
#include "intl/charsets.h"
#include "protocol/uri.h"
#include "terminal/draw.h"
@ -37,6 +39,7 @@
#include "util/memdebug.h"
#include "util/memory.h"
#include "util/string.h"
#include "viewer/text/vs.h"
/* Unsafe macros */
#include "document/html/internal.h"
@ -343,8 +346,29 @@ imported:
}
if (html_context->part->document && *html != '^') {
struct string code, ret;
struct part *part = html_context->part;
struct document *document = part->document;
struct view_state *vs = document->vs;
struct ecmascript_interpreter *interpreter = vs->ecmascript;
if (!interpreter) {
ecmascript_reset_state(vs);
interpreter = vs->ecmascript;
}
if (!interpreter) return;
if (!init_string(&code) || !init_string(&ret))
return;
add_bytes_to_string(&code, html, *end - html);
ecmascript_eval(interpreter, &code);
done_string(&code);
#if 0
add_to_string_list(&html_context->part->document->onload_snippets,
html, *end - html);
#endif
}
#endif
}

View File

@ -284,7 +284,6 @@ render_document(struct view_state *vs, struct document_view *doc_view,
options->gradual_rerendering, struri(vs->uri),
doc_view, doc_view->name, vs);
#endif
name = doc_view->name;
doc_view->name = NULL;
@ -328,13 +327,18 @@ render_document(struct view_state *vs, struct document_view *doc_view,
document = get_cached_document(cached, options);
if (document) {
doc_view->document = document;
#ifdef CONFIG_ECMASCRIPT
document->vs = vs;
#endif
} else {
document = init_document(cached, options);
if (!document) return;
doc_view->document = document;
shrink_memory(0);
#ifdef CONFIG_ECMASCRIPT
document->vs = vs;
#endif
render_encoded_document(cached, document);
sort_links(document);
if (!document->title) {