| 
									
										
										
										
											2023-06-01 17:01:09 +01:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2025-07-10 12:17:27 +01:00
										 |  |  |  * Copyright (c) 2023-2025, Sam Atkins <sam@ladybird.org> | 
					
						
							| 
									
										
										
										
											2023-06-01 17:01:09 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-08 10:55:30 +01:00
										 |  |  | #include <LibWeb/CSS/StyleValues/StyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-06-01 17:01:09 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace Web::CSS { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-08 10:55:30 +01:00
										 |  |  | class IntegerStyleValue final : public StyleValue { | 
					
						
							| 
									
										
										
										
											2023-06-01 17:01:09 +01:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2025-04-15 15:18:27 -06:00
										 |  |  |     static ValueComparingNonnullRefPtr<IntegerStyleValue const> create(i64 value) | 
					
						
							| 
									
										
										
										
											2023-06-01 17:01:09 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2023-08-19 14:00:10 +01:00
										 |  |  |         return adopt_ref(*new (nothrow) IntegerStyleValue(value)); | 
					
						
							| 
									
										
										
										
											2023-06-01 17:01:09 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     i64 integer() const { return m_value; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-07 00:59:49 +01:00
										 |  |  |     virtual String to_string(SerializationMode) const override; | 
					
						
							| 
									
										
										
										
											2025-07-10 12:17:27 +01:00
										 |  |  |     virtual Vector<Parser::ComponentValue> tokenize() const override; | 
					
						
							| 
									
										
										
										
											2025-08-18 15:29:22 +01:00
										 |  |  |     virtual GC::Ref<CSSStyleValue> reify(JS::Realm&, String const& associated_property) const override; | 
					
						
							| 
									
										
										
										
											2023-06-01 17:01:09 +01: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_integer = other.as_integer(); | 
					
						
							|  |  |  |         return m_value == other_integer.m_value; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-06-01 17:01:09 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  |     explicit IntegerStyleValue(i64 value) | 
					
						
							| 
									
										
										
										
											2025-08-08 10:55:30 +01:00
										 |  |  |         : StyleValue(Type::Integer) | 
					
						
							| 
									
										
										
										
											2023-06-01 17:01:09 +01:00
										 |  |  |         , m_value(value) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     i64 m_value { 0 }; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |