| 
									
										
										
										
											2023-03-25 00:12:21 +00:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2024-10-04 13:19:50 +02:00
										 |  |  |  * Copyright (c) 2018-2020, Andreas Kling <andreas@ladybird.org> | 
					
						
							| 
									
										
										
										
											2023-03-25 00:12:21 +00:00
										 |  |  |  * Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org> | 
					
						
							|  |  |  |  * Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org> | 
					
						
							|  |  |  |  * Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | #include <LibWeb/CSS/CSSStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-03-25 00:12:21 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace Web::CSS { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class StyleValueList final : public StyleValueWithDefaultOperators<StyleValueList> { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     enum class Separator { | 
					
						
							|  |  |  |         Space, | 
					
						
							|  |  |  |         Comma, | 
					
						
							|  |  |  |     }; | 
					
						
							| 
									
										
										
										
											2023-08-19 14:00:10 +01:00
										 |  |  |     static ValueComparingNonnullRefPtr<StyleValueList> create(StyleValueVector&& values, Separator separator) | 
					
						
							| 
									
										
										
										
											2023-05-05 15:02:03 +01:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2023-08-19 14:00:10 +01:00
										 |  |  |         return adopt_ref(*new (nothrow) StyleValueList(move(values), separator)); | 
					
						
							| 
									
										
										
										
											2023-05-05 15:02:03 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-03-25 00:12:21 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     size_t size() const { return m_properties.values.size(); } | 
					
						
							|  |  |  |     StyleValueVector const& values() const { return m_properties.values; } | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  |     ValueComparingNonnullRefPtr<CSSStyleValue const> value_at(size_t i, bool allow_loop) const | 
					
						
							| 
									
										
										
										
											2023-03-25 00:12:21 +00:00
										 |  |  |     { | 
					
						
							|  |  |  |         if (allow_loop) | 
					
						
							|  |  |  |             return m_properties.values[i % size()]; | 
					
						
							|  |  |  |         return m_properties.values[i]; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-22 14:08:15 +01:00
										 |  |  |     virtual String to_string() const override; | 
					
						
							| 
									
										
										
										
											2023-03-25 00:12:21 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     bool properties_equal(StyleValueList const& other) const { return m_properties == other.m_properties; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-03 18:25:13 +01:00
										 |  |  |     Separator separator() const { return m_properties.separator; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-25 00:12:21 +00:00
										 |  |  | private: | 
					
						
							|  |  |  |     StyleValueList(StyleValueVector&& values, Separator separator) | 
					
						
							|  |  |  |         : StyleValueWithDefaultOperators(Type::ValueList) | 
					
						
							|  |  |  |         , m_properties { .separator = separator, .values = move(values) } | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     struct Properties { | 
					
						
							|  |  |  |         Separator separator; | 
					
						
							|  |  |  |         StyleValueVector values; | 
					
						
							|  |  |  |         bool operator==(Properties const&) const; | 
					
						
							|  |  |  |     } m_properties; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |