mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-09 09:39:39 +00:00
LibWeb/CSS: Add CSSOM types for @layer
rules
Depending on usage, `@layer` has two forms, with two different CSSOM types. One simply lists layer names and the other defines a layer with its contained rules.
This commit is contained in:
parent
bf9d05d97a
commit
1c6133aa52
Notes:
github-actions[bot]
2024-09-06 05:51:10 +00:00
Author: https://github.com/AtkinsSJ
Commit: 1c6133aa52
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1291
17 changed files with 346 additions and 27 deletions
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2021, the SerenityOS developers.
|
||||
* Copyright (c) 2021-2024, Sam Atkins <sam@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -10,6 +11,8 @@
|
|||
#include <AK/Utf8View.h>
|
||||
#include <LibWeb/CSS/CSSFontFaceRule.h>
|
||||
#include <LibWeb/CSS/CSSImportRule.h>
|
||||
#include <LibWeb/CSS/CSSLayerBlockRule.h>
|
||||
#include <LibWeb/CSS/CSSLayerStatementRule.h>
|
||||
#include <LibWeb/CSS/CSSMediaRule.h>
|
||||
#include <LibWeb/CSS/CSSRule.h>
|
||||
#include <LibWeb/CSS/CSSStyleRule.h>
|
||||
|
@ -617,21 +620,28 @@ ErrorOr<void> dump_rule(StringBuilder& builder, CSS::CSSRule const& rule, int in
|
|||
case CSS::CSSRule::Type::Import:
|
||||
dump_import_rule(builder, verify_cast<CSS::CSSImportRule const>(rule), indent_levels);
|
||||
break;
|
||||
case CSS::CSSRule::Type::Keyframe:
|
||||
case CSS::CSSRule::Type::Keyframes:
|
||||
// TODO: Dump them!
|
||||
break;
|
||||
case CSS::CSSRule::Type::LayerBlock:
|
||||
dump_layer_block_rule(builder, verify_cast<CSS::CSSLayerBlockRule const>(rule), indent_levels);
|
||||
break;
|
||||
case CSS::CSSRule::Type::LayerStatement:
|
||||
dump_layer_statement_rule(builder, verify_cast<CSS::CSSLayerStatementRule const>(rule), indent_levels);
|
||||
break;
|
||||
case CSS::CSSRule::Type::Media:
|
||||
TRY(dump_media_rule(builder, verify_cast<CSS::CSSMediaRule const>(rule), indent_levels));
|
||||
break;
|
||||
case CSS::CSSRule::Type::Namespace:
|
||||
TRY(dump_namespace_rule(builder, verify_cast<CSS::CSSNamespaceRule const>(rule), indent_levels));
|
||||
break;
|
||||
case CSS::CSSRule::Type::Style:
|
||||
TRY(dump_style_rule(builder, verify_cast<CSS::CSSStyleRule const>(rule), indent_levels));
|
||||
break;
|
||||
case CSS::CSSRule::Type::Supports:
|
||||
TRY(dump_supports_rule(builder, verify_cast<CSS::CSSSupportsRule const>(rule), indent_levels));
|
||||
break;
|
||||
case CSS::CSSRule::Type::Keyframe:
|
||||
case CSS::CSSRule::Type::Keyframes:
|
||||
break;
|
||||
case CSS::CSSRule::Type::Namespace:
|
||||
TRY(dump_namespace_rule(builder, verify_cast<CSS::CSSNamespaceRule const>(rule), indent_levels));
|
||||
break;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
@ -676,6 +686,21 @@ void dump_import_rule(StringBuilder& builder, CSS::CSSImportRule const& rule, in
|
|||
builder.appendff(" Document URL: {}\n", rule.url());
|
||||
}
|
||||
|
||||
void dump_layer_block_rule(StringBuilder& builder, CSS::CSSLayerBlockRule const& layer_block, int indent_levels)
|
||||
{
|
||||
indent(builder, indent_levels);
|
||||
builder.appendff(" Layer Block: `{}`\n Rules ({}):\n", layer_block.internal_name(), layer_block.css_rules().length());
|
||||
for (auto& rule : layer_block.css_rules())
|
||||
MUST(dump_rule(builder, rule, indent_levels + 1));
|
||||
}
|
||||
|
||||
void dump_layer_statement_rule(StringBuilder& builder, CSS::CSSLayerStatementRule const& layer_statement, int indent_levels)
|
||||
{
|
||||
indent(builder, indent_levels);
|
||||
builder.append(" Layer Statement: "sv);
|
||||
builder.join(", "sv, layer_statement.name_list());
|
||||
}
|
||||
|
||||
ErrorOr<void> dump_media_rule(StringBuilder& builder, CSS::CSSMediaRule const& media, int indent_levels)
|
||||
{
|
||||
indent(builder, indent_levels);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue