1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:48:12 +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:
Andreas Kling 2022-02-21 21:54:21 +01:00
parent bb1f26c149
commit 8b2499b112
7 changed files with 67 additions and 38 deletions

View file

@ -34,11 +34,11 @@ NonnullRefPtr<DOM::Document> DOMParser::parse_from_string(String const& string,
// 2. Create an HTML parser parser, associated with document.
// 3. Place string into the input stream for parser. The encoding confidence is irrelevant.
// FIXME: We don't have the concept of encoding confidence yet.
HTMLParser parser(document, string, "UTF-8");
auto parser = HTMLParser::create(document, string, "UTF-8");
// 4. Start parser and let it run until it has consumed all the characters just inserted into the input stream.
// FIXME: This is to match the default URL. Instead, pass in this's relevant global object's associated Document's URL.
parser.run("about:blank");
parser->run("about:blank");
} else {
// -> Otherwise
// FIXME: 1. Create an XML parser parse, associated with document, and with XML scripting support disabled.