From 7aa7a2078ff9a1dc45c3d44ea5e397e44d9f7939 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 28 May 2020 11:45:40 +0200 Subject: [PATCH] LibWeb: Parse "td" start tags during "in cell" insertion mode --- .../LibWeb/Parser/HTMLDocumentParser.cpp | 21 ++++++++++++++++++- Libraries/LibWeb/Parser/HTMLDocumentParser.h | 1 + 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp b/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp index 42fc24d253..ead7ee555c 100644 --- a/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp +++ b/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp @@ -907,6 +907,19 @@ void HTMLDocumentParser::handle_in_row(HTMLToken& token) TODO(); } +void HTMLDocumentParser::close_the_cell() +{ + generate_implied_end_tags(); + if (!current_node().tag_name().is_one_of("td", "th")) { + PARSE_ERROR(); + } + while (!current_node().tag_name().is_one_of("td", "th")) + m_stack_of_open_elements.pop(); + m_stack_of_open_elements.pop(); + m_list_of_active_formatting_elements.clear_up_to_the_last_marker(); + m_insertion_mode = InsertionMode::InRow; +} + void HTMLDocumentParser::handle_in_cell(HTMLToken& token) { if (token.is_end_tag() && token.tag_name().is_one_of("td", "th")) { @@ -930,7 +943,13 @@ void HTMLDocumentParser::handle_in_cell(HTMLToken& token) return; } if (token.is_start_tag() && token.tag_name().is_one_of("caption", "col", "colgroup", "tbody", "td", "tfoot", "th", "thead", "tr")) { - TODO(); + if (!m_stack_of_open_elements.has_in_table_scope("td") && m_stack_of_open_elements.has_in_table_scope("th")) { + PARSE_ERROR(); + return; + } + close_the_cell(); + process_using_the_rules_for(m_insertion_mode, token); + return; } if (token.is_end_tag() && token.tag_name().is_one_of("body", "caption", "col", "colgroup", "html")) { diff --git a/Libraries/LibWeb/Parser/HTMLDocumentParser.h b/Libraries/LibWeb/Parser/HTMLDocumentParser.h index 884380a29d..27efc95885 100644 --- a/Libraries/LibWeb/Parser/HTMLDocumentParser.h +++ b/Libraries/LibWeb/Parser/HTMLDocumentParser.h @@ -114,6 +114,7 @@ private: void clear_the_stack_back_to_a_table_context(); void clear_the_stack_back_to_a_table_body_context(); void clear_the_stack_back_to_a_table_row_context(); + void close_the_cell(); InsertionMode m_insertion_mode { InsertionMode::Initial }; InsertionMode m_original_insertion_mode { InsertionMode::Initial };