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
commit f0722671c3
Notes: sideshowbarker 2024-07-16 23:52:10 +09:00
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();