mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 09:27:34 +00:00
LibWeb: Move Declaration code into Declaration.cpp
This commit is contained in:
parent
3e49036edf
commit
6848a0ef05
3 changed files with 31 additions and 17 deletions
|
@ -46,6 +46,7 @@ set(SOURCES
|
||||||
CSS/MediaQueryList.cpp
|
CSS/MediaQueryList.cpp
|
||||||
CSS/Parser/Block.cpp
|
CSS/Parser/Block.cpp
|
||||||
CSS/Parser/ComponentValue.cpp
|
CSS/Parser/ComponentValue.cpp
|
||||||
|
CSS/Parser/Declaration.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
|
||||||
|
|
30
Userland/Libraries/LibWeb/CSS/Parser/Declaration.cpp
Normal file
30
Userland/Libraries/LibWeb/CSS/Parser/Declaration.cpp
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
* 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/Declaration.h>
|
||||||
|
#include <LibWeb/CSS/Serialize.h>
|
||||||
|
|
||||||
|
namespace Web::CSS {
|
||||||
|
|
||||||
|
Declaration::Declaration() = default;
|
||||||
|
Declaration::~Declaration() = default;
|
||||||
|
|
||||||
|
String Declaration::to_string() const
|
||||||
|
{
|
||||||
|
StringBuilder builder;
|
||||||
|
|
||||||
|
serialize_an_identifier(builder, m_name);
|
||||||
|
builder.append(": ");
|
||||||
|
builder.join(" ", m_values);
|
||||||
|
|
||||||
|
if (m_important == Important::Yes)
|
||||||
|
builder.append(" !important");
|
||||||
|
|
||||||
|
return builder.to_string();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -33,9 +33,6 @@ StyleRule::StyleRule(StyleRule::Type type)
|
||||||
}
|
}
|
||||||
StyleRule::~StyleRule() = default;
|
StyleRule::~StyleRule() = default;
|
||||||
|
|
||||||
Declaration::Declaration() = default;
|
|
||||||
Declaration::~Declaration() = default;
|
|
||||||
|
|
||||||
template<class SeparatorType, class CollectionType>
|
template<class SeparatorType, class CollectionType>
|
||||||
void append_with_to_string(StringBuilder& builder, SeparatorType& separator, CollectionType& collection)
|
void append_with_to_string(StringBuilder& builder, SeparatorType& separator, CollectionType& collection)
|
||||||
{
|
{
|
||||||
|
@ -83,18 +80,4 @@ String StyleRule::to_string() const
|
||||||
|
|
||||||
return builder.to_string();
|
return builder.to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
String Declaration::to_string() const
|
|
||||||
{
|
|
||||||
StringBuilder builder;
|
|
||||||
|
|
||||||
serialize_an_identifier(builder, m_name);
|
|
||||||
builder.append(": ");
|
|
||||||
append_with_to_string(builder, " ", m_values);
|
|
||||||
|
|
||||||
if (m_important == Important::Yes)
|
|
||||||
builder.append(" !important");
|
|
||||||
|
|
||||||
return builder.to_string();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue