1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-20 18:05:07 +00:00

LibWeb: Use a switch-statement on the delimiter for MatchType selection

... in Parser::parse_simple_selector
This commit is contained in:
Hendiadyoin1 2022-03-13 18:03:32 +01:00 committed by Andreas Kling
parent 19cca57f8a
commit 397d8b4aca

View file

@ -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();
}
}