Coverage Report

Created: 2025-11-16 07:46

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/serenity/Userland/Libraries/LibWeb/CSS/Display.cpp
Line
Count
Source
1
/*
2
 * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
3
 *
4
 * SPDX-License-Identifier: BSD-2-Clause
5
 */
6
7
#include <LibWeb/CSS/Display.h>
8
9
namespace Web::CSS {
10
11
String Display::to_string() const
12
0
{
13
0
    StringBuilder builder;
14
0
    switch (m_type) {
15
0
    case Type::OutsideAndInside:
16
        // NOTE: Following the precedence rules of “most backwards-compatible, then shortest”,
17
        //       serialization of equivalent display values uses the “Short display” column.
18
0
        if (*this == Display::from_short(Display::Short::Block))
19
0
            return "block"_string;
20
0
        if (*this == Display::from_short(Display::Short::FlowRoot))
21
0
            return "flow-root"_string;
22
0
        if (*this == Display::from_short(Display::Short::Inline))
23
0
            return "inline"_string;
24
0
        if (*this == Display::from_short(Display::Short::InlineBlock))
25
0
            return "inline-block"_string;
26
0
        if (*this == Display::from_short(Display::Short::RunIn))
27
0
            return "run-in"_string;
28
0
        if (*this == Display::from_short(Display::Short::ListItem))
29
0
            return "list-item"_string;
30
0
        if (*this == Display::from_short(Display::Short::Flex))
31
0
            return "flex"_string;
32
0
        if (*this == Display::from_short(Display::Short::InlineFlex))
33
0
            return "inline-flex"_string;
34
0
        if (*this == Display::from_short(Display::Short::Grid))
35
0
            return "grid"_string;
36
0
        if (*this == Display::from_short(Display::Short::InlineGrid))
37
0
            return "inline-grid"_string;
38
0
        if (*this == Display::from_short(Display::Short::Ruby))
39
0
            return "ruby"_string;
40
0
        if (*this == Display::from_short(Display::Short::Table))
41
0
            return "table"_string;
42
0
        if (*this == Display::from_short(Display::Short::InlineTable))
43
0
            return "inline-table"_string;
44
45
0
        builder.append(CSS::to_string(m_value.outside_inside.outside));
46
0
        builder.append(' ');
47
0
        builder.append(CSS::to_string(m_value.outside_inside.inside));
48
0
        if (m_value.outside_inside.list_item == ListItem::Yes)
49
0
            builder.append(" list-item"sv);
50
0
        break;
51
0
    case Type::Internal:
52
0
        builder.append(CSS::to_string(m_value.internal));
53
0
        break;
54
0
    case Type::Box:
55
0
        builder.append(CSS::to_string(m_value.box));
56
0
        break;
57
0
    };
58
0
    return MUST(builder.to_string());
59
0
}
60
61
}