summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/CSS/StyleValues/GridTrackPlacementShorthandStyleValue.h
blob: c9345eaa9110237bdc8c3f065db749bd7efc1b96 (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
/*
 * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
 * Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
 * Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
 * Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <LibWeb/CSS/StyleValue.h>

namespace Web::CSS {

class GridTrackPlacementShorthandStyleValue final : public StyleValueWithDefaultOperators<GridTrackPlacementShorthandStyleValue> {
public:
    static ValueComparingNonnullRefPtr<GridTrackPlacementShorthandStyleValue> create(ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> start, ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> end);
    static ValueComparingNonnullRefPtr<GridTrackPlacementShorthandStyleValue> create(GridTrackPlacement start);
    virtual ~GridTrackPlacementShorthandStyleValue() override = default;

    auto start() const { return m_properties.start; }
    auto end() const { return m_properties.end; }

    virtual ErrorOr<String> to_string() const override;

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

private:
    GridTrackPlacementShorthandStyleValue(ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> start, ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> end)
        : StyleValueWithDefaultOperators(Type::GridTrackPlacementShorthand)
        , m_properties { .start = move(start), .end = move(end) }
    {
    }

    struct Properties {
        ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> start;
        ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> end;
        bool operator==(Properties const&) const = default;
    } m_properties;
};

}