| 
									
										
										
										
											2023-05-26 23:16:43 +03:30
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2023, Ali Mohammad Pur <mpfard@serenityos.org> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  | #include <LibWeb/CSS/CSSStyleValue.h>
 | 
					
						
							| 
									
										
										
										
											2023-05-26 23:16:43 +03:30
										 |  |  | 
 | 
					
						
							|  |  |  | namespace Web::CSS { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-09-19 12:21:15 +01:00
										 |  |  | class ShorthandStyleValue final : public StyleValueWithDefaultOperators<ShorthandStyleValue> { | 
					
						
							| 
									
										
										
										
											2023-05-26 23:16:43 +03:30
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  |     static ValueComparingNonnullRefPtr<ShorthandStyleValue> create(PropertyID shorthand, Vector<PropertyID> sub_properties, Vector<ValueComparingNonnullRefPtr<CSSStyleValue const>> values) | 
					
						
							| 
									
										
										
										
											2023-05-26 23:16:43 +03:30
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2023-09-19 16:26:23 +01:00
										 |  |  |         return adopt_ref(*new ShorthandStyleValue(shorthand, move(sub_properties), move(values))); | 
					
						
							| 
									
										
										
										
											2023-05-26 23:16:43 +03:30
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-09-19 12:21:15 +01:00
										 |  |  |     virtual ~ShorthandStyleValue() override; | 
					
						
							| 
									
										
										
										
											2023-05-26 23:16:43 +03:30
										 |  |  | 
 | 
					
						
							|  |  |  |     Vector<PropertyID> const& sub_properties() const { return m_properties.sub_properties; } | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  |     Vector<ValueComparingNonnullRefPtr<CSSStyleValue const>> const& values() const { return m_properties.values; } | 
					
						
							| 
									
										
										
										
											2023-05-26 23:16:43 +03:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  |     ValueComparingRefPtr<CSSStyleValue const> longhand(PropertyID) const; | 
					
						
							| 
									
										
										
										
											2023-09-19 16:26:23 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-07 00:59:49 +01:00
										 |  |  |     virtual String to_string(SerializationMode) const override; | 
					
						
							| 
									
										
										
										
											2023-05-26 23:16:43 +03:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-09-19 12:21:15 +01:00
										 |  |  |     bool properties_equal(ShorthandStyleValue const& other) const { return m_properties == other.m_properties; } | 
					
						
							| 
									
										
										
										
											2023-05-26 23:16:43 +03:30
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  |     ShorthandStyleValue(PropertyID shorthand, Vector<PropertyID> sub_properties, Vector<ValueComparingNonnullRefPtr<CSSStyleValue const>> values); | 
					
						
							| 
									
										
										
										
											2023-05-26 23:16:43 +03:30
										 |  |  | 
 | 
					
						
							|  |  |  |     struct Properties { | 
					
						
							| 
									
										
										
										
											2023-09-19 16:26:23 +01:00
										 |  |  |         PropertyID shorthand_property; | 
					
						
							| 
									
										
										
										
											2023-05-26 23:16:43 +03:30
										 |  |  |         Vector<PropertyID> sub_properties; | 
					
						
							| 
									
										
										
										
											2024-08-14 11:10:54 +01:00
										 |  |  |         Vector<ValueComparingNonnullRefPtr<CSSStyleValue const>> values; | 
					
						
							| 
									
										
										
										
											2023-05-26 23:16:43 +03:30
										 |  |  |         bool operator==(Properties const&) const = default; | 
					
						
							|  |  |  |     } m_properties; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |