mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-28 14:59:41 +03:00
Improve logging and inline script handling
This commit is contained in:
parent
1fc96acf47
commit
752261c66c
@ -133,7 +133,7 @@ bool js_exec(jscontext *ctx, const char *txt, size_t txtlen)
|
||||
{
|
||||
JSContext *cx = (JSContext *)ctx;
|
||||
|
||||
LOG(("%p \"%s\"",cx ,txt));
|
||||
/* LOG(("%p \"%s\"",cx ,txt)); */
|
||||
|
||||
if (ctx == NULL) {
|
||||
return false;
|
||||
|
@ -56,7 +56,7 @@ static JSBool JSAPI_NATIVE(write, JSContext *cx, uintN argc, jsval *vp)
|
||||
|
||||
JSString_to_char(u16_txt, txt, length);
|
||||
|
||||
LOG(("content %p writing %s",htmlc, txt));
|
||||
LOG(("content %p parser %p writing %s",htmlc, htmlc->parser_binding, txt));
|
||||
|
||||
dom_hubbub_parser_insert_chunk(htmlc->parser_binding, (uint8_t *)txt, length);
|
||||
|
||||
|
@ -183,21 +183,6 @@ static bool html_scripts_exec(html_content *c)
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
struct lwc_string_s *lwcmimetype;
|
||||
dom_string_intern(s->mimetype, &lwcmimetype);
|
||||
|
||||
/* ensure script handler for content type */
|
||||
script_handler = select_script_handler(content_factory_type_from_mime_type(lwcmimetype));
|
||||
lwc_string_unref(lwcmimetype);
|
||||
|
||||
if (script_handler == NULL)
|
||||
continue; /* unsupported type */
|
||||
|
||||
script_handler(c->jscontext,
|
||||
dom_string_data(s->data.internal),
|
||||
dom_string_byte_length(s->data.internal));
|
||||
s->already_started = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -511,6 +496,8 @@ html_process_script(void *ctx, dom_node *node)
|
||||
}
|
||||
}
|
||||
|
||||
LOG(("content %p parser %p node %p",c,c->parser_binding, node));
|
||||
|
||||
exc = dom_element_get_attribute(node, html_dom_string_type, &mimetype);
|
||||
if (exc != DOM_NO_ERR || mimetype == NULL) {
|
||||
mimetype = dom_string_ref(html_dom_string_text_javascript);
|
||||
@ -518,6 +505,9 @@ html_process_script(void *ctx, dom_node *node)
|
||||
|
||||
exc = dom_element_get_attribute(node, html_dom_string_src, &src);
|
||||
if (exc != DOM_NO_ERR || src == NULL) {
|
||||
struct lwc_string_s *lwcmimetype;
|
||||
script_handler_t *script_handler;
|
||||
|
||||
/* does not appear to be a src so script is inline content */
|
||||
exc = dom_node_get_text_content(node, &script);
|
||||
if ((exc != DOM_NO_ERR) || (script == NULL)) {
|
||||
@ -534,8 +524,22 @@ html_process_script(void *ctx, dom_node *node)
|
||||
|
||||
nscript->data.internal = script;
|
||||
nscript->mimetype = mimetype;
|
||||
nscript->already_started = true;
|
||||
|
||||
/* charset (encoding) */
|
||||
|
||||
/* ensure script handler for content type */
|
||||
dom_string_intern(mimetype, &lwcmimetype);
|
||||
script_handler = select_script_handler(content_factory_type_from_mime_type(lwcmimetype));
|
||||
lwc_string_unref(lwcmimetype);
|
||||
|
||||
if (script_handler != NULL) {
|
||||
script_handler(c->jscontext,
|
||||
dom_string_data(script),
|
||||
dom_string_byte_length(script));
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
/* script with a src tag */
|
||||
nserror ns_error;
|
||||
|
Loading…
Reference in New Issue
Block a user