1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:38:11 +00:00

LibWeb: Move box_type_agnostic_position() from layout node to paintable

For this method, there is no need to go through the layout node when we
can directly reach the paintable.
This commit is contained in:
Aliaksandr Kalenik 2024-01-14 11:14:20 +01:00 committed by Andreas Kling
parent 31e5b5f5de
commit 814bed33b4
8 changed files with 39 additions and 36 deletions

View file

@ -215,7 +215,7 @@ int HTMLElement::offset_top() const
// ignoring any transforms that apply to the element and its ancestors, and terminate this algorithm.
auto offset_parent = this->offset_parent();
if (!offset_parent || !offset_parent->layout_node()) {
auto position = layout_node()->box_type_agnostic_position();
auto position = paintable()->box_type_agnostic_position();
return position.y().to_int();
}
@ -224,8 +224,8 @@ int HTMLElement::offset_top() const
// from the y-coordinate of the top border edge of the first box associated with the element,
// relative to the initial containing block origin,
// ignoring any transforms that apply to the element and its ancestors.
auto offset_parent_position = offset_parent->layout_node()->box_type_agnostic_position();
auto position = layout_node()->box_type_agnostic_position();
auto offset_parent_position = offset_parent->paintable()->box_type_agnostic_position();
auto position = paintable()->box_type_agnostic_position();
return position.y().to_int() - offset_parent_position.y().to_int();
}
@ -248,7 +248,7 @@ int HTMLElement::offset_left() const
// ignoring any transforms that apply to the element and its ancestors, and terminate this algorithm.
auto offset_parent = this->offset_parent();
if (!offset_parent || !offset_parent->layout_node()) {
auto position = layout_node()->box_type_agnostic_position();
auto position = paintable()->box_type_agnostic_position();
return position.x().to_int();
}
@ -257,8 +257,8 @@ int HTMLElement::offset_left() const
// from the x-coordinate of the left border edge of the first CSS layout box associated with the element,
// relative to the initial containing block origin,
// ignoring any transforms that apply to the element and its ancestors.
auto offset_parent_position = offset_parent->layout_node()->box_type_agnostic_position();
auto position = layout_node()->box_type_agnostic_position();
auto offset_parent_position = offset_parent->paintable()->box_type_agnostic_position();
auto position = paintable()->box_type_agnostic_position();
return position.x().to_int() - offset_parent_position.x().to_int();
}