| 
									
										
										
										
											2022-04-12 14:31:49 +01:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2020-2021, the SerenityOS developers. | 
					
						
							|  |  |  |  * Copyright (c) 2021-2022, Sam Atkins <atkinssj@serenityos.org> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <LibWeb/CSS/Parser/DeclarationOrAtRule.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-12 14:51:19 +01:00
										 |  |  | namespace Web::CSS::Parser { | 
					
						
							| 
									
										
										
										
											2022-04-12 14:31:49 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | DeclarationOrAtRule::DeclarationOrAtRule(RefPtr<StyleRule> at) | 
					
						
							|  |  |  |     : m_type(DeclarationType::At) | 
					
						
							|  |  |  |     , m_at(move(at)) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | DeclarationOrAtRule::DeclarationOrAtRule(Declaration declaration) | 
					
						
							|  |  |  |     : m_type(DeclarationType::Declaration) | 
					
						
							|  |  |  |     , m_declaration(move(declaration)) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | DeclarationOrAtRule::~DeclarationOrAtRule() = default; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | String DeclarationOrAtRule::to_string() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     StringBuilder builder; | 
					
						
							|  |  |  |     switch (m_type) { | 
					
						
							|  |  |  |     default: | 
					
						
							|  |  |  |     case DeclarationType::At: | 
					
						
							|  |  |  |         builder.append(m_at->to_string()); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     case DeclarationType::Declaration: | 
					
						
							|  |  |  |         builder.append(m_declaration.to_string()); | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return builder.to_string(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |