From e452550fda5b50762cbda84f9afc9d8fa331042b Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 26 Sep 2021 00:00:00 +0200 Subject: [PATCH] LibWeb: Split out "The end" from the HTML parsing spec to a function Also add a spec link and some comments. --- .../Libraries/LibWeb/HTML/Parser/HTMLParser.cpp | 15 +++++++++++++-- .../Libraries/LibWeb/HTML/Parser/HTMLParser.h | 2 ++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp index 007073aa57..dc00efe47d 100644 --- a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp +++ b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp @@ -175,11 +175,22 @@ void HTMLParser::run(const AK::URL& url) flush_character_insertions(); - // "The end" + the_end(); +} +// https://html.spec.whatwg.org/multipage/parsing.html#the-end +void HTMLParser::the_end() +{ + // Once the user agent stops parsing the document, the user agent must run the following steps: + + // FIXME: 1. If the active speculative HTML parser is not null, then stop the speculative HTML parser and return. + + // FIXME: 2. Set the insertion point to undefined. + + // 3. Update the current document readiness to "interactive". m_document->set_ready_state("interactive"); - // 3. Pop all the nodes off the stack of open elements. + // 4. Pop all the nodes off the stack of open elements. while (!m_stack_of_open_elements.is_empty()) m_stack_of_open_elements.pop(); diff --git a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.h b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.h index 60f8553221..c30c374e7a 100644 --- a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.h +++ b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.h @@ -94,6 +94,8 @@ private: void handle_after_frameset(HTMLToken&); void handle_after_after_frameset(HTMLToken&); + void the_end(); + void stop_parsing() { m_stop_parsing = true; } void generate_implied_end_tags(const FlyString& exception = {});