summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/CSS/Display.cpp
blob: 45844cef7f5e3bd8e06f95b6e63f6f332d3c21d9 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
 * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#include <LibWeb/CSS/Display.h>

namespace Web::CSS {

DeprecatedString Display::to_deprecated_string() const
{
    StringBuilder builder;
    switch (m_type) {
    case Type::OutsideAndInside:
        switch (m_value.outside_inside.outside) {
        case Outside::Block:
            builder.append("block"sv);
            break;
        case Outside::Inline:
            builder.append("inline"sv);
            break;
        case Outside::RunIn:
            builder.append("run-in"sv);
            break;
        }
        builder.append(' ');
        switch (m_value.outside_inside.inside) {
        case Inside::Flow:
            builder.append("flow"sv);
            break;
        case Inside::FlowRoot:
            builder.append("flow-root"sv);
            break;
        case Inside::Table:
            builder.append("table"sv);
            break;
        case Inside::Flex:
            builder.append("flex"sv);
            break;
        case Inside::Grid:
            builder.append("grid"sv);
            break;
        case Inside::Ruby:
            builder.append("ruby"sv);
            break;
        }
        if (m_value.outside_inside.list_item == ListItem::Yes)
            builder.append(" list-item"sv);
        break;
    case Type::Internal:
        switch (m_value.internal) {
        case Internal::TableRowGroup:
            builder.append("table-row-group"sv);
            break;
        case Internal::TableHeaderGroup:
            builder.append("table-header-group"sv);
            break;
        case Internal::TableFooterGroup:
            builder.append("table-footer-group"sv);
            break;
        case Internal::TableRow:
            builder.append("table-row"sv);
            break;
        case Internal::TableCell:
            builder.append("table-cell"sv);
            break;
        case Internal::TableColumnGroup:
            builder.append("table-column-group"sv);
            break;
        case Internal::TableColumn:
            builder.append("table-column"sv);
            break;
        case Internal::TableCaption:
            builder.append("table-caption"sv);
            break;
        case Internal::RubyBase:
            builder.append("ruby-base"sv);
            break;
        case Internal::RubyText:
            builder.append("ruby-text"sv);
            break;
        case Internal::RubyBaseContainer:
            builder.append("ruby-base-container"sv);
            break;
        case Internal::RubyTextContainer:
            builder.append("ruby-text-container"sv);
            break;
        }
        break;
    case Type::Box:
        switch (m_value.box) {
        case Box::Contents:
            builder.append("contents"sv);
            break;
        case Box::None:
            builder.append("none"sv);
            break;
        }
        break;
    };
    return builder.to_deprecated_string();
}

}