LibWeb: Avoid unnecessary work when element display property changes

`play_or_cancel_animations_after_display_property_change` is called
whenever an element is inserted or removed, or it's display property
changes, but it is only required to run if we actually have animations
to play or cancel.

Reduces time spent in the aforementioned function from ~2% to ~0.03%
when loading https://en.wikipedia.org/wiki/2023_in_American_television
This commit is contained in:
Callum Law 2025-11-11 16:08:42 +13:00 committed by Tim Ledbetter
parent cfc22a4075
commit 55afa9d37e
Notes: github-actions[bot] 2025-11-11 08:36:51 +00:00
4 changed files with 21 additions and 0 deletions

View file

@ -4177,6 +4177,10 @@ FlyString const& Element::html_uppercased_qualified_name() const
void Element::play_or_cancel_animations_after_display_property_change()
{
// OPTIMIZATION: We don't care about elements with no CSS defined animations
if (!has_css_defined_animations())
return;
// OPTIMIZATION: We don't care about animations in disconnected subtrees.
if (!is_connected())
return;