| 
									
										
										
										
											2022-04-12 11:14:12 +01:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2020-2021, the SerenityOS developers. | 
					
						
							|  |  |  |  * Copyright (c) 2021-2022, Sam Atkins <atkinssj@serenityos.org> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-12 14:08:26 +01:00
										 |  |  | #include <LibWeb/CSS/Parser/Block.h>
 | 
					
						
							| 
									
										
										
										
											2022-04-12 11:14:12 +01:00
										 |  |  | #include <LibWeb/CSS/Parser/ComponentValue.h>
 | 
					
						
							| 
									
										
										
										
											2022-04-12 13:35:55 +01:00
										 |  |  | #include <LibWeb/CSS/Parser/Function.h>
 | 
					
						
							| 
									
										
										
										
											2022-04-12 11:14:12 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-12 12:13:10 +01:00
										 |  |  | namespace Web::CSS::Parser { | 
					
						
							| 
									
										
										
										
											2022-04-12 11:14:12 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | ComponentValue::ComponentValue(Token token) | 
					
						
							|  |  |  |     : m_value(token) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-04-12 13:35:55 +01:00
										 |  |  | ComponentValue::ComponentValue(NonnullRefPtr<Function> function) | 
					
						
							| 
									
										
										
										
											2022-04-12 11:14:12 +01:00
										 |  |  |     : m_value(function) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-04-12 14:08:26 +01:00
										 |  |  | ComponentValue::ComponentValue(NonnullRefPtr<Block> block) | 
					
						
							| 
									
										
										
										
											2022-04-12 11:14:12 +01:00
										 |  |  |     : m_value(block) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ComponentValue::~ComponentValue() = default; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | String ComponentValue::to_string() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return m_value.visit( | 
					
						
							|  |  |  |         [](Token const& token) { return token.to_string(); }, | 
					
						
							| 
									
										
										
										
											2022-04-12 14:08:26 +01:00
										 |  |  |         [](NonnullRefPtr<Block> const& block) { return block->to_string(); }, | 
					
						
							| 
									
										
										
										
											2022-04-12 13:35:55 +01:00
										 |  |  |         [](NonnullRefPtr<Function> const& function) { return function->to_string(); }); | 
					
						
							| 
									
										
										
										
											2022-04-12 11:14:12 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | String ComponentValue::to_debug_string() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return m_value.visit( | 
					
						
							|  |  |  |         [](Token const& token) { | 
					
						
							|  |  |  |             return String::formatted("Token: {}", token.to_debug_string()); | 
					
						
							|  |  |  |         }, | 
					
						
							| 
									
										
										
										
											2022-04-12 14:08:26 +01:00
										 |  |  |         [](NonnullRefPtr<Block> const& block) { | 
					
						
							| 
									
										
										
										
											2022-04-12 11:14:12 +01:00
										 |  |  |             return String::formatted("Function: {}", block->to_string()); | 
					
						
							|  |  |  |         }, | 
					
						
							| 
									
										
										
										
											2022-04-12 13:35:55 +01:00
										 |  |  |         [](NonnullRefPtr<Function> const& function) { | 
					
						
							| 
									
										
										
										
											2022-04-12 11:14:12 +01:00
										 |  |  |             return String::formatted("Block: {}", function->to_string()); | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |