소스 검색

LibWeb: Parse "td" start tags during "in cell" insertion mode

Andreas Kling 5 년 전
부모
커밋
7aa7a2078f
2개의 변경된 파일21개의 추가작업 그리고 1개의 파일을 삭제
  1. 20 1
      Libraries/LibWeb/Parser/HTMLDocumentParser.cpp
  2. 1 0
      Libraries/LibWeb/Parser/HTMLDocumentParser.h

+ 20 - 1
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")) {

+ 1 - 0
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 };