blob: bce71af1c421938591c9bba5698e918b69499831 (
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
/*
* Copyright (c) 2022, Martin Falisse <mfalisse@outlook.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/CSS/Length.h>
#include <LibWeb/CSS/Percentage.h>
namespace Web::CSS {
class GridTrackSize {
public:
enum class Type {
Length,
Percentage,
FlexibleLength,
// TODO: MinMax
// TODO: Repeat
// TODO: Max-Content
};
GridTrackSize(Length);
GridTrackSize(Percentage);
GridTrackSize(float);
~GridTrackSize();
static GridTrackSize make_auto();
Type type() const { return m_type; }
bool is_length() const { return m_type == Type::Length; }
bool is_percentage() const { return m_type == Type::Percentage; }
bool is_flexible_length() const { return m_type == Type::FlexibleLength; }
Length length() const;
Percentage percentage() const { return m_percentage; }
float flexible_length() const { return m_flexible_length; }
// https://drafts.csswg.org/css-grid/#layout-algorithm
// Intrinsic sizing function - min-content, max-content, auto, fit-content()
// FIXME: Add missing properties once implemented.
bool is_intrinsic_track_sizing() const
{
return (m_type == Type::Length && m_length.is_auto());
}
String to_string() const;
bool operator==(GridTrackSize const& other) const
{
return m_type == other.type()
&& m_length == other.length()
&& m_percentage == other.percentage()
&& m_flexible_length == other.flexible_length();
}
private:
Type m_type;
// Length includes a RefPtr<CalculatedStyleValue> member, but we can't include the header StyleValue.h as it includes
// this file already. To break the cyclic dependency, we must initialize m_length in the constructor.
Length m_length;
Percentage m_percentage { Percentage(0) };
float m_flexible_length { 0 };
};
}
|