| 
									
										
										
										
											2023-03-24 17:04:04 +00:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2024-10-04 13:19:50 +02:00
										 |  |  |  * Copyright (c) 2018-2020, Andreas Kling <andreas@ladybird.org> | 
					
						
							| 
									
										
										
										
											2023-03-24 17:04:04 +00:00
										 |  |  |  * Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org> | 
					
						
							| 
									
										
										
										
											2024-08-14 16:25:48 +01:00
										 |  |  |  * Copyright (c) 2021-2024, Sam Atkins <sam@ladybird.org> | 
					
						
							| 
									
										
										
										
											2023-03-24 17:04:04 +00:00
										 |  |  |  * Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 16:25:48 +01:00
										 |  |  | #include <LibWeb/CSS/Length.h>
 | 
					
						
							|  |  |  | #include <LibWeb/CSS/StyleValues/CSSUnitValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-03-24 17:04:04 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace Web::CSS { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 16:25:48 +01:00
										 |  |  | class LengthStyleValue final : public CSSUnitValue { | 
					
						
							| 
									
										
										
										
											2023-03-24 17:04:04 +00:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2023-08-19 14:00:10 +01:00
										 |  |  |     static ValueComparingNonnullRefPtr<LengthStyleValue> create(Length const&); | 
					
						
							| 
									
										
										
										
											2023-03-24 17:04:04 +00:00
										 |  |  |     virtual ~LengthStyleValue() override = default; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Length const& length() const { return m_length; } | 
					
						
							| 
									
										
										
										
											2024-08-14 16:25:48 +01:00
										 |  |  |     virtual double value() const override { return m_length.raw_value(); } | 
					
						
							|  |  |  |     virtual StringView unit() const override { return m_length.unit_name(); } | 
					
						
							| 
									
										
										
										
											2023-03-24 17:04:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-22 14:08:15 +01:00
										 |  |  |     virtual String to_string() const override { return m_length.to_string(); } | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  |     virtual ValueComparingNonnullRefPtr<CSSStyleValue const> absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const override; | 
					
						
							| 
									
										
										
										
											2023-03-24 17:04:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 16:25:48 +01:00
										 |  |  |     bool equals(CSSStyleValue const& other) const override; | 
					
						
							| 
									
										
										
										
											2023-03-24 17:04:04 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  |     explicit LengthStyleValue(Length const& length) | 
					
						
							| 
									
										
										
										
											2024-08-14 16:25:48 +01:00
										 |  |  |         : CSSUnitValue(Type::Length) | 
					
						
							| 
									
										
										
										
											2023-03-24 17:04:04 +00:00
										 |  |  |         , m_length(length) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Length m_length; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |