mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 16:45:03 +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:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user