Coverage Report

Created: 2026-06-07 07:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/serenity/Userland/Libraries/LibWeb/CSS/StyleValues/BasicShapeStyleValue.h
Line
Count
Source
1
/*
2
 * Copyright (c) 2024, MacDue <macdue@dueutil.tech>
3
 *
4
 * SPDX-License-Identifier: BSD-2-Clause
5
 */
6
7
#pragma once
8
9
#include <AK/Variant.h>
10
#include <LibGfx/Path.h>
11
#include <LibWeb/CSS/CSSStyleValue.h>
12
#include <LibWeb/CSS/PercentageOr.h>
13
14
namespace Web::CSS {
15
16
struct Polygon {
17
    struct Point {
18
0
        bool operator==(Point const&) const = default;
19
        LengthPercentage x;
20
        LengthPercentage y;
21
    };
22
23
    Gfx::Path to_path(CSSPixelRect reference_box, Layout::Node const&) const;
24
    String to_string() const;
25
26
0
    bool operator==(Polygon const&) const = default;
27
28
    FillRule fill_rule;
29
    Vector<Point> points;
30
};
31
32
// FIXME: Implement other basic shapes. See: https://www.w3.org/TR/css-shapes-1/#basic-shape-functions
33
using BasicShape = Variant<Polygon>;
34
35
class BasicShapeStyleValue : public StyleValueWithDefaultOperators<BasicShapeStyleValue> {
36
public:
37
    static ValueComparingNonnullRefPtr<BasicShapeStyleValue> create(BasicShape basic_shape)
38
0
    {
39
0
        return adopt_ref(*new (nothrow) BasicShapeStyleValue(move(basic_shape)));
40
0
    }
41
    virtual ~BasicShapeStyleValue() override;
42
43
0
    BasicShape const& basic_shape() const { return m_basic_shape; }
44
45
    virtual String to_string() const override;
46
47
0
    bool properties_equal(BasicShapeStyleValue const& other) const { return m_basic_shape == other.m_basic_shape; }
48
49
    Gfx::Path to_path(CSSPixelRect reference_box, Layout::Node const&) const;
50
51
private:
52
    BasicShapeStyleValue(BasicShape basic_shape)
53
0
        : StyleValueWithDefaultOperators(Type::BasicShape)
54
0
        , m_basic_shape(move(basic_shape))
55
0
    {
56
0
    }
57
58
    BasicShape m_basic_shape;
59
};
60
61
}