| 
									
										
										
										
											2020-11-22 13:38:18 +01:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2020, Andreas Kling <kling@serenityos.org> | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2021-04-22 01:24:48 -07:00
										 |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							| 
									
										
										
										
											2020-11-22 13:38:18 +01:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <AK/Forward.h>
 | 
					
						
							| 
									
										
										
										
											2022-12-04 21:57:21 +03:00
										 |  |  | #include <LibWeb/Layout/FormattingContext.h>
 | 
					
						
							| 
									
										
										
										
											2020-11-22 13:38:18 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace Web::Layout { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-04 21:57:21 +03:00
										 |  |  | class TableFormattingContext final : public FormattingContext { | 
					
						
							| 
									
										
										
										
											2020-11-22 13:38:18 +01:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2022-07-16 23:30:32 +02:00
										 |  |  |     explicit TableFormattingContext(LayoutState&, BlockContainer const&, FormattingContext* parent); | 
					
						
							| 
									
										
										
										
											2020-11-22 13:38:18 +01:00
										 |  |  |     ~TableFormattingContext(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-27 15:29:17 +02:00
										 |  |  |     virtual void run(Box const&, LayoutMode, AvailableSpace const&) override; | 
					
						
							| 
									
										
										
										
											2022-11-23 17:46:10 +00:00
										 |  |  |     virtual CSSPixels automatic_content_height() const override; | 
					
						
							| 
									
										
										
										
											2020-11-22 13:38:18 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2022-12-04 22:39:38 +03:00
										 |  |  |     void calculate_row_column_grid(Box const&); | 
					
						
							|  |  |  |     void compute_table_measures(); | 
					
						
							| 
									
										
										
										
											2022-12-15 12:57:36 +00:00
										 |  |  |     void compute_table_width(CSSPixels&); | 
					
						
							|  |  |  |     void distribute_width_to_columns(CSSPixels extra_width); | 
					
						
							| 
									
										
										
										
											2022-12-04 22:39:38 +03:00
										 |  |  |     void determine_intrisic_size_of_table_container(AvailableSpace const& available_space); | 
					
						
							| 
									
										
										
										
											2022-09-24 13:39:43 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-15 12:57:36 +00:00
										 |  |  |     CSSPixels m_automatic_content_height { 0 }; | 
					
						
							| 
									
										
										
										
											2022-12-04 22:39:38 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-05 18:44:04 +03:00
										 |  |  |     Optional<AvailableSpace> m_available_space; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-04 22:39:38 +03:00
										 |  |  |     struct Column { | 
					
						
							| 
									
										
										
										
											2022-12-15 12:57:36 +00:00
										 |  |  |         CSSPixels left_offset { 0 }; | 
					
						
							|  |  |  |         CSSPixels min_width { 0 }; | 
					
						
							|  |  |  |         CSSPixels max_width { 0 }; | 
					
						
							|  |  |  |         CSSPixels used_width { 0 }; | 
					
						
							| 
									
										
										
										
											2022-12-04 22:39:38 +03:00
										 |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     struct Row { | 
					
						
							|  |  |  |         Box& box; | 
					
						
							| 
									
										
										
										
											2022-12-15 12:57:36 +00:00
										 |  |  |         CSSPixels used_width { 0 }; | 
					
						
							|  |  |  |         CSSPixels baseline { 0 }; | 
					
						
							| 
									
										
										
										
											2022-12-04 22:39:38 +03:00
										 |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     struct Cell { | 
					
						
							|  |  |  |         Box& box; | 
					
						
							|  |  |  |         size_t column_index; | 
					
						
							|  |  |  |         size_t row_index; | 
					
						
							|  |  |  |         size_t column_span; | 
					
						
							| 
									
										
										
										
											2022-12-09 13:36:56 +03:00
										 |  |  |         size_t row_span; | 
					
						
							| 
									
										
										
										
											2022-12-15 12:57:36 +00:00
										 |  |  |         CSSPixels baseline { 0 }; | 
					
						
							| 
									
										
										
										
											2022-12-04 22:39:38 +03:00
										 |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Vector<Cell> m_cells; | 
					
						
							|  |  |  |     Vector<Column> m_columns; | 
					
						
							|  |  |  |     Vector<Row> m_rows; | 
					
						
							| 
									
										
										
										
											2020-11-22 13:38:18 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |