LibWeb: Ignore repaint requests inside iframes with visibility: hidden

This reduces idle CPU usage on https://gymgrossisten.com/ from 100%
(split between WebContent and Ladybird) to ~4% on my machine.
This commit is contained in:
Andreas Kling 2025-10-23 11:19:10 +02:00 committed by Andreas Kling
parent f34361950c
commit dbf041aa98
Notes: github-actions[bot] 2025-10-23 15:43:56 +00:00
3 changed files with 23 additions and 0 deletions

View file

@ -2766,4 +2766,19 @@ void Navigable::reset_zoom()
document->visual_viewport()->reset();
}
bool Navigable::has_inclusive_ancestor_with_visibility_hidden() const
{
if (auto container = this->container()) {
if (auto container_computed_properties = container->computed_properties()) {
if (container_computed_properties->visibility() == CSS::Visibility::Hidden)
return true;
}
if (auto ancestor_navigable = container->document().navigable()) {
if (auto ancestor_container = ancestor_navigable->container())
return ancestor_navigable->has_inclusive_ancestor_with_visibility_hidden();
}
}
return false;
}
}

View file

@ -203,6 +203,8 @@ public:
bool needs_repaint() const { return m_needs_repaint; }
void set_needs_repaint() { m_needs_repaint = true; }
[[nodiscard]] bool has_inclusive_ancestor_with_visibility_hidden() const;
RefPtr<Gfx::SkiaBackendContext> skia_backend_context() const;
void set_pending_set_browser_zoom_request(bool value) { m_pending_set_browser_zoom_request = value; }