mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-27 03:37:53 +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:
@@ -59,7 +59,7 @@ void LayoutWidget::did_set_rect()
|
||||
|
||||
void LayoutWidget::update_widget()
|
||||
{
|
||||
auto adjusted_widget_position = rect().location().to_int_point();
|
||||
auto adjusted_widget_position = absolute_rect().location().to_int_point();
|
||||
auto& page_view = static_cast<const PageView&>(document().frame()->page().client());
|
||||
adjusted_widget_position.move_by(-page_view.horizontal_scrollbar().value(), -page_view.vertical_scrollbar().value());
|
||||
widget().move_to(adjusted_widget_position);
|
||||
|
||||
Reference in New Issue
Block a user