mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:37:35 +00:00
LibWeb+WebContent: Don't relayout page on every scroll event
The WebContent process was redoing page layout every time you scrolled the page. This was a huge CPU hog for no reason. Fix this by only doing a relayout when the viewport is resized, not when it moves around.
This commit is contained in:
parent
964894dee6
commit
f24b674d7a
3 changed files with 24 additions and 4 deletions
|
@ -108,6 +108,28 @@ void Frame::set_document(DOM::Document* document)
|
|||
m_page->client().page_did_set_document_in_main_frame(m_document);
|
||||
}
|
||||
|
||||
void Frame::set_viewport_rect(const Gfx::IntRect& rect)
|
||||
{
|
||||
bool did_change = false;
|
||||
|
||||
if (m_size != rect.size()) {
|
||||
m_size = rect.size();
|
||||
if (m_document)
|
||||
m_document->update_layout();
|
||||
did_change = true;
|
||||
}
|
||||
|
||||
if (m_viewport_scroll_offset != rect.location()) {
|
||||
m_viewport_scroll_offset = rect.location();
|
||||
did_change = true;
|
||||
}
|
||||
|
||||
if (did_change) {
|
||||
for (auto* client : m_viewport_clients)
|
||||
client->frame_did_set_viewport_rect(rect);
|
||||
}
|
||||
}
|
||||
|
||||
void Frame::set_size(const Gfx::IntSize& size)
|
||||
{
|
||||
if (m_size == size)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue