diff options
author | Andreas Kling <kling@serenityos.org> | 2020-05-28 18:55:18 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-05-28 18:55:18 +0200 |
commit | 68b1bdc2346102f49e3563676eb0b3735f653e2c (patch) | |
tree | 19174675a11a411114d81f618d76f0de00e00173 /Libraries/LibWeb | |
parent | 00b44ab1489332d33e60979d7688145f097bd6e6 (diff) | |
download | serenity-68b1bdc2346102f49e3563676eb0b3735f653e2c.zip |
LibWeb: Add a way to stop the new HTML parser
Some things are specced to "stop parsing", which basically just means
to stop fetching tokens and jump to "The end"
Diffstat (limited to 'Libraries/LibWeb')
-rw-r--r-- | Libraries/LibWeb/Parser/HTMLDocumentParser.cpp | 11 | ||||
-rw-r--r-- | Libraries/LibWeb/Parser/HTMLDocumentParser.h | 3 |
2 files changed, 11 insertions, 3 deletions
diff --git a/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp b/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp index 9a85af72a4..323b25919f 100644 --- a/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp +++ b/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp @@ -76,6 +76,11 @@ void HTMLDocumentParser::run(const URL& url) dbg() << "[" << insertion_mode_name() << "] " << token.to_string(); #endif process_using_the_rules_for(m_insertion_mode, token); + + if (m_stop_parsing) { + dbg() << "Stop parsing! :^)"; + break; + } } // "The end" @@ -497,8 +502,8 @@ void HTMLDocumentParser::handle_after_body(HTMLToken& token) } if (token.is_end_of_file()) { - // FIXME: Stop parsing! - TODO(); + stop_parsing(); + return; } if (token.is_end_tag() && token.tag_name() == "html") { @@ -522,7 +527,7 @@ void HTMLDocumentParser::handle_after_after_body(HTMLToken& token) } if (token.is_end_of_file()) { - dbg() << "Stop parsing! :^)"; + stop_parsing(); return; } ASSERT_NOT_REACHED(); diff --git a/Libraries/LibWeb/Parser/HTMLDocumentParser.h b/Libraries/LibWeb/Parser/HTMLDocumentParser.h index de4c817efb..df98658e4c 100644 --- a/Libraries/LibWeb/Parser/HTMLDocumentParser.h +++ b/Libraries/LibWeb/Parser/HTMLDocumentParser.h @@ -94,6 +94,8 @@ private: void handle_in_row(HTMLToken&); void handle_in_cell(HTMLToken&); + void stop_parsing() { m_stop_parsing = true; } + void generate_implied_end_tags(const FlyString& exception = {}); bool stack_of_open_elements_has_element_with_tag_name_in_scope(const FlyString& tag_name); NonnullRefPtr<Element> create_element_for(HTMLToken&); @@ -131,6 +133,7 @@ private: bool m_invoked_via_document_write { false }; bool m_aborted { false }; bool m_parser_pause_flag { false }; + bool m_stop_parsing { false }; size_t m_script_nesting_level { 0 }; RefPtr<Document> m_document; |