diff options
-rw-r--r-- | Userland/Libraries/LibWeb/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/Parser/StyleFunctionRule.cpp | 38 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/Parser/StyleRules.cpp | 24 |
3 files changed, 39 insertions, 24 deletions
diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt index cc7177f99d..020e4838de 100644 --- a/Userland/Libraries/LibWeb/CMakeLists.txt +++ b/Userland/Libraries/LibWeb/CMakeLists.txt @@ -46,6 +46,7 @@ set(SOURCES CSS/MediaQueryList.cpp CSS/Parser/ComponentValue.cpp CSS/Parser/Parser.cpp + CSS/Parser/StyleFunctionRule.cpp CSS/Parser/StyleRules.cpp CSS/Parser/Token.cpp CSS/Parser/Tokenizer.cpp diff --git a/Userland/Libraries/LibWeb/CSS/Parser/StyleFunctionRule.cpp b/Userland/Libraries/LibWeb/CSS/Parser/StyleFunctionRule.cpp new file mode 100644 index 0000000000..f3978fd437 --- /dev/null +++ b/Userland/Libraries/LibWeb/CSS/Parser/StyleFunctionRule.cpp @@ -0,0 +1,38 @@ +/* + * 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/StyleFunctionRule.h> +#include <LibWeb/CSS/Serialize.h> + +namespace Web::CSS { + +StyleFunctionRule::StyleFunctionRule(String name) + : m_name(move(name)) +{ +} + +StyleFunctionRule::StyleFunctionRule(String name, Vector<Parser::ComponentValue>&& values) + : m_name(move(name)) + , m_values(move(values)) +{ +} + +StyleFunctionRule::~StyleFunctionRule() = default; + +String StyleFunctionRule::to_string() const +{ + StringBuilder builder; + + serialize_an_identifier(builder, m_name); + builder.append("("); + builder.join(" ", m_values); + builder.append(")"); + + return builder.to_string(); +} + +} diff --git a/Userland/Libraries/LibWeb/CSS/Parser/StyleRules.cpp b/Userland/Libraries/LibWeb/CSS/Parser/StyleRules.cpp index a8bf8e9743..b46001cc53 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/StyleRules.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/StyleRules.cpp @@ -39,18 +39,6 @@ StyleBlockRule::~StyleBlockRule() = default; Declaration::Declaration() = default; Declaration::~Declaration() = default; -StyleFunctionRule::StyleFunctionRule(String name) - : m_name(move(name)) -{ -} - -StyleFunctionRule::StyleFunctionRule(String name, Vector<Parser::ComponentValue>&& values) - : m_name(move(name)) - , m_values(move(values)) -{ -} -StyleFunctionRule::~StyleFunctionRule() = default; - template<class SeparatorType, class CollectionType> void append_with_to_string(StringBuilder& builder, SeparatorType& separator, CollectionType& collection) { @@ -123,16 +111,4 @@ String Declaration::to_string() const return builder.to_string(); } - -String StyleFunctionRule::to_string() const -{ - StringBuilder builder; - - serialize_an_identifier(builder, m_name); - builder.append("("); - append_with_to_string(builder, " ", m_values); - builder.append(")"); - - return builder.to_string(); -} } |