diff options
author | Hendiadyoin1 <leon.a@serenityos.org> | 2022-03-13 18:03:32 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-03-21 12:49:00 +0100 |
commit | 397d8b4acac07863723e3d98f6fc47a99d19dce8 (patch) | |
tree | 90110c351bb6cf0c6b9b8c8b31129fc26c408636 /Userland | |
parent | 19cca57f8ab9b34d0f4a9392e2b71b0584c0ac3a (diff) | |
download | serenity-397d8b4acac07863723e3d98f6fc47a99d19dce8.zip |
LibWeb: Use a switch-statement on the delimiter for MatchType selection
... in Parser::parse_simple_selector
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index e7764534e8..829bc44936 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -423,18 +423,23 @@ Result<Selector::SimpleSelector, Parser::ParsingResult> Parser::parse_simple_sel dbgln_if(CSS_PARSER_DEBUG, "Expected a double delim for attribute comparison, got: '{}{}'", delim_part.to_debug_string(), delim_second_part.to_debug_string()); return ParsingResult::SyntaxError; } - - if (delim_part.token().delim() == '~') { + switch (delim_part.token().delim()) { + case '~': simple_selector.attribute.match_type = Selector::SimpleSelector::Attribute::MatchType::ContainsWord; - } else if (delim_part.token().delim() == '*') { + break; + case '*': simple_selector.attribute.match_type = Selector::SimpleSelector::Attribute::MatchType::ContainsString; - } else if (delim_part.token().delim() == '|') { + break; + case '|': simple_selector.attribute.match_type = Selector::SimpleSelector::Attribute::MatchType::StartsWithSegment; - } else if (delim_part.token().delim() == '^') { + break; + case '^': simple_selector.attribute.match_type = Selector::SimpleSelector::Attribute::MatchType::StartsWithString; - } else if (delim_part.token().delim() == '$') { + break; + case '$': simple_selector.attribute.match_type = Selector::SimpleSelector::Attribute::MatchType::EndsWithString; - } else { + break; + default: attribute_tokens.reconsume_current_input_token(); } } |