Coverage Report

Created: 2026-02-14 08:01

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/serenity/Userland/Libraries/LibWeb/CSS/StyleValues/BasicShapeStyleValue.cpp
Line
Count
Source
1
/*
2
 * Copyright (c) 2024, MacDue <macdue@dueutil.tech>
3
 *
4
 * SPDX-License-Identifier: BSD-2-Clause
5
 */
6
7
#include "BasicShapeStyleValue.h"
8
9
namespace Web::CSS {
10
11
Gfx::Path Polygon::to_path(CSSPixelRect reference_box, Layout::Node const& node) const
12
0
{
13
0
    Gfx::Path path;
14
0
    bool first = true;
15
0
    for (auto const& point : points) {
16
0
        Gfx::FloatPoint resolved_point {
17
0
            static_cast<float>(point.x.to_px(node, reference_box.width())),
18
0
            static_cast<float>(point.y.to_px(node, reference_box.height()))
19
0
        };
20
0
        if (first)
21
0
            path.move_to(resolved_point);
22
0
        else
23
0
            path.line_to(resolved_point);
24
0
        first = false;
25
0
    }
26
0
    path.close();
27
0
    return path;
28
0
}
29
30
String Polygon::to_string() const
31
0
{
32
0
    StringBuilder builder;
33
0
    builder.append("polygon("sv);
34
0
    bool first = true;
35
0
    for (auto const& point : points) {
36
0
        if (!first)
37
0
            builder.append(',');
38
0
        builder.appendff("{} {}", point.x, point.y);
39
0
        first = false;
40
0
    }
41
0
    builder.append(')');
42
0
    return MUST(builder.to_string());
43
0
}
44
45
0
BasicShapeStyleValue::~BasicShapeStyleValue() = default;
46
47
Gfx::Path BasicShapeStyleValue::to_path(CSSPixelRect reference_box, Layout::Node const& node) const
48
0
{
49
0
    return m_basic_shape.visit([&](auto const& shape) {
50
0
        return shape.to_path(reference_box, node);
51
0
    });
52
0
}
53
54
String BasicShapeStyleValue::to_string() const
55
0
{
56
0
    return m_basic_shape.visit([](auto const& shape) {
57
0
        return shape.to_string();
58
0
    });
59
0
}
60
61
}