diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2022-04-12 14:31:49 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-04-12 23:03:46 +0200 |
commit | ba7149a27d5adcf7064526ef594e925967b300aa (patch) | |
tree | 5304ee9fc6b567b068db1b1fbb7130d2d4924382 /Userland/Libraries/LibWeb | |
parent | 92320f30001e3e64b96bab5e3a5b5e139071f77e (diff) | |
download | serenity-ba7149a27d5adcf7064526ef594e925967b300aa.zip |
LibWeb: Move DeclarationOrAtRule code into DeclarationOrAtRule.cpp
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r-- | Userland/Libraries/LibWeb/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/Parser/DeclarationOrAtRule.cpp | 42 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/Parser/StyleRules.cpp | 28 |
3 files changed, 43 insertions, 28 deletions
diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt index 07b583af8d..13cc6987db 100644 --- a/Userland/Libraries/LibWeb/CMakeLists.txt +++ b/Userland/Libraries/LibWeb/CMakeLists.txt @@ -47,6 +47,7 @@ set(SOURCES CSS/Parser/Block.cpp CSS/Parser/ComponentValue.cpp CSS/Parser/Declaration.cpp + CSS/Parser/DeclarationOrAtRule.cpp CSS/Parser/Function.cpp CSS/Parser/Parser.cpp CSS/Parser/StyleRules.cpp diff --git a/Userland/Libraries/LibWeb/CSS/Parser/DeclarationOrAtRule.cpp b/Userland/Libraries/LibWeb/CSS/Parser/DeclarationOrAtRule.cpp new file mode 100644 index 0000000000..637a96255a --- /dev/null +++ b/Userland/Libraries/LibWeb/CSS/Parser/DeclarationOrAtRule.cpp @@ -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(); +} + +} diff --git a/Userland/Libraries/LibWeb/CSS/Parser/StyleRules.cpp b/Userland/Libraries/LibWeb/CSS/Parser/StyleRules.cpp index cfd4012ccd..ca71929a75 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/StyleRules.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/StyleRules.cpp @@ -15,18 +15,6 @@ 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) : 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 { StringBuilder builder; |