From 08920b7a34a6da50a76cbb1d9eef35bde46239dd Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Sun, 10 Dec 2023 17:07:32 +1300 Subject: [PATCH] LibWeb: Simplify a conditional check in parse_pseudo_simple_selector Put a shared `pseudo_element.has_value()` check into the same block. --- .../LibWeb/CSS/Parser/SelectorParsing.cpp | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/Userland/Libraries/LibWeb/CSS/Parser/SelectorParsing.cpp b/Userland/Libraries/LibWeb/CSS/Parser/SelectorParsing.cpp index 162f20dc70..a4058cf38b 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/SelectorParsing.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/SelectorParsing.cpp @@ -352,21 +352,20 @@ Parser::ParseErrorOr Parser::parse_pseudo_simple_selec } auto pseudo_name = name_token.token().ident(); - auto pseudo_element = pseudo_element_from_string(pseudo_name); // Note: We allow the "ignored" -webkit prefix here for -webkit-progress-bar/-webkit-progress-bar - if (!pseudo_element.has_value() && has_ignored_vendor_prefix(pseudo_name)) - return ParseError::IncludesIgnoredVendorPrefix; - - if (!pseudo_element.has_value()) { - dbgln_if(CSS_PARSER_DEBUG, "Unrecognized pseudo-element: '::{}'", pseudo_name); - return ParseError::SyntaxError; + if (auto pseudo_element = pseudo_element_from_string(pseudo_name); pseudo_element.has_value()) { + return Selector::SimpleSelector { + .type = Selector::SimpleSelector::Type::PseudoElement, + .value = pseudo_element.release_value() + }; } - return Selector::SimpleSelector { - .type = Selector::SimpleSelector::Type::PseudoElement, - .value = pseudo_element.value() - }; + if (has_ignored_vendor_prefix(pseudo_name)) + return ParseError::IncludesIgnoredVendorPrefix; + + dbgln_if(CSS_PARSER_DEBUG, "Unrecognized pseudo-element: '::{}'", pseudo_name); + return ParseError::SyntaxError; } if (peek_token_ends_selector())