| 
									
										
										
										
											2022-08-24 12:21:58 +02:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2023-08-25 23:29:13 +02:00
										 |  |  |  * Copyright (c) 2023, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com> | 
					
						
							| 
									
										
										
										
											2022-08-24 12:21:58 +02:00
										 |  |  |  * Copyright (c) 2022, Martin Falisse <mfalisse@outlook.com> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "GridTrackPlacement.h"
 | 
					
						
							| 
									
										
										
										
											2023-01-16 17:29:15 +01:00
										 |  |  | #include <AK/StringBuilder.h>
 | 
					
						
							| 
									
										
										
										
											2022-08-24 12:21:58 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace Web::CSS { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-04 22:04:18 +12:00
										 |  |  | String GridTrackPlacement::to_string(SerializationMode mode) const | 
					
						
							| 
									
										
										
										
											2022-08-24 12:21:58 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     StringBuilder builder; | 
					
						
							| 
									
										
										
										
											2023-08-25 23:29:13 +02:00
										 |  |  |     m_value.visit( | 
					
						
							|  |  |  |         [&](Auto const&) { | 
					
						
							|  |  |  |             builder.append("auto"sv); | 
					
						
							|  |  |  |         }, | 
					
						
							| 
									
										
										
										
											2023-08-27 16:27:35 +02:00
										 |  |  |         [&](AreaOrLine const& area_or_line) { | 
					
						
							|  |  |  |             if (area_or_line.line_number.has_value() && area_or_line.name.has_value()) { | 
					
						
							| 
									
										
										
										
											2025-08-04 22:04:18 +12:00
										 |  |  |                 builder.appendff("{} {}", area_or_line.line_number->to_string(mode), *area_or_line.name); | 
					
						
							| 
									
										
										
										
											2023-08-27 16:27:35 +02:00
										 |  |  |             } else if (area_or_line.line_number.has_value()) { | 
					
						
							| 
									
										
										
										
											2025-08-04 22:04:18 +12:00
										 |  |  |                 builder.appendff("{}", area_or_line.line_number->to_string(mode)); | 
					
						
							| 
									
										
										
										
											2025-03-18 15:00:44 +00:00
										 |  |  |             } else if (area_or_line.name.has_value()) { | 
					
						
							| 
									
										
										
										
											2023-08-27 16:27:35 +02:00
										 |  |  |                 builder.appendff("{}", *area_or_line.name); | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2023-08-25 23:29:13 +02:00
										 |  |  |         }, | 
					
						
							|  |  |  |         [&](Span const& span) { | 
					
						
							| 
									
										
										
										
											2025-07-08 14:31:40 +12:00
										 |  |  |             builder.append("span"sv); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if (!span.name.has_value() || span.value.is_calculated() || span.value.value() != 1) | 
					
						
							| 
									
										
										
										
											2025-08-04 22:04:18 +12:00
										 |  |  |                 builder.appendff(" {}", span.value.to_string(mode)); | 
					
						
							| 
									
										
										
										
											2025-07-08 14:31:40 +12:00
										 |  |  | 
 | 
					
						
							|  |  |  |             if (span.name.has_value()) | 
					
						
							|  |  |  |                 builder.appendff(" {}", span.name.value()); | 
					
						
							| 
									
										
										
										
											2023-08-25 23:29:13 +02:00
										 |  |  |         }); | 
					
						
							| 
									
										
										
										
											2023-08-22 12:35:16 +01:00
										 |  |  |     return MUST(builder.to_string()); | 
					
						
							| 
									
										
										
										
											2022-08-24 12:21:58 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |