浏览代码

LibWeb: Simplify a conditional check in parse_pseudo_simple_selector

Put a shared `pseudo_element.has_value()` check into the same block.
Shannon Booth 1 年之前
父节点
当前提交
08920b7a34
共有 1 个文件被更改,包括 10 次插入11 次删除
  1. 10 11
      Userland/Libraries/LibWeb/CSS/Parser/SelectorParsing.cpp

+ 10 - 11
Userland/Libraries/LibWeb/CSS/Parser/SelectorParsing.cpp

@@ -352,21 +352,20 @@ Parser::ParseErrorOr<Selector::SimpleSelector> 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())