summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/CSS/GridTrackPlacement.h
blob: 32483641b7cbb681a89e9fa54f14095389c4f8f9 (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
45
/*
 * Copyright (c) 2022, Martin Falisse <mfalisse@outlook.com>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/String.h>

namespace Web::CSS {

class GridTrackPlacement {
public:
    enum class Type {
        Span,
        Position,
        Auto
    };

    GridTrackPlacement(int, bool = false);
    GridTrackPlacement();

    static GridTrackPlacement make_auto() { return GridTrackPlacement(); };

    bool is_span() const { return m_type == Type::Span; }
    bool is_position() const { return m_type == Type::Position; }
    bool is_auto() const { return m_type == Type::Auto; }
    bool is_auto_positioned() const { return m_type == Type::Auto || m_type == Type::Span; }

    int raw_value() const { return m_value; }
    Type type() const { return m_type; }

    String to_string() const;
    bool operator==(GridTrackPlacement const& other) const
    {
        return m_type == other.type() && m_value == other.raw_value();
    }

private:
    Type m_type;
    int m_value { 0 };
};

}