| 
									
										
										
										
											2024-07-24 15:47:11 +01:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2024, Sam Atkins <atkinssj@serenityos.org> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <AK/FlyString.h>
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | #include <LibWeb/CSS/CSSStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2024-07-24 15:47:11 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace Web::CSS { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct CounterDefinition { | 
					
						
							|  |  |  |     FlyString name; | 
					
						
							|  |  |  |     bool is_reversed; | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  |     ValueComparingRefPtr<CSSStyleValue const> value; | 
					
						
							| 
									
										
										
										
											2024-07-24 15:47:11 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * Holds a list of CounterDefinitions. | 
					
						
							|  |  |  |  * Shared between counter-increment, counter-reset, and counter-set properties that have (almost) identical grammar. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | class CounterDefinitionsStyleValue : public StyleValueWithDefaultOperators<CounterDefinitionsStyleValue> { | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2025-04-15 15:18:27 -06:00
										 |  |  |     static ValueComparingNonnullRefPtr<CounterDefinitionsStyleValue const> create(Vector<CounterDefinition> counter_definitions) | 
					
						
							| 
									
										
										
										
											2024-07-24 15:47:11 +01:00
										 |  |  |     { | 
					
						
							|  |  |  |         return adopt_ref(*new (nothrow) CounterDefinitionsStyleValue(move(counter_definitions))); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     virtual ~CounterDefinitionsStyleValue() override = default; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     auto const& counter_definitions() const { return m_counter_definitions; } | 
					
						
							| 
									
										
										
										
											2024-12-07 00:59:49 +01:00
										 |  |  |     virtual String to_string(SerializationMode) const override; | 
					
						
							| 
									
										
										
										
											2024-07-24 15:47:11 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     bool properties_equal(CounterDefinitionsStyleValue const& other) const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  |     explicit CounterDefinitionsStyleValue(Vector<CounterDefinition> counter_definitions) | 
					
						
							|  |  |  |         : StyleValueWithDefaultOperators(Type::CounterDefinitions) | 
					
						
							|  |  |  |         , m_counter_definitions(move(counter_definitions)) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Vector<CounterDefinition> m_counter_definitions; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |