mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-30 23:02:44 +00:00 
			
		
		
		
	LibWeb: Rework the layout engine to use relative offsets
The box tree and line boxes now all store a relative offset from their containing block, instead of an absolute (document-relative) position. This removes a huge pain point from the layout system which was having to adjust offsets recursively when something moved. It also makes some layout logic significantly simpler. Every box can still find its absolute position by walking its chain of containing blocks and accumulating the translation from the root. This is currently what we do both for rendering and hit testing.
This commit is contained in:
		
							parent
							
								
									e836f09094
								
							
						
					
					
						commit
						656b01eb0f
					
				
					 21 changed files with 183 additions and 119 deletions
				
			
		|  | @ -161,14 +161,14 @@ void PageView::layout_and_sync_size() | |||
| 
 | ||||
|     page().main_frame().set_size(available_size()); | ||||
|     document()->layout(); | ||||
|     set_content_size(enclosing_int_rect(layout_root()->rect()).size()); | ||||
|     set_content_size(layout_root()->size().to_int_size()); | ||||
| 
 | ||||
|     // NOTE: If layout caused us to gain or lose scrollbars, we have to lay out again
 | ||||
|     //       since the scrollbars now take up some of the available space.
 | ||||
|     if (had_vertical_scrollbar != vertical_scrollbar().is_visible() || had_horizontal_scrollbar != horizontal_scrollbar().is_visible()) { | ||||
|         page().main_frame().set_size(available_size()); | ||||
|         document()->layout(); | ||||
|         set_content_size(enclosing_int_rect(layout_root()->rect()).size()); | ||||
|         set_content_size(layout_root()->size().to_int_size()); | ||||
|     } | ||||
| 
 | ||||
|     page().main_frame().set_viewport_rect(viewport_rect_in_content_coordinates()); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling