summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/CSS/Parser/DeclarationOrAtRule.cpp
blob: 637a96255aefba0ee78f72d65434c2a7086d354a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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();
}

}