From 30d64fccdee74167474e3bcc53d30d3dbb450f1f Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 29 May 2020 21:44:36 +0200 Subject: LibWeb: Parse "li" start tags in the "in body" insertion mode --- Libraries/LibWeb/Parser/HTMLDocumentParser.cpp | 115 ++++++++++++++++++++++++- 1 file changed, 112 insertions(+), 3 deletions(-) (limited to 'Libraries/LibWeb') diff --git a/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp b/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp index cacf1ba8c5..d504633f73 100644 --- a/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp +++ b/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp @@ -44,8 +44,8 @@ ASSERT_NOT_REACHED(); \ } while (0) -#define PARSE_ERROR() \ - do { \ +#define PARSE_ERROR() \ + do { \ dbg() << "Parse error! " << __PRETTY_FUNCTION__ << " @ " << __LINE__; \ } while (0) @@ -642,6 +642,93 @@ void HTMLDocumentParser::run_the_adoption_agency_algorithm(HTMLToken& token) TODO(); } +static bool is_special_tag(const FlyString& tag_name) +{ + return tag_name.is_one_of( + "address", + "applet", + "area", + "article", + "aside", + "base", + "basefont", + "bgsound", + "blockquote", + "body", + "br", + "button", + "caption", + "center", + "col", + "colgroup", + "dd", + "details", + "dir", + "div", + "dl", + "dt", + "embed", + "fieldset", + "figcaption", + "figure", + "footer", + "form", + "frame", + "frameset", + "h1", + "h2", + "h3", + "h4", + "h5", + "h6", + "head", + "header", + "hgroup", + "hr", + "html", + "iframe", + "img", + "input", + "keygen", + "li", + "link", + "listing", + "main", + "marquee", + "menu", + "meta", + "nav", + "noembed", + "noframes", + "noscript", + "object", + "ol", + "p", + "param", + "plaintext", + "pre", + "script", + "section", + "select", + "source", + "style", + "summary", + "table", + "tbody", + "td", + "template", + "textarea", + "tfoot", + "th", + "thead", + "title", + "tr", + "track", + "ul", + "wbr", + "xmp"); +} + void HTMLDocumentParser::handle_in_body(HTMLToken& token) { if (token.is_character()) { @@ -742,7 +829,29 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token) } if (token.is_start_tag() && token.tag_name() == "li") { - TODO(); + m_frameset_ok = false; + + for (ssize_t i = m_stack_of_open_elements.elements().size() - 1; i >= 0; --i) { + RefPtr node = m_stack_of_open_elements.elements()[i]; + + if (node->tag_name() == "li") { + generate_implied_end_tags("li"); + if (current_node().tag_name() != "li") { + PARSE_ERROR(); + } + m_stack_of_open_elements.pop_until_an_element_with_tag_name_has_been_popped("li"); + break; + } + + if (is_special_tag(node->tag_name()) && !node->tag_name().is_one_of("address", "div", "p")) + break; + } + + if (m_stack_of_open_elements.has_in_button_scope("p")) + close_a_p_element(); + + insert_html_element(token); + return; } if (token.is_start_tag() && token.tag_name().is_one_of("dd", "dt")) { -- cgit v1.2.3