mirror of
https://github.com/RGBCube/serenity
synced 2025-05-21 14:45:07 +00:00
LibWeb: Use a switch-statement on the delimiter for MatchType selection
... in Parser::parse_simple_selector
This commit is contained in:
parent
19cca57f8a
commit
397d8b4aca
1 changed files with 12 additions and 7 deletions
|
@ -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());
|
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;
|
return ParsingResult::SyntaxError;
|
||||||
}
|
}
|
||||||
|
switch (delim_part.token().delim()) {
|
||||||
if (delim_part.token().delim() == '~') {
|
case '~':
|
||||||
simple_selector.attribute.match_type = Selector::SimpleSelector::Attribute::MatchType::ContainsWord;
|
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;
|
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;
|
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;
|
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;
|
simple_selector.attribute.match_type = Selector::SimpleSelector::Attribute::MatchType::EndsWithString;
|
||||||
} else {
|
break;
|
||||||
|
default:
|
||||||
attribute_tokens.reconsume_current_input_token();
|
attribute_tokens.reconsume_current_input_token();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue