/src/serenity/Userland/Libraries/LibWeb/CSS/CalculatedOr.cpp
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2023, Sam Atkins <atkinssj@serenityos.org> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #include "CalculatedOr.h" |
8 | | #include <LibWeb/CSS/StyleValues/AngleStyleValue.h> |
9 | | #include <LibWeb/CSS/StyleValues/FlexStyleValue.h> |
10 | | #include <LibWeb/CSS/StyleValues/FrequencyStyleValue.h> |
11 | | #include <LibWeb/CSS/StyleValues/IntegerStyleValue.h> |
12 | | #include <LibWeb/CSS/StyleValues/LengthStyleValue.h> |
13 | | #include <LibWeb/CSS/StyleValues/NumberStyleValue.h> |
14 | | #include <LibWeb/CSS/StyleValues/PercentageStyleValue.h> |
15 | | #include <LibWeb/CSS/StyleValues/ResolutionStyleValue.h> |
16 | | #include <LibWeb/CSS/StyleValues/TimeStyleValue.h> |
17 | | |
18 | | namespace Web::CSS { |
19 | | |
20 | | Angle AngleOrCalculated::resolve_calculated(NonnullRefPtr<CSSMathValue> const& calculated, Layout::Node const&) const |
21 | 0 | { |
22 | 0 | return calculated->resolve_angle().value(); |
23 | 0 | } |
24 | | |
25 | | NonnullRefPtr<CSSStyleValue> AngleOrCalculated::create_style_value() const |
26 | 0 | { |
27 | 0 | return AngleStyleValue::create(value()); |
28 | 0 | } |
29 | | |
30 | | Flex FlexOrCalculated::resolve_calculated(NonnullRefPtr<CSSMathValue> const& calculated, Layout::Node const&) const |
31 | 0 | { |
32 | 0 | return calculated->resolve_flex().value(); |
33 | 0 | } |
34 | | |
35 | | NonnullRefPtr<CSSStyleValue> FlexOrCalculated::create_style_value() const |
36 | 0 | { |
37 | 0 | return FlexStyleValue::create(value()); |
38 | 0 | } |
39 | | |
40 | | Frequency FrequencyOrCalculated::resolve_calculated(NonnullRefPtr<CSSMathValue> const& calculated, Layout::Node const&) const |
41 | 0 | { |
42 | 0 | return calculated->resolve_frequency().value(); |
43 | 0 | } |
44 | | |
45 | | NonnullRefPtr<CSSStyleValue> FrequencyOrCalculated::create_style_value() const |
46 | 0 | { |
47 | 0 | return FrequencyStyleValue::create(value()); |
48 | 0 | } |
49 | | |
50 | | i64 IntegerOrCalculated::resolve_calculated(NonnullRefPtr<CSSMathValue> const& calculated, Layout::Node const&) const |
51 | 0 | { |
52 | 0 | return calculated->resolve_integer().value(); |
53 | 0 | } |
54 | | |
55 | | NonnullRefPtr<CSSStyleValue> IntegerOrCalculated::create_style_value() const |
56 | 0 | { |
57 | 0 | return IntegerStyleValue::create(value()); |
58 | 0 | } |
59 | | |
60 | | Length LengthOrCalculated::resolve_calculated(NonnullRefPtr<CSSMathValue> const& calculated, Layout::Node const& layout_node) const |
61 | 0 | { |
62 | 0 | return calculated->resolve_length(layout_node).value(); |
63 | 0 | } |
64 | | |
65 | | Length LengthOrCalculated::resolved(Length::ResolutionContext const& context) const |
66 | 0 | { |
67 | 0 | if (is_calculated()) |
68 | 0 | return calculated()->resolve_length(context).value(); |
69 | 0 | return value(); |
70 | 0 | } |
71 | | |
72 | | NonnullRefPtr<CSSStyleValue> LengthOrCalculated::create_style_value() const |
73 | 0 | { |
74 | 0 | return LengthStyleValue::create(value()); |
75 | 0 | } |
76 | | |
77 | | double NumberOrCalculated::resolve_calculated(NonnullRefPtr<CSSMathValue> const& calculated, Layout::Node const&) const |
78 | 0 | { |
79 | 0 | return calculated->resolve_number().value(); |
80 | 0 | } |
81 | | |
82 | | NonnullRefPtr<CSSStyleValue> NumberOrCalculated::create_style_value() const |
83 | 0 | { |
84 | 0 | return NumberStyleValue::create(value()); |
85 | 0 | } |
86 | | |
87 | | Percentage PercentageOrCalculated::resolve_calculated(NonnullRefPtr<CSSMathValue> const& calculated, Layout::Node const&) const |
88 | 0 | { |
89 | 0 | return calculated->resolve_percentage().value(); |
90 | 0 | } |
91 | | |
92 | | NonnullRefPtr<CSSStyleValue> PercentageOrCalculated::create_style_value() const |
93 | 0 | { |
94 | 0 | return PercentageStyleValue::create(value()); |
95 | 0 | } |
96 | | |
97 | | Resolution ResolutionOrCalculated::resolve_calculated(NonnullRefPtr<CSSMathValue> const& calculated, Layout::Node const&) const |
98 | 0 | { |
99 | 0 | return calculated->resolve_resolution().value(); |
100 | 0 | } |
101 | | |
102 | | NonnullRefPtr<CSSStyleValue> ResolutionOrCalculated::create_style_value() const |
103 | 0 | { |
104 | 0 | return ResolutionStyleValue::create(value()); |
105 | 0 | } |
106 | | |
107 | | Time TimeOrCalculated::resolve_calculated(NonnullRefPtr<CSSMathValue> const& calculated, Layout::Node const&) const |
108 | 0 | { |
109 | 0 | return calculated->resolve_time().value(); |
110 | 0 | } |
111 | | |
112 | | NonnullRefPtr<CSSStyleValue> TimeOrCalculated::create_style_value() const |
113 | 0 | { |
114 | 0 | return TimeStyleValue::create(value()); |
115 | 0 | } |
116 | | |
117 | | } |