diff options
author | Andreas Kling <kling@serenityos.org> | 2020-05-29 21:44:36 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-05-30 11:31:49 +0200 |
commit | 30d64fccdee74167474e3bcc53d30d3dbb450f1f (patch) | |
tree | 7c427e65d2532e50e0b9d99a5ecefd9244f48022 /Libraries/LibWeb | |
parent | 643464c455cf94f270bb6656b4a15b157b4a400c (diff) | |
download | serenity-30d64fccdee74167474e3bcc53d30d3dbb450f1f.zip |
LibWeb: Parse "li" start tags in the "in body" insertion mode
Diffstat (limited to 'Libraries/LibWeb')
-rw-r--r-- | Libraries/LibWeb/Parser/HTMLDocumentParser.cpp | 115 |
1 files changed, 112 insertions, 3 deletions
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<Element> 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")) { |