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/CSS/Parser/DeclarationOrAtRule.cpp | |
parent | 92320f30001e3e64b96bab5e3a5b5e139071f77e (diff) | |
download | serenity-ba7149a27d5adcf7064526ef594e925967b300aa.zip |
LibWeb: Move DeclarationOrAtRule code into DeclarationOrAtRule.cpp
Diffstat (limited to 'Userland/Libraries/LibWeb/CSS/Parser/DeclarationOrAtRule.cpp')
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/Parser/DeclarationOrAtRule.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
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(); +} + +} |