mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 04:09:13 +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,12 +1,13 @@
|
|||
/*
|
||||
* Copyright (c) 2021, the SerenityOS developers.
|
||||
* Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
|
||||
* Copyright (c) 2022-2024, Sam Atkins <sam@ladybird.org>
|
||||
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/CSSRulePrototype.h>
|
||||
#include <LibWeb/CSS/CSSLayerBlockRule.h>
|
||||
#include <LibWeb/CSS/CSSRule.h>
|
||||
#include <LibWeb/CSS/CSSStyleSheet.h>
|
||||
|
||||
|
@ -47,4 +48,37 @@ void CSSRule::set_parent_style_sheet(CSSStyleSheet* parent_style_sheet)
|
|||
m_parent_style_sheet = parent_style_sheet;
|
||||
}
|
||||
|
||||
String CSSRule::parent_layer_internal_qualified_name() const
|
||||
{
|
||||
// TODO: Cache this?
|
||||
Vector<FlyString> layer_names;
|
||||
for (auto* rule = parent_rule(); rule; rule = rule->parent_rule()) {
|
||||
switch (rule->type()) {
|
||||
case CSSRule::Type::Import:
|
||||
// TODO: Handle `layer(foo)` in import rules once we implement that.
|
||||
break;
|
||||
|
||||
case CSSRule::Type::LayerBlock: {
|
||||
auto& layer_block = static_cast<CSSLayerBlockRule const&>(*rule);
|
||||
layer_names.append(layer_block.internal_name());
|
||||
break;
|
||||
}
|
||||
|
||||
// Ignore everything else
|
||||
// Note that LayerStatement cannot have child rules so we still ignore it here.
|
||||
case CSSRule::Type::LayerStatement:
|
||||
case CSSRule::Type::Style:
|
||||
case CSSRule::Type::Media:
|
||||
case CSSRule::Type::FontFace:
|
||||
case CSSRule::Type::Keyframes:
|
||||
case CSSRule::Type::Keyframe:
|
||||
case CSSRule::Type::Namespace:
|
||||
case CSSRule::Type::Supports:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return MUST(String::join("."sv, layer_names.in_reverse()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue