mirror of
https://github.com/RGBCube/serenity
synced 2025-05-22 11:35:06 +00:00
LibWeb: Make :host()
take a <compound-selector>
This matches the spec: https://drafts.csswg.org/css-scoping-1/#selectordef-host
This commit is contained in:
parent
b314a115ca
commit
b684bab5f1
4 changed files with 23 additions and 1 deletions
|
@ -71,6 +71,7 @@ struct PseudoClassMetadata {
|
|||
None,
|
||||
ANPlusB,
|
||||
ANPlusBOf,
|
||||
CompoundSelector,
|
||||
ForgivingSelectorList,
|
||||
LanguageRanges,
|
||||
SelectorList,
|
||||
|
@ -164,6 +165,8 @@ PseudoClassMetadata pseudo_class_metadata(PseudoClass pseudo_class)
|
|||
parameter_type = "ANPlusB"_string;
|
||||
} else if (argument_string == "<an+b-of>"sv) {
|
||||
parameter_type = "ANPlusBOf"_string;
|
||||
} else if (argument_string == "<compound-selector>"sv) {
|
||||
parameter_type = "CompoundSelector"_string;
|
||||
} else if (argument_string == "<forgiving-selector-list>"sv) {
|
||||
parameter_type = "ForgivingSelectorList"_string;
|
||||
} else if (argument_string == "<language-ranges>"sv) {
|
||||
|
|
|
@ -633,6 +633,24 @@ Parser::ParseErrorOr<Selector::SimpleSelector> Parser::parse_pseudo_simple_selec
|
|||
return parse_nth_child_selector(pseudo_class, pseudo_function.values(), false);
|
||||
case PseudoClassMetadata::ParameterType::ANPlusBOf:
|
||||
return parse_nth_child_selector(pseudo_class, pseudo_function.values(), true);
|
||||
case PseudoClassMetadata::ParameterType::CompoundSelector: {
|
||||
auto function_token_stream = TokenStream(pseudo_function.values());
|
||||
auto compound_selector = MUST(parse_compound_selector(function_token_stream));
|
||||
if (!compound_selector.has_value()) {
|
||||
dbgln_if(CSS_PARSER_DEBUG, "Failed to parse :{}() parameter as a compound selector", pseudo_function.name());
|
||||
return ParseError::SyntaxError;
|
||||
}
|
||||
|
||||
Vector compound_selectors { compound_selector.release_value() };
|
||||
auto selector = Selector::create(move(compound_selectors));
|
||||
|
||||
return Selector::SimpleSelector {
|
||||
.type = Selector::SimpleSelector::Type::PseudoClass,
|
||||
.value = Selector::SimpleSelector::PseudoClassSelector {
|
||||
.type = pseudo_class,
|
||||
.argument_selector_list = { move(selector) } }
|
||||
};
|
||||
}
|
||||
case PseudoClassMetadata::ParameterType::ForgivingSelectorList: {
|
||||
auto function_token_stream = TokenStream(pseudo_function.values());
|
||||
// NOTE: Because it's forgiving, even complete garbage will parse OK as an empty selector-list.
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
"argument": ""
|
||||
},
|
||||
"host": {
|
||||
"argument": "<selector-list>?"
|
||||
"argument": "<compound-selector>?"
|
||||
},
|
||||
"hover": {
|
||||
"argument": ""
|
||||
|
|
|
@ -496,6 +496,7 @@ void dump_selector(StringBuilder& builder, CSS::Selector const& selector)
|
|||
builder.append(")"sv);
|
||||
break;
|
||||
}
|
||||
case CSS::PseudoClassMetadata::ParameterType::CompoundSelector:
|
||||
case CSS::PseudoClassMetadata::ParameterType::ForgivingSelectorList:
|
||||
case CSS::PseudoClassMetadata::ParameterType::SelectorList: {
|
||||
builder.append("(["sv);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue