mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-16 17:22:44 +03:00
Makes the Javascript document.writeln() function work as well as write()
This commit is contained in:
parent
4bdd4cf7b6
commit
33264e012b
@ -13,6 +13,7 @@ class Document {
|
||||
#include "utils/corestrings.h"
|
||||
#include "render/html_internal.h"
|
||||
#include "utils/libdom.h"
|
||||
#include "utils/utils.h"
|
||||
%};
|
||||
};
|
||||
|
||||
@ -38,6 +39,27 @@ method Document::write()
|
||||
return 0;
|
||||
%}
|
||||
|
||||
method Document::writeln()
|
||||
%{
|
||||
const char nl[] = "\n";
|
||||
struct html_content *htmlc;
|
||||
duk_size_t text_len;
|
||||
for (int i = 0; i < duk_get_top(ctx); ++i)
|
||||
duk_safe_to_string(ctx, i);
|
||||
duk_concat(ctx, duk_get_top(ctx));
|
||||
const char *text = duk_safe_to_lstring(ctx, 0, &text_len);
|
||||
LOG("Writeln %*s", (int)text_len, text);
|
||||
dom_exception err;
|
||||
err = dom_node_get_user_data(priv->parent.node,
|
||||
corestring_dom___ns_key_html_content_data,
|
||||
&htmlc);
|
||||
if (err == DOM_NO_ERR && htmlc->parser != NULL) {
|
||||
dom_hubbub_parser_insert_chunk(htmlc->parser, (uint8_t *)text, text_len);
|
||||
dom_hubbub_parser_insert_chunk(htmlc->parser, (uint8_t *)nl, SLEN(nl));
|
||||
}
|
||||
return 0;
|
||||
%}
|
||||
|
||||
method Document::createTextNode()
|
||||
%{
|
||||
dom_node *newnode;
|
||||
|
Loading…
Reference in New Issue
Block a user