| 
									
										
										
										
											2023-03-30 16:57:49 +01:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2023, Sam Atkins <atkinssj@serenityos.org> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "CalculatedOr.h"
 | 
					
						
							| 
									
										
										
										
											2023-12-28 17:37:37 +00:00
										 |  |  | #include <LibWeb/CSS/StyleValues/AngleStyleValue.h>
 | 
					
						
							|  |  |  | #include <LibWeb/CSS/StyleValues/FlexStyleValue.h>
 | 
					
						
							|  |  |  | #include <LibWeb/CSS/StyleValues/FrequencyStyleValue.h>
 | 
					
						
							|  |  |  | #include <LibWeb/CSS/StyleValues/IntegerStyleValue.h>
 | 
					
						
							|  |  |  | #include <LibWeb/CSS/StyleValues/LengthStyleValue.h>
 | 
					
						
							|  |  |  | #include <LibWeb/CSS/StyleValues/NumberStyleValue.h>
 | 
					
						
							|  |  |  | #include <LibWeb/CSS/StyleValues/PercentageStyleValue.h>
 | 
					
						
							|  |  |  | #include <LibWeb/CSS/StyleValues/ResolutionStyleValue.h>
 | 
					
						
							|  |  |  | #include <LibWeb/CSS/StyleValues/TimeStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-03-30 16:57:49 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace Web::CSS { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-18 17:27:47 +01:00
										 |  |  | Angle AngleOrCalculated::resolve_calculated(NonnullRefPtr<CSSMathValue> const& calculated, Layout::Node const&) const | 
					
						
							| 
									
										
										
										
											2023-03-30 16:57:49 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     return calculated->resolve_angle().value(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | NonnullRefPtr<CSSStyleValue> AngleOrCalculated::create_style_value() const | 
					
						
							| 
									
										
										
										
											2023-12-28 17:37:37 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     return AngleStyleValue::create(value()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-18 17:27:47 +01:00
										 |  |  | Flex FlexOrCalculated::resolve_calculated(NonnullRefPtr<CSSMathValue> const& calculated, Layout::Node const&) const | 
					
						
							| 
									
										
										
										
											2023-12-27 12:56:00 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     return calculated->resolve_flex().value(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | NonnullRefPtr<CSSStyleValue> FlexOrCalculated::create_style_value() const | 
					
						
							| 
									
										
										
										
											2023-12-28 17:37:37 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     return FlexStyleValue::create(value()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-18 17:27:47 +01:00
										 |  |  | Frequency FrequencyOrCalculated::resolve_calculated(NonnullRefPtr<CSSMathValue> const& calculated, Layout::Node const&) const | 
					
						
							| 
									
										
										
										
											2023-03-30 16:57:49 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     return calculated->resolve_frequency().value(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | NonnullRefPtr<CSSStyleValue> FrequencyOrCalculated::create_style_value() const | 
					
						
							| 
									
										
										
										
											2023-12-28 17:37:37 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     return FrequencyStyleValue::create(value()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-18 17:27:47 +01:00
										 |  |  | i64 IntegerOrCalculated::resolve_calculated(NonnullRefPtr<CSSMathValue> const& calculated, Layout::Node const&) const | 
					
						
							| 
									
										
										
										
											2023-12-27 12:56:00 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     return calculated->resolve_integer().value(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | NonnullRefPtr<CSSStyleValue> IntegerOrCalculated::create_style_value() const | 
					
						
							| 
									
										
										
										
											2023-12-28 17:37:37 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     return IntegerStyleValue::create(value()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-18 17:27:47 +01:00
										 |  |  | Length LengthOrCalculated::resolve_calculated(NonnullRefPtr<CSSMathValue> const& calculated, Layout::Node const& layout_node) const | 
					
						
							| 
									
										
										
										
											2023-03-30 16:57:49 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     return calculated->resolve_length(layout_node).value(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-28 15:52:06 +02:00
										 |  |  | Length LengthOrCalculated::resolved(Length::ResolutionContext const& context) const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (is_calculated()) | 
					
						
							|  |  |  |         return calculated()->resolve_length(context).value(); | 
					
						
							|  |  |  |     return value(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | NonnullRefPtr<CSSStyleValue> LengthOrCalculated::create_style_value() const | 
					
						
							| 
									
										
										
										
											2023-12-28 17:37:37 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     return LengthStyleValue::create(value()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-18 17:27:47 +01:00
										 |  |  | double NumberOrCalculated::resolve_calculated(NonnullRefPtr<CSSMathValue> const& calculated, Layout::Node const&) const | 
					
						
							| 
									
										
										
										
											2023-12-27 12:56:00 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     return calculated->resolve_number().value(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | NonnullRefPtr<CSSStyleValue> NumberOrCalculated::create_style_value() const | 
					
						
							| 
									
										
										
										
											2023-12-28 17:37:37 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     return NumberStyleValue::create(value()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-18 17:27:47 +01:00
										 |  |  | Percentage PercentageOrCalculated::resolve_calculated(NonnullRefPtr<CSSMathValue> const& calculated, Layout::Node const&) const | 
					
						
							| 
									
										
										
										
											2023-03-30 16:57:49 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     return calculated->resolve_percentage().value(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | NonnullRefPtr<CSSStyleValue> PercentageOrCalculated::create_style_value() const | 
					
						
							| 
									
										
										
										
											2023-12-28 17:37:37 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     return PercentageStyleValue::create(value()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-18 17:27:47 +01:00
										 |  |  | Resolution ResolutionOrCalculated::resolve_calculated(NonnullRefPtr<CSSMathValue> const& calculated, Layout::Node const&) const | 
					
						
							| 
									
										
										
										
											2023-12-30 17:05:23 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     return calculated->resolve_resolution().value(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | NonnullRefPtr<CSSStyleValue> ResolutionOrCalculated::create_style_value() const | 
					
						
							| 
									
										
										
										
											2023-12-28 17:37:37 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     return ResolutionStyleValue::create(value()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-18 17:27:47 +01:00
										 |  |  | Time TimeOrCalculated::resolve_calculated(NonnullRefPtr<CSSMathValue> const& calculated, Layout::Node const&) const | 
					
						
							| 
									
										
										
										
											2023-03-30 16:57:49 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     return calculated->resolve_time().value(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | NonnullRefPtr<CSSStyleValue> TimeOrCalculated::create_style_value() const | 
					
						
							| 
									
										
										
										
											2023-12-28 17:37:37 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     return TimeStyleValue::create(value()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-30 16:57:49 +01:00
										 |  |  | } |