From 6e2f8166f4841e7935d600fd413991a695fd9d56 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Tue, 25 Nov 2025 14:44:07 +0000 Subject: [PATCH] LibWeb/HTML: Combine duplicate parsing branches These are combined in the current spec. No behaviour change. --- Libraries/LibWeb/HTML/Parser/HTMLParser.cpp | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp b/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp index e5898155cb1..1bcb4843c0b 100644 --- a/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp +++ b/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp @@ -2095,14 +2095,9 @@ void HTMLParser::handle_in_body(HTMLToken& token) } // -> A start tag whose tag name is one of: "base", "basefont", "bgsound", "link", "meta", "noframes", "script", "style", "template", "title" - if (token.is_start_tag() && token.tag_name().is_one_of(HTML::TagNames::base, HTML::TagNames::basefont, HTML::TagNames::bgsound, HTML::TagNames::link, HTML::TagNames::meta, HTML::TagNames::noframes, HTML::TagNames::script, HTML::TagNames::style, HTML::TagNames::template_, HTML::TagNames::title)) { - // Process the token using the rules for the "in head" insertion mode. - process_using_the_rules_for(InsertionMode::InHead, token); - return; - } - // -> An end tag whose tag name is "template" - if (token.is_end_tag() && token.tag_name() == HTML::TagNames::template_) { + if ((token.is_start_tag() && token.tag_name().is_one_of(HTML::TagNames::base, HTML::TagNames::basefont, HTML::TagNames::bgsound, HTML::TagNames::link, HTML::TagNames::meta, HTML::TagNames::noframes, HTML::TagNames::script, HTML::TagNames::style, HTML::TagNames::template_, HTML::TagNames::title)) + || (token.is_end_tag() && token.tag_name() == HTML::TagNames::template_)) { // Process the token using the rules for the "in head" insertion mode. process_using_the_rules_for(InsertionMode::InHead, token); return; @@ -4373,13 +4368,10 @@ void HTMLParser::handle_in_template(HTMLToken& token) } // -> A start tag whose tag name is one of: "base", "basefont", "bgsound", "link", "meta", "noframes", "script", "style", "template", "title" - if (token.is_start_tag() && token.tag_name().is_one_of(HTML::TagNames::base, HTML::TagNames::basefont, HTML::TagNames::bgsound, HTML::TagNames::link, HTML::TagNames::meta, HTML::TagNames::noframes, HTML::TagNames::script, HTML::TagNames::style, HTML::TagNames::template_, HTML::TagNames::title)) { - process_using_the_rules_for(InsertionMode::InHead, token); - return; - } - // -> An end tag whose tag name is "template" - if (token.is_end_tag() && token.tag_name() == HTML::TagNames::template_) { + if ((token.is_start_tag() && token.tag_name().is_one_of(HTML::TagNames::base, HTML::TagNames::basefont, HTML::TagNames::bgsound, HTML::TagNames::link, HTML::TagNames::meta, HTML::TagNames::noframes, HTML::TagNames::script, HTML::TagNames::style, HTML::TagNames::template_, HTML::TagNames::title)) + || (token.is_end_tag() && token.tag_name() == HTML::TagNames::template_)) { + // Process the token using the rules for the "in head" insertion mode. process_using_the_rules_for(InsertionMode::InHead, token); return; }