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

LibWeb: Cache the viewport rect across all of style computation

Fetching the viewport rect is currently somewhat expensive, since it
requires finding the navigable the document is active in.

We can avoid the cost of repeated calls by simply allowing StyleComputer
to cache the viewport rect at the start of style computation.
This commit is contained in:
Andreas Kling 2024-01-11 14:04:18 +01:00
parent 3cd455e554
commit f0722671c3
3 changed files with 9 additions and 8 deletions

View file

@ -2356,13 +2356,6 @@ void StyleComputer::invalidate_rule_cache()
m_user_agent_rule_cache = nullptr;
}
CSSPixelRect StyleComputer::viewport_rect() const
{
if (auto const navigable = document().navigable())
return navigable->viewport_rect();
return {};
}
void StyleComputer::did_load_font(FlyString const&)
{
document().invalidate_style();