mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
LibWeb: Allow anonymous layer block rule with no declarations
This commit is contained in:
parent
30cdacc05a
commit
701fcb9e87
Notes:
github-actions[bot]
2025-06-17 07:59:15 +00:00
Author: https://github.com/tcl3
Commit: 701fcb9e87
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5111
Reviewed-by: https://github.com/AtkinsSJ ✅
6 changed files with 51 additions and 2 deletions
|
@ -441,6 +441,7 @@ Optional<AtRule> Parser::consume_an_at_rule(TokenStream<T>& input, Nested nested
|
|||
.name = ((Token)input.consume_a_token()).at_keyword(),
|
||||
.prelude = {},
|
||||
.child_rules_and_lists_of_declarations = {},
|
||||
.is_block_rule = false,
|
||||
};
|
||||
|
||||
// Process input:
|
||||
|
@ -479,6 +480,7 @@ Optional<AtRule> Parser::consume_an_at_rule(TokenStream<T>& input, Nested nested
|
|||
// Consume a block from input, and assign the result to rule’s child rules.
|
||||
m_rule_context.append(rule_context_type_for_at_rule(rule.name));
|
||||
rule.child_rules_and_lists_of_declarations = consume_a_block(input);
|
||||
rule.is_block_rule = true;
|
||||
m_rule_context.take_last();
|
||||
|
||||
// If rule is valid in the current context, return it. Otherwise, return nothing.
|
||||
|
|
|
@ -288,7 +288,7 @@ Optional<FlyString> Parser::parse_layer_name(TokenStream<ComponentValue>& tokens
|
|||
GC::Ptr<CSSRule> Parser::convert_to_layer_rule(AtRule const& rule, Nested nested)
|
||||
{
|
||||
// https://drafts.csswg.org/css-cascade-5/#at-layer
|
||||
if (!rule.child_rules_and_lists_of_declarations.is_empty()) {
|
||||
if (rule.is_block_rule) {
|
||||
// CSSLayerBlockRule
|
||||
// @layer <layer-name>? {
|
||||
// <rule-list>
|
||||
|
|
|
@ -31,6 +31,7 @@ struct AtRule {
|
|||
FlyString name;
|
||||
Vector<ComponentValue> prelude;
|
||||
Vector<RuleOrListOfDeclarations> child_rules_and_lists_of_declarations;
|
||||
bool is_block_rule { false };
|
||||
|
||||
void for_each(AtRuleVisitor&& visit_at_rule, QualifiedRuleVisitor&& visit_qualified_rule, DeclarationVisitor&& visit_declaration) const;
|
||||
void for_each_as_declaration_list(DeclarationVisitor&& visit) const;
|
||||
|
|
|
@ -6,5 +6,5 @@ CSSFontFaceRule type = 5
|
|||
CSSKeyframesRule type = 7
|
||||
CSSSupportsRule type = 12
|
||||
CSSLayerStatementRule type = 0
|
||||
CSSLayerStatementRule type = 0
|
||||
CSSLayerBlockRule type = 0
|
||||
CSSPropertyRule type = 0
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
Harness status: OK
|
||||
|
||||
Found 11 tests
|
||||
|
||||
11 Pass
|
||||
Pass @layer A; should be a valid rule
|
||||
Pass @layer A, B, C; should be a valid rule
|
||||
Pass @layer A.A; should be a valid rule
|
||||
Pass @layer A, B.C.D, C; should be a valid rule
|
||||
Pass @layer; should be an invalid rule
|
||||
Pass @layer A . A; should be an invalid rule
|
||||
Pass @layer {
|
||||
} should be a valid rule
|
||||
Pass @layer A {
|
||||
} should be a valid rule
|
||||
Pass @layer A.B {
|
||||
} should be a valid rule
|
||||
Pass @layer A . B {
|
||||
} should be an invalid rule
|
||||
Pass @layer A, B, C {
|
||||
} should be an invalid rule
|
|
@ -0,0 +1,25 @@
|
|||
<!doctype html>
|
||||
<meta charset="utf-8">
|
||||
<title>@layer rule parsing / serialization</title>
|
||||
<link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io">
|
||||
<link rel="author" title="Mozilla" href="https://mozilla.org">
|
||||
<link rel="help" href="https://drafts.csswg.org/css-cascade-5/#layering">
|
||||
<script src="../../../resources/testharness.js"></script>
|
||||
<script src="../../../resources/testharnessreport.js"></script>
|
||||
<script src="../../../css/support/parsing-testcommon.js"></script>
|
||||
<script>
|
||||
test_valid_rule("@layer A;");
|
||||
test_valid_rule("@layer A, B, C;");
|
||||
test_valid_rule("@layer A.A;");
|
||||
test_valid_rule("@layer A, B.C.D, C;");
|
||||
|
||||
test_invalid_rule("@layer;");
|
||||
test_invalid_rule("@layer A . A;");
|
||||
|
||||
test_valid_rule("@layer {\n}");
|
||||
test_valid_rule("@layer A {\n}");
|
||||
test_valid_rule("@layer A.B {\n}");
|
||||
test_invalid_rule("@layer A . B {\n}");
|
||||
|
||||
test_invalid_rule("@layer A, B, C {\n}");
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue