Coverage Report

Created: 2025-03-04 07:22

/src/serenity/Userland/Libraries/LibWeb/CSS/StyleValues/ContentStyleValue.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
3
 * Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
4
 * Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
5
 * Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech>
6
 *
7
 * SPDX-License-Identifier: BSD-2-Clause
8
 */
9
10
#pragma once
11
12
#include <LibWeb/CSS/CSSStyleValue.h>
13
14
namespace Web::CSS {
15
16
class ContentStyleValue final : public StyleValueWithDefaultOperators<ContentStyleValue> {
17
public:
18
    static ValueComparingNonnullRefPtr<ContentStyleValue> create(ValueComparingNonnullRefPtr<StyleValueList> content, ValueComparingRefPtr<StyleValueList> alt_text)
19
0
    {
20
0
        return adopt_ref(*new (nothrow) ContentStyleValue(move(content), move(alt_text)));
21
0
    }
22
0
    virtual ~ContentStyleValue() override = default;
23
24
0
    StyleValueList const& content() const { return *m_properties.content; }
25
0
    bool has_alt_text() const { return !m_properties.alt_text.is_null(); }
26
0
    StyleValueList const* alt_text() const { return m_properties.alt_text; }
27
28
    virtual String to_string() const override;
29
30
0
    bool properties_equal(ContentStyleValue const& other) const { return m_properties == other.m_properties; }
31
32
private:
33
    ContentStyleValue(ValueComparingNonnullRefPtr<StyleValueList> content, ValueComparingRefPtr<StyleValueList> alt_text)
34
0
        : StyleValueWithDefaultOperators(Type::Content)
35
0
        , m_properties { .content = move(content), .alt_text = move(alt_text) }
36
0
    {
37
0
    }
38
39
    struct Properties {
40
        ValueComparingNonnullRefPtr<StyleValueList> content;
41
        ValueComparingRefPtr<StyleValueList> alt_text;
42
0
        bool operator==(Properties const&) const = default;
43
    } m_properties;
44
};
45
46
}