mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 08:17:35 +00:00
LibWeb: Make document.write() work while document is parsing
This necessitated making HTMLParser ref-counted, and having it register itself with Document when created. That makes it possible for scripts to add new input at the current parser insertion point. There is now a reference cycle between Document and HTMLParser. This cycle is explicitly broken by calling Document::detach_parser() at the end of HTMLParser::run(). This is a huge progression on ACID3, from 31% to 49%! :^)
This commit is contained in:
parent
bb1f26c149
commit
8b2499b112
7 changed files with 67 additions and 38 deletions
|
@ -46,8 +46,8 @@ static bool build_markdown_document(DOM::Document& document, const ByteBuffer& d
|
|||
if (!markdown_document)
|
||||
return false;
|
||||
|
||||
HTML::HTMLParser parser(document, markdown_document->render_to_html(), "utf-8");
|
||||
parser.run(document.url());
|
||||
auto parser = HTML::HTMLParser::create(document, markdown_document->render_to_html(), "utf-8");
|
||||
parser->run(document.url());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -116,8 +116,8 @@ static bool build_gemini_document(DOM::Document& document, const ByteBuffer& dat
|
|||
dbgln_if(GEMINI_DEBUG, "Gemini data:\n\"\"\"{}\"\"\"", gemini_data);
|
||||
dbgln_if(GEMINI_DEBUG, "Converted to HTML:\n\"\"\"{}\"\"\"", html_data);
|
||||
|
||||
HTML::HTMLParser parser(document, html_data, "utf-8");
|
||||
parser.run(document.url());
|
||||
auto parser = HTML::HTMLParser::create(document, html_data, "utf-8");
|
||||
parser->run(document.url());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -226,9 +226,9 @@ bool FrameLoader::load(const AK::URL& url, Type type)
|
|||
void FrameLoader::load_html(StringView html, const AK::URL& url)
|
||||
{
|
||||
auto document = DOM::Document::create(url);
|
||||
HTML::HTMLParser parser(document, html, "utf-8");
|
||||
parser.run(url);
|
||||
browsing_context().set_active_document(&parser.document());
|
||||
auto parser = HTML::HTMLParser::create(document, html, "utf-8");
|
||||
parser->run(url);
|
||||
browsing_context().set_active_document(&parser->document());
|
||||
}
|
||||
|
||||
// FIXME: Use an actual templating engine (our own one when it's built, preferably
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue