blob: 3cd4004f84cccd9fba2a579f90cd1881f2129912 (
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
|
/*
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Layout/AvailableSpace.h>
#include <math.h>
namespace Web::Layout {
AvailableSize AvailableSize::make_definite(CSSPixels value)
{
return AvailableSize { Type::Definite, value };
}
AvailableSize AvailableSize::make_indefinite()
{
return AvailableSize { Type::Indefinite, INFINITY };
}
AvailableSize AvailableSize::make_min_content()
{
return AvailableSize { Type::MinContent, 0 };
}
AvailableSize AvailableSize::make_max_content()
{
return AvailableSize { Type::MaxContent, INFINITY };
}
DeprecatedString AvailableSize::to_deprecated_string() const
{
switch (m_type) {
case Type::Definite:
return DeprecatedString::formatted("definite({})", m_value);
case Type::Indefinite:
return "indefinite";
case Type::MinContent:
return "min-content";
case Type::MaxContent:
return "max-content";
}
VERIFY_NOT_REACHED();
}
DeprecatedString AvailableSpace::to_deprecated_string() const
{
return DeprecatedString::formatted("{} x {}", width, height);
}
AvailableSize::AvailableSize(Type type, CSSPixels value)
: m_type(type)
, m_value(value)
{
}
}
|