mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 19:12:43 +00:00 
			
		
		
		
	 bd9ec60305
			
		
	
	
		bd9ec60305
		
	
	
	
	
		
			
			On the basis of the values passed to the minmax functions, do different actions given different min and max grid track sizes.
		
			
				
	
	
		
			62 lines
		
	
	
	
		
			2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			62 lines
		
	
	
	
		
			2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2022, Martin Falisse <mfalisse@outlook.com>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <LibWeb/Layout/BlockFormattingContext.h>
 | |
| #include <LibWeb/Layout/Box.h>
 | |
| #include <LibWeb/Layout/FormattingContext.h>
 | |
| 
 | |
| namespace Web::Layout {
 | |
| 
 | |
| class GridFormattingContext final : public BlockFormattingContext {
 | |
| public:
 | |
|     explicit GridFormattingContext(LayoutState&, BlockContainer const&, FormattingContext* parent);
 | |
|     ~GridFormattingContext();
 | |
| 
 | |
|     virtual void run(Box const&, LayoutMode, AvailableSpace const& available_space) override;
 | |
|     virtual float automatic_content_height() const override;
 | |
| 
 | |
| private:
 | |
|     float m_automatic_content_height { 0 };
 | |
|     bool is_auto_positioned_row(CSS::GridTrackPlacement const&, CSS::GridTrackPlacement const&) const;
 | |
|     bool is_auto_positioned_column(CSS::GridTrackPlacement const&, CSS::GridTrackPlacement const&) const;
 | |
|     bool is_auto_positioned_track(CSS::GridTrackPlacement const&, CSS::GridTrackPlacement const&) const;
 | |
| 
 | |
|     struct GridTrack {
 | |
|         CSS::GridTrackSize min_track_sizing_function;
 | |
|         CSS::GridTrackSize max_track_sizing_function;
 | |
|         float base_size { 0 };
 | |
|         float growth_limit { 0 };
 | |
|         float space_to_distribute { 0 };
 | |
|         float planned_increase { 0 };
 | |
|     };
 | |
| 
 | |
|     Vector<GridTrack> m_grid_rows;
 | |
|     Vector<GridTrack> m_grid_columns;
 | |
| 
 | |
|     float get_free_space_x(Box const&);
 | |
|     float get_free_space_y(Box const&);
 | |
| };
 | |
| 
 | |
| class OccupationGrid {
 | |
| public:
 | |
|     OccupationGrid(int column_count, int row_count);
 | |
| 
 | |
|     void maybe_add_column(int needed_number_of_columns);
 | |
|     void maybe_add_row(int needed_number_of_rows);
 | |
|     void set_occupied(int column_start, int column_end, int row_start, int row_end);
 | |
|     void set_occupied(int column_index, int row_index);
 | |
| 
 | |
|     int column_count() { return static_cast<int>(m_occupation_grid[0].size()); }
 | |
|     int row_count() { return static_cast<int>(m_occupation_grid.size()); }
 | |
|     bool is_occupied(int column_index, int row_index);
 | |
| 
 | |
| private:
 | |
|     Vector<Vector<bool>> m_occupation_grid;
 | |
| };
 | |
| 
 | |
| }
 |