| 
									
										
										
										
											2022-08-24 12:21:58 +02:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2022, Martin Falisse <mfalisse@outlook.com> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <AK/String.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace Web::CSS { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class GridTrackPlacement { | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2022-09-17 18:09:35 +02:00
										 |  |  |     enum class Type { | 
					
						
							|  |  |  |         Span, | 
					
						
							|  |  |  |         Position, | 
					
						
							|  |  |  |         Auto | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-30 13:46:50 +01:00
										 |  |  |     GridTrackPlacement(String line_name, int span_count_or_position, bool has_span = false); | 
					
						
							| 
									
										
										
										
											2022-10-30 13:40:57 +01:00
										 |  |  |     GridTrackPlacement(int span_count_or_position, bool has_span = false); | 
					
						
							| 
									
										
										
										
											2022-10-30 13:46:50 +01:00
										 |  |  |     GridTrackPlacement(String line_name, bool has_span = false); | 
					
						
							| 
									
										
										
										
											2022-08-24 12:21:58 +02:00
										 |  |  |     GridTrackPlacement(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     static GridTrackPlacement make_auto() { return GridTrackPlacement(); }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-17 18:09:35 +02:00
										 |  |  |     bool is_span() const { return m_type == Type::Span; } | 
					
						
							|  |  |  |     bool is_position() const { return m_type == Type::Position; } | 
					
						
							|  |  |  |     bool is_auto() const { return m_type == Type::Auto; } | 
					
						
							| 
									
										
										
										
											2022-10-30 13:46:50 +01:00
										 |  |  |     bool is_auto_positioned() const { return m_type == Type::Auto || (m_type == Type::Span && !has_line_name()); } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     bool has_line_name() const { return !m_line_name.is_empty(); } | 
					
						
							| 
									
										
										
										
											2022-08-24 12:21:58 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-30 13:40:57 +01:00
										 |  |  |     int raw_value() const { return m_span_count_or_position; } | 
					
						
							| 
									
										
										
										
											2022-09-17 18:09:35 +02:00
										 |  |  |     Type type() const { return m_type; } | 
					
						
							| 
									
										
										
										
											2022-10-30 13:46:50 +01:00
										 |  |  |     String line_name() const { return m_line_name; } | 
					
						
							| 
									
										
										
										
											2022-09-07 15:03:23 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-24 12:21:58 +02:00
										 |  |  |     String to_string() const; | 
					
						
							|  |  |  |     bool operator==(GridTrackPlacement const& other) const | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-10-30 13:40:57 +01:00
										 |  |  |         return m_type == other.type() && m_span_count_or_position == other.raw_value(); | 
					
						
							| 
									
										
										
										
											2022-08-24 12:21:58 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2022-09-17 18:09:35 +02:00
										 |  |  |     Type m_type; | 
					
						
							| 
									
										
										
										
											2022-10-30 13:40:57 +01:00
										 |  |  |     int m_span_count_or_position { 0 }; | 
					
						
							| 
									
										
										
										
											2022-10-30 13:46:50 +01:00
										 |  |  |     String m_line_name; | 
					
						
							| 
									
										
										
										
											2022-08-24 12:21:58 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |