| 
									
										
										
										
											2023-03-24 23:47:56 +00:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2024-10-04 13:19:50 +02:00
										 |  |  |  * Copyright (c) 2018-2020, Andreas Kling <andreas@ladybird.org> | 
					
						
							| 
									
										
										
										
											2023-03-24 23:47:56 +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 23:47:56 +00:00
										 |  |  |  * Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-08 11:08:54 +01:00
										 |  |  | #include <LibWeb/CSS/StyleValues/DimensionStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-03-24 23:47:56 +00:00
										 |  |  | #include <LibWeb/CSS/Time.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace Web::CSS { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-08 11:08:54 +01:00
										 |  |  | class TimeStyleValue : public DimensionStyleValue { | 
					
						
							| 
									
										
										
										
											2023-03-24 23:47:56 +00:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2025-04-15 15:18:27 -06:00
										 |  |  |     static ValueComparingNonnullRefPtr<TimeStyleValue const> create(Time time) | 
					
						
							| 
									
										
										
										
											2023-03-24 23:47:56 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2023-08-19 14:00:10 +01:00
										 |  |  |         return adopt_ref(*new (nothrow) TimeStyleValue(move(time))); | 
					
						
							| 
									
										
										
										
											2023-03-24 23:47:56 +00:00
										 |  |  |     } | 
					
						
							|  |  |  |     virtual ~TimeStyleValue() override = default; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Time const& time() const { return m_time; } | 
					
						
							| 
									
										
										
										
											2025-08-08 11:08:54 +01:00
										 |  |  |     virtual double raw_value() const override { return m_time.raw_value(); } | 
					
						
							|  |  |  |     virtual StringView unit_name() const override { return m_time.unit_name(); } | 
					
						
							| 
									
										
										
										
											2023-03-24 23:47:56 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-05-16 20:02:16 +01:00
										 |  |  |     virtual String to_string(SerializationMode serialization_mode) const override { return m_time.to_string(serialization_mode); } | 
					
						
							| 
									
										
										
										
											2023-03-24 23:47:56 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-08 10:11:51 +01:00
										 |  |  |     bool equals(StyleValue const& other) const override | 
					
						
							| 
									
										
										
										
											2024-08-14 16:25:48 +01:00
										 |  |  |     { | 
					
						
							|  |  |  |         if (type() != other.type()) | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         auto const& other_time = other.as_time(); | 
					
						
							|  |  |  |         return m_time == other_time.m_time; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-03-24 23:47:56 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  |     explicit TimeStyleValue(Time time) | 
					
						
							| 
									
										
										
										
											2025-08-08 11:08:54 +01:00
										 |  |  |         : DimensionStyleValue(Type::Time) | 
					
						
							| 
									
										
										
										
											2023-03-24 23:47:56 +00:00
										 |  |  |         , m_time(move(time)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Time m_time; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |