mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-24 18:28:57 +00:00
LibWeb: Avoid some redundant calls to Layout::Box::absolute_rect()
Computing the absolute rect of a box requires walking the chain of containing blocks and apply any offsets encountered. This can be slow in deeply nested box trees, so let's at least avoid doing it multiple times when once is enough.
This commit is contained in:
parent
1103eb8d44
commit
eac31e21f2
Notes:
sideshowbarker
2024-07-18 03:56:38 +09:00
Author: https://github.com/awesomekling
Commit: eac31e21f2
2 changed files with 8 additions and 6 deletions
|
@ -34,10 +34,11 @@ public:
|
|||
|
||||
Gfx::FloatRect padded_rect() const
|
||||
{
|
||||
auto absolute_rect = this->absolute_rect();
|
||||
Gfx::FloatRect rect;
|
||||
rect.set_x(absolute_x() - box_model().padding.left);
|
||||
rect.set_x(absolute_rect.x() - box_model().padding.left);
|
||||
rect.set_width(width() + box_model().padding.left + box_model().padding.right);
|
||||
rect.set_y(absolute_y() - box_model().padding.top);
|
||||
rect.set_y(absolute_rect.y() - box_model().padding.top);
|
||||
rect.set_height(height() + box_model().padding.top + box_model().padding.bottom);
|
||||
return rect;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue