mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-28 14:02:51 +00:00
LibWeb/CSS: Move RuleContext type out of Parser.h
This was previously internal to the Parser, but we'd like to pass it in from outside.
This commit is contained in:
parent
9465492edf
commit
763b1b0ee2
Notes:
github-actions[bot]
2025-04-23 10:40:02 +00:00
Author: https://github.com/AtkinsSJ
Commit: 763b1b0ee2
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4354
6 changed files with 135 additions and 73 deletions
58
Libraries/LibWeb/CSS/Parser/RuleContext.cpp
Normal file
58
Libraries/LibWeb/CSS/Parser/RuleContext.cpp
Normal file
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Sam Atkins <sam@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/CSS/Parser/RuleContext.h>
|
||||
|
||||
namespace Web::CSS::Parser {
|
||||
|
||||
RuleContext rule_context_type_for_rule(CSSRule::Type rule_type)
|
||||
{
|
||||
switch (rule_type) {
|
||||
case CSSRule::Type::Style:
|
||||
return RuleContext::Style;
|
||||
case CSSRule::Type::Media:
|
||||
return RuleContext::AtMedia;
|
||||
case CSSRule::Type::FontFace:
|
||||
return RuleContext::AtFontFace;
|
||||
case CSSRule::Type::Keyframes:
|
||||
return RuleContext::AtKeyframes;
|
||||
case CSSRule::Type::Keyframe:
|
||||
return RuleContext::Keyframe;
|
||||
case CSSRule::Type::Supports:
|
||||
return RuleContext::AtSupports;
|
||||
case CSSRule::Type::LayerBlock:
|
||||
return RuleContext::AtLayer;
|
||||
case CSSRule::Type::NestedDeclarations:
|
||||
return RuleContext::Style;
|
||||
case CSSRule::Type::Property:
|
||||
return RuleContext::AtProperty;
|
||||
// Other types shouldn't be trying to create a context.
|
||||
case CSSRule::Type::Import:
|
||||
case CSSRule::Type::LayerStatement:
|
||||
case CSSRule::Type::Namespace:
|
||||
break;
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
RuleContext rule_context_type_for_at_rule(FlyString const& name)
|
||||
{
|
||||
if (name == "media")
|
||||
return RuleContext::AtMedia;
|
||||
if (name == "font-face")
|
||||
return RuleContext::AtFontFace;
|
||||
if (name == "keyframes")
|
||||
return RuleContext::AtKeyframes;
|
||||
if (name == "supports")
|
||||
return RuleContext::AtSupports;
|
||||
if (name == "layer")
|
||||
return RuleContext::AtLayer;
|
||||
if (name == "property")
|
||||
return RuleContext::AtProperty;
|
||||
return RuleContext::Unknown;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue