mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 13:12:46 +00:00 
			
		
		
		
	LibWeb: Give FormattingState a reference to its root state
FormattingStates can have parents, in case we're performing nested layouts to determine something's intrinsic size. In those cases, it will soon be useful to find the outermost (root) state.
This commit is contained in:
		
							parent
							
								
									60c781ebc7
								
							
						
					
					
						commit
						d3932b5880
					
				
					 1 changed files with 15 additions and 1 deletions
				
			
		|  | @ -15,12 +15,25 @@ | |||
| namespace Web::Layout { | ||||
| 
 | ||||
| struct FormattingState { | ||||
|     FormattingState() { } | ||||
|     FormattingState() | ||||
|         : m_root(*this) | ||||
|     { | ||||
|     } | ||||
| 
 | ||||
|     explicit FormattingState(FormattingState const* parent) | ||||
|         : m_parent(parent) | ||||
|         , m_root(find_root()) | ||||
|     { | ||||
|     } | ||||
| 
 | ||||
|     FormattingState const& find_root() const | ||||
|     { | ||||
|         FormattingState const* root = this; | ||||
|         for (auto* state = m_parent; state; state = state->m_parent) | ||||
|             root = state; | ||||
|         return *root; | ||||
|     } | ||||
| 
 | ||||
|     struct NodeState { | ||||
|         float content_width { 0 }; | ||||
|         float content_height { 0 }; | ||||
|  | @ -92,6 +105,7 @@ struct FormattingState { | |||
|     HashMap<NodeWithStyleAndBoxModelMetrics const*, IntrinsicSizes> mutable intrinsic_sizes; | ||||
| 
 | ||||
|     FormattingState const* m_parent { nullptr }; | ||||
|     FormattingState const& m_root; | ||||
| }; | ||||
| 
 | ||||
| Gfx::FloatRect absolute_content_rect(Box const&, FormattingState const&); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling