mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Eval embedded scripts at once
This commit is contained in:
parent
6761b3995d
commit
2f0490cb04
@ -16,6 +16,7 @@ struct frame_desc;
|
|||||||
struct frameset_desc;
|
struct frameset_desc;
|
||||||
struct module;
|
struct module;
|
||||||
struct screen_char;
|
struct screen_char;
|
||||||
|
struct view_state;
|
||||||
|
|
||||||
/* Nodes are used for marking areas of text on the document canvas as
|
/* Nodes are used for marking areas of text on the document canvas as
|
||||||
* searchable. */
|
* searchable. */
|
||||||
@ -147,6 +148,8 @@ struct document {
|
|||||||
* dependencies between the various entries so nothing gets removed
|
* dependencies between the various entries so nothing gets removed
|
||||||
* unneeded. */
|
* unneeded. */
|
||||||
struct uri_list ecmascript_imports;
|
struct uri_list ecmascript_imports;
|
||||||
|
/* For ecmascript access */
|
||||||
|
struct view_state *vs;
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_CSS
|
#ifdef CONFIG_CSS
|
||||||
/* FIXME: We should externally maybe using cache_entry store the
|
/* FIXME: We should externally maybe using cache_entry store the
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include "config/options.h"
|
#include "config/options.h"
|
||||||
#include "document/css/apply.h"
|
#include "document/css/apply.h"
|
||||||
|
#include "document/document.h"
|
||||||
#include "document/html/frames.h"
|
#include "document/html/frames.h"
|
||||||
#include "document/html/parser/general.h"
|
#include "document/html/parser/general.h"
|
||||||
#include "document/html/parser/link.h"
|
#include "document/html/parser/link.h"
|
||||||
@ -26,6 +27,7 @@
|
|||||||
#include "document/html/renderer.h"
|
#include "document/html/renderer.h"
|
||||||
#include "document/html/tables.h"
|
#include "document/html/tables.h"
|
||||||
#include "document/options.h"
|
#include "document/options.h"
|
||||||
|
#include "ecmascript/ecmascript.h"
|
||||||
#include "intl/charsets.h"
|
#include "intl/charsets.h"
|
||||||
#include "protocol/uri.h"
|
#include "protocol/uri.h"
|
||||||
#include "terminal/draw.h"
|
#include "terminal/draw.h"
|
||||||
@ -37,6 +39,7 @@
|
|||||||
#include "util/memdebug.h"
|
#include "util/memdebug.h"
|
||||||
#include "util/memory.h"
|
#include "util/memory.h"
|
||||||
#include "util/string.h"
|
#include "util/string.h"
|
||||||
|
#include "viewer/text/vs.h"
|
||||||
|
|
||||||
/* Unsafe macros */
|
/* Unsafe macros */
|
||||||
#include "document/html/internal.h"
|
#include "document/html/internal.h"
|
||||||
@ -343,8 +346,29 @@ imported:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (html_context->part->document && *html != '^') {
|
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,
|
add_to_string_list(&html_context->part->document->onload_snippets,
|
||||||
html, *end - html);
|
html, *end - html);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -284,7 +284,6 @@ render_document(struct view_state *vs, struct document_view *doc_view,
|
|||||||
options->gradual_rerendering, struri(vs->uri),
|
options->gradual_rerendering, struri(vs->uri),
|
||||||
doc_view, doc_view->name, vs);
|
doc_view, doc_view->name, vs);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
name = doc_view->name;
|
name = doc_view->name;
|
||||||
doc_view->name = NULL;
|
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);
|
document = get_cached_document(cached, options);
|
||||||
if (document) {
|
if (document) {
|
||||||
doc_view->document = document;
|
doc_view->document = document;
|
||||||
|
#ifdef CONFIG_ECMASCRIPT
|
||||||
|
document->vs = vs;
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
document = init_document(cached, options);
|
document = init_document(cached, options);
|
||||||
if (!document) return;
|
if (!document) return;
|
||||||
doc_view->document = document;
|
doc_view->document = document;
|
||||||
|
|
||||||
shrink_memory(0);
|
shrink_memory(0);
|
||||||
|
#ifdef CONFIG_ECMASCRIPT
|
||||||
|
document->vs = vs;
|
||||||
|
#endif
|
||||||
render_encoded_document(cached, document);
|
render_encoded_document(cached, document);
|
||||||
sort_links(document);
|
sort_links(document);
|
||||||
if (!document->title) {
|
if (!document->title) {
|
||||||
|
Loading…
Reference in New Issue
Block a user