mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:47:44 +00:00
LibWeb: Move ComponentValue code into ComponentValue.cpp
This commit is contained in:
parent
8f5d80a41d
commit
b7453eafbb
3 changed files with 52 additions and 36 deletions
|
@ -44,6 +44,7 @@ set(SOURCES
|
||||||
CSS/MediaList.cpp
|
CSS/MediaList.cpp
|
||||||
CSS/MediaQuery.cpp
|
CSS/MediaQuery.cpp
|
||||||
CSS/MediaQueryList.cpp
|
CSS/MediaQueryList.cpp
|
||||||
|
CSS/Parser/ComponentValue.cpp
|
||||||
CSS/Parser/Parser.cpp
|
CSS/Parser/Parser.cpp
|
||||||
CSS/Parser/StyleRules.cpp
|
CSS/Parser/StyleRules.cpp
|
||||||
CSS/Parser/Token.cpp
|
CSS/Parser/Token.cpp
|
||||||
|
|
51
Userland/Libraries/LibWeb/CSS/Parser/ComponentValue.cpp
Normal file
51
Userland/Libraries/LibWeb/CSS/Parser/ComponentValue.cpp
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
* 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/ComponentValue.h>
|
||||||
|
#include <LibWeb/CSS/Parser/StyleBlockRule.h>
|
||||||
|
#include <LibWeb/CSS/Parser/StyleFunctionRule.h>
|
||||||
|
|
||||||
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
ComponentValue::ComponentValue(Token token)
|
||||||
|
: m_value(token)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
ComponentValue::ComponentValue(NonnullRefPtr<StyleFunctionRule> function)
|
||||||
|
: m_value(function)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
ComponentValue::ComponentValue(NonnullRefPtr<StyleBlockRule> block)
|
||||||
|
: m_value(block)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
ComponentValue::~ComponentValue() = default;
|
||||||
|
|
||||||
|
String ComponentValue::to_string() const
|
||||||
|
{
|
||||||
|
return m_value.visit(
|
||||||
|
[](Token const& token) { return token.to_string(); },
|
||||||
|
[](NonnullRefPtr<StyleBlockRule> const& block) { return block->to_string(); },
|
||||||
|
[](NonnullRefPtr<StyleFunctionRule> const& function) { return function->to_string(); });
|
||||||
|
}
|
||||||
|
|
||||||
|
String ComponentValue::to_debug_string() const
|
||||||
|
{
|
||||||
|
return m_value.visit(
|
||||||
|
[](Token const& token) {
|
||||||
|
return String::formatted("Token: {}", token.to_debug_string());
|
||||||
|
},
|
||||||
|
[](NonnullRefPtr<StyleBlockRule> const& block) {
|
||||||
|
return String::formatted("Function: {}", block->to_string());
|
||||||
|
},
|
||||||
|
[](NonnullRefPtr<StyleFunctionRule> const& function) {
|
||||||
|
return String::formatted("Block: {}", function->to_string());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -36,20 +36,6 @@ StyleRule::~StyleRule() = default;
|
||||||
StyleBlockRule::StyleBlockRule() = default;
|
StyleBlockRule::StyleBlockRule() = default;
|
||||||
StyleBlockRule::~StyleBlockRule() = default;
|
StyleBlockRule::~StyleBlockRule() = default;
|
||||||
|
|
||||||
ComponentValue::ComponentValue(Token token)
|
|
||||||
: m_value(token)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
ComponentValue::ComponentValue(NonnullRefPtr<StyleFunctionRule> function)
|
|
||||||
: m_value(function)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
ComponentValue::ComponentValue(NonnullRefPtr<StyleBlockRule> block)
|
|
||||||
: m_value(block)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
ComponentValue::~ComponentValue() = default;
|
|
||||||
|
|
||||||
Declaration::Declaration() = default;
|
Declaration::Declaration() = default;
|
||||||
Declaration::~Declaration() = default;
|
Declaration::~Declaration() = default;
|
||||||
|
|
||||||
|
@ -124,28 +110,6 @@ String StyleBlockRule::to_string() const
|
||||||
return builder.to_string();
|
return builder.to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
String ComponentValue::to_string() const
|
|
||||||
{
|
|
||||||
return m_value.visit(
|
|
||||||
[](Token const& token) { return token.to_string(); },
|
|
||||||
[](NonnullRefPtr<StyleBlockRule> const& block) { return block->to_string(); },
|
|
||||||
[](NonnullRefPtr<StyleFunctionRule> const& function) { return function->to_string(); });
|
|
||||||
}
|
|
||||||
|
|
||||||
String ComponentValue::to_debug_string() const
|
|
||||||
{
|
|
||||||
return m_value.visit(
|
|
||||||
[](Token const& token) {
|
|
||||||
return String::formatted("Token: {}", token.to_debug_string());
|
|
||||||
},
|
|
||||||
[](NonnullRefPtr<StyleBlockRule> const& block) {
|
|
||||||
return String::formatted("Function: {}", block->to_string());
|
|
||||||
},
|
|
||||||
[](NonnullRefPtr<StyleFunctionRule> const& function) {
|
|
||||||
return String::formatted("Block: {}", function->to_string());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
String Declaration::to_string() const
|
String Declaration::to_string() const
|
||||||
{
|
{
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue