summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/CSS/StyleValues/EdgeStyleValue.h
blob: ca23e9174d8fedbf999389503716129a4c89ee8b (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
/*
 * Copyright (c) 2023, MacDue <macdue@dueutil.tech>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <LibWeb/CSS/Enums.h>
#include <LibWeb/CSS/PercentageOr.h>
#include <LibWeb/CSS/StyleValue.h>

namespace Web::CSS {

class EdgeStyleValue final : public StyleValueWithDefaultOperators<EdgeStyleValue> {
public:
    static ValueComparingNonnullRefPtr<EdgeStyleValue> create(PositionEdge edge, LengthPercentage const& offset)
    {
        return adopt_ref(*new EdgeStyleValue(edge, offset));
    }
    virtual ~EdgeStyleValue() override = default;

    PositionEdge edge() const { return m_properties.edge; }
    LengthPercentage const& offset() const { return m_properties.offset; }

    virtual ErrorOr<String> to_string() const override;

    bool properties_equal(EdgeStyleValue const& other) const { return m_properties == other.m_properties; }

private:
    EdgeStyleValue(PositionEdge edge, LengthPercentage const& offset)
        : StyleValueWithDefaultOperators(Type::Edge)
        , m_properties { .edge = edge, .offset = offset }
    {
    }

    struct Properties {
        PositionEdge edge;
        LengthPercentage offset;
        bool operator==(Properties const&) const = default;
    } m_properties;
};

}