LibWeb/CSS: Reject non-grouping-rules as descendants of style rules

For example, `@font-face` is not only invalid inside a style rule, it's
also invalid inside a child of a style rule. This fixes a test
regression that we previously passed by accident.
This commit is contained in:
Sam Atkins 2025-04-03 12:31:26 +01:00
parent 9cce791424
commit e43bb1410c
Notes: github-actions[bot] 2025-04-04 09:41:27 +00:00
2 changed files with 9 additions and 4 deletions

View file

@ -1427,14 +1427,18 @@ bool Parser::is_valid_in_the_current_context(AtRule const& at_rule) const
if (m_rule_context.is_empty())
return true;
// Only grouping rules can be nested within style rules
if (m_rule_context.contains_slow(ContextType::Style))
return first_is_one_of(at_rule.name, "layer", "media", "supports");
switch (m_rule_context.last()) {
case ContextType::Unknown:
// If the context is an unknown type, we don't accept anything.
return false;
case ContextType::Style:
// Style rules can contain grouping rules
return first_is_one_of(at_rule.name, "layer", "media", "supports");
// Already handled above
VERIFY_NOT_REACHED();
case ContextType::AtLayer:
case ContextType::AtMedia: