mirror of
https://github.com/SerenityOS/serenity
synced 2024-07-24 03:25:02 +00:00
LibWeb: Change update_style() to update animated style only if needed
Instead of invalidating animated style properties whenever `Document::update_style()` is called, now we only do that when animations might have actually progressed. We still have to ensure animated properties are up-to-date in `update_style()` to ensure that JS methods can access updated style properties.
This commit is contained in:
parent
3c8d4c9876
commit
b7d28ee57d
|
@ -1151,17 +1151,7 @@ void Document::update_style()
|
|||
if (!browsing_context())
|
||||
return;
|
||||
|
||||
for (auto& timeline : m_associated_animation_timelines) {
|
||||
for (auto& animation : timeline->associated_animations()) {
|
||||
if (auto effect = animation->effect(); effect && effect->target())
|
||||
effect->target()->reset_animated_css_properties();
|
||||
}
|
||||
|
||||
for (auto& animation : timeline->associated_animations()) {
|
||||
if (auto effect = animation->effect())
|
||||
effect->update_style_properties();
|
||||
}
|
||||
}
|
||||
update_animated_style_if_needed();
|
||||
|
||||
if (!needs_full_style_update() && !needs_style_update() && !child_needs_style_update())
|
||||
return;
|
||||
|
@ -1187,6 +1177,25 @@ void Document::update_style()
|
|||
m_needs_full_style_update = false;
|
||||
}
|
||||
|
||||
void Document::update_animated_style_if_needed()
|
||||
{
|
||||
if (!m_needs_animated_style_update)
|
||||
return;
|
||||
|
||||
for (auto& timeline : m_associated_animation_timelines) {
|
||||
for (auto& animation : timeline->associated_animations()) {
|
||||
if (auto effect = animation->effect(); effect && effect->target())
|
||||
effect->target()->reset_animated_css_properties();
|
||||
}
|
||||
|
||||
for (auto& animation : timeline->associated_animations()) {
|
||||
if (auto effect = animation->effect())
|
||||
effect->update_style_properties();
|
||||
}
|
||||
}
|
||||
m_needs_animated_style_update = false;
|
||||
}
|
||||
|
||||
void Document::update_paint_and_hit_testing_properties_if_needed()
|
||||
{
|
||||
if (!m_needs_to_resolve_paint_only_properties)
|
||||
|
@ -4055,6 +4064,8 @@ void Document::ensure_animation_timer()
|
|||
for (auto& animation : timeline->associated_animations())
|
||||
dispatch_events_for_animation_if_necessary(animation);
|
||||
}
|
||||
|
||||
m_needs_animated_style_update = true;
|
||||
}));
|
||||
}
|
||||
|
||||
|
|
|
@ -211,6 +211,7 @@ public:
|
|||
void update_style();
|
||||
void update_layout();
|
||||
void update_paint_and_hit_testing_properties_if_needed();
|
||||
void update_animated_style_if_needed();
|
||||
|
||||
void set_needs_layout();
|
||||
|
||||
|
@ -736,6 +737,8 @@ private:
|
|||
|
||||
bool m_needs_full_style_update { false };
|
||||
|
||||
bool m_needs_animated_style_update { false };
|
||||
|
||||
HashTable<JS::GCPtr<NodeIterator>> m_node_iterators;
|
||||
|
||||
HashTable<JS::NonnullGCPtr<DocumentObserver>> m_document_observers;
|
||||
|
|
Loading…
Reference in a new issue