| 
									
										
										
										
											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>
 | 
					
						
							| 
									
										
										
										
											2025-08-08 11:08:54 +01:00
										 |  |  | #include <LibWeb/CSS/StyleValues/DimensionStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2025-07-19 19:35:33 -07:00
										 |  |  | #include <LibWeb/Export.h>
 | 
					
						
							| 
									
										
										
										
											2023-03-24 17:04:04 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace Web::CSS { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-19 19:35:33 -07:00
										 |  |  | class WEB_API LengthStyleValue final : public DimensionStyleValue { | 
					
						
							| 
									
										
										
										
											2023-03-24 17:04:04 +00:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2025-04-15 15:18:27 -06:00
										 |  |  |     static ValueComparingNonnullRefPtr<LengthStyleValue const> create(Length const&); | 
					
						
							| 
									
										
										
										
											2023-03-24 17:04:04 +00:00
										 |  |  |     virtual ~LengthStyleValue() override = default; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Length const& length() const { return m_length; } | 
					
						
							| 
									
										
										
										
											2025-08-08 11:08:54 +01:00
										 |  |  |     virtual double raw_value() const override { return m_length.raw_value(); } | 
					
						
							|  |  |  |     virtual StringView unit_name() const override { return m_length.unit_name(); } | 
					
						
							| 
									
										
										
										
											2023-03-24 17:04:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-05-16 20:02:16 +01:00
										 |  |  |     virtual String to_string(SerializationMode serialization_mode) const override { return m_length.to_string(serialization_mode); } | 
					
						
							| 
									
										
										
										
											2025-08-08 10:11:51 +01:00
										 |  |  |     virtual ValueComparingNonnullRefPtr<StyleValue 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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-08 10:11:51 +01:00
										 |  |  |     bool equals(StyleValue const& other) const override; | 
					
						
							| 
									
										
										
										
											2023-03-24 17:04:04 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  |     explicit LengthStyleValue(Length const& length) | 
					
						
							| 
									
										
										
										
											2025-08-08 11:08:54 +01:00
										 |  |  |         : DimensionStyleValue(Type::Length) | 
					
						
							| 
									
										
										
										
											2023-03-24 17:04:04 +00:00
										 |  |  |         , m_length(length) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Length m_length; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |