From 201cc1bfcc24d692ecdcacb45bf344c5839f021b Mon Sep 17 00:00:00 2001 From: Luke Date: Tue, 21 Jul 2020 19:03:05 +0100 Subject: [PATCH] LibWeb: Assert we're parsing a fragment on fragment cases The specification says that parts labelled as a "fragment case" will only occur when parsing a fragment. It says that if it occurs when not parsing a fragment, then it is a specification error. We should probably assume at this point that it's an implementation error. This fixes a few little mistakes that were caught out by this. Also moves the context element outside insertion mode reset, as other (unimplemented) parts refer to it, such as "adjusted current node". Also cleans up insertion mode reset. --- .../LibWeb/Parser/HTMLDocumentParser.cpp | 87 ++++++++++++++----- Libraries/LibWeb/Parser/HTMLDocumentParser.h | 3 +- 2 files changed, 68 insertions(+), 22 deletions(-) diff --git a/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp b/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp index 83ac40917b..86182c075a 100644 --- a/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp +++ b/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp @@ -139,7 +139,7 @@ void HTMLDocumentParser::run(const URL& url) if (m_stop_parsing) { #ifdef PARSER_DEBUG - dbg() << "Stop parsing! :^)"; + dbg() << "Stop parsing" << (m_parsing_fragment ? " fragment" : "") << "! :^)"; #endif break; } @@ -382,8 +382,10 @@ HTMLDocumentParser::AdjustedInsertionLocation HTMLDocumentParser::find_appropria if (m_foster_parenting && target.tag_name().is_one_of(HTML::TagNames::table, HTML::TagNames::tbody, HTML::TagNames::tfoot, HTML::TagNames::thead, HTML::TagNames::tr)) { // FIXME: There's a bunch of steps for