mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:37:35 +00:00
LibWeb: Move DeclarationOrAtRule code into DeclarationOrAtRule.cpp
This commit is contained in:
parent
92320f3000
commit
ba7149a27d
3 changed files with 43 additions and 28 deletions
|
@ -47,6 +47,7 @@ set(SOURCES
|
||||||
CSS/Parser/Block.cpp
|
CSS/Parser/Block.cpp
|
||||||
CSS/Parser/ComponentValue.cpp
|
CSS/Parser/ComponentValue.cpp
|
||||||
CSS/Parser/Declaration.cpp
|
CSS/Parser/Declaration.cpp
|
||||||
|
CSS/Parser/DeclarationOrAtRule.cpp
|
||||||
CSS/Parser/Function.cpp
|
CSS/Parser/Function.cpp
|
||||||
CSS/Parser/Parser.cpp
|
CSS/Parser/Parser.cpp
|
||||||
CSS/Parser/StyleRules.cpp
|
CSS/Parser/StyleRules.cpp
|
||||||
|
|
42
Userland/Libraries/LibWeb/CSS/Parser/DeclarationOrAtRule.cpp
Normal file
42
Userland/Libraries/LibWeb/CSS/Parser/DeclarationOrAtRule.cpp
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020-2021, the SerenityOS developers.
|
||||||
|
* Copyright (c) 2021-2022, Sam Atkins <atkinssj@serenityos.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <LibWeb/CSS/Parser/DeclarationOrAtRule.h>
|
||||||
|
|
||||||
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
DeclarationOrAtRule::DeclarationOrAtRule(RefPtr<StyleRule> at)
|
||||||
|
: m_type(DeclarationType::At)
|
||||||
|
, m_at(move(at))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
DeclarationOrAtRule::DeclarationOrAtRule(Declaration declaration)
|
||||||
|
: m_type(DeclarationType::Declaration)
|
||||||
|
, m_declaration(move(declaration))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
DeclarationOrAtRule::~DeclarationOrAtRule() = default;
|
||||||
|
|
||||||
|
String DeclarationOrAtRule::to_string() const
|
||||||
|
{
|
||||||
|
StringBuilder builder;
|
||||||
|
switch (m_type) {
|
||||||
|
default:
|
||||||
|
case DeclarationType::At:
|
||||||
|
builder.append(m_at->to_string());
|
||||||
|
break;
|
||||||
|
case DeclarationType::Declaration:
|
||||||
|
builder.append(m_declaration.to_string());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return builder.to_string();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -15,18 +15,6 @@
|
||||||
|
|
||||||
namespace Web::CSS {
|
namespace Web::CSS {
|
||||||
|
|
||||||
DeclarationOrAtRule::DeclarationOrAtRule(RefPtr<StyleRule> at)
|
|
||||||
: m_type(DeclarationType::At)
|
|
||||||
, m_at(move(at))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
DeclarationOrAtRule::DeclarationOrAtRule(Declaration declaration)
|
|
||||||
: m_type(DeclarationType::Declaration)
|
|
||||||
, m_declaration(move(declaration))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
DeclarationOrAtRule::~DeclarationOrAtRule() = default;
|
|
||||||
|
|
||||||
StyleRule::StyleRule(StyleRule::Type type)
|
StyleRule::StyleRule(StyleRule::Type type)
|
||||||
: m_type(type)
|
: m_type(type)
|
||||||
{
|
{
|
||||||
|
@ -46,22 +34,6 @@ void append_with_to_string(StringBuilder& builder, SeparatorType& separator, Col
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String DeclarationOrAtRule::to_string() const
|
|
||||||
{
|
|
||||||
StringBuilder builder;
|
|
||||||
switch (m_type) {
|
|
||||||
default:
|
|
||||||
case DeclarationType::At:
|
|
||||||
builder.append(m_at->to_string());
|
|
||||||
break;
|
|
||||||
case DeclarationType::Declaration:
|
|
||||||
builder.append(m_declaration.to_string());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return builder.to_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
String StyleRule::to_string() const
|
String StyleRule::to_string() const
|
||||||
{
|
{
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue