| 
									
										
										
										
											2022-04-12 14:14:00 +01:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2020-2021, the SerenityOS developers. | 
					
						
							| 
									
										
										
										
											2023-02-15 11:28:23 +00:00
										 |  |  |  * Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org> | 
					
						
							| 
									
										
										
										
											2022-04-12 14:14:00 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <LibWeb/CSS/Parser/Declaration.h>
 | 
					
						
							|  |  |  | #include <LibWeb/CSS/Serialize.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-12 14:51:19 +01:00
										 |  |  | namespace Web::CSS::Parser { | 
					
						
							| 
									
										
										
										
											2022-04-12 14:14:00 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-15 11:28:23 +00:00
										 |  |  | Declaration::Declaration(FlyString name, Vector<ComponentValue> values, Important important) | 
					
						
							| 
									
										
										
										
											2022-04-12 16:16:55 +01:00
										 |  |  |     : m_name(move(name)) | 
					
						
							|  |  |  |     , m_values(move(values)) | 
					
						
							|  |  |  |     , m_important(move(important)) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-12 14:14:00 +01:00
										 |  |  | Declaration::~Declaration() = default; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-22 13:00:28 +01:00
										 |  |  | String Declaration::to_string() const | 
					
						
							| 
									
										
										
										
											2022-04-12 14:14:00 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     StringBuilder builder; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-22 12:05:44 +01:00
										 |  |  |     serialize_an_identifier(builder, m_name); | 
					
						
							| 
									
										
										
										
											2023-08-22 13:00:28 +01:00
										 |  |  |     builder.append(": "sv); | 
					
						
							|  |  |  |     builder.join(' ', m_values); | 
					
						
							| 
									
										
										
										
											2022-04-12 14:14:00 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (m_important == Important::Yes) | 
					
						
							| 
									
										
										
										
											2023-08-22 13:00:28 +01:00
										 |  |  |         builder.append(" !important"sv); | 
					
						
							| 
									
										
										
										
											2022-04-12 14:14:00 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-22 13:00:28 +01:00
										 |  |  |     return MUST(builder.to_string()); | 
					
						
							| 
									
										
										
										
											2022-04-12 14:14:00 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |